[gdal-dev] [ogr] Unexplained third dimension in linear ring

Chaitanya kumar CH chaitanya.ch at gmail.com
Fri Jan 14 10:54:48 EST 2011


Alex,

But, for now, the addPoint() method does not check the dimension of the
point being passed and forces the geometry to 3D. You can overcome this by
calling the method like this:

ring->addPoint( poPoint->getX(), poPoint->getY() );

This sounds like a reasonable feature. Please file a ticket at
http://trac.osgeo.org/gdal/newticket for this. Since this change has a
potential to introduce errors in existing applications, this may not be
released before gdal1.9

On Fri, Jan 14, 2011 at 8:45 PM, Alex Hagen-Zanker <ahh34 at cam.ac.uk> wrote:

> Dear all,
>
> I am using OGR 1.7.3 to create polygons in C++.
>
> The polygons end up as "Polygon ZM" instead of "Polygon".
>
> The problem seems to be that adding a 2D OGRPoint  to a 2D OGRLinearRing
> results in a 3D OGRLinearRing.
>
> Can somebody explain?
>
> Thanks, Alex
>
> //test.cpp
> #include <ogr_geometry.h>
> #include <iostream>
>
> int main()
> {
>    OGRLinearRing* ring = ( OGRLinearRing* )
> OGRGeometryFactory::createGeometry( wkbLinearRing );
>    OGRPoint* point = ( OGRPoint* ) OGRGeometryFactory::createGeometry(
> wkbPoint );
>    point->setX( 1.0 );
>    point->setY( 1.0 );
>
>    std::cout << "Point before: " << point->getCoordinateDimension() << "D"
> << std::endl;
>    std::cout << "Ring before: " << ring->getCoordinateDimension() << "D" <<
> std::endl;
>
>    ring->addPoint(point);
>
>    std::cout << "Ring after: " << ring->getCoordinateDimension() << "D" <<
>  std::endl;
>
>    return 1;
> }
>
> Output:
> Point before: 2D
> Ring before: 2D
> Ring after: 3D
>
> --
> Alex Hagen-Zanker
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Best regards,
Chaitanya kumar CH.
/tʃaɪθənjə/ /kʊmɑr/
+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110114/82216e36/attachment.html


More information about the gdal-dev mailing list