From OpenStreetMap
RoadNet
Generate GeoJSON Data
from mosstool.map.osm import RoadNet
object = RoadNet()
-
Download raw OpenStreetMap data
- object._get_osm()
-
Remove duplicated
ways
andnodes
- object._remove_redundant_ways(), object._remove_simple_joints()
- In cases where there are multiple roads connecting
nodes
, if it is a two-way road, keep it as a two-way road; if it is a one-way road, only keep the shortest one. - Delete simple nodes with only one incoming and one outgoing road, and merge the incoming and outgoing roads together. (Short merges into long)
-
Transform all roads into one-way road
- object._make_all_one_way()
- Splitting two-way roads into two one-way roads going in opposite directions.
-
Remove isolated roads
- object._remove_out_of_roadnet()
- Remove isolated ways outside the largest connected component of the road network.
-
Build junctions
- object._init_junctions(), object._merge_junction_by_motif()
- Initialize junctions based on the connectivity of nodes, so that every node connected to more than 1 way is considered a junction.
- Identify fixed patterns in the road network topology and merge them into a single junction.
-
Delete redundant units
- object._clean_topo()
- If there are multiple roads connecting between two junctions, only the one with the most lanes and the shortest length will be retained. If a junction only has two roads, one entering and one exiting, then the junction will be removed and the two roads will be combined.
AOI
Generate GeoJSON Data
from mosstool.map.osm import Building
object = Building()
-
Download raw OpenStreetMap data
- object._query_raw_data()
- Ways that constitute
AOIs
independently are separately classified asways_aoi
. Ways that require relation descriptions are classified asways_rel
.
-
Make polygon
AOIs
-
For
ways_aoi
, each way contained represents a closed loop shape without any inner shapes, directly serving as the shape of theAOI
. -
For
ways_rel
and the described relations:-
If the number of external edges is greater than 1
-
If there are multiple closed loop edges and no open edges, take the union of all the edges.
-
If the union result contains multiple polygons, each polygon becomes a separate
AOI
. -
If the union result is a single polygon, it becomes an
AOI.
-
If there are no closed loop edges but there are open edges:
- Connect these open edges. If a unique polygon can be formed, it becomes an
AOI
.
- Connect these open edges. If a unique polygon can be formed, it becomes an
-
-
-
If there is only one external edge:
- f this edge forms a closed loop (i.e., it is self-contained), the polygon formed by this edge becomes the shape of the
AOI
.
- f this edge forms a closed loop (i.e., it is self-contained), the polygon formed by this edge becomes the shape of the
-
POI
Generate GeoJSON Data
from mosstool.map.osm import PointOfInterest
object = PointOfInterest()
-
Download raw OpenStreetMap data
- object._query_raw_data()
- Ways that constitute
AOIs
independently are separately classified asways_aoi
. Ways that require relation descriptions are classified asways_rel
.
-
Make polygon
AOIs
-
For
ways_aoi
, each way contained represents a closed loop shape without any inner shapes, directly serving as the shape of theAOI
. -
For
ways_rel
and the described relations:-
If the number of external edges is greater than 1
-
If there are multiple closed loop edges and no open edges, take the union of all the edges.
-
If the union result contains multiple polygons, each polygon becomes a separate
AOI
. -
If the union result is a single polygon, it becomes an
AOI.
-
If there are no closed loop edges but there are open edges:
- Connect these open edges. If a unique polygon can be formed, it becomes an
AOI
.
- Connect these open edges. If a unique polygon can be formed, it becomes an
-
-
If there is only one external edge:
- f this edge forms a closed loop (i.e., it is self-contained), the polygon formed by this edge becomes the shape of the
AOI
.
- f this edge forms a closed loop (i.e., it is self-contained), the polygon formed by this edge becomes the shape of the
-
-