Skip to content

createOgrGeometry failed on MultiPoints on recent GDAL #2900

@MCA4213

Description

@MCA4213

osgEarth Version (required): latest (master)

Description of the problem:
I have an old code that usually works, but now when i built the new version of the gdal with the master brunch of osgearth, it is not working any more:

std::string convertGeomToWkt(osgEarth::Geometry* geom)
{
	QString wkt = osgEarth::GeometryUtils::geometryToIsoWKT(geom).c_str(); 
	return wkt.toStdString();
}

This code failed only when the geometry is multipoints. (I have not tested any other multygeometry types)

I have fixed this problem by modifying the createOgrGeometry by replacing this:

else
{
    encodeMultiGeometry(geometry, root, mono_type, sub_type);
}

with:

else if (geom_type == wkbMultiPoint)
{
    // MultiPoint must directly contain Point geometries
    for (int v = 0; v < geometry->size(); v++)
    {
        osg::Vec3d p = (*geometry)[v];
        OGRGeometryH pt = OGR_G_CreateGeometry(wkbPoint);
        OGR_G_SetPoint(pt, 0, p.x(), p.y(), p.z());
        OGR_G_AddGeometryDirectly(root, pt);
    }
}
else
{
    encodeMultiGeometry(geometry, root, mono_type, sub_type);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions