[postgis-devel] [PostGIS] #231: New distance-calculations proposal

PostGIS trac at osgeo.org
Sat Oct 17 07:06:10 PDT 2009


#231: New distance-calculations proposal
--------------------------+-------------------------------------------------
  Reporter:  nicklas      |       Owner:  robe         
      Type:  enhancement  |      Status:  assigned     
  Priority:  medium       |   Milestone:  postgis 1.5.0
 Component:  postgis      |     Version:               
Resolution:               |    Keywords:               
--------------------------+-------------------------------------------------
Comment (by nicklas):

 As discussed above in august the distance-calculation of today gives a
 slightly different answer in some cases than this new calculation.

 here is an example:

 {{{
 select[[BR]]
 st_distance('POINT(774983.955351382 2949487.72566304)'::geometry,[[BR]]
  'LINESTRING(775212.698335966 2948028.5564237,775121.04258857 [[BR]]
 2950068.84568561)'::geometry)
 }}}

 in todays calculation this gives :[[BR]]
 163.028426002135 meters, and in my calulation:[[BR]]
 163.028426002146 meters

 The thing is that the answer in the distance-calculations is given in
 double precision data type. in this case that gives room for 12 decimals
 but the coordinates that the distance is calculated from only has 8 or 9
 decimals. So no one of the answers is right or wrong. The reason for the
 difference between the two ways of calculating is that in my calculation a
 point is calculated on the line and then is the distance calculated to
 that point instead of directly to the line in itself. That point also have
 the smaller number of decimals so the answer will get another round-of
 error than the calculatin of today.

 But note, no one of the answers is right. The deciamals beyond the
 coordinates precision is worthless (besides they represent about the
 distance between the eyes of a bacteria if they had eyes) since they can't
 be calculated from the coordinates precision.

 How to handle this. It is very small distances we are talking about but it
 can cause trouble in regression tests and if people is comparing distances
 on this last decimals.

 I guess this is a common issue.
 Is it a problem?
 Have I understood the precision problem of floating data-types right.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/231#comment:13>
PostGIS <http://trac.osgeo.org/postgis/>
PostGIS


More information about the postgis-devel mailing list