Skip to content

Commit

Permalink
Merge pull request #59 from simulate-digital-rail/support-railway-typ…
Browse files Browse the repository at this point in the history
…e-options

when querying overpass, allow specifying desired railway types

e.g., to include disused tracks or not
  • Loading branch information
lpirl authored May 22, 2024
2 parents 38c9859 + b075f0d commit 70a016a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 70a016a

Please sign in to comment.