Right, so you're seeing very slight coordinate drift. Probably Kosmo is inserting the object as hex-encoded WKB, and then your other application is pulling WKT, which is ever-so-slightly different than the underlying binary. The only way to avoid drift and precision issues is to get both applications using exactly the same representation, preferably the more exact WKB ones.


On Feb 13, 2008, at 12:14 PM, Johannes Sommer wrote:

Hi Paul,

The update worked. Now I get the correct boolean values. But my problem is not solved. As I wrote the problem is that the Desktop Client tries to insert a geometry object as GeometryFromText in a way that results in a slightly different binary geometry object.

example:
application (Kosmo) insert:
7;"0103000020EC7A000001000000060000007101EE208F2E51416E <----
252C38668A5441320DDB8DF62F514174604A3E2E8A544154E6C014F52F514164A38519888A54418CAB1FB4132F5141C4 <---
F318A8BB8A54415<---
36F90B2A62E514125384224A18A54417101EE208F2E51416E252C38668A5441"

after update in psql-terminal (ST_GeomFromText...):
7;"0103000020EC7A000001000000060000007001EE208F2E51416D <----
252C38668A5441370DDB8DF62F514176604A3E2E8A54414FE6C014F52F514163A38519888A54418CAB1FB4132F5141C2 <---
F318A8BB8A54414<---
E6F90B2A62E514129384224A18A54417001EE208F2E51416D252C38668A5441"


I'm not sure, but I think Kosmo uses "GeometryFromText" (I have asked the list for this). I could not reproduce the reaction in a psql terminal with "GeometryFromText". If I do the INSERTS on the terminal, I get the correct results.

Can this happen if one uses (GeometryFromText, SRID) instead of (ST_GeomFromText, SRID) in an application with JDBC-Driver?

thanks,
Johannes


Paul Ramsey schrieb:
I think your geometries have slightly different topology than your text representations admit. I cannot reproduce your result, but then I started from your text representations.

Do this:

update test set geometry = ST_GeomFromText('POLYGON((4506577.35665529 5381992.48407281,4506597.92548351 5381745.65813424,4506999.01763368 5381784.22468715, 4506834.46700796 5382069.61717861,4506615.92320819 5382085.04379977,4506577.35665529 5381992.48407281))', 31468) where t_id = 3;

And then see what happens.

On Feb 13, 2008, at 3:44 AM, Johannes Sommer wrote:

Hi,

I ve got a problem with the ST_Within() function. It does not always return correct answers.

SELECT AsText(geometry) FROM test WHERE t_id=3;
-->result:
"POLYGON((
4506577.35665529 5381992.48407281,
4506597.92548351 5381745.65813424,
4506999.01763368 5381784.22468715,
4506834.46700796 5382069.61717861,
4506615.92320819 5382085.04379977,
4506577.35665529 5381992.48407281))"

-- (WKT/WKB):
SELECT ST_Within(ST_GeomFromText('POLYGON((
4506577.35665529 5381992.48407281,
4506597.92548351 5381745.65813424,
4506999.01763368 5381784.22468715,
4506834.46700796 5382069.61717861,
4506615.92320819 5382085.04379977,
4506577.35665529 5381992.48407281))', 31468), a.geometry) FROM test a WHERE t_id=3;

-->result: false (but obviously it should be true)

-- (WKT/WKT):

SELECT ST_Within(ST_GeomFromText('POLYGON((
4506577.35665529 5381992.48407281,
4506597.92548351 5381745.65813424,
4506999.01763368 5381784.22468715,
4506834.46700796 5382069.61717861,
4506615.92320819 5382085.04379977,
4506577.35665529 5381992.48407281))', 31468), (SELECT AsText(geometry) FROM test WHERE t_id=3));

--> result:
ERROR: Operation on two geometries with different SRIDs
KONTEXT: SQL function "st_within" statement 1

Ok - I understand this reaction, because AsText returns no SRID.

-- (WKT/WKT):
SELECT ST_Within((select st_astext(geometry) FROM test WHERE t_id=3), (SELECTst_astext(geometry) FROM test WHERE t_id=3));

-->result: true (as it should be)

-- (WKB/WKB):
select st_within((SELECT geometry FROM test WHERE t_id=3), (SELECT geometry FROM test WHERE t_id=3));
-->result: true (correct)

SELECT ST_Within((select st_astext(geometry) FROM test WHERE t_id=3), (SELECTst_astext(geometry) FROM test WHERE t_id=3));

So the problem is that the Desktop Client tries to insert a geometry object as GeometryFromText / ST_GeomFromText / GeomFromText and I have to compare this new geometry object with an existing Polygon.

It makes no difference if I use _st_within / st_within / within, geometryfromtext / st_geomfromtext / geomfromtext or astext / st_astext.

I used:
-Windows XP, "POSTGIS="1.3.1" GEOS="3.0.0rc4-CAPI-1.3.3" PROJ="Rel. 4.5.0, 22 Oct 2006" USE_STATS", "PostgreSQL 8.2.5 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)"

-Linux, "POSTGIS="1.3.2" GEOS="3.0.0rc5-CAPI-1.4.0" PROJ="Rel. 4.6.0, 21 Dec 2007" USE_STATS", "PostgreSQL 8.2.6 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.2.1 (SUSE Linux)"

Where am I going wrong?

regards,
Johannes


_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to