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;
}


_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to