start implementing RangeLocator
This commit is contained in:
parent
e3afa4b2ea
commit
0b6362c8ab
8 changed files with 125 additions and 21 deletions
|
@ -184,6 +184,10 @@ class MapUpdate(models.Model):
|
|||
from c3nav.routing.locator import Locator
|
||||
Locator.rebuild(new_updates[-1].to_tuple)
|
||||
|
||||
logger.info('Rebuilding range locator...')
|
||||
from c3nav.routing.rangelocator import RangeLocator
|
||||
RangeLocator.rebuild(new_updates[-1].to_tuple)
|
||||
|
||||
for new_update in reversed(new_updates):
|
||||
new_update.processed = True
|
||||
new_update.save()
|
||||
|
|
|
@ -2,9 +2,10 @@ import math
|
|||
import operator
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
from dataclasses import dataclass, field
|
||||
from functools import reduce
|
||||
from itertools import chain
|
||||
from typing import List, Mapping, Optional, Union
|
||||
from typing import Any, List, Mapping, Optional, Union
|
||||
|
||||
from django.apps import apps
|
||||
from django.db.models import Prefetch, Q
|
||||
|
@ -271,20 +272,23 @@ def get_custom_location_for_request(slug: str, request):
|
|||
AccessPermission.get_for_request(request))
|
||||
|
||||
|
||||
@dataclass
|
||||
class CustomLocation:
|
||||
can_search = True
|
||||
can_describe = True
|
||||
access_restriction_id = None
|
||||
|
||||
def __init__(self, level, x, y, permissions, icon='pin_drop'):
|
||||
x = round(x, 2)
|
||||
y = round(y, 2)
|
||||
self.pk = 'c:%s:%s:%s' % (level.short_label, x, y)
|
||||
self.permissions = permissions
|
||||
self.level = level
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.icon = icon
|
||||
pk: str = field(init=False)
|
||||
level: Level
|
||||
x: float | int
|
||||
y: float | int
|
||||
permissions: Any = () # todo: correct this
|
||||
icon: str = "pin_drop"
|
||||
|
||||
def __post_init__(self):
|
||||
x = round(self.x, 2)
|
||||
y = round(self.y, 2)
|
||||
self.pk = 'c:%s:%s:%s' % (self.level.short_label, x, y)
|
||||
|
||||
@property
|
||||
def serialized_geometry(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue