[postgis-users] Confused about st_snaptogrid and precision.

Paul Moen pmoen at offroadsoftware.com
Tue Mar 23 04:57:41 PDT 2010


On Mar 23, 2010, at 5:16 AM, strk wrote:

> On Tue, Mar 23, 2010 at 12:01:40AM -0500, Paul moen wrote:
> 
>> Can someone help explain this to me?  How do I see what coordinates  
>> are actually stored in the geometry?  Is there a way to force the  
>> precision of the geometry using a contstraint?
> 
> If you snap all geometries to the same grid you should get a
> consistent precision all over. The equality tests you report
> are only snapping one operator, thus the false return.

But I first am applying the following SQL, which should set the precision on every point in the table.

UPDATE the_control SET the_geom=st_snaptogrid(the_geom,.0000001);

After setting the precision, shouldn't I be able to find the point, POINT(1881581.0894989 638200.5564884), at that precision, in the table by using

SELECT * FROM the_control WHERE st_equals(st_geomfromewkt('POINT(1881581.0894989 638200.5564884)'),the_geom);

The exact order I am doing this is
create the table. (see previous message i thread)
UPDATE the_control SET the_geom=st_snaptogrid(the_geom,.0000001);
SELECT * FROM the_control WHERE st_equals(st_geomfromewkt('POINT(1881581.0894989 638200.5564884)'),the_geom);

After I set the precision the output looks like

SELECT gid,st_asewkt(the_geom) FROM the_control WHERE gid in (1,2,3,4,5);

1;"POINT(1881581.0894989 638200.5564884)"
2;"POINT(1884216.5177923 638182.4339277)"
3;"POINT(1886849.9642134 638166.8449733)"
4;"POINT(1888166.6848637 638159.1895214)"
5;"POINT(1889483.4131081 638151.6228238)"

and it looks like 
SELECT * FROM the_control WHERE st_equals(st_geomfromewkt('POINT(1881581.0894989 638200.5564884)'),the_geom);
should return a row.

sorry if I am just not getting this,

Paul
> 
> 
> --strk;
> 
>  ()   Free GIS & Flash consultant/developer
>  /\   http://strk.keybit.net/services.html
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-users mailing list