Way
Represents a single OSM feature with geometry and tags.
A Way is the fundamental unit of map data. It wraps an OSM way or
relation with its parsed geometry and tag dictionary, and provides
helpers to classify the feature and convert it to a point cloud.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
any
|
OSM way ID (positive integer) or a negative integer / string for manually annotated ways. |
is_area |
bool
|
|
nodes |
list
|
Ordered list of node IDs that make up this way. |
tags |
dict
|
OSM key-value tags (e.g. |
line |
BaseGeometry or None
|
Shapely geometry representing the way in UTM coordinates. |
in_out |
str
|
Direction hint used by some planners ( |
pcd_points |
ndarray or None
|
Cached point cloud generated by :meth: |
Attributes
Way objects are created by MapData.run_parse() and are not typically constructed manually.
| Attribute | Type | Description |
|---|---|---|
id |
int |
OSM way or relation ID |
nodes |
list |
Ordered list of OSM node IDs defining the geometry |
tags |
dict[str, str] |
OSM tags (e.g. {"highway": "footway", "surface": "asphalt"}) |
line |
shapely.Geometry \| None |
Geometry in UTM metres. LineString for roads and footways; Polygon for area-type barriers. None if unparsed. |
in_out |
str \| None |
Direction hint set by GraphPlanner: "in", "out", or None for bidirectional |
pcd_points |
np.ndarray \| None |
Array of equidistant 3D points along the way, populated by to_pcd_points() |
Note
The line geometry uses the same UTM coordinate system (metres) as the parent MapData
object. To convert a point to WGS84, use utm.to_latlon(x, y, md.zone_number, md.zone_letter).
Methods
map_data.utils.way.Way.is_road()
Return True if this way is a vehicle road (any highway value not in footway types).
map_data.utils.way.Way.is_footway()
Return True if this way is a pedestrian footway (highway in the footway value set).
map_data.utils.way.Way.is_barrier(yes_tags, not_tags, anti_tags)
Return True if this way should be classified as an untraversable barrier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yes_tags
|
dict
|
Mapping of OSM tag key → list of values that indicate a barrier.
A |
required |
not_tags
|
dict
|
Exceptions to |
required |
anti_tags
|
dict
|
Tags that, if present, override a barrier match and return
|
required |
Source code in map_data/utils/way.py
map_data.utils.way.Way.to_pcd_points(density=2.0, *, filled=True)
Convert the way's geometry to a dense 2-D point cloud.
For closed polygon areas the interior is filled with a regular grid
of points. For linestrings (or unfilled polygons) points are sampled
along the edges at the given density. The result is cached in
:attr:pcd_points after the first call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
density
|
float
|
Points per metre (default |
2.0
|
filled
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape |