Commit afd123db authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck Committed by Daniel Lehmberg

add osm_helper to directly manipulate the osm.xml

planed features:

* simplified obstacles are configured using a .config which
defines the osm way elements which should be combined in a
convexhull. The way elements are *not* deleted, only turned of
using custom tags (e.g. edu.hm.cs.rover.simplified = 'id-of-simple-version')

* benefit: simplification can be undone easily
parent 54390f94
......@@ -31,6 +31,7 @@ __pycache__/
*.py[cod]
*$py.class
**/venv/
_trial_temp/
Tools/VadereAnalysisTools/VadereAnalysisTool/vadereanalysistool.egg-info/
Tools/VadereAnalysisTools/VadereAnalysisTool/build/
Tools/VadereAnalysisTools/VadereAnalysisTool/dist/
......@@ -58,4 +59,4 @@ VadereModelTests/*_private
# Vadere Cache
**/__cache__
**/vadere-server-output
\ No newline at end of file
**/vadere-server-output
......@@ -8,6 +8,33 @@
### Changed
## v1.3 (2019-07-31)
### Added
- new `referenceCoordinateSystem` attributes in the topography element (default: `null`). This
object holds information about the base coordinate system and an optional translation used
on the coordinates in the topography. If the description field is a free text field which
can be used for miscellaneous information. (see osm2vadere converter)
```
"referenceCoordinateSystem" : {
"epsgCode" : "UTM Zone 32U",
"description" : "OpenStreetMap export osm2vadere.py-ed63d4e94898a15a6bf25fa59c05a5b2f73d8f74-dirty",
"translation" : {
"x" : 692152.0894735109,
"y" : 5337384.6661008
}
}
```
### Changed
- osm2vadere.py refactored.
- Extract osm-xml manipulation into `osm_helper.py`
- Changes command line structure
- osm_helper.py: cl-based manipulation of osm xml to add additional information into the xml
structure readable by osm2vadere.py converter.
## v1.2 (2019-07-13)
### Added
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import json
from attrdict import AttrDict
class VadereScenario:
def __init__(self, path):
with open(path, 'r') as f:
data = json.load(f)
self.data = data
self.path = path
@classmethod
def load(cls, path):
s = cls(path)
return s
@property
def name(self):
return self.data['name']
@name.setter
def name(self, val: str):
self.data['name'] = str(val)
@property
def description(self):
return self.data['description']
@description.setter
def description(self, val: str):
self.data['description'] = str(val)
@property
def release(self):
return self.data['release']
@release.setter
def release(self, val: str):
self.data['release'] = str(val)
@property
def process_writers(self):
return self.data['processWriters']
@process_writers.setter
def process_writers(self, val: dict):
if type(val) is not dict:
raise ValueError("process_writer must be dict")
self.data['processWriters'] = val
@property
def scenario(self):
return self.data['scenario']
@scenario.setter
def scenario(self, val: dict):
if type(val) is not dict:
raise ValueError("scenario must be dict")
self.data['scenario'] = val
@property
def topography(self):
return self.data['scenario']['topography']
@topography.setter
def topography(self, val: dict):
if type(val) is not dict:
raise ValueError("topography must be dict")
self.data['scenario']['topography'] = val
@property
def obstacles(self):
return self.data['scenario']['topography']['obstacles']
@obstacles.setter
def obstacles(self, val: list):
if type(val) is not list:
raise ValueError("obstacles must be list of dicts")
self.data['scenario']['topography']['obstacles'] = val
@property
def measurement_areas(self):
return self.data['scenario']['topography']['measurementAreas']
@measurement_areas.setter
def measurement_areas(self, val: list):
if type(val) is not list:
raise ValueError("measurementAreas must be list of dicts")
self.data['scenario']['topography']['measurementAreas'] = val
@property
def stairs(self):
return self.data['scenario']['topography']['stairs']
@stairs.setter
def stairs(self, val: list):
if type(val) is not list:
raise ValueError("stairs must be list of dicts")
self.data['scenario']['topography']['stairs'] = val
@property
def targets(self):
return self.data['scenario']['topography']['targets']
@targets.setter
def targets(self, val: list):
if type(val) is not list:
raise ValueError("targets must be list of dicts")
self.data['scenario']['topography']['targets'] = val
@property
def absorbing_areas(self):
return self.data['scenario']['topography']['absorbingAreas']
@absorbing_areas.setter
def absorbing_areas(self, val: list):
if type(val) is not list:
raise ValueError("absorbingAreas must be list of dicts")
self.data['scenario']['topography']['absorbingAreas'] = val
@property
def sources(self):
return self.data['scenario']['topography']['sources']
@sources.setter
def sources(self, val: list):
if type(val) is not list:
raise ValueError("sources must be list of dicts")
self.data['scenario']['topography']['sources'] = val
@property
def raw(self):
return self.data
@property
def scenario(self):
return self.data["scenario"]
@property
def topography(self):
return self.scenario["topography"]
if __name__ == '__main__':
s = VadereScenario.load('./mf_small_2.scenario')
{
"id" : $id,
"shape" : {
"type" : "POLYGON",
"points" : [
$points
]
},
"interSpawnTimeDistribution" : "$interSpawnTimeDistribution",
"distributionParameters" : $distributionParameters,
"spawnNumber" : $spawnNumber,
"maxSpawnNumberTotal" : $maxSpawnNumberTotal,
"startTime" : $startTime,
"endTime" : $endTime,
"spawnAtRandomPositions" : $spawnAtRandomPositions,
"useFreeSpaceOnly" : $useFreeSpaceOnly,
"targetIds" : $targetIds,
"groupSizeDistribution" : $groupSizeDistribution,
"dynamicElementType" : "$dynamicElementType"
}
\ No newline at end of file
{
"id" : $id,
"absorbing" : $absorbing,
"shape" : {
"type" : "POLYGON",
"points" : [
$points
]
},
"waitingTime" : $waitingTime,
"waitingTimeYellowPhase" : $waitingTimeYellowPhase,
"parallelWaiters" : $parallelWaiters,
"individualWaiting" : $individualWaiting,
"deletionDistance" : $deletionDistance,
"startingWithRedLight" : $startingWithRedLight,
"nextSpeed" : $nextSpeed
}
\ No newline at end of file
......@@ -7,12 +7,29 @@
"height" : $height
},
"boundingBoxWidth" : 0.5,
"bounded" : true
"bounded" : true,
"referenceCoordinateSystem" : {
"epsgCode" : "$epsg",
"description" : "$epsg_description",
"translation" : {
"x" : $translate_x,
"y" : $translate_y
}
}
},
"obstacles" : [ $obstacles],
"obstacles" : [
$obstacles
],
"measurementAreas" : [
$measurement_areas
],
"stairs" : [ ],
"targets" : [ ],
"sources" : [ ],
"targets" : [
$targets
],
"sources" : [
$sources
],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
......@@ -23,20 +40,5 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : {
"id" : -1,
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"length" : 4.5,
"width" : 1.7,
"direction" : {
"x" : 1.0,
"y" : 0.0
}
}
"attributesCar" : null
}
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
<bounds minlat='48.16077' minlon='11.58451' maxlat='48.16386' maxlon='11.58936' origin='CGImap 0.7.5 (31203 thorn-02.openstreetmap.org)' />
<way id='-999069167' action='modify' visible='true'>
<nd ref='-127405' />
<nd ref='-127407' />
<nd ref='-127425' />
<nd ref='-127405' />
<tag k='test' v='1' />
<tag k='rover:id' v='-133507' />
<tag k='rover:obstacle' v='yes' />
<tag k='rover:obstacle:type' v='polygon' />
</way>
<way id='173168628' timestamp='2014-06-30T12:12:19Z' uid='8703' user='rolandg' visible='true' version='4' changeset='23344904'>
<nd ref='1318876746' />
<nd ref='1324414637' />
<nd ref='1324414707' />
<nd ref='1318876746' />
<tag k='test' v='2' />
<tag k='addr:city' v='München' />
<tag k='addr:country' v='DE' />
<tag k='addr:housenumber' v='53' />
<tag k='addr:postcode' v='80802' />
<tag k='addr:street' v='Leopoldstraße' />
<tag k='building' v='yes' />
</way>
<node id='-127405' action='modify' visible='true' lat='48.16256981067' lon='11.5868239213' > <tag k='rover:id' v='333'/> </node>
<node id='-127407' action='modify' visible='true' lat='48.16254537153' lon='11.58697933476' />
<node id='-127433' action='modify' visible='true' lat='48.18254537153' lon='11.57697933476' />
<node id='-127425' action='modify' visible='true' lat='48.16255438099' lon='11.58692204178' />
<node id='1318876746' timestamp='2011-06-10T13:33:45Z' uid='342705' user='KonB' visible='true' version='1' changeset='8397338' lat='48.1608727' lon='11.5891088' />
<node id='1324414637' timestamp='2016-09-30T12:57:28Z' uid='14390' user='BeKri' visible='true' version='3' changeset='42541803' lat='48.1624082' lon='11.5894932' />
<node id='1324414707' timestamp='2011-06-13T23:03:06Z' uid='342705' user='KonB' visible='true' version='1' changeset='8432586' lat='48.1630255' lon='11.588295' />
</osm>
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
<bounds minlat='48.16077' minlon='11.58451' maxlat='48.16386' maxlon='11.58936' origin='CGImap 0.7.5 (31203 thorn-02.openstreetmap.org)' />
<way id='-999069167' action='modify' visible='true'>
<nd ref='-127405' />
<nd ref='-127407' />
<nd ref='-127425' />
<nd ref='-127405' />
<tag k='test' v='1' />
<tag k='rover:obstacle' v='yes' />
<tag k='rover:obstacle:type' v='polygon' />
</way>
<way id='173168628' timestamp='2014-06-30T12:12:19Z' uid='8703' user='rolandg' visible='true' version='4' changeset='23344904'>
<nd ref='1318876746' />
<nd ref='1324414637' />
<nd ref='1324414707' />
<nd ref='1318876746' />
<tag k='test' v='2' />
<tag k='addr:city' v='München' />
<tag k='addr:country' v='DE' />
<tag k='addr:housenumber' v='53' />
<tag k='addr:postcode' v='80802' />
<tag k='addr:street' v='Leopoldstraße' />
<tag k='building' v='yes' />
</way>
<node id='-127405' action='modify' visible='true' lat='48.16256981067' lon='11.5868239213' > <tag k='rover:id' v='333'/> </node>
<node id='-127407' action='modify' visible='true' lat='48.16254537153' lon='11.58697933476' />
<node id='-127433' action='modify' visible='true' lat='48.18254537153' lon='11.57697933476' />
<node id='-127425' action='modify' visible='true' lat='48.16255438099' lon='11.58692204178' />
<node id='1318876746' timestamp='2011-06-10T13:33:45Z' uid='342705' user='KonB' visible='true' version='1' changeset='8397338' lat='48.1608727' lon='11.5891088' />
<node id='1324414637' timestamp='2016-09-30T12:57:28Z' uid='14390' user='BeKri' visible='true' version='3' changeset='42541803' lat='48.1624082' lon='11.5894932' />
<node id='1324414707' timestamp='2011-06-13T23:03:06Z' uid='342705' user='KonB' visible='true' version='1' changeset='8432586' lat='48.1630255' lon='11.588295' />
</osm>
<?xml version='1.0' encoding='utf8'?>
<osm version="0.6" generator="JOSM">
<bounds minlat="48.16077" minlon="11.58451" maxlat="48.16386" maxlon="11.58936" origin="CGImap 0.7.5 (31203 thorn-02.openstreetmap.org)"/>
<way id="-999069167" action="modify" visible="true">
<nd ref="-127405"/>
<nd ref="-127407"/>
<nd ref="-127425"/>
<nd ref="-127405"/>
<tag k="test" v="1"/>
<tag k="rover:obstacle" v="yes"/>
<tag k="rover:obstacle:type" v="polygon"/>
<tag k="rover:id" v="999069167"/>
</way>
<way id="-999069167" timestamp="2014-06-30T12:12:19Z" uid="8703" user="rolandg" visible="true" version="4" changeset="23344904">
<nd ref="1318876746"/>
<nd ref="1324414637"/>
<nd ref="1324414707"/>
<nd ref="1318876746"/>
<tag k="test" v="2"/>
<tag k="addr:city" v="München"/>
<tag k="addr:country" v="DE"/>
<tag k="addr:housenumber" v="53"/>
<tag k="addr:postcode" v="80802"/>
<tag k="addr:street" v="Leopoldstraße"/>
<tag k="building" v="yes"/>
</way>
<node id="-127405" action="modify" visible="true" lat="48.16256981067" lon="11.5868239213">
<tag k="rover:id" v="333"/>
</node>
<node id="-127405" action="modify" visible="true" lat="48.16256981067" lon="11.5868239213">
<tag k="rover:id" v="333"/>
</node>
<node id="-127407" action="modify" visible="true" lat="48.16254537153" lon="11.58697933476">
<tag k="rover:id" v="127407"/>
</node>
<node id="-127433" action="modify" visible="true" lat="48.18254537153" lon="11.57697933476">
<tag k="rover:id" v="127433"/>
</node>
<node id="-127425" action="modify" visible="true" lat="48.16255438099" lon="11.58692204178">
<tag k="rover:id" v="127425"/>
</node>
<node id="1318876746" timestamp="2011-06-10T13:33:45Z" uid="342705" user="KonB" visible="true" version="1" changeset="8397338" lat="48.1608727" lon="11.5891088"/>
<node id="1324414637" timestamp="2016-09-30T12:57:28Z" uid="14390" user="BeKri" visible="true" version="3" changeset="42541803" lat="48.1624082" lon="11.5894932"/>
<node id="1324414707" timestamp="2011-06-13T23:03:06Z" uid="342705" user="KonB" visible="true" version="1" changeset="8432586" lat="48.1630255" lon="11.588295"/>
</osm>
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
<bounds minlat='48.16077' minlon='11.58451' maxlat='48.16386' maxlon='11.58936' origin='CGImap 0.7.5 (31203 thorn-02.openstreetmap.org)' />
<way id='44' timestamp='2017-07-07T11:40:46Z' uid='367380' user='Mloni' visible='true' version='7' changeset='50106355'>
<nd ref='22' />
<nd ref='33' />
<tag k='addr:city' v='München' />
<tag k='addr:country' v='DE' />
<tag k='addr:housenumber' v='15' />
<tag k='addr:postcode' v='80802' />
<tag k='addr:street' v='Feilitzschstraße' />
<tag k='building' v='yes' />
</way>
<way id='39057410' timestamp='2017-07-07T11:40:46Z' uid='367380' user='Mloni' visible='true' version='7' changeset='50106355'>
<nd ref='466194487' />
<nd ref='429741712' />
<nd ref='429583850' />
<nd ref='429583851' />
<nd ref='429583852' />
<nd ref='429583853' />
<nd ref='429583298' />
<tag k='addr:city' v='München' />
<tag k='addr:country' v='DE' />
<tag k='addr:housenumber' v='15' />
<tag k='addr:postcode' v='80802' />
<tag k='addr:street' v='Feilitzschstraße' />
<tag k='building' v='yes' />
</way>
<way id='36942797' timestamp='2014-11-02T20:04:54Z' uid='78613' user='heilbron' visible='true' version='8' changeset='26511966'>
<nd ref='466194487' />
<nd ref='429583279' />
<nd ref='429583282' />
<nd ref='429583298' />
<nd ref='466194487' />
<tag k='addr:city' v='München' />
<tag k='addr:country' v='DE' />
<tag k='addr:housenumber' v='2' />
<tag k='addr:postcode' v='80802' />
<tag k='addr:street' v='Occamstraße' />
<tag k='building' v='yes' />
<tag k='roof:shape' v='gabled' />
</way>
<node id='466194487' timestamp='2011-02-08T23:34:18Z' uid='342705' user='KonB' visible='true' version='2' changeset='7232063' lat='48.1613442' lon='11.5895291' />
<node id='429583279' timestamp='2012-01-17T18:42:57Z' uid='8748' user='ToniE' visible='true' version='6' changeset='10420560' lat='48.1614825' lon='11.5896403' />
<node id='429583282' timestamp='2016-09-30T12:57:39Z' uid='14390' user='BeKri' visible='true' version='7' changeset='42541803' lat='48.1615473' lon='11.5894436' />
<node id='429583298' timestamp='2016-09-30T12:57:39Z' uid='14390' user='BeKri' visible='true' version='5' changeset='42541803' lat='48.1614152' lon='11.5893355' />
<node id='429741712' timestamp='2016-09-30T12:57:42Z' uid='14390' user='BeKri' visible='true' version='4' changeset='42541803' lat='48.161294' lon='11.5894882' />
<node id='429583850' timestamp='2016-09-30T12:57:39Z' uid='14390' user='BeKri' visible='true' version='5' changeset='42541803' lat='48.1612473' lon='11.5896375' />
<node id='429583851' timestamp='2017-07-07T11:40:44Z' uid='367380' user='Mloni' visible='true' version='6' changeset='50106355' lat='48.1611339' lon='11.5895559' />
<node id='429583852' timestamp='2016-09-30T12:57:40Z' uid='14390' user='BeKri' visible='true' version='4' changeset='42541803' lat='48.1612045' lon='11.5893331' />
<node id='429583853' timestamp='2016-09-30T12:57:40Z' uid='14390' user='BeKri' visible='true' version='3' changeset='42541803' lat='48.16133' lon='11.5892698' />
</osm>
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
<bounds minlat='48.16077' minlon='11.58451' maxlat='48.16386' maxlon='11.58936' origin='CGImap 0.7.5 (31203 thorn-02.openstreetmap.org)' />
<way id='-999069167' action='modify' visible='true'>
<nd ref='-127405' />
<nd ref='-127407' />
<nd ref='-127425' />
<nd ref='-127405' />
<tag k='test' v='1' />
<tag k='rover:id' v='-133507' />
<tag k='rover:obstacle' v='yes' />
<tag k='rover:obstacle:type' v='polygon' />
</way>
<way id='173168628' timestamp='2014-06-30T12:12:19Z' uid='8703' user='rolandg' visible='true' version='4' changeset='23344904'>
<nd ref='1318876746' />
<nd ref='1324414637' />
<nd ref='1324414707' />
<nd ref='1318876746' />
<tag k='test' v='2' />
<tag k='addr:city' v='München' />
<tag k='addr:country' v='DE' />