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

Alex Hagen-Zanker ahh34 at cam.ac.uk
Fri Jan 14 11:29:10 EST 2011


Thanks for your clear explanation and easy workaround.

I filed the ticket: http://trac.osgeo.org/gdal/ticket/3907


On 14/01/2011 16:07, Chaitanya kumar CH wrote:
> Alex,
>
> I thought of pretty much the same modification. But it could potentially
> break some software. It may be added in 1.8 which is in the process of being
> released but I doubt it. Please file the ticket.
>
> On Fri, Jan 14, 2011 at 9:27 PM, Alex Hagen-Zanker<ahh34 at cam.ac.uk>  wrote:
>
>>   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 at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>


-- 
Alex Hagen-Zanker
University of Cambridge, Department of Architecture,  1-5 Scroope Terrace, Cambridge, CB2 1PX, United Kingdom
Tel: +44(0) 1223 330573



More information about the gdal-dev mailing list