Ticket #12410: line_locate_point.patch

File line_locate_point.patch, 2.9 KB (added by IanWard, 15 years ago)
  • django/contrib/gis/db/models/manager.py

     
    8888    def translate(self, *args, **kwargs):
    8989        return self.get_query_set().translate(*args, **kwargs)
    9090
     91    def line_locate_point(self, *args, **kwargs):
     92        return self.get_query_set().line_locate_point(*args, **kwargs)
     93
    9194    def union(self, *args, **kwargs):
    9295        return self.get_query_set().union(*args, **kwargs)
    9396
  • django/contrib/gis/db/models/query.py

     
    375375        self.query.custom_select[geo_field] = custom_sel
    376376        return self._clone()
    377377
     378    def line_locate_point(self, geom, **kwargs):
     379        """
     380        Return a float between 0 and 1 representing the location of the
     381        closest point on the LineString passed to the specified PointField.
     382        """
     383        if SpatialBackend.postgis:
     384            s = {'geom_args' : ('geom',),
     385                 'procedure_fmt' : '%(geom)s,%(geo_col)s',
     386                 'procedure_args' : {'geom': geom},
     387                 }
     388        else:
     389            raise NotImplementedError('backend does not support line_locate_point')
     390        return self._spatial_attribute('line_locate_point', s, **kwargs)
     391
    378392    def union(self, geom, **kwargs):
    379393        """
    380394        Returns the union of the geographic field with the given
  • django/contrib/gis/db/backend/postgis/__init__.py

     
    4141                                    sym_difference=SYM_DIFFERENCE,
    4242                                    transform=TRANSFORM,
    4343                                    translate=TRANSLATE,
     44                                    line_locate_point=LINE_LOCATE_POINT,
    4445                                    union=UNION,
    4546                                    unionagg=UNIONAGG,
    4647                                    version=(MAJOR_VERSION, MINOR_VERSION1, MINOR_VERSION2),
  • django/contrib/gis/db/backend/postgis/query.py

     
    8484    SYM_DIFFERENCE = get_func('SymDifference')
    8585    TRANSFORM = get_func('Transform')
    8686    TRANSLATE = get_func('Translate')
     87    LINE_LOCATE_POINT = get_func('Line_Locate_Point')
    8788
    8889    # Special cases for union, KML, and GeoJSON methods.
    8990    if MINOR_VERSION1 < 3:
Back to Top