fix bugs with new ramps
This commit is contained in:
parent
5eb7cd363c
commit
bbbdfd15fb
6 changed files with 25 additions and 13 deletions
|
@ -16,8 +16,8 @@ def forwards_func(apps, schema_editor):
|
|||
for area in AltitudeArea.objects.all():
|
||||
if area.point1 is not None:
|
||||
area.points = [
|
||||
AltitudeAreaPoint(coordinates=[area.point1.x, area.point1.y], altitude=float(area.altitude1)),
|
||||
AltitudeAreaPoint(coordinates=[area.point2.x, area.point2.y], altitude=float(area.altitude))
|
||||
AltitudeAreaPoint(coordinates=[area.point1.x, area.point1.y], altitude=float(area.altitude)),
|
||||
AltitudeAreaPoint(coordinates=[area.point2.x, area.point2.y], altitude=float(area.altitude2))
|
||||
]
|
||||
area.altitude = None
|
||||
area.save()
|
||||
|
|
|
@ -269,9 +269,9 @@ class AltitudeArea(LevelGeometryMixin, models.Model):
|
|||
tuple(unwrap_geom(h.geometry) for h in space.holes.all()))
|
||||
)
|
||||
|
||||
space_ramps = unary_union(tuple(unwrap_geom(r.geometry) for r in space.ramps.all()))
|
||||
areas.append(space_accessible.difference(space_ramps))
|
||||
for geometry in assert_multipolygon(space_accessible.intersection(space_ramps)):
|
||||
space_ramps_geom = unary_union(tuple(unwrap_geom(r.geometry) for r in space.ramps.all()))
|
||||
areas.append(space_accessible.difference(space_ramps_geom))
|
||||
for geometry in assert_multipolygon(space_accessible.intersection(space_ramps_geom)):
|
||||
ramp = AltitudeArea(geometry=geometry, level=level)
|
||||
ramp.geometry_prep = prepared.prep(geometry)
|
||||
ramp.space = space.pk
|
||||
|
@ -644,7 +644,8 @@ class AltitudeArea(LevelGeometryMixin, models.Model):
|
|||
else:
|
||||
potential_areas = [areas[tmpid] for tmpid in level_areas.get(candidate.level, set())]
|
||||
potential_areas = [area for area in potential_areas
|
||||
if set(p.altitude for p in candidate.points) == set(p.altitude for p in area.points)]
|
||||
if ((candidate.altitude, set(p.altitude for p in (candidate.points or ()))) ==
|
||||
(area.altitude, set(p.altitude for p in (area.points or ()))))]
|
||||
potential_areas = [(area, area.geometry.intersection(unwrap_geom(candidate.geometry)).area)
|
||||
for area in potential_areas
|
||||
if candidate.geometry_prep.intersects(unwrap_geom(area.geometry))]
|
||||
|
|
|
@ -4,6 +4,7 @@ from itertools import chain
|
|||
import numpy as np
|
||||
|
||||
from c3nav.mapdata.models import AltitudeArea
|
||||
from c3nav.mapdata.models.geometry.level import AltitudeAreaPoint
|
||||
from c3nav.mapdata.render.geometry.hybrid import HybridGeometry
|
||||
|
||||
|
||||
|
@ -11,8 +12,10 @@ class AltitudeAreaGeometries:
|
|||
def __init__(self, altitudearea=None, colors=None, obstacles=None):
|
||||
if altitudearea is not None:
|
||||
self.geometry = altitudearea.geometry
|
||||
self.altitude = int(altitudearea.altitude * 1000)
|
||||
self.points = altitudearea.points
|
||||
self.altitude = None if altitudearea.altitude is None else int(altitudearea.altitude * 1000)
|
||||
self.points = None if altitudearea.points is None else [AltitudeAreaPoint(coordinates=p.coordinates,
|
||||
altitude=int(p.altitude*2))
|
||||
for p in altitudearea.points]
|
||||
else:
|
||||
self.geometry = None
|
||||
self.altitude = None
|
||||
|
@ -22,6 +25,14 @@ class AltitudeAreaGeometries:
|
|||
self.colors = colors
|
||||
self.obstacles = obstacles
|
||||
|
||||
@property
|
||||
def min_altitude(self):
|
||||
return self.altitude if self.altitude is not None else min(p.altitude for p in self.points)
|
||||
|
||||
@property
|
||||
def max_altitude(self):
|
||||
return self.altitude if self.altitude is not None else max(p.altitude for p in self.points)
|
||||
|
||||
def get_altitudes(self, points):
|
||||
# noinspection PyCallByClass,PyTypeChecker
|
||||
return AltitudeArea.get_altitudes(self, points/1000).astype(np.int32)
|
||||
|
|
|
@ -250,9 +250,9 @@ class LevelGeometries:
|
|||
geoms.base_altitude = int(level.base_altitude * 1000)
|
||||
geoms.default_height = int(level.default_height * 1000)
|
||||
geoms.door_height = int(level.door_height * 1000)
|
||||
geoms.min_altitude = (min(area.altitude for area in geoms.altitudeareas)
|
||||
geoms.min_altitude = (min(area.min_altitude for area in geoms.altitudeareas)
|
||||
if geoms.altitudeareas else geoms.base_altitude)
|
||||
geoms.max_altitude = (max(area.altitude for area in geoms.altitudeareas)
|
||||
geoms.max_altitude = (max(area.max_altitude for area in geoms.altitudeareas)
|
||||
if geoms.altitudeareas else geoms.base_altitude)
|
||||
geoms.max_height = (min(height for area, height in geoms.heightareas)
|
||||
if geoms.heightareas else geoms.default_height)
|
||||
|
|
|
@ -303,9 +303,9 @@ class LevelRenderData:
|
|||
new_geoms.base_altitude = old_geoms.base_altitude
|
||||
new_geoms.default_height = old_geoms.default_height
|
||||
new_geoms.door_height = old_geoms.door_height
|
||||
new_geoms.min_altitude = (min(area.altitude for area in new_geoms.altitudeareas)
|
||||
new_geoms.min_altitude = (min(area.min_altitude for area in new_geoms.altitudeareas)
|
||||
if new_geoms.altitudeareas else new_geoms.base_altitude)
|
||||
new_geoms.max_altitude = (max(area.altitude for area in new_geoms.altitudeareas)
|
||||
new_geoms.max_altitude = (max(area.max_altitude for area in new_geoms.altitudeareas)
|
||||
if new_geoms.altitudeareas else new_geoms.base_altitude)
|
||||
new_geoms.max_height = (min(height for area, height in new_geoms.heightareas)
|
||||
if new_geoms.heightareas else new_geoms.default_height)
|
||||
|
|
|
@ -4,7 +4,7 @@ from c3nav.mapdata.render.renderdata import LevelRenderData
|
|||
|
||||
|
||||
def get_min_altitude(levels, default):
|
||||
min_altitude = min(chain(*(tuple(area.altitude for area in geoms.altitudeareas)
|
||||
min_altitude = min(chain(*(tuple(area.min_altitude for area in geoms.altitudeareas)
|
||||
for geoms in levels)),
|
||||
default=None)
|
||||
if min_altitude is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue