def validate(self, data):
     validators.validate_formats(data)
     extents = validators.validate_bbox_params(data)
     bbox = validators.validate_bbox(extents)
     the_geom = GEOSGeometry(bbox, srid=4326)
     data['the_geom'] = the_geom
     logger.debug(data)
     regions = Region.objects.filter(the_geom__intersects=the_geom).intersection(the_geom, field_name='the_geom').order_by( '-intersection')
     data['region'] = validators.validate_region(regions)
     # remove unwanted fields
     data.pop('xmin'),  data.pop('ymin'), data.pop('xmax'), data.pop('ymax'), data.pop('formats')
     return data
 def validate(self, data):
     user = data['user']
     validators.validate_formats(data)
     extents = validators.validate_bbox_params(data)
     bbox = validators.validate_bbox(extents, user=user)
     the_geom = GEOSGeometry(bbox, srid=4326)
     data['the_geom'] = the_geom
     regions = Region.objects.filter(the_geom__intersects=the_geom).intersection(the_geom, field_name='the_geom')
     sorted_regions = sorted(regions.all(), key=lambda a: a.intersection.area, reverse=True)  # order by largest area of intersection
     data['region'] = validators.validate_region(sorted_regions)
     # remove unwanted fields
     data.pop('xmin'), data.pop('ymin'), data.pop('xmax'), data.pop('ymax'), data.pop('formats')
     return data
Exemple #3
0
 def validate(self, data):
     user = data['user']
     validators.validate_formats(data)
     extents = validators.validate_bbox_params(data)
     bbox = validators.validate_bbox(extents, user=user)
     the_geom = GEOSGeometry(bbox, srid=4326)
     data['the_geom'] = the_geom
     regions = Region.objects.filter(
         the_geom__intersects=the_geom).intersection(the_geom,
                                                     field_name='the_geom')
     sorted_regions = sorted(
         regions.all(), key=lambda a: a.intersection.area,
         reverse=True)  # order by largest area of intersection
     data['region'] = validators.validate_region(sorted_regions)
     # remove unwanted fields
     data.pop('xmin'), data.pop('ymin'), data.pop('xmax'), data.pop(
         'ymax'), data.pop('formats')
     return data
    def validate(self, data):
        """
        Validates the data submitted during Job creation.

        See api/validators.py for validation code.
        """
        user = data['user']
        validators.validate_formats(data)
        extents = validators.validate_bbox_params(data)
        the_geom = validators.validate_bbox(extents, user=user)
        data['the_geom'] = the_geom
        regions = Region.objects.filter(the_geom__intersects=the_geom).intersection(the_geom, field_name='the_geom')
        # sort the returned regions by area of intersection, largest first.
        sorted_regions = sorted(regions.all(), key=lambda a: a.intersection.area, reverse=True) 
        data['region'] = validators.validate_region(sorted_regions)
        # remove unwanted fields, these are pulled from the request in the view if the serializer is valid
        data.pop('xmin'), data.pop('ymin'), data.pop('xmax'), data.pop('ymax'), data.pop('formats')
        return data
Exemple #5
0
    def validate(self, data):
        """
        Validates the data submitted during Job creation.

        See api/validators.py for validation code.
        """
        user = data['user']
        validators.validate_formats(data)
        extents = validators.validate_bbox_params(data)
        the_geom = validators.validate_bbox(extents, user=user)
        data['the_geom'] = the_geom
        regions = Region.objects.filter(
            the_geom__intersects=the_geom).intersection(the_geom,
                                                        field_name='the_geom')
        # sort the returned regions by area of intersection, largest first.
        sorted_regions = sorted(regions.all(),
                                key=lambda a: a.intersection.area,
                                reverse=True)
        data['region'] = validators.validate_region(sorted_regions)
        # remove unwanted fields, these are pulled from the request in the view if the serializer is valid
        data.pop('xmin'), data.pop('ymin'), data.pop('xmax'), data.pop(
            'ymax'), data.pop('formats')
        return data