[gdal-dev] [ogr] Unexplained third dimension in linear ring
Alex Hagen-Zanker
ahh34 at cam.ac.uk
Fri Jan 14 10:15:03 EST 2011
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
More information about the gdal-dev
mailing list