...
 
Commits (4)
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ZHV_Converter" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="opener-zhv-converter" />
<module name="ZHV-Tools" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
......@@ -13,7 +13,7 @@
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zhv_parser/ZHV_Converter.py" />
<option name="PARAMETERS" value="../data/example_single_station.xml" />
<option name="PARAMETERS" value="../data/examples_zhv/example_single_station.xml" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
......
<mxfile host="Electron" modified="2020-05-01T05:57:12.428Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.0.3 Chrome/80.0.3987.163 Electron/8.2.1 Safari/537.36" etag="P1GgqGGmlAnZn9IErmBI" version="13.0.3" type="device"><diagram id="pHs3ds1OwH5PlH7i_tdf" name="Page-1">7Vtbc9o6EP41zLQPYXzBgB8DJG3OJA0tOW16Xs4ILIwTY3GECJBff1a2fJVtzJ3MlAew1pIs7X777UoyNb07XX2haDZ5IBZ2a5pirWp6r6ZpqmJq8MMl60DSajYDgU0dS1SKBQPnHYcthXThWHieqsgIcZkzSwtHxPPwiKVkiFKyTFcbEzf91BmysSQYjJArS385FpsIqdo04xtfsWNPxKPbWiu4MUVhZTGT+QRZZJkQ6Tc1vUsJYcHVdNXFLldeqJeg3W3B3WhgFHusSoNfK2Qp7OVL46/vzfvnUb83uB9fiV7ekLsQExaDZetQA9gChYgioWxCbOIh9yaWdihZeBbmj1GgFNe5J2QGQhWEL5ixtbAuWjACogmbuuKuPBUxrjlZ0JEYx9+28Z9963i93y/0YbJeT+/Mt3D8DFEbs5J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Qs/AYwg2Pf0Ou9P7TmwziU6erxhnT1Z8/++vZi9d5eLyjT99d5V/UpRd1CpPxm42+mgsTs6Kvqlq+oU5zDGNKav9GrLLV1Gm2wrLwjLY9zrZJHx7GJjT14HBi+nED3V7f3T72n6D0hGwfHEsnhwjgJs+F3xfw1UGUOhhUBNc2nta6eu26wb/NW7khEAxU++W8OpxE3pd1nkvf3N/e1bSPtoBpVdwtNk+8gFFlAvrheyCRT2LO7Q3nP7JStY/BG2fYQs/Xl3wYcY7wFmWrUYb6O3Fnj2y11KU2hkAzN+zuERLzc8eGkqEehYMj8Ul3WDUllbo1+EF+/MmM88jZqSrv+33YFytCp7moNyvCUYUn1Epd15XUp5Xu8yBHz/kKqnJmczpWUWs7HPYo9VZ6Jb5hFX4COgqD27H5qJklDlUtI46qfNQ0MzEwmwUUMNA1pfwQPKomvLpw+C2JTpXScWXrh+MqnIdRWh8ughEf1qXk7dEPS58hO1wWfWZQ0DROxpbyxo3MljvsJWb2ETftIu50Mm7dOnyyfmkO/svCUQ5dMnoNhaJS5Te5KtNk2UH5pW4yctTqe5MpxPZtuj12cidv1/yBcKWtt73eiD4Ngg3pUAfSAS0BNW03CDfMbL98oVu47DkyhDV5H+0PhItz0IO9UHsmDDcUWGIfAcP82Kd9AgznnlXIiD3gzsxWqygoSCeS0cpqS5fIPd6UPDHtBbng2w3xWuXlWUGyeqL/rVQ4qAp34EcL6q47FPJ4PqFN25/pvdLyJcA8wBEsnvVGwgvaDb8fFmxb6z3IeUvXzFts2/O1afrNgLxdaD2HWvSclxMqmAOK8R/DAs+N/16n3/wP</diagram></mxfile>
\ No newline at end of file
from enum import Enum
# This is representing the first two digits of Germany's "Amtlicher Gemeindeschlüssel":
# https://www.destatis.de/DE/Themen/Laender-Regionen/Regionales/Gemeindeverzeichnis/Glossar/amtlicher-gemeindeschluessel.html
from zhv_parser.ZHV_Classes import StopPlace
class RegionCode(Enum):
SCHLESWIG_HOLSTEIN = "01"
HAMBURG="02"
NIEDERSACHSEN="03"
BREMEN="04"
NORDRHEIN_WESTFALEN="05"
HESSEN="06"
RHEINLAND_PFALZ = "07"
BADEN_WUERTEMBERG = "08"
BAYERN = "09"
SAARLAND = "10"
BERLIN = "11"
BRANDENBURG = "12"
MECKLENBURG_VORPOMMERN = "13"
SACHSEN = "14"
SACHSEN_ANHALT = "15"
THUERINGEN = "16"
def isStopPlaceInRegion(self, stop_place: StopPlace):
dhid = stop_place.get_DHID()
region_code = self.value
found = str(dhid).find(region_code, 3, 5)
if found == -1:
return False
else:
return True
......@@ -4,22 +4,28 @@ from io import StringIO
from lxml import etree
from zhv_parser import ZHV_Classes
from zhv_parser.RegionCode import RegionCode
from zhv_parser.ZHV_Classes import StopPlace
def parse(xml_file):
#f = StringIO(xml_file)
context = etree.iterparse(xml_file, events=("start",), tag="{http://zhv.xml.wvi/}StopPlace")
for action, node in context:
stop_place_class = ZHV_Classes.StopPlace
stop_place = stop_place_class.factory()
stop_place.build(node)
print(stop_place)
if is_stop_place_in_region(RegionCode.BRANDENBURG, stop_place):
print(stop_place)
convert_to_osm(stop_place)
else:
print("Not in Region!")
def isStopPlaceInRegion(stop_place):
pass
def is_stop_place_in_region(region_code: RegionCode, stop_place: StopPlace):
return region_code.isStopPlaceInRegion(stop_place)
def convertToOSM(stop_place):
def convert_to_osm(stop_place: StopPlace):
"""Converts stop place to an OSM object """
pass
......