Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#9745 closed (fixed)

Add support of PostGIS's SnapToGrid function

Reported by: norn Owned by: jbronn
Component: GIS Version: master
Severity: Keywords: postgis
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'd like to have support of SnapToGrid function from PostGIS. I made patch and it works for me. I believe it is simple enough to be implemented in trunk.

Attachments (2)

snaptogrid.diff (1.6 KB) - added by norn 8 years ago.
SnapToGrid support patch against django-1.0.2-final
snaptogrid_corrected.diff (3.0 KB) - added by jbronn 8 years ago.
SVN diff of user-provided patch

Download all attachments as: .zip

Change History (10)

Changed 8 years ago by norn

Attachment: snaptogrid.diff added

SnapToGrid support patch against django-1.0.2-final

Changed 8 years ago by jbronn

Attachment: snaptogrid_corrected.diff added

SVN diff of user-provided patch

comment:1 Changed 8 years ago by jbronn

Needs documentation: unset
Needs tests: set
Owner: changed from nobody to jbronn
Patch needs improvement: unset
Status: newassigned

I'm +1 on having this feature in GeoDjango. However, we'll have to talk about implementation details -- I see you have this done on the geometry in-place rather than attaching a new geometry on the GeoQuerySet (otherwise you could've just used the _geom_attribute method to simplify the implementation). I wonder if this option should be an option for all methods, e.g., GeoModel.objects.intersection(other, in_place=True).

Also, I'll need tests before including it trunk, but otherwise it's a very good start. Thanks for contributing.

comment:2 Changed 8 years ago by norn

'In place' method was chosen because I have a need of chaining snaptogrid after transform().
Also I am interested in filtering out records with empty geometry field after snapping, but I have no idea how to implement it in effective way (avoiding double calculation in SQL).
I think your decision about in_place is quite useful and will allow building longer chains.

comment:3 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:4 Changed 8 years ago by Jacob

Triage Stage: UnreviewedAccepted

comment:5 Changed 8 years ago by jbronn

milestone: 1.1

comment:6 Changed 8 years ago by jbronn

Now that values() and defer() work, there's really no need to do the in_place option anymore.

comment:7 Changed 8 years ago by jbronn

Resolution: fixed
Status: assignedclosed

(In [10369]) Fixed #9745 -- Added the GeoQuerySet methods snap_to_grid and geojson.

comment:8 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top