Opened 12 years ago

Closed 12 years ago

#4688 closed defect (fixed)

GeometryType change after setPoint

Reported by: royeral Owned by: warmerdam
Priority: normal Milestone: 1.10.0
Component: OGR_SF Version: 1.9.1
Severity: normal Keywords: GeometryType
Cc:

Description

Not sure if i'm using the function correctly, but after changing a point, the geometry type change to an invalid number.

Can be reproduce with this code :

#include "ogrsf_frmts.h"
#include <iostream>
using namespace std;

int main()
{
    OGRLineString line;

    line.addPoint(12, 12);
    line.addPoint(18, 18);

    cout << line.getGeometryType() << endl;

    OGRPoint point;

    line.getPoint(0, &point);

    point.setX(10);
    point.setX(10);

    line.setPoint(0, &point); // <==== GeometryType change from 2 to -2147483646
    //line.setPoint(0, point.getX(), point.getY());

    cout << line.getGeometryType() << endl;
}

Change History (1)

comment:1 by Even Rouault, 12 years ago

Component: defaultOGR_SF
Milestone: 2.0.0
Resolution: fixed
Status: newclosed

The geometry type wasn't actually an invalid value, but the value of wkbLineString25D. This was due to the fact that setPoint() always promoted the line to 2.5D even if the passed point was only 2D.

Fixed in trunk :

r24519 /trunk/gdal/ogr/ogrlinestring.cpp: OGRLineString::setPoint( int iPoint, OGRPoint * poPoint ) : avoid promotting the line to 25D if the point is only 2D (#4688)

r24520 /trunk/gdal/ogr/ (gml2ogrgeometry.cpp ogrlinearring.cpp): A few code simplifications due to the fact that OGRLineString::setPoint/addPoint no longer force the coordinate dimension of the line to 25D (#4688)

Note: See TracTickets for help on using tickets.