Subject: Re: [geometry] Integrating OGR library with Boost.Geometry
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2015-01-12 12:38:49
Eric Msp Veith wrote:
> did I say "implementing the Iterator for OGRLineString wasn't that hard"?
> Well, I guess it actually is.
> bg::model::linestring<OGRPoint> delivers the correct results for any
> bg::distance() call. However, when my OGRLineString iterator_facade is being
> used, the wrong points are selected. In the example containing the
> LINESTRING(0.0 0.0, 1.0 1.0, 2.0 2.0, 3.0 3.0, 4.0 4.0) and POINT(15.0 15.0),
> using my own iterator_facade meant that bg::distance always calculated the
> distance between the n-1th point on the linestring and the single point.
> I.e., my iterator_facade is at fault. I don't know yet what's exactly wrong,
> but I'll find it! :-)
> Thanks for all the help so far!
Now when everything is clear and you decided to use cartesian CS. Note
that the distance between geographical points calculated as if they were
cartesian points will not be the "correct" one. By correctness I have in
mind being in line with the definition of a geodesic, the shortest path
between two points on the surface of the Earth. Depending on the points
configuration and actual position on the globe for a pair of geographic
coordinates treated as cartesian coordinates you will get the same or
greater distance than you should if you represented the points in
spherical or geographic CS.
For instance, in cartesian CS the result of distance(POINT(15 15),
POINT(4 4)) is 15.556349186104045, but in spherical (assuming that the
coordinates are degrees) 15.43701697622119 degrees (0.26942677292131906
radians). For the spherical Earth with radius 6371000 meters the
difference between those distances is around 13 kilometers. And for
geographic CS the distance will be different than in the above cases. Of
course this kind of error may be acceptable for you. I'm just pointing
out this aspect in case you find it important/interesting.
And AFAIU you must also deal with it when you're using GEOS or
ST_GeomFromText in PostGIS no matter what SRID you passed. However I'm
not entirely sure if this is true, feel free to proove me wrong.
Geometry list run by mateusz at loskot.net