mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-05 04:12:08 +02:00
Issue #23: fix building height and shade.
This commit is contained in:
parent
2fccc9cf67
commit
2ffac6f98b
3 changed files with 20 additions and 12 deletions
|
@ -1089,9 +1089,9 @@ ways:
|
|||
- tags: {"area:highway": "*"}
|
||||
|
||||
- tags: {boundary: "*"}
|
||||
stroke: boundary_color
|
||||
stroke-width: 0.3
|
||||
stroke-dasharray: 10,5
|
||||
# stroke: boundary_color
|
||||
# stroke-width: 0.3
|
||||
# stroke-dasharray: 10,5
|
||||
priority: 60
|
||||
|
||||
tags_to_write: [
|
||||
|
|
|
@ -3,6 +3,8 @@ Author: Sergey Vartanov (me@enzet.ru)
|
|||
|
||||
Geo projection.
|
||||
"""
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
|
||||
from roentgen.util import MinMax
|
||||
|
@ -66,11 +68,15 @@ class Flinger:
|
|||
|
||||
return result
|
||||
|
||||
def get_scale(self, coordinates: np.array) -> float:
|
||||
def get_scale(self, coordinates: Optional[np.array] = None) -> float:
|
||||
"""
|
||||
Return pixels per meter ratio for the given geo coordinates.
|
||||
|
||||
:param coordinates: geo coordinates
|
||||
"""
|
||||
scale_factor = 1 / np.cos(coordinates[0] / 180 * np.pi)
|
||||
if coordinates is None:
|
||||
# Get pixels per meter ratio for the center of the boundary box.
|
||||
coordinates = self.geo_boundaries.center()
|
||||
|
||||
scale_factor: float = 1 / np.cos(coordinates[0] / 180 * np.pi)
|
||||
return self.pixels_per_meter * scale_factor
|
||||
|
|
|
@ -240,9 +240,10 @@ class Painter:
|
|||
self.svg.add(p)
|
||||
ui.progress_bar(-1, 0, text="Drawing ways")
|
||||
|
||||
# Building shade
|
||||
# Draw building shade.
|
||||
|
||||
building_shade = Group(opacity=0.1)
|
||||
building_shade: Group = Group(opacity=0.1)
|
||||
length: float = self.flinger.get_scale()
|
||||
|
||||
for way in constructor.buildings: # type: Building
|
||||
shift = [2 * way.get_levels(), 0 * way.get_levels()]
|
||||
|
@ -257,9 +258,10 @@ class Painter:
|
|||
|
||||
self.svg.add(building_shade)
|
||||
|
||||
previous_level: float = 0
|
||||
# Draw buildings.
|
||||
|
||||
height = 1
|
||||
previous_level: float = 0
|
||||
height: float = self.flinger.get_scale()
|
||||
|
||||
for level in sorted(constructor.levels):
|
||||
fill: Color()
|
||||
|
@ -274,8 +276,8 @@ class Painter:
|
|||
elif level == 1:
|
||||
fill = Color("#C3C3C3")
|
||||
else:
|
||||
a = 0.8 + segment.angle * 0.2
|
||||
fill = Color(rgb=(a, a, a))
|
||||
color_part: float = 0.8 + segment.angle * 0.2
|
||||
fill = Color(rgb=(color_part, color_part, color_part))
|
||||
|
||||
self.svg.add(self.svg.path(
|
||||
d=("M", np.add(segment.point_1, shift_1), "L",
|
||||
|
@ -286,7 +288,7 @@ class Painter:
|
|||
fill=fill.hex, stroke=fill.hex, stroke_width=1,
|
||||
stroke_linejoin="round"))
|
||||
|
||||
# Draw roof.
|
||||
# Draw building roof.
|
||||
|
||||
if way.get_levels() == level:
|
||||
shift = np.array([0, -way.get_levels() * height])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue