[gdal-dev] [ogr] Unexplained third dimension in linear ring
Alex Hagen-Zanker
ahh34 at cam.ac.uk
Fri Jan 14 10:57:02 EST 2011
> The problem seems to be that adding a 2D OGRPoint to a 2D
> OGRLinearRing results in a 3D OGRLinearRing.
Sorry to bother you with this, I found it myself.
It is the following function in ogrlinestring.cpp that looks like a bug
to me:
void OGRLineString::setPoint( int iPoint, double xIn, double yIn, double
zIn )
{
if( getCoordinateDimension() == 2 )
Make3D();
if( iPoint >= nPointCount )
setNumPoints( iPoint+1 );
paoPoints[iPoint].x = xIn;
paoPoints[iPoint].y = yIn;
if( zIn != 0.0 )
{
Make3D();
padfZ[iPoint] = zIn;
}
else if( getCoordinateDimension() == 3 )
{
padfZ[iPoint] = 0.0;
}
}
How about changing it to this:
void OGRLineString::setPoint( int iPoint, double xIn, double yIn, double
zIn )
{
if( iPoint >= nPointCount )
setNumPoints( iPoint+1 );
paoPoints[iPoint].x = xIn;
paoPoints[iPoint].y = yIn;
if( zIn != 0.0 && getCoordinateDimension() < 3 )
Make3D();
if( getCoordinateDimension() == 3 )
padfZ[iPoint] = zln;
}
More information about the gdal-dev
mailing list