1 | diff -r Django-1.0.2-final/django/contrib/gis/db/backend/postgis/__init__.py Django-1.0.2-final-patched/django/contrib/gis/db/backend/postgis/__init__.py
|
---|
2 | 31a32
|
---|
3 | > snaptogrid=SNAP_TO_GRID,
|
---|
4 | diff -r Django-1.0.2-final/django/contrib/gis/db/backend/postgis/query.py Django-1.0.2-final-patched/django/contrib/gis/db/backend/postgis/query.py
|
---|
5 | 62a63
|
---|
6 | > SNAP_TO_GRID = get_func('SnapToGrid')
|
---|
7 | diff -r Django-1.0.2-final/django/contrib/gis/db/models/manager.py Django-1.0.2-final-patched/django/contrib/gis/db/models/manager.py
|
---|
8 | 65a66,68
|
---|
9 | > def snaptogrid(self, *args, **kwargs):
|
---|
10 | > return self.get_query_set().snaptogrid(*args, **kwargs)
|
---|
11 | >
|
---|
12 | diff -r Django-1.0.2-final/django/contrib/gis/db/models/query.py Django-1.0.2-final-patched/django/contrib/gis/db/models/query.py
|
---|
13 | 219a220,237
|
---|
14 | > def snaptogrid(self, size=0.01, **kwargs):
|
---|
15 | > """
|
---|
16 | > Snap all points of the input geometry to the grid defined by
|
---|
17 | > cell size.
|
---|
18 | > """
|
---|
19 | > if SpatialBackend.version[0]<1:
|
---|
20 | > raise "Postgis version doesn't support SnapToGrid"
|
---|
21 | > if not isinstance(size, (float, int)):
|
---|
22 | > raise TypeError('Size of the grid must be float or int.')
|
---|
23 | >
|
---|
24 | > field_name = kwargs.get('field_name', None)
|
---|
25 | > tmp, geo_field = self._spatial_setup('snaptogrid', field_name=field_name)
|
---|
26 | > field_col = self._geocol_select(geo_field, field_name)
|
---|
27 | > geo_col = self.query.custom_select.get(geo_field, field_col)
|
---|
28 | > custom_sel = '%s(%s, %s)' % (SpatialBackend.snaptogrid, geo_col, size)
|
---|
29 | > self.query.custom_select[geo_field] = custom_sel
|
---|
30 | > return self._clone()
|
---|
31 | >
|
---|