[postgis-users] AsBinary returns differing values on different systems

Paul Ramsey pramsey at cleverelephant.ca
Wed Jul 15 10:18:01 PDT 2009


Yes, the numbers will probably be slightly different as the floating
point calcs will come out slightly different. And the WKT encodes
slightly less precision than the WKB, so it's visible in the latter
and not the former.

P

On Wed, Apr 14, 2010 at 2:09 AM, Tobias Sauerwein
<tobias.sauerwein at camptocamp.com> wrote:
> Hi!
>
> For unit tests I was comparing the hex values returned by AsBinary(), but it
> seem like that AsBinary() returns different values on different systems (but
> only sometimes). Please consider the following query:
>
> select AsBinary(Centroid(GeomFromText('LINESTRING(-88.6748409363057
> 43.1035032292994,-88.6464173694267 42.9981688343949,-88.607961955414
> 42.9680732929936,-88.5160033566879 42.9363057770701,-88.4390925286624
> 43.0031847579618)', 4326)));
>
> On a 32-bit system with PostGIS 1.3.3 the following is returned:
>  \001\001\000\000\0006l\362\211\354$V\300\033\266f\215\353~E@
>
> But on a 64-bit system with PostGIS 1.3.5 the following:
>  \001\001\000\000\0007l\362\211\354$V\300\033\266f\215\353~E@
>                                 ^
>
> But somehow it is the same geometry which you can see with the following two
> queries:
>
> select
> AsText(GeomFromWKB(AsBinary(Centroid(GeomFromText('LINESTRING(-88.6748409363057
> 43.1035032292994,-88.6464173694267 42.9981688343949,-88.607961955414
> 42.9680732929936,-88.5160033566879 42.9363057770701,-88.4390925286624
> 43.0031847579618)', 4326))), 4326));
>
> or
>
> select AsText(Centroid(GeomFromText('LINESTRING(-88.6748409363057
> 43.1035032292994,-88.6464173694267 42.9981688343949,-88.607961955414
> 42.9680732929936,-88.5160033566879 42.9363057770701,-88.4390925286624
> 43.0031847579618)', 4326)));
>
>
> Then both systems return:
> POINT(-88.5769371859941 42.9915634871979)
>
>
> I originally thought that the precision may be different on the two systems,
> but then the WKT values would not be the same. Or does WKT use a different
> precision then WKB?
>
> Thank you,
> Tobias
>
> _______________________________________________
> 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