Commit f11f7817 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Introduce LOCATE_POINT_MAX_DISTANCE setting

parent d27b2769
......@@ -48,7 +48,8 @@ There are also celutz-specific settings:
- `LOGIN_REQUIRED`: is celutz public or are users required to login first?
- `PANORAMA_TILES_DIR`: where the tiles are, relatively to `MEDIA_ROOT` and `MEDIA_URL`
- `PANORAMA_MAX_DISTANCE`: maximum distance (in meters) after which reference points are considered to be too far away
- `PANORAMA_MAX_DISTANCE`: maximum distance (in meters) for reference points to be displayed when viewing a panorama
- `LOCATE_POINT_MAX_DISTANCE`: when locating a reference point, only consider panoramas that are closer than this maximum distance, in meters.
- `MAP_BOUNDS`: if defined, limit the view of the main map to the given rectangle. By default, the view is fitted to display all points. See `celutz/settings.py` for an example.
Then run the migrations:
......
......@@ -133,10 +133,15 @@ MEDIA_URL = '/media/'
# Relative to MEDIA_ROOT and MEDIA_URL
PANORAMA_TILES_DIR = "tiles"
# Max distance around a point at which to consider reference points
# Maximum distance for reference points to be displayed when viewing a panorama
# (in meters)
PANORAMA_MAX_DISTANCE = 50000
# When locating a reference point, only consider panoramas that are closer than
# this maximum distance, in meters.
# Cannot be greater than PANORAMA_MAX_DISTANCE.
LOCATE_POINT_MAX_DISTANCE = 50000
# Map bounds (in degrees) for the main view.
# If not defined, all points are used to fit the view.
#MAP_BOUNDS = {
......@@ -157,3 +162,5 @@ try:
except ImportError:
pass
# Ensure that LOCATE_POINT_MAX_DISTANCE <= PANORAMA_MAX_DISTANCE
LOCATE_POINT_MAX_DISTANCE = min(LOCATE_POINT_MAX_DISTANCE, PANORAMA_MAX_DISTANCE)
......@@ -87,7 +87,7 @@ class MainView(CelutzLoginMixin, TemplateView):
else:
queryset = Panorama.objects
l = [(pano, pano.line_distance(point), pano.bearing(point), pano.elevation(point))
for pano in queryset.all() if pano.is_visible(point)]
for pano in queryset.all() if pano.is_visible(point) and pano.great_circle_distance(point) <= settings.LOCATE_POINT_MAX_DISTANCE]
# Sort by increasing distance
return sorted(l, key=lambda x: x[1])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment