Example #1
0
    def _elevation_at_point(self):
        if self._elevation is None:
            request = self.context['request']

            if not request.query_params.get('point'):
                return None
            else:
                try:
                    x, y = [float(x) for x in request.query_params['point'].split(',')]
                except ValueError:
                    raise ParseError()

                point = Point(x, y)
                self._elevation = get_elevation_at_point(point)

        return self._elevation
Example #2
0
    def get_queryset(self):
        if not self.request.query_params.get('point'):
            return self.queryset
        else:
            try:
                x, y = [float(x) for x in self.request.query_params['point'].split(',')]
            except ValueError:
                raise ParseError()

            elevation = get_elevation_at_point(Point(x, y))

            if elevation is None or is_masked(elevation):
                return self.queryset.none()

            # Elevation bands are stored in feet
            return self.queryset.filter(
                Q(low__lt=elevation/0.3048, high__gte=elevation/0.3048) | Q(low__isnull=True, high__isnull=True)
            )