Opened 6 years ago

Closed 6 years ago

Last modified 4 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 6 years ago.
SnapToGrid support patch against django-1.0.2-final
snaptogrid_corrected.diff (3.0 KB) - added by jbronn 6 years ago.
SVN diff of user-provided patch

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by norn

SnapToGrid support patch against django-1.0.2-final

Changed 6 years ago by jbronn

SVN diff of user-provided patch

comment:1 Changed 6 years ago by jbronn

  • Needs documentation unset
  • Needs tests set
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Status changed from new to assigned

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 6 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 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:4 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 6 years ago by jbronn

  • milestone set to 1.1

comment:6 Changed 6 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 6 years ago by jbronn

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:8 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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