[gdal-dev] Othogonal projcetion

MARION VIOLOT marion.violot at gmail.com
Mon May 6 07:12:57 PDT 2013


Dear everyone,

I found sometehing a way more easy that I could use. It's the method
Distance(). Apparently, " if OGR is built without the GEOS library, this
method will always fail, issuing a CPLE_NotSupported error ". I guess if it
returns me -1 means that it was built with GEOS, but an error occured,
isn't it? My code is quite simple,

I got the following polyligne poLine that seems to be correctly read as
when I look at its numbers of points, its length and so on, it seems to be
found without error. Then, I got the start point of my poLine, which is
also correct.


poLine = (OGRLineString *) poGeometry;
poPoint = OGRPoint::OGRPoint(0,0);
poLine->StartPoint(& poPoint);


After that I have some points poPointBis in one layer, and it gives me well
the number of points :


poPointBis = (OGRPoint *) poGeometryBis;


But when I do the following with a loop over the number of points, I have
-1 as the return value.

poPointBis = (OGRPoint *) poGeometryBis;
vector<double> Shorter;
for all the points {
 Shorter.push_back(poPointBis->Distance(poLine));
}


I thought may be it's beacause one geometry is a line and the other one is
a point. So I did the same thing with poGeometry and poGeometryBis and now
I'm trying with two points. And I still have -1 as the return value.

So, I missed something, but I really don't see what.  Does someone know
something about it?

Thanks a lot in advance,
Marion.





On Mon, May 6, 2013 at 9:27 AM, MARION VIOLOT <marion.violot at gmail.com>wrote:

> Dear everyone,
>
> I am new with GDAL-OGR and only need to orthogonally project points on
> polyline and then calculate the distance from the projections and the start
> point of the polyline (in C++, in a Windows Form Application with Visual
> Studio 2008).
>
> I didn't find yet a developed method in GDAL-OGR that enables me to do it.
> I would like to know if there is any existing one, or at least one method
> that calculates the shorter distance between a point and a polyline? I was
> thinking about first understanding and then using the OGR Projections
> Tutorial, but it's seems very complicated for doing so little.
>
> Thanks a lot for your time and your help.
> Marion.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130506/6e2ad5c3/attachment.html>


More information about the gdal-dev mailing list