mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-09 06:11:54 +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: {"area:highway": "*"}
|
||||||
|
|
||||||
- tags: {boundary: "*"}
|
- tags: {boundary: "*"}
|
||||||
stroke: boundary_color
|
# stroke: boundary_color
|
||||||
stroke-width: 0.3
|
# stroke-width: 0.3
|
||||||
stroke-dasharray: 10,5
|
# stroke-dasharray: 10,5
|
||||||
priority: 60
|
priority: 60
|
||||||
|
|
||||||
tags_to_write: [
|
tags_to_write: [
|
||||||
|
|
|
@ -3,6 +3,8 @@ Author: Sergey Vartanov (me@enzet.ru)
|
||||||
|
|
||||||
Geo projection.
|
Geo projection.
|
||||||
"""
|
"""
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from roentgen.util import MinMax
|
from roentgen.util import MinMax
|
||||||
|
@ -66,11 +68,15 @@ class Flinger:
|
||||||
|
|
||||||
return result
|
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.
|
Return pixels per meter ratio for the given geo coordinates.
|
||||||
|
|
||||||
:param coordinates: 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
|
return self.pixels_per_meter * scale_factor
|
||||||
|
|
|
@ -240,9 +240,10 @@ class Painter:
|
||||||
self.svg.add(p)
|
self.svg.add(p)
|
||||||
ui.progress_bar(-1, 0, text="Drawing ways")
|
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
|
for way in constructor.buildings: # type: Building
|
||||||
shift = [2 * way.get_levels(), 0 * way.get_levels()]
|
shift = [2 * way.get_levels(), 0 * way.get_levels()]
|
||||||
|
@ -257,9 +258,10 @@ class Painter:
|
||||||
|
|
||||||
self.svg.add(building_shade)
|
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):
|
for level in sorted(constructor.levels):
|
||||||
fill: Color()
|
fill: Color()
|
||||||
|
@ -274,8 +276,8 @@ class Painter:
|
||||||
elif level == 1:
|
elif level == 1:
|
||||||
fill = Color("#C3C3C3")
|
fill = Color("#C3C3C3")
|
||||||
else:
|
else:
|
||||||
a = 0.8 + segment.angle * 0.2
|
color_part: float = 0.8 + segment.angle * 0.2
|
||||||
fill = Color(rgb=(a, a, a))
|
fill = Color(rgb=(color_part, color_part, color_part))
|
||||||
|
|
||||||
self.svg.add(self.svg.path(
|
self.svg.add(self.svg.path(
|
||||||
d=("M", np.add(segment.point_1, shift_1), "L",
|
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,
|
fill=fill.hex, stroke=fill.hex, stroke_width=1,
|
||||||
stroke_linejoin="round"))
|
stroke_linejoin="round"))
|
||||||
|
|
||||||
# Draw roof.
|
# Draw building roof.
|
||||||
|
|
||||||
if way.get_levels() == level:
|
if way.get_levels() == level:
|
||||||
shift = np.array([0, -way.get_levels() * height])
|
shift = np.array([0, -way.get_levels() * height])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue