I noticed that some error is introduced when converting from WKB to WKT (and back). For example, the following computation of a polygon's area, divided by itself, should return one:

  SELECT (ST_Area(ST_GeomFromEWKB(ST_AsEWKB(tiger.the_geom)))
         / ST_Area(tiger.the_geom))
         AS area_ratio
  FROM tiger

      area_ratio
  -------------------
                   1
                   1
                   1
                   .
                   .


But when I convert to WKT as an intermediate format, the results get thrown off by as much as 0.1% (I realize the first couple of rows don't show this, but my tests break when the error passes that threshold):

  SELECT (ST_Area(ST_GeomFromEWKT(ST_AsEWKT(tiger.the_geom)))
         / ST_Area(tiger.the_geom))
         AS area_ratio
  FROM tiger;

      area_ratio
  -------------------
                   1
    1.00000014105231
    1.00000017733961
    1.00000021839733
    1.00000004515224
                etc.


Is this just a floating point limitation, or something else entirely?
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to