wifimeasurement → beaconmeasurement… and editor scancollector implementation
This commit is contained in:
parent
35d030a6fd
commit
20fbcc9139
13 changed files with 169 additions and 85 deletions
|
@ -48,7 +48,7 @@ def geometrystyles(request):
|
|||
'graphnode': '#009900',
|
||||
'graphedge': '#00CC00',
|
||||
'altitudemarker': '#0000FF',
|
||||
'wifimeasurement': '#DDDD00',
|
||||
'beaconmeasurement': '#DDDD00',
|
||||
'rangingbeacon': '#CC00CC',
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ def get_level_geometries_result(request, level_id: int, update_cache_key: str, u
|
|||
Building = request.changeset.wrap_model('Building')
|
||||
Door = request.changeset.wrap_model('Door')
|
||||
LocationGroup = request.changeset.wrap_model('LocationGroup')
|
||||
WifiMeasurement = request.changeset.wrap_model('WifiMeasurement')
|
||||
BeaconMeasurement = request.changeset.wrap_model('BeaconMeasurement')
|
||||
RangingBeacon = request.changeset.wrap_model('RangingBeacon')
|
||||
|
||||
try:
|
||||
|
@ -149,7 +149,7 @@ def get_level_geometries_result(request, level_id: int, update_cache_key: str, u
|
|||
Prefetch('buildings', Building.objects.only('geometry', 'level')),
|
||||
Prefetch('spaces__holes', Hole.objects.only('geometry', 'space')),
|
||||
Prefetch('spaces__altitudemarkers', AltitudeMarker.objects.only('geometry', 'space')),
|
||||
Prefetch('spaces__wifi_measurements', WifiMeasurement.objects.only('geometry', 'space')),
|
||||
Prefetch('spaces__beacon_measurements', BeaconMeasurement.objects.only('geometry', 'space')),
|
||||
Prefetch('spaces__ranging_beacons', RangingBeacon.objects.only('geometry', 'space')),
|
||||
Prefetch('spaces__graphnodes', graphnodes_qs)
|
||||
)
|
||||
|
@ -184,7 +184,7 @@ def get_level_geometries_result(request, level_id: int, update_cache_key: str, u
|
|||
_get_geometries_for_one_level(level),
|
||||
*(_get_geometries_for_one_level(level) for level in levels_on_top),
|
||||
*(space.altitudemarkers.all() for space in level.spaces.all()),
|
||||
*(space.wifi_measurements.all() for space in level.spaces.all()),
|
||||
*(space.beacon_measurements.all() for space in level.spaces.all()),
|
||||
*(space.ranging_beacons.all() for space in level.spaces.all()),
|
||||
graphedges,
|
||||
graphnodes,
|
||||
|
@ -309,7 +309,7 @@ def get_space_geometries_result(request, space_id: int, update_cache_key: str, u
|
|||
space.lineobstacles.all().only('geometry', 'width', 'space').prefetch_related('group'),
|
||||
space.columns.all().only('geometry', 'space'),
|
||||
space.altitudemarkers.all().only('geometry', 'space'),
|
||||
space.wifi_measurements.all().only('geometry', 'space'),
|
||||
space.beacon_measurements.all().only('geometry', 'space'),
|
||||
space.ranging_beacons.all().only('geometry', 'space'),
|
||||
space.pois.filter(POI.q_for_request(request)).only('geometry', 'space').prefetch_related(
|
||||
Prefetch('groups', LocationGroup.objects.only(
|
||||
|
|
|
@ -396,38 +396,41 @@ textarea.form-control {
|
|||
height: 75px;
|
||||
}
|
||||
|
||||
.wificollector {
|
||||
.scancollector {
|
||||
padding: 10px;
|
||||
height: auto;
|
||||
}
|
||||
body > .wificollector {
|
||||
body > .scancollector {
|
||||
display: none;
|
||||
}
|
||||
.wificollector:not(.empty) .btn.start,
|
||||
.wificollector:not(.running) .btn.stop,
|
||||
.wificollector:not(.done) .btn.reset,
|
||||
.wificollector.empty .count-line,
|
||||
body:not(.mobileclient) .wificollector .btn {
|
||||
.scancollector:not(.empty) .btn.start,
|
||||
.scancollector:not(.running) .btn.stop,
|
||||
.scancollector:not(.done) .btn.reset,
|
||||
.scancollector.empty .count-line,
|
||||
body:not(.mobileclient) .scancollector .btn {
|
||||
display: none;
|
||||
}
|
||||
.wificollector .btn {
|
||||
.scancollector .btn {
|
||||
margin: 0 5px 0 0;
|
||||
}
|
||||
.wificollector p:first-child {
|
||||
.scancollector p:first-child {
|
||||
height: 26px;
|
||||
margin: 0;
|
||||
}
|
||||
.wificollector table {
|
||||
.scancollector table {
|
||||
width: 100%;
|
||||
border-style: solid;
|
||||
border-width: 0 0 1px;
|
||||
border-color: #666666;
|
||||
}
|
||||
.wificollector table td {
|
||||
.scancollector table td {
|
||||
padding: 5px 5px 0 0;
|
||||
}
|
||||
.wificollector table td:last-child {
|
||||
.scancollector table td:last-child {
|
||||
padding-right: 0;
|
||||
text-align: right;
|
||||
}
|
||||
.wificollector table tr td {
|
||||
.scancollectorŝ table tr td {
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ editor = {
|
|||
editor._sublevel_control_container = $(editor._sublevel_control._container);
|
||||
|
||||
editor.init_geometries();
|
||||
editor.init_wificollector();
|
||||
editor.init_scancollector();
|
||||
editor.sidebar_content_loaded();
|
||||
},
|
||||
_inform_mobile_client: function(elem) {
|
||||
|
@ -175,7 +175,7 @@ editor = {
|
|||
editor._fixed_point_layer = null;
|
||||
}
|
||||
|
||||
if (window.mobileclient && mobileclient.wificollectorStop && $('#sidebar').find('.wificollector.running').length) {
|
||||
if (window.mobileclient && mobileclient.wificollectorStop && $('#sidebar').find('.scancollector.running').length) {
|
||||
mobileclient.wificollectorStop();
|
||||
}
|
||||
|
||||
|
@ -413,13 +413,13 @@ editor = {
|
|||
var data_field = $('form [name=data]');
|
||||
if (data_field.length) {
|
||||
data_field.hide();
|
||||
var collector = $($('body .wificollector')[0].outerHTML);
|
||||
var collector = $($('body .scancollector')[0].outerHTML);
|
||||
var existing_data = [];
|
||||
if (data_field.val()) {
|
||||
existing_data = JSON.parse(data_field.val());
|
||||
}
|
||||
if (existing_data.length > 0) {
|
||||
collector.removeClass('empty').addClass('done').find('.count').text(existing_data.length);
|
||||
collector.removeClass('empty').addClass('done').find('.wifi-count').text(existing_data.length);
|
||||
} else {
|
||||
data_field.closest('form').addClass('scan-lock');
|
||||
}
|
||||
|
@ -1304,50 +1304,58 @@ editor = {
|
|||
}
|
||||
},
|
||||
|
||||
init_wificollector: function () {
|
||||
init_scancollector: function () {
|
||||
// init geometries and edit listeners
|
||||
editor._highlight_layer = L.layerGroup().addTo(editor.map);
|
||||
|
||||
$('#sidebar').on('click', '.wificollector .start', editor._wificollector_start)
|
||||
.on('click', '.wificollector .stop', editor._wificollector_stop)
|
||||
.on('click', '.wificollector .reset', editor._wificollector_reset);
|
||||
window.setInterval(editor._wificollector_scan_perhaps, 1000);
|
||||
$('#sidebar').on('click', '.scancollector .start', editor._scancollector_start)
|
||||
.on('click', '.scancollector .stop', editor._scancollector_stop)
|
||||
.on('click', '.scancollector .reset', editor._scancollector_reset);
|
||||
window.setInterval(editor._scancollector_wifi_scan_perhaps, 1000);
|
||||
},
|
||||
_wificollector_data: [],
|
||||
_wificollector_start: function () {
|
||||
var $collector = $('#sidebar').find('.wificollector');
|
||||
_scancollector_data: {
|
||||
wifi: [],
|
||||
ibeacon: [],
|
||||
},
|
||||
_scancollector_start: function () {
|
||||
var $collector = $('#sidebar').find('.scancollector');
|
||||
$collector.removeClass('empty').addClass('running');
|
||||
editor._wificollector_data = [];
|
||||
$collector.find('.count').text(0);
|
||||
editor._scancollector_data.wifi = [];
|
||||
editor._scancollector_data.ibeacon = [];
|
||||
$collector.find('.wifi-count').text(0);
|
||||
$collector.find('.ibeacon-count').text(0);
|
||||
if (mobileclient.wificollectorStart) mobileclient.wificollectorStart();
|
||||
if (mobileclient.registerBeaconUuid) mobileclient.registerBeaconUuid("a142621a-2f42-09b3-245b-e1ac6356e9b0");
|
||||
},
|
||||
_wificollector_stop: function () {
|
||||
_scancollector_stop: function () {
|
||||
if (mobileclient.wificollectorStop) mobileclient.wificollectorStop();
|
||||
if (!editor._wificollector_data.length) return editor._wificollector_reset();
|
||||
var $collector = $('#sidebar').find('.wificollector');
|
||||
if (mobileclient.unregisterBeaconUuid) mobileclient.unregisterBeaconUuid("a142621a-2f42-09b3-245b-e1ac6356e9b0");
|
||||
// todo: maybe reset if either is empty?
|
||||
if (!editor._scancollector_data.wifi.length && editor._scancollector_data.ibeacon.length) return editor._scancollector_reset();
|
||||
var $collector = $('#sidebar').find('.scancollector');
|
||||
$collector.removeClass('running').delay(1000).queue(function(n) {
|
||||
$(this).addClass('done');
|
||||
n();
|
||||
});
|
||||
$collector.closest('form').removeClass('scan-lock');
|
||||
},
|
||||
_wificollector_reset: function () {
|
||||
var $collector = $('#sidebar').find('.wificollector');
|
||||
$collector.removeClass('done').removeClass('running').addClass('empty').find('table').html('');
|
||||
_scancollector_reset: function () {
|
||||
var $collector = $('#sidebar').find('.scancollector');
|
||||
$collector.removeClass('done').removeClass('running').addClass('empty').find('table').forEach(function(elem) {elem.html('');});
|
||||
$collector.siblings('[name=data]').val('');
|
||||
$collector.closest('form').addClass('scan-lock');
|
||||
},
|
||||
_wificollector_last_max_last: 0,
|
||||
_wificollector_last_result: 0,
|
||||
_wificollector_result: function(data) {
|
||||
var $collector = $('#sidebar').find('.wificollector.running'),
|
||||
$table = $collector.find('table'),
|
||||
_scancollector_wifi_last_max_last: 0,
|
||||
_scancollector_wifi_last_result: 0,
|
||||
_scancollector_wifi_result: function(data) {
|
||||
var $collector = $('#sidebar').find('.scancollector.running'),
|
||||
$table = $collector.find('.wifi-table'),
|
||||
item, i, line, apid, color, max_last = 0, now = Date.now();
|
||||
editor._scan_waits = false;
|
||||
editor._wifi_scan_waits = false;
|
||||
|
||||
if (!data.length) return;
|
||||
if (now-2000 < editor._wificollector_last_result) return;
|
||||
editor._wificollector_last_result = now;
|
||||
if (now-2000 < editor._scancollector_wifi_last_result) return;
|
||||
editor._scancollector_wifi_last_result = now;
|
||||
|
||||
// ignore this scan?
|
||||
for (i=0; i < data.length; i++) {
|
||||
|
@ -1356,8 +1364,8 @@ editor = {
|
|||
max_last = Math.max(max_last, item.last);
|
||||
}
|
||||
}
|
||||
if (max_last && editor._wificollector_last_max_last && max_last === editor._max_last_max) return;
|
||||
editor._wificollector_last_max_last = max_last;
|
||||
if (max_last && editor._scancollector_wifi_last_max_last && max_last === editor._max_last_max) return;
|
||||
editor._scancollector_wifi_last_max_last = max_last;
|
||||
|
||||
$table.find('tr').addClass('old');
|
||||
for (i=0; i < data.length; i++) {
|
||||
|
@ -1388,23 +1396,55 @@ editor = {
|
|||
$table.append(line);
|
||||
}
|
||||
}
|
||||
editor._wificollector_data.push(data);
|
||||
$collector.find('.count').text(editor._wificollector_data.length);
|
||||
$collector.siblings('[name=data]').val(JSON.stringify(editor._wificollector_data));
|
||||
editor._scancollector_data.wifi.push(data);
|
||||
$collector.find('.wifi-count').text(editor._scancollector_data.wifi.length);
|
||||
$collector.siblings('[name=data]').val(JSON.stringify(editor._scancollector_data));
|
||||
},
|
||||
_scan_waits: false,
|
||||
_wificollector_scan_perhaps: function() {
|
||||
if (!editor._scan_waits && $('#sidebar').find('.wificollector.running').length) {
|
||||
editor._scan_waits = true;
|
||||
_scancollector_ibeacon_result: function(data) {
|
||||
var $collector = $('#sidebar').find('.scancollector.running'),
|
||||
$table = $collector.find('.ibeacon-table'),
|
||||
item, i, line, beaconid, color = Date.now();
|
||||
|
||||
if (!data.length) return;
|
||||
|
||||
$table.find('tr').addClass('old');
|
||||
for (i=0; i < data.length; i++) {
|
||||
item = data[i];
|
||||
|
||||
beaconid = 'beacon-'+item.uuid+'-'+item.major+'-'+item-minor;
|
||||
line = $table.find('tr.'+beaconid);
|
||||
color = Math.max(0, Math.min(50, item.distance));
|
||||
color = 'rgb('+String(color*5)+', '+String(200-color*4)+', 0)';
|
||||
if (line.length) {
|
||||
line.removeClass('old').find(':last-child').text(item.distance).css('color', color);
|
||||
} else {
|
||||
line = $('<tr>').addClass(beaconid);
|
||||
line.append($('<td>').text(item.major));
|
||||
line.append($('<td>').text(item.minor));
|
||||
line.append($('<td>').text(item.distance).css('color', color));
|
||||
$table.append(line);
|
||||
}
|
||||
}
|
||||
editor._scancollector_data.ibeacon.push(data);
|
||||
$collector.find('.ibeacon-count').text(editor._scancollector_data.ibeacon.length);
|
||||
$collector.siblings('[name=data]').val(JSON.stringify(editor._scancollector_data));
|
||||
},
|
||||
_wifi_scan_waits: false,
|
||||
_scancollector_wifi_scan_perhaps: function() {
|
||||
if (!editor._wifi_scan_waits && $('#sidebar').find('.scancollector.running').length) {
|
||||
editor._wifi_scan_waits = true;
|
||||
mobileclient.scanNow();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function nearby_stations_available() {
|
||||
editor._wificollector_result(JSON.parse(mobileclient.getNearbyStations()));
|
||||
editor._scancollector_wifi_result(JSON.parse(mobileclient.getNearbyStations()));
|
||||
}
|
||||
|
||||
function ibeacon_results_available() {
|
||||
c3nav._scancollector_ibeacon_result(mobileclient.getNearbyBeacons());
|
||||
}
|
||||
|
||||
LevelControl = L.Control.extend({
|
||||
options: {
|
||||
|
|
|
@ -69,17 +69,19 @@
|
|||
{% endblock %}
|
||||
</div>
|
||||
|
||||
<div class="wificollector form-control empty">
|
||||
<div class="scancollector form-control empty">
|
||||
<p>
|
||||
<a class="btn btn-xs btn-primary start">{% trans 'Start scanning' %}</a>
|
||||
<a class="btn btn-xs btn-default stop">{% trans 'Stop scanning' %}</a>
|
||||
<a class="btn btn-xs btn-danger reset">{% trans 'Reset scan results' %}</a>
|
||||
<span class="count-line"><span class="count">0</span> scans</span>
|
||||
</p>
|
||||
<p class="nomobileclient"><em>
|
||||
{% trans 'mobileclient not found. Please install the c3nav app for wifi scanning support.' %}
|
||||
</em></p>
|
||||
<table></table>
|
||||
<p><span class="count-line"><span class="wifi-count">0</span> WiFi scans</span></p>
|
||||
<table class="wifi-table"></table>
|
||||
<p><span class="count-line"><span class="ibeacon-count">0</span> iBeacon scans</span></p>
|
||||
<table class="ibeacon-table"></table>
|
||||
</div>
|
||||
|
||||
<div class="theme-editor-filter">
|
||||
|
|
|
@ -80,5 +80,5 @@ urlpatterns.extend(add_editor_urls('POI', 'Space'))
|
|||
urlpatterns.extend(add_editor_urls('AltitudeMarker', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('LeaveDescription', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('CrossDescription', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('WifiMeasurement', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('BeaconMeasurement', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('RangingBeacon', 'Space'))
|
||||
|
|
|
@ -108,7 +108,7 @@ def space_detail(request, level, pk):
|
|||
if edit_utils.can_access_child_base_mapdata:
|
||||
submodels = ('POI', 'Area', 'Obstacle', 'LineObstacle', 'Stair', 'Ramp', 'Column',
|
||||
'Hole', 'AltitudeMarker', 'LeaveDescription', 'CrossDescription',
|
||||
'WifiMeasurement', 'RangingBeacon')
|
||||
'BeaconMeasurement', 'RangingBeacon')
|
||||
else:
|
||||
submodels = ('POI', 'Area', 'AltitudeMarker', 'LeaveDescription', 'CrossDescription')
|
||||
|
||||
|
@ -281,9 +281,9 @@ def edit(request, pk=None, model=None, level=None, space=None, on_top_of=None, e
|
|||
'nozoom': True
|
||||
})
|
||||
|
||||
if new and model.__name__ == 'WifiMeasurement' and not request.user.is_authenticated:
|
||||
if new and model.__name__ == 'BeaconMeasurement' and not request.user.is_authenticated:
|
||||
return APIHybridLoginRequiredResponse(next=request.path_info, login_url='editor.login', level='info',
|
||||
message=_('You need to log in to create Wifi Measurements.'))
|
||||
message=_('You need to log in to create Beacon Measurements.'))
|
||||
|
||||
error = None
|
||||
delete = getattr(request, 'is_delete', None)
|
||||
|
|
|
@ -12,7 +12,7 @@ class Command(BaseCommand):
|
|||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--yes', action='store_true', help='really delete it')
|
||||
parser.add_argument('--wifi-measurements', action='store_true', help='delete wifi measurements')
|
||||
parser.add_argument('--beacon-measurements', action='store_true', help='delete beacon measurements')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
from django.contrib.auth import get_user_model
|
||||
|
@ -21,7 +21,7 @@ class Command(BaseCommand):
|
|||
from c3nav.editor.models import ChangeSet
|
||||
from c3nav.mapdata.models import MapUpdate
|
||||
from c3nav.mapdata.models.access import AccessPermissionToken
|
||||
from c3nav.mapdata.models.geometry.space import WifiMeasurement
|
||||
from c3nav.mapdata.models.geometry.space import BeaconMeasurement
|
||||
from c3nav.site.models import Announcement
|
||||
|
||||
logger = logging.getLogger('c3nav')
|
||||
|
@ -46,9 +46,9 @@ class Command(BaseCommand):
|
|||
UserPermissions.objects.filter(user__is_superuser=False).delete()
|
||||
logger.info('Deleted all UserPermissions not attached to a super user')
|
||||
|
||||
if options['wifi_measurements']:
|
||||
WifiMeasurement.objects.all().delete()
|
||||
logger.info('Deleted all WifiMeasurements')
|
||||
if options['beacon_measurements']:
|
||||
BeaconMeasurement.objects.all().delete()
|
||||
logger.info('Deleted all BeaconMeasurements')
|
||||
|
||||
get_user_model().objects.filter(is_superuser=False).delete()
|
||||
logger.info('Deleted all Users who are not a super user')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import numpy as np
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from c3nav.mapdata.models.geometry.space import WifiMeasurement, RangingBeacon
|
||||
from c3nav.mapdata.models.geometry.space import BeaconMeasurement, RangingBeacon
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -10,11 +10,11 @@ class Command(BaseCommand):
|
|||
def handle(self, *args, **options):
|
||||
found_beacons = {}
|
||||
# lets collect them
|
||||
for wifi_measurement in WifiMeasurement.objects.select_related("space"):
|
||||
for measurement_list in wifi_measurement.data:
|
||||
for beacon_measurement in BeaconMeasurement.objects.select_related("space"):
|
||||
for measurement_list in beacon_measurement.data:
|
||||
for measurement in measurement_list:
|
||||
if measurement.get("supports80211mc", False) or measurement.get("distance", None):
|
||||
found_beacons.setdefault(measurement["bssid"], []).append((wifi_measurement, measurement))
|
||||
found_beacons.setdefault(measurement["bssid"], []).append((beacon_measurement, measurement))
|
||||
|
||||
# put in the ones we know
|
||||
known = {r.wifi_bssid: r for r in RangingBeacon.objects.all()}
|
||||
|
@ -22,8 +22,8 @@ class Command(BaseCommand):
|
|||
# lets go through them
|
||||
for bssid, measurements in found_beacons.items():
|
||||
print(bssid, measurements[0][1]["ssid"], known.get(bssid))
|
||||
points = {wifi_measurement.geometry for wifi_measurement, measurement in measurements}
|
||||
for wifi_measurement, measurement in measurements:
|
||||
points = {beacon_measurement.geometry for beacon_measurement, measurement in measurements}
|
||||
for beacon_measurement, measurement in measurements:
|
||||
break
|
||||
#print(f" Space={wifi_measurement.space.title!r} RSSI={measurement['rssi']} "
|
||||
# f"distance={measurement.get('distance')} distance_sd={measurement.get('distance_sd')}")
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# Generated by Django 5.0.1 on 2024-03-31 13:58
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
BeaconMeasurement = apps.get_model('mapdata', 'BeaconMeasurement')
|
||||
for measurement in BeaconMeasurement.objects.all():
|
||||
measurement.data = {"wifi": measurement.data}
|
||||
measurement.save()
|
||||
|
||||
|
||||
def backwards_func(apps, schema_editor):
|
||||
BeaconMeasurement = apps.get_model('mapdata', 'BeaconMeasurement')
|
||||
for measurement in BeaconMeasurement.objects.all():
|
||||
measurement.data = measurement.data["wifi"]
|
||||
measurement.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0105_alter_theme_color_background_and_more'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='WifiMeasurement',
|
||||
new_name='BeaconMeasurement',
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='beaconmeasurement',
|
||||
options={'default_related_name': 'beacon_measurements', 'verbose_name': 'Beacon Measurement',
|
||||
'verbose_name_plural': 'Beacon Measurements'},
|
||||
),
|
||||
migrations.RunPython(forwards_func, backwards_func),
|
||||
]
|
|
@ -453,20 +453,20 @@ class CrossDescription(SerializableMixin):
|
|||
)
|
||||
|
||||
|
||||
class WifiMeasurement(SpaceGeometryMixin, models.Model):
|
||||
class BeaconMeasurement(SpaceGeometryMixin, models.Model):
|
||||
"""
|
||||
A Wi-Fi measurement
|
||||
A Beacon (WiFI / iBeacon) measurement
|
||||
"""
|
||||
geometry = GeometryField('point')
|
||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True,
|
||||
verbose_name=_('author'))
|
||||
comment = models.TextField(null=True, blank=True, verbose_name=_('comment'))
|
||||
data = models.JSONField(_('Measurement list'), default=list)
|
||||
data = models.JSONField(_('Measurement list'), default=list) # would be nice if this used pydantic
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Wi-Fi Measurement')
|
||||
verbose_name_plural = _('Wi-Fi Measurements')
|
||||
default_related_name = 'wifi_measurements'
|
||||
verbose_name = _('Beacon Measurement')
|
||||
verbose_name_plural = _('Beacon Measurements')
|
||||
default_related_name = 'beacon_measurements'
|
||||
|
||||
@property
|
||||
def all_geometry_changed(self):
|
||||
|
|
4
src/c3nav/mapdata/utils/cache/stats.py
vendored
4
src/c3nav/mapdata/utils/cache/stats.py
vendored
|
@ -8,7 +8,7 @@ from kombu.utils import cached_property
|
|||
from c3nav.control.models import UserPermissions
|
||||
from c3nav.mapdata.grid import grid
|
||||
from c3nav.mapdata.models import Level, LocationGroup, LocationSlug, Space
|
||||
from c3nav.mapdata.models.geometry.space import POI, Area, WifiMeasurement
|
||||
from c3nav.mapdata.models.geometry.space import POI, Area, BeaconMeasurement
|
||||
from c3nav.mapdata.models.locations import LocationRedirect
|
||||
from c3nav.mapdata.utils.locations import CustomLocation, get_location_by_id_for_request
|
||||
|
||||
|
@ -87,7 +87,7 @@ def convert_locate(data):
|
|||
'by_level': {},
|
||||
}
|
||||
measurement_lookup = {}
|
||||
for measurement in WifiMeasurement.objects.all().select_related('space', 'space__level'):
|
||||
for measurement in BeaconMeasurement.objects.all().select_related('space', 'space__level'):
|
||||
pos = CustomLocation(measurement.space.level, measurement.geometry.x, measurement.geometry.y,
|
||||
permissions=set())
|
||||
space_slug = measurement.space.get_slug()
|
||||
|
|
|
@ -78,16 +78,16 @@ class Locator:
|
|||
)
|
||||
self.xyz = np.array(tuple(peer.xyz for peer in self.peers))
|
||||
|
||||
for space in Space.objects.prefetch_related('wifi_measurements'):
|
||||
for space in Space.objects.prefetch_related('beacon_measurements'):
|
||||
new_space = LocatorSpace.create(
|
||||
pk=space.pk,
|
||||
points=tuple(
|
||||
LocatorPoint(
|
||||
x=measurement.geometry.x,
|
||||
y=measurement.geometry.y,
|
||||
values=self.convert_scans(measurement.data, create_peers=True),
|
||||
values=self.convert_scans(measurement.data["wifi"], create_peers=True),
|
||||
)
|
||||
for measurement in space.wifi_measurements.all()
|
||||
for measurement in space.beacon_measurements.all()
|
||||
)
|
||||
)
|
||||
if new_space.points:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue