dont connect level altitudes using graphs, that was unelegant
@@ -4,7 +4,6 @@ from operator import attrgetter, itemgetter
import numpy as np
from django.db import models
-from django.db.models import F
from django.urls import reverse
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
@@ -279,43 +278,6 @@ class AltitudeArea(LevelGeometryMixin, models.Model):
space_areas[space] = set(area.tmpid for area in space_areas[space])
areas_without_altitude = set(area.tmpid for area in areas if area.altitude is None)
- # connect levels
- from c3nav.mapdata.models import GraphEdge
- edges = GraphEdge.objects.exclude(from_node__space__level=F('to_node__space__level'))
- edges = edges.select_related('from_node', 'to_node')
- node_areas = {}
- area_connections = {}
- for edge in edges:
- for node in (edge.from_node, edge.to_node):
- if node.pk not in node_areas:
- tmpid = next(tmpid for tmpid in space_areas[node.space_id]
- if areas[tmpid].geometry.contains(node.geometry))
- node_areas[node.pk] = tmpid
- area_connections.setdefault(node_areas[edge.from_node.pk], set()).add(node_areas[edge.to_node.pk])
- area_connections.setdefault(node_areas[edge.to_node.pk], set()).add(node_areas[edge.from_node.pk])
-
- del_keys = tuple(tmpid for tmpid in area_connections.keys() if tmpid not in areas_without_altitude)
- for tmpid in del_keys:
- del area_connections[tmpid]
-
- do_continue = True
- while do_continue:
- do_continue = False
- del_keys = []
- for tmpid in area_connections.keys():
- connections = area_connections[tmpid] - areas_without_altitude
- if connections:
- area = areas[tmpid]
- other_area = areas[next(iter(connections))]
- area.altitude = other_area.altitude
- areas_without_altitude.remove(tmpid)
- del_keys.append(tmpid)
-
- if del_keys:
- do_continue = True
- for tmpid in del_keys:
- del area_connections[tmpid]
-
# interpolate altitudes
areas_with_altitude = [i for i in range(len(areas)) if i not in areas_without_altitude]
for i, tmpid in enumerate(areas_with_altitude):
