Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support railway type options #59

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions orm_importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ def __init__(self):
self.api = overpy.Overpass(url="https://osm.hpi.de/overpass/api/interpreter")
self.topology = Topology()

def _get_track_objects(self, polygon: str):
query = f'(way["railway"="rail"](poly: "{polygon}");node(w)(poly: "{polygon}"););out body;'
def _get_track_objects(self, polygon: str, railway_option_types: list[str]):
query_parts = ""
for type in railway_option_types:
query_parts = query_parts + f'way["railway"="{type}"](poly: "{polygon}");node(w)(poly: "{polygon}");'
query = f'({query_parts});out body;'
print(query)
return self._query_api(query)

def _query_api(self, query):
Expand Down Expand Up @@ -141,8 +145,8 @@ def _should_add_edge(self, node_a: model.Node, node_b: model.Node, path: list[in
present_paths = self.paths[(node_a, node_b)] + self.paths[(node_b, node_a)]
return path not in present_paths and reversed_path not in present_paths

def run(self, polygon):
track_objects = self._get_track_objects(polygon)
def run(self, polygon, railway_option_types):
track_objects = self._get_track_objects(polygon, railway_option_types)
self.graph = self._build_graph(track_objects)

# ToDo: Check whether all edges really link to each other in ORM or if there might be edges missing for nodes that are just a few cm from each other
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "orm-importer"
version = "1.0.0"
version = "1.1.0"
description = "This tool converts data from OpenRailwayMap into yaramo models."
authors = ["Your Name <[email protected]>"]
authors = ["OSM@HPI <[email protected]>"]
license = "MIT"
readme = "README.md"
packages = [{include = "orm_importer"}]
Expand Down
Loading