Commit 36cbeaa9 authored by Thomas Graichen's avatar Thomas Graichen

Add Readme and region code filtering as argument

parent 22576317
This Python toolset can be used for converting ZHV data (German: Daten des Zentralen Haltestellenverzeichnisses) to OSM.
Use case of the converted data is the mapping of accessibility barriers at public transport stops with the [OPENER App](
The tool's software is licensed under the GPL 3.0.
Further information can be found at the German-speaking [project website of OPENER](
The development of this app is sponsored by the Federal Ministry of Transport and Digital Infrastructure under the project ID VB18F1016A
within the digital innovation program mFUND.
## Dependencies:
- Python 3.8
- pyosmium
- lxml
## Usage:
python zHV_aktuell_xml.2020-05-05.xml --regionfilter SACHSEN
The output file is in your current working directory and has the name "yyyy-mm-dd-stop_places.osm" (e.g. 2020-05-08-stop_places.osm).
## XML-Scheme of ZHV:
The ZHV classes were generated by [generateDS]( using a [ZHV XML scheme](data/scheme/zhv_scheme.xsd).
Regeneration of these classes can be done by:
generateDS -o zhv_scheme.xsd
\ No newline at end of file
This diff is collapsed.
......@@ -7,7 +7,7 @@ from zhv_parser.ZhvClasses import StopPlace
class RegionCode(Enum):
ALL = ""
......@@ -26,6 +26,8 @@ class RegionCode(Enum):
def isStopPlaceInRegion(self, stop_place: StopPlace):
if self == RegionCode.ALL:
return True
dhid = stop_place.get_DHID()
region_code = self.value
found = str(dhid).find(region_code, 3, 5)
import argparse
import os
import sys
from datetime import date
......@@ -88,7 +89,7 @@ class ZhvConverter:
def __init__(self):
self.unused_osm_id = 0
def parse(self, xml_file):
def parse(self, xml_file, region_code: RegionCode = RegionCode.ALL):
today =
# dd/mm/YY
d1 = today.strftime("%Y-%m-%d-")
......@@ -104,7 +105,7 @@ class ZhvConverter:
stop_place_class = ZhvClasses.StopPlace
stop_place = stop_place_class.factory()
if not self.is_stop_place_in_region(RegionCode.SACHSEN, stop_place):
if not self.is_stop_place_in_region(region_code, stop_place):
(stop_place_relation, nodes) = self.stop_place_to_osm(stop_place, context)
......@@ -240,11 +241,19 @@ def usage():
def main():
args = sys.argv[1:]
if len(args) != 1:
infile_name = args[0]
parser = argparse.ArgumentParser()
parser.add_argument("inputfile", help="ZHV input file")
parser.add_argument("--regionfilter", help="zhv")
args = parser.parse_args()
infile_name = args.inputfile
if args.regionfilter:
region_code = RegionCode[args.regionfilter]
region_code = RegionCode.ALL
print(f'Start conversion with region filer {region_code}')
ZhvConverter().parse(infile_name, region_code)
if __name__ == '__main__':
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment