mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-13 16:21:55 +02:00
Issue #45: support parsing from tags.
This commit is contained in:
parent
acfeee97eb
commit
62f10ab647
2 changed files with 10 additions and 4 deletions
|
@ -202,9 +202,12 @@ class Road(Figure):
|
||||||
self.matcher: RoadMatcher = matcher
|
self.matcher: RoadMatcher = matcher
|
||||||
|
|
||||||
self.width: Optional[float] = None
|
self.width: Optional[float] = None
|
||||||
|
self.lanes: int = 1
|
||||||
|
|
||||||
if "lanes" in tags:
|
if "lanes" in tags:
|
||||||
try:
|
try:
|
||||||
self.width = float(tags["lanes"]) * 3.7
|
self.width = float(tags["lanes"]) * 3.7
|
||||||
|
self.lanes = float(tags["lanes"])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
if "width" in tags:
|
if "width" in tags:
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
Road shape drawing.
|
Road shape drawing.
|
||||||
"""
|
"""
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List
|
from typing import List, Any, Dict
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import svgwrite
|
import svgwrite
|
||||||
from shapely.geometry import LineString, Point
|
from shapely.geometry import LineString, Point
|
||||||
|
|
||||||
|
from roentgen.constructor import Road
|
||||||
from roentgen.flinger import Flinger, angle, turn_by_angle, norm
|
from roentgen.flinger import Flinger, angle, turn_by_angle, norm
|
||||||
from roentgen.osm_reader import OSMNode
|
from roentgen.osm_reader import OSMNode
|
||||||
|
|
||||||
|
@ -64,13 +65,15 @@ class RoadPart:
|
||||||
node_1: OSMNode,
|
node_1: OSMNode,
|
||||||
node_2: OSMNode,
|
node_2: OSMNode,
|
||||||
flinger: Flinger,
|
flinger: Flinger,
|
||||||
left_offset: float,
|
road: Road,
|
||||||
right_offset: float,
|
|
||||||
lanes: List[Lane],
|
|
||||||
) -> "RoadPart":
|
) -> "RoadPart":
|
||||||
"""
|
"""
|
||||||
Construct road part from OSM nodes.
|
Construct road part from OSM nodes.
|
||||||
"""
|
"""
|
||||||
|
left_offset: float = road.width / 2
|
||||||
|
right_offset: float = road.width / 2
|
||||||
|
lanes = [Lane(road.width / road.lanes)] * road.lanes
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
flinger.fling(node_1.coordinates),
|
flinger.fling(node_1.coordinates),
|
||||||
flinger.fling(node_2.coordinates),
|
flinger.fling(node_2.coordinates),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue