fix incorrect exclusion
This commit is contained in:
parent
8581418712
commit
256b525a6c
2 changed files with 12 additions and 4 deletions
|
@ -3,6 +3,7 @@ import os
|
|||
from django.conf import settings
|
||||
from django.db.models import Max, Min
|
||||
from shapely.geometry import box
|
||||
from shapely.ops import cascaded_union
|
||||
|
||||
from c3nav.mapdata.models import Package
|
||||
from c3nav.mapdata.utils.cache import cache_result
|
||||
|
@ -29,8 +30,12 @@ def get_render_path(filetype, level, mode, public):
|
|||
|
||||
|
||||
def get_public_private_area(level):
|
||||
from c3nav.mapdata.models import AreaLocation
|
||||
|
||||
width, height = get_dimensions()
|
||||
everything = box(0, 0, width, height)
|
||||
public_area = level.public_geometries.areas_and_doors
|
||||
needs_permission = [location.geometry
|
||||
for location in AreaLocation.objects.filter(routing_inclusion='needs_permission')]
|
||||
public_area = level.public_geometries.areas_and_doors.difference(cascaded_union(needs_permission))
|
||||
private_area = everything.difference(public_area)
|
||||
return public_area, private_area
|
||||
|
|
|
@ -276,15 +276,18 @@ class GraphRoom():
|
|||
|
||||
if ':nonpublic' in self.excludables and ':nonpublic' not in include:
|
||||
points, = self.excludable_points[self.excludables.index(':nonpublic')].nonzero()
|
||||
factors[points[:, None], points] = 1000 if allow_nonpublic else np.inf
|
||||
factors[points[:, None], :] = 1000 if allow_nonpublic else np.inf
|
||||
factors[:, points] = 1000 if allow_nonpublic else np.inf
|
||||
|
||||
if avoid:
|
||||
points, = self.excludable_points[avoid, :].any(axis=0).nonzero()
|
||||
factors[points[:, None], points] = np.maximum(factors[points[:, None], points], 1000)
|
||||
factors[points[:, None], :] = np.maximum(factors[points[:, None], :], 1000)
|
||||
factors[:, points] = np.maximum(factors[:, points], 1000)
|
||||
|
||||
if include:
|
||||
points, = self.excludable_points[include, :].any(axis=0).nonzero()
|
||||
factors[points[:, None], points] = 1
|
||||
factors[points[:, None], :] = 1
|
||||
factors[:, points] = 1
|
||||
|
||||
g_sparse = csgraph_from_dense(distances*factors, null_value=np.inf)
|
||||
shortest_paths, predecessors = shortest_path(g_sparse, return_predecessors=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue