[Gdal-dev] OGR: how to get length of line-features
Frank Warmerdam
warmerdam at pobox.com
Fri Oct 12 17:49:24 EDT 2007
J.F wrote:
> Hi ,
>
> I'm trying to get length of line-features from a TAb file using ogr,but
>
> OGRGeometry does not support the method get_Length().
>
> How can I get it when I'm reading ?
JF,
If you are using the C++ API, and you know that a particular
geometry is a linestring or linearring you can just explicitly
cast the OGRGeometry* to OGRLineString and then call get_Length()
on it.
eg.
if( wkbFlatten(poGeometry->geGeometryType() == wkbLineString )
printf( "Length = %g\n",
((OGRLineString *) poGeometry))->get_Length() );
I see get_Length() is implemented in 1.4 branch, but I'm not sure
how long it has existed in OGR.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the Gdal-dev
mailing list