Opened 13 years ago

Closed 13 years ago

#3907 closed defect (fixed)

OGRLineString functions setPoint and addPoint forces linestring to 3D

Reported by: alexhagenzanker Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: OGR_SF Version: 1.7.3
Severity: normal Keywords:
Cc:

Description

The method addPoint(OGRPoint* point) always causes the linestring to become 3D. Even if the added point is a 2D point.

The reason is that the method setPoint(i,x,y,z)which is called by addPoint(point) always causes the linestring to become 3D even if z has the value of 0.0.

This could be desired behaviour for setPoint, after all the user took the effort to specify the 3rd dimension.

It cannot be desired behaviour for addPoint.

I'd suggest to either fix addPoint or setPoint, addPoint being the safest option.

How about:

void OGRLineString::addPoint( OGRPoint * poPoint )

{

if(poPoint->getCoordinateDimension() < 3)

setPoint( nPointCount, poPoint->getX(), poPoint->getY());

else

setPoint( nPointCount, poPoint->getX(), poPoint->getY(),

poPoint->getZ() );

}

Change History (2)

comment:1 by Even Rouault, 13 years ago

I agree with both your analysis and fix. Commited in trunk (1.9.0) in r21498. Could be potentially backported to 1.8 but I am not convinced this is really needed since there's an easy workaround (that I now realize to have used a lot in the past without trying to fix the core issue).

comment:2 by Even Rouault, 13 years ago

Milestone: 1.9.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.