Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
vadere
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
110
Issues
110
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
4
Merge Requests
4
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vadere
vadere
Commits
392c48e3
Commit
392c48e3
authored
Nov 12, 2019
by
Stefan Schuhbaeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add area-of-intrest filter to osm2vadere converter
parent
fa0d8ae4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
Tools/Converters/osm2vadere/osm2vadere.py
Tools/Converters/osm2vadere/osm2vadere.py
+19
-0
Tools/Converters/osm2vadere/osm_helper.py
Tools/Converters/osm2vadere/osm_helper.py
+32
-0
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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