diff --git a/src/c3nav/routing/locator.py b/src/c3nav/routing/locator.py index ada4524c..dffe93b3 100644 --- a/src/c3nav/routing/locator.py +++ b/src/c3nav/routing/locator.py @@ -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] diff --git a/src/c3nav/site/static/site/js/c3nav.js b/src/c3nav/site/static/site/js/c3nav.js index d3f16782..d4ae4d8b 100644 --- a/src/c3nav/site/static/site/js/c3nav.js +++ b/src/c3nav/site/static/site/js/c3nav.js @@ -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'); }