[postgis-users] ST_SnapToGrid details

Sandro Santilli strk at keybit.net
Tue Jun 25 03:32:22 PDT 2013


On Tue, Jun 25, 2013 at 12:31:41PM +0200, Sandro Santilli wrote:
> On Tue, Jun 25, 2013 at 11:48:03AM +0200, Egil Möller wrote:
> > Hi!
> > 
> > I'm implementing a dynamic clustering of points in a map, where if you
> > zoom out, any area with too many points in it has its points replaced by
> > a big circle with the number of points it's covering written on it. When
> > you zoom in, the big circles are gradually replaced with several smaller
> > circles and finally with individual points.
> > 
> > On the server side this is implemented using ST_SnapToGrid followed by a
> > group by (with count) over the table with the points. Then for each row
> > where count < some number, a new select query is done to get the actual
> > points in the area.
> > 
> > The problem is that I seem to get the are to select points from wrong.
> > So, here's the question:
> > 
> >     Given that
> > 
> >     ST_SnapToGrid(ST_Point(lon, lat), sizeLon, sizeLat) =
> >     ST_Point(resultLon, resultLat)
> > 
> >     for a given pair of values resultLon and resultLat, and given
> >     sizeLon and sizeLat, what are the min and max values for lon and lat?
> 
> They should be :
> 
>  resultLong +/- sizeLon
>  resultLat +/- sizeLat

Sorry, that is:

  resultLong +/- (sizeLon/2)
  resultLat +/- (sizeLat/2)

--strk;

> 
> > This does not seem to be documented anywhere in
> > http://postgis.net/docs/manual-2.0/ST_SnapToGrid.html :(
> 
> Patch welcome (after confirmation:)
> 
> --strk;


More information about the postgis-users mailing list