Commit 6e908aeb authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

add area of interest switch to osm2vadere tool.

parent 99837cfd
......@@ -151,7 +151,8 @@ class OsmConverter:
def from_args(cls, arg):
c = cls(arg.input, arg.use_osm_id)
c.filter()
c.filter_area_of_interest()
if arg.use_aoi:
c.filter_area_of_interest()
return c
@staticmethod
......@@ -499,6 +500,15 @@ def parse_command_line_arguments():
default=True,
help="Set to use osm ids for obstacles")
convert_parser.add_argument("--use-aoi",
dest='use_aoi',
type=str2bool,
const=True,
nargs="?",
default=False,
help="Set to reduce export to elements within an area of interest. "
"(way taged with vadere:area-of-intrest) ")
convert_parser.set_defaults(main_func=main_convert)
cmd_args = main.parse_args()
......
......@@ -808,6 +808,12 @@ class OsmData:
lon = [0,0]
nodes = [self.lookup.node_to_latlon[int(id)] for id in self.xml.xpath("/osm/way[./tag/@k='vadere:area-of-intrest']/nd/@ref")][:-1]
if len(nodes) == 0:
raise RuntimeError(f"No area of interst found. Map does not contain a way with the tag 'vadere:area-of-intrest'")
elif len(nodes) < 2:
raise RuntimeError(f"area-of-intrest path contains only '{len(nodes)}' nodes. Need at least 3 nodes to "
f"create area of interest.")
node_lat = [n[0] for n in nodes]
node_lon = [n[1] for n in nodes]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment