shapely's cascaded_union was deprecated, replace with unary_union
This commit is contained in:
parent
aebb158b12
commit
36df1fed66
4 changed files with 14 additions and 14 deletions
|
@ -3,13 +3,13 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from shapely.ops import cascaded_union
|
||||
from shapely.ops import unary_union
|
||||
|
||||
|
||||
def set_space_outside(apps, schema_editor):
|
||||
Section = apps.get_model('mapdata', 'Section')
|
||||
for section in Section.objects.all():
|
||||
building_geometries = cascaded_union(tuple(building.geometry for building in section.buildings.all()))
|
||||
building_geometries = unary_union(tuple(building.geometry for building in section.buildings.all()))
|
||||
for space in section.spaces.all():
|
||||
if space.geometry.intersection(building_geometries).area / space.geometry.area < 0.5:
|
||||
space.outside = True
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.db import models
|
|||
from django.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from shapely.ops import cascaded_union
|
||||
from shapely.ops import unary_union
|
||||
|
||||
from c3nav.mapdata.models.locations import SpecificLocation
|
||||
|
||||
|
@ -94,8 +94,8 @@ class Level(SpecificLocation, models.Model):
|
|||
|
||||
@cached_property
|
||||
def bounds(self):
|
||||
return cascaded_union(tuple(item.geometry.buffer(0)
|
||||
for item in chain(self.altitudeareas.all(), self.buildings.all()))).bounds
|
||||
return unary_union(tuple(item.geometry.buffer(0)
|
||||
for item in chain(self.altitudeareas.all(), self.buildings.all()))).bounds
|
||||
|
||||
def get_icon(self):
|
||||
return super().get_icon() or 'layers'
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.apps import apps
|
|||
from django.db.models import Prefetch, Q
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from shapely.ops import cascaded_union
|
||||
from shapely.ops import unary_union
|
||||
|
||||
from c3nav.mapdata.grid import grid
|
||||
from c3nav.mapdata.models import Level, Location, LocationGroup, MapUpdate
|
||||
|
@ -137,7 +137,7 @@ def get_better_space_geometries():
|
|||
result = {}
|
||||
for space in Space.objects.prefetch_related('columns', 'holes'):
|
||||
geometry = space.geometry.difference(
|
||||
cascaded_union(tuple(obj.geometry for obj in chain(space.columns.all(), space.holes.all())))
|
||||
unary_union(tuple(obj.geometry for obj in chain(space.columns.all(), space.holes.all())))
|
||||
)
|
||||
if not geometry.is_empty:
|
||||
result[space.pk] = geometry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue