lanestyle 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lanestyle-0.3.0/src/lanestyle.egg-info → lanestyle-0.3.2}/PKG-INFO +2 -2
- {lanestyle-0.3.0 → lanestyle-0.3.2}/pyproject.toml +2 -2
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/__init__.py +1 -1
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/data/lanestyle.json +10 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/editor.py +27 -2
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/settings.py +14 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2/src/lanestyle.egg-info}/PKG-INFO +2 -2
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle.egg-info/requires.txt +1 -1
- {lanestyle-0.3.0 → lanestyle-0.3.2}/tests/test_roads_and_items.py +8 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/LICENSE +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/README.md +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/setup.cfg +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/arrows.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/gmns.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/items.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/levels.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/page.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle/strokes.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle.egg-info/SOURCES.txt +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle.egg-info/dependency_links.txt +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/src/lanestyle.egg-info/top_level.txt +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/tests/test_lanestyle.py +0 -0
- {lanestyle-0.3.0 → lanestyle-0.3.2}/tests/test_strokes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lanestyle
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Lane-level road maps on roadstyle: every road as wide as its lanes, with bus and bike lanes, lane lines, turn arrows, zebra crossings and sidewalks, from duckOSM's GMNS lanes
|
|
5
5
|
Author: Kaveh
|
|
6
6
|
License-Expression: MIT
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: roadstyle>=0.
|
|
25
|
+
Requires-Dist: roadstyle>=0.24.2
|
|
26
26
|
Requires-Dist: geopandas
|
|
27
27
|
Requires-Dist: shapely>=2
|
|
28
28
|
Requires-Dist: duckdb
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lanestyle"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "Lane-level road maps on roadstyle: every road as wide as its lanes, with bus and bike lanes, lane lines, turn arrows, zebra crossings and sidewalks, from duckOSM's GMNS lanes"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
"Topic :: Scientific/Engineering :: GIS",
|
|
24
24
|
"Topic :: Scientific/Engineering :: Visualization",
|
|
25
25
|
]
|
|
26
|
-
dependencies = ["roadstyle>=0.
|
|
26
|
+
dependencies = ["roadstyle>=0.24.2", "geopandas", "shapely>=2", "duckdb", "pandas"]
|
|
27
27
|
|
|
28
28
|
[project.optional-dependencies]
|
|
29
29
|
dev = ["pytest"]
|
|
@@ -9,5 +9,5 @@ from lanestyle.gmns import (
|
|
|
9
9
|
from lanestyle.page import lane_page
|
|
10
10
|
from lanestyle.settings import lane_settings
|
|
11
11
|
|
|
12
|
-
__version__ = "0.3.
|
|
12
|
+
__version__ = "0.3.2"
|
|
13
13
|
__all__ = ["lane_page", "from_gmns", "read_crossings", "read_boundary", "boundary_from_geojson", "lane_settings"]
|
|
@@ -42,6 +42,16 @@
|
|
|
42
42
|
"walk": 2.0,
|
|
43
43
|
"bike": 1.5
|
|
44
44
|
},
|
|
45
|
+
"path_width_m": {
|
|
46
|
+
"footway": 2.0,
|
|
47
|
+
"steps": 2.0,
|
|
48
|
+
"path": 1.5,
|
|
49
|
+
"pedestrian": 5.0,
|
|
50
|
+
"service": 3.0,
|
|
51
|
+
"residential": 3.0,
|
|
52
|
+
"track": 2.5,
|
|
53
|
+
"default": 2.0
|
|
54
|
+
},
|
|
45
55
|
"casing_m": 0.14,
|
|
46
56
|
"casing_min_px": 1,
|
|
47
57
|
"centre_line_m": 0.15
|
|
@@ -94,6 +94,22 @@ def _strokes(gmns, source_db, connectors=False):
|
|
|
94
94
|
return lane_fc, line_fc, marks_fc, width, lines, conn_fc, zebra_fc, side_fc, special
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def _width_tags(edge_ref, source_db):
|
|
98
|
+
"""The OSM ``width`` tag of each road's way (``edge_ref``: ``<way>#<piece><f|r>``, a negative way: its OSM way with a minus), from
|
|
99
|
+
duckOSM's ``raw.ways``; None where there is none (or no source db)."""
|
|
100
|
+
if not source_db:
|
|
101
|
+
return [None] * len(edge_ref)
|
|
102
|
+
import duckdb
|
|
103
|
+
ways = [abs(int(m)) if m else None for m in edge_ref.astype(str).str.extract(r"^(-?\d+)")[0].fillna("")]
|
|
104
|
+
con = duckdb.connect(str(source_db), read_only=True)
|
|
105
|
+
try:
|
|
106
|
+
ids = sorted({w for w in ways if w is not None})
|
|
107
|
+
tag = dict(con.execute("SELECT osm_id, tags['width'] FROM raw.ways WHERE osm_id IN (SELECT unnest(?::BIGINT[]))", [ids]).fetchall()) if ids else {}
|
|
108
|
+
finally:
|
|
109
|
+
con.close()
|
|
110
|
+
return [tag.get(w) for w in ways]
|
|
111
|
+
|
|
112
|
+
|
|
97
113
|
def lane_items(roads, gmns=None, source_db=None, connectors=None):
|
|
98
114
|
"""The editor's hook (roadstyle.level_editor): each road one line at its full width (``width_m``, both directions; config
|
|
99
115
|
``single_line_classes``: every class) on the lanes' line, in the car lane colour, with roadstyle's street names; the road's own items
|
|
@@ -125,14 +141,23 @@ def lane_items(roads, gmns=None, source_db=None, connectors=None):
|
|
|
125
141
|
edges = roads["edge"].astype(str)
|
|
126
142
|
own = {r: e for r, e in zip(roads["road"], edges, strict=True) if e in width}
|
|
127
143
|
roads["width_m"] = [width.get(own.get(r), np.nan) for r in roads["road"]]
|
|
144
|
+
# a road without lanes (a footway, steps, a path: no GMNS lanes of the driving network) in metres too, as the roads with lanes
|
|
145
|
+
# (2026-10-10): its OSM width tag, else lanestyle.json path_width_m by its class
|
|
146
|
+
from lanestyle.settings import _path_widths, lane_settings
|
|
147
|
+
s = lane_settings()
|
|
148
|
+
need = roads["width_m"].isna()
|
|
149
|
+
if need.any():
|
|
150
|
+
tag = _width_tags(roads.loc[need, "edge_ref"], src) if "edge_ref" in roads else [None] * int(need.sum())
|
|
151
|
+
w, unread = _path_widths(roads.loc[need, "highway"], tag, s["path_width_m"])
|
|
152
|
+
roads.loc[need, "width_m"] = w
|
|
153
|
+
if unread:
|
|
154
|
+
print(f"lanestyle.editor: {len(unread)} width tags are no width in metres, the class width instead: {sorted(set(unread))[:5]}", flush=True)
|
|
128
155
|
roads.geometry = [lines[e] if e in lines else (LineString(list(lines[own[r]].coords)[::-1]) if own.get(r) in lines else g)
|
|
129
156
|
for e, r, g in zip(edges, roads["road"], roads.geometry, strict=True)]
|
|
130
157
|
# the road's own items in roadstyle's one road layer (render items=, 2026-10-10): the car lanes unseen (picked and highlighted), every bus
|
|
131
158
|
# and bike lane drawn on the road; the lane lines and marks on it; connectors unseen, not picked (route highlights)
|
|
132
159
|
items = (on_edges(lane_fc, pick=True, seen=lambda f: f["properties"]["lane_id"] in special) + on_edges(line_fc) + on_edges(zebra_fc) + on_edges(side_fc) + on_edges(marks_fc)
|
|
133
160
|
+ on_edges(conn_fc, seen=lambda f: False))
|
|
134
|
-
from lanestyle.settings import lane_settings
|
|
135
|
-
s = lane_settings()
|
|
136
161
|
# metres at every zoom (width_m_zoom 0) and lanestyle's casing; roadstyle's street names, not its one-way chevrons (lanestyle's arrows instead);
|
|
137
162
|
kw = {"width_m_col": "width_m", "width_m_zoom": 0, "casing_m": float(s["casing_m"]), "casing_min_px": float(s["casing_min_px"]), "arrows": False,
|
|
138
163
|
"items": {"type": "FeatureCollection", "features": items},
|
|
@@ -68,6 +68,20 @@ def _widths(g, s):
|
|
|
68
68
|
return w.fillna(default)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
|
|
72
|
+
def _path_widths(highway, width_tag, table):
|
|
73
|
+
"""A road without lanes (a footway, steps, a path, a walking-only service road ...) in metres: its OSM ``width`` tag (metres: "2",
|
|
74
|
+
"2.5 m"), else ``path_width_m`` by its class, else its ``default``. Returns ``(widths, unread)``: the tags that are no width in metres."""
|
|
75
|
+
import re
|
|
76
|
+
|
|
77
|
+
out, unread = [], []
|
|
78
|
+
for hw, tag in zip(highway, width_tag, strict=True):
|
|
79
|
+
m = re.fullmatch(r"\s*(\d+(?:[.,]\d+)?)\s*(?:m)?\s*", str(tag)) if isinstance(tag, str) else None
|
|
80
|
+
if isinstance(tag, str) and not m:
|
|
81
|
+
unread.append(tag)
|
|
82
|
+
out.append(float(m.group(1).replace(",", ".")) if m else float(table.get(str(hw), table["default"])))
|
|
83
|
+
return out, unread
|
|
84
|
+
|
|
71
85
|
def _roads_only(g):
|
|
72
86
|
"""The lanes of links that have a road class: a link with none is no road (a ferry in the walking network, a way with no ``highway`` tag)."""
|
|
73
87
|
return g[g["highway"].notna()] if "highway" in g and g["highway"].isna().any() else g
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lanestyle
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Lane-level road maps on roadstyle: every road as wide as its lanes, with bus and bike lanes, lane lines, turn arrows, zebra crossings and sidewalks, from duckOSM's GMNS lanes
|
|
5
5
|
Author: Kaveh
|
|
6
6
|
License-Expression: MIT
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: roadstyle>=0.
|
|
25
|
+
Requires-Dist: roadstyle>=0.24.2
|
|
26
26
|
Requires-Dist: geopandas
|
|
27
27
|
Requires-Dist: shapely>=2
|
|
28
28
|
Requires-Dist: duckdb
|
|
@@ -116,6 +116,7 @@ def test_the_level_editor_hook_puts_each_lane_on_its_edge_of_the_editor(tmp_path
|
|
|
116
116
|
# a road cars do not use in lanestyle's colour for who uses it (colors.groups), every other one in the car lane colour (2026-10-09)
|
|
117
117
|
table = kw.pop("color_table")
|
|
118
118
|
assert kw.pop("color_key") == "edge" and table["999"] == "#f0cb8c" and {table[e] for e in links[1:]} == {"#a3a3a3"}
|
|
119
|
+
assert drawn.loc[drawn["road"] == "foot", "width_m"].tolist() == [2.0] # a footway without lanes: lanestyle.json path_width_m, in metres
|
|
119
120
|
drawn = drawn[drawn["road"] != "foot"]
|
|
120
121
|
st, items, popup = kw.pop("settings"), kw.pop("items")["features"], kw.pop("items_popup")
|
|
121
122
|
assert overlays == [] and kw == {"width_m_col": "width_m", "width_m_zoom": 0, "casing_m": 0.14, "casing_min_px": 1.0, "arrows": False,
|
|
@@ -175,3 +176,10 @@ def test_the_lane_page_is_the_editors_drawing_without_its_panel(tmp_path):
|
|
|
175
176
|
html = ls.lane_page(tmp_path / "area", str(gmns), str(src)).html
|
|
176
177
|
assert "roads-simple" in html and '"lane_id"' in html and "1_2" in html # the one road layer, its lane items
|
|
177
178
|
assert "lv-apply" not in html and "Lanes" in html # no editor panel; the page's own name
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def test_a_road_without_lanes_is_its_width_tag_else_its_class_width():
|
|
182
|
+
from lanestyle.settings import _path_widths
|
|
183
|
+
table = {"footway": 2.0, "steps": 2.0, "default": 1.0}
|
|
184
|
+
w, unread = _path_widths(["footway", "steps", "corridor", "footway", "footway"], [None, "2.5 m", None, "3,5", "8'"], table)
|
|
185
|
+
assert w == [2.0, 2.5, 1.0, 3.5, 2.0] and unread == ["8'"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|