display user location on the map
This commit is contained in:
parent
38ca95791f
commit
a3c1e6d227
2 changed files with 19 additions and 2 deletions
|
@ -121,14 +121,14 @@ class LocatorSpace:
|
|||
self.stations = tuple(self.stations_set)
|
||||
self.stations_lookup = {station_id: i for i, station_id in enumerate(self.stations)}
|
||||
|
||||
self.levels = np.full((len(self.points), len(self.stations)), fill_value=-100, dtype=np.int8)
|
||||
self.levels = np.full((len(self.points), len(self.stations)), fill_value=-100, dtype=np.int16)
|
||||
for i, point in enumerate(self.points):
|
||||
for station_id, value in point.values.items():
|
||||
self.levels[i][self.stations_lookup[station_id]] = value
|
||||
|
||||
def get_best_point(self, scan_values, station_ids):
|
||||
stations = tuple(self.stations_lookup[station_id] for station_id in station_ids)
|
||||
values = np.array(tuple(scan_values[station_id] for station_id in station_ids), dtype=np.int8)
|
||||
values = np.array(tuple(scan_values[station_id] for station_id in station_ids), dtype=np.int16)
|
||||
scores = np.sum((self.levels[:, stations]-values)**2, axis=1)
|
||||
best_point = np.argmin(scores).ravel()[0]
|
||||
return self.points[best_point], scores[best_point]
|
||||
|
|
|
@ -1037,6 +1037,7 @@ c3nav = {
|
|||
c3nav._detailLayers = {};
|
||||
c3nav._routeLayers = {};
|
||||
c3nav._routeLayerBounds = {};
|
||||
c3nav._positionLayers = {};
|
||||
c3nav._firstRouteLevel = null;
|
||||
for (i = c3nav.levels.length - 1; i >= 0; i--) {
|
||||
var level = c3nav.levels[i];
|
||||
|
@ -1044,6 +1045,7 @@ c3nav = {
|
|||
c3nav._detailLayers[level[0]] = L.layerGroup().addTo(layerGroup);
|
||||
c3nav._locationLayers[level[0]] = L.layerGroup().addTo(layerGroup);
|
||||
c3nav._routeLayers[level[0]] = L.layerGroup().addTo(layerGroup);
|
||||
c3nav._positionLayers[level[0]] = L.layerGroup().addTo(layerGroup);
|
||||
}
|
||||
c3nav._levelControl.finalize();
|
||||
c3nav._levelControl.setLevel(c3nav.initial_level);
|
||||
|
@ -1258,8 +1260,23 @@ c3nav = {
|
|||
});
|
||||
},
|
||||
_set_user_location: function(location) {
|
||||
for (var id in c3nav._positionLayers) {
|
||||
c3nav._positionLayers[id].clearLayers();
|
||||
}
|
||||
if (location) {
|
||||
$('.locationinput .locate').text('my_location');
|
||||
var latlng = L.GeoJSON.coordsToLatLng(location.geometry.coordinates),
|
||||
layer = c3nav._positionLayers[location.level];
|
||||
L.circleMarker(latlng, {
|
||||
radius: 11,
|
||||
stroke: 0,
|
||||
fillOpacity: 0.2
|
||||
}).addTo(layer);
|
||||
L.circleMarker(latlng, {
|
||||
radius: 5,
|
||||
stroke: 0,
|
||||
fillOpacity: 1
|
||||
}).addTo(layer);
|
||||
} else {
|
||||
$('.locationinput .locate').text('location_searching');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue