Skip to content

Commit

Permalink
Fix for the last part of issue #310
Browse files Browse the repository at this point in the history
  • Loading branch information
gloriajjl committed Aug 11, 2020
1 parent e6d6ec1 commit 3f4b0aa
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions backend/promis/backend_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import datetime
from rest_framework.decorators import permission_classes
from django.contrib.gis.geos import GEOSGeometry

class PromisViewSet(viewsets.ReadOnlyModelViewSet):
'''Collects most commonly used View stuff'''
Expand Down Expand Up @@ -297,13 +298,17 @@ def get_queryset(self):
if space_project:
filter_opts['channel__device__space_project'] = int(space_project)

poly = self.request.query_params.get('polygon')

if poly:
try:
filter_opts['session__geo_line__intersects'] = poly
except ValueError:
raise NotFound("Invalid WKT for polygon selection")
# This code doesn't work because poly is a 3d polygon (geography),
# while geo_line is 2d (geometry)
# and it seems like it's not needed anyway,
# because this work is already done in DataSerializer.get_selection.
#
# poly = self.request.query_params.get('polygon')
# if poly:
# try:
# filter_opts['session__geo_line__intersects'] = poly
# except ValueError:
# raise NotFound("Invalid WKT for polygon selection")

# Applying the filter
return models.Measurement.objects.filter(**filter_opts)

0 comments on commit 3f4b0aa

Please sign in to comment.