[postgis-devel] [PostGIS] #1292: ST_SnapToGrid returns a value out of range

PostGIS trac at osgeo.org
Mon Jan 30 17:36:07 PST 2012


#1292: ST_SnapToGrid returns a value out of range
---------------------------+------------------------------------------------
 Reporter:  realityexists  |       Owner:  pramsey      
     Type:  defect         |      Status:  new          
 Priority:  medium         |   Milestone:  PostGIS 2.0.0
Component:  postgis        |     Version:  trunk        
 Keywords:                 |  
---------------------------+------------------------------------------------

Comment(by realityexists):

 OK, I see - thanks for the detailed explanation! It totally makes sense
 from an implementation point of view, but totally doesn't from the user
 point of view. Agreed - it's tricky. The entire point of me calling
 ST_SnapToGrid is to "round" the coordinates - I would never expect it to
 increase the precision. Having the cast to geography automatically wrap
 might be a nice thing in general, but it wouldn't solve this particular
 problem*. I can't see any user expecting 'POINT(180 50)' to snap to
 'POINT(-179.9999999 50)' or even to 'POINT(-180 50)' (for ''any'' snap
 size value). The only result a user would expect here is 'POINT(180 50)'.
 So I don't think that 180plusabit is "correct", it just isn't "incorrect
 enough" to matter in most cases.

 Maybe ST_SnapToGrid() can err on the side of 180minusabit here somehow? Or
 maybe the cast to geography (and any other functions that check the range)
 can treat 180plusabit as equal to 180? For the latter to work the epsilon
 used would have to be greater than any imprecision that any snap size
 could ever create, so the former sounds safer to me.

 *) Yes, for larger snap size values that don't fit evenly into 180
 wrapping becomes a genuine user issue, not just an implementation issue.
 Eg.
 {{{
 ST_SnapToGrid(ST_GeomFromText('POINT(180 50)', 4326), 7)
 }}}
 returns 'POINT(182 50)' Should that fail or wrap when cast to geography?
 I'd say it should wrap, but that's probably outside the scope of this
 ticket.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1292#comment:4>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list