mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-03 19:31:52 +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.width: Optional[float] = None
|
||||
self.lanes: int = 1
|
||||
|
||||
if "lanes" in tags:
|
||||
try:
|
||||
self.width = float(tags["lanes"]) * 3.7
|
||||
self.lanes = float(tags["lanes"])
|
||||
except ValueError:
|
||||
pass
|
||||
if "width" in tags:
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
Road shape drawing.
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
from typing import List, Any, Dict
|
||||
|
||||
import numpy as np
|
||||
import svgwrite
|
||||
from shapely.geometry import LineString, Point
|
||||
|
||||
from roentgen.constructor import Road
|
||||
from roentgen.flinger import Flinger, angle, turn_by_angle, norm
|
||||
from roentgen.osm_reader import OSMNode
|
||||
|
||||
|
@ -64,13 +65,15 @@ class RoadPart:
|
|||
node_1: OSMNode,
|
||||
node_2: OSMNode,
|
||||
flinger: Flinger,
|
||||
left_offset: float,
|
||||
right_offset: float,
|
||||
lanes: List[Lane],
|
||||
road: Road,
|
||||
) -> "RoadPart":
|
||||
"""
|
||||
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(
|
||||
flinger.fling(node_1.coordinates),
|
||||
flinger.fling(node_2.coordinates),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue