Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
vadere
vadere
Commits
392c48e3
Commit
392c48e3
authored
Nov 12, 2019
by
Stefan Schuhbaeck
Browse files
add area-of-intrest filter to osm2vadere converter
parent
fa0d8ae4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Tools/Converters/osm2vadere/osm2vadere.py
View file @
392c48e3
...
...
@@ -136,10 +136,22 @@ class OsmConverter:
for
f
in
self
.
osm
.
measurement_selectors
:
self
.
measurement
.
extend
(
f
())
def
filter_area_of_interest
(
self
):
aoi
=
self
.
osm
.
get_area_of_intrest
()
if
aoi
:
self
.
obstacles
=
[
o
for
o
in
self
.
obstacles
if
self
.
osm
.
contained_in_area_of_intrest
(
aoi
,
o
)]
self
.
targets
=
[
o
for
o
in
self
.
targets
if
self
.
osm
.
contained_in_area_of_intrest
(
aoi
,
o
)]
self
.
sources
=
[
o
for
o
in
self
.
sources
if
self
.
osm
.
contained_in_area_of_intrest
(
aoi
,
o
)]
self
.
measurement
=
[
o
for
o
in
self
.
measurement
if
self
.
osm
.
contained_in_area_of_intrest
(
aoi
,
o
)]
@
classmethod
def
from_args
(
cls
,
arg
):
c
=
cls
(
arg
.
input
,
arg
.
use_osm_id
)
c
.
filter
()
c
.
filter_area_of_interest
()
return
c
@
staticmethod
...
...
@@ -557,5 +569,12 @@ def main_convert(cmd_args):
if
__name__
==
"__main__"
:
# i = '/home/stsc/repos/vadere/Scenarios/Demos/roVer/scenarios/mf_underground.osm'
# o = '/home/stsc/repos/vadere/Scenarios/Demos/roVer/scenarios/mf_underground.scenario'
# c = OsmConverter(i, True)
# c.filter()
# c.filter_area_of_interest()
#
# #
args
=
parse_command_line_arguments
()
args
.
main_func
(
args
)
Tools/Converters/osm2vadere/osm_helper.py
View file @
392c48e3
...
...
@@ -782,6 +782,38 @@ class OsmData:
print
(
f
"created new hull-way (id:
{
hull_way
.
id
}
) containing
{
way_ids
}
"
)
return
hull_way
.
id
def
contained_in_area_of_intrest
(
self
,
aoi
,
way
:
Element
):
min_lat
=
aoi
[
0
][
0
]
max_lat
=
aoi
[
0
][
1
]
min_lon
=
aoi
[
1
][
0
]
max_lon
=
aoi
[
1
][
1
]
nodes
=
[
self
.
lookup
.
node_to_latlon
[
int
(
id
)]
for
id
in
way
.
xpath
(
"nd/@ref"
)]
for
n
in
nodes
:
if
n
[
0
]
<
min_lat
or
n
[
0
]
>
max_lat
or
n
[
1
]
<
min_lon
or
n
[
1
]
>
max_lon
:
return
False
return
True
def
get_area_of_intrest
(
self
):
'''
Return lat/lon min/max values for element within area of intrest
:return:
'''
self
.
xml
.
xpath
(
"/osm/way/tag[@k='vadere:area-of-intrest']"
)
lat
=
[
0
,
0
]
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
]
node_lat
=
[
n
[
0
]
for
n
in
nodes
]
node_lon
=
[
n
[
1
]
for
n
in
nodes
]
return
([
min
(
node_lat
),
max
(
node_lat
)],
[
min
(
node_lon
),
max
(
node_lon
)])
def
lint_add_ids
(
self
,
dry_run
=
False
):
ways_without_id
:
List
[
Element
]
=
self
.
xml
.
xpath
(
"/osm/way[@id < 0 and not (./tag[@k='rover:id'])]"
)
print
(
f
"found
{
len
(
ways_without_id
)
}
way elements without id"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment