Commit 0dde3bf4 authored by Guillaume Pasero's avatar Guillaume Pasero

Merge branch 'fix_topology_exception' into 'develop'

BUG: fix potential TopologyException in GDAL

See merge request !576
parents 4ffb954d bf50d05c
Pipeline #2454 passed with stages
in 87 minutes and 11 seconds
......@@ -292,7 +292,7 @@ private:
//Creation of a multipolygon where are stored the geometries to be merged
OGRMultiPolygon geomToMerge;
geomToMerge.addGeometry(firstFeature.GetGeometry());
AddValidGeometry(geomToMerge, firstFeature.GetGeometry());
bool merging = true;
otb::ogr::Feature nextFeature(nullptr);
bool haveMerged=false;
......@@ -309,7 +309,7 @@ private:
//Storing of the new geometry if labels are identical
if(merging)
{
geomToMerge.addGeometry(nextFeature.GetGeometry());
AddValidGeometry(geomToMerge, nextFeature.GetGeometry());
layer.DeleteFeature(nextFeature.GetFID());
haveMerged=true;
}
......@@ -378,6 +378,18 @@ private:
otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds");
}
void AddValidGeometry(OGRMultiPolygon &multi, OGRGeometry const * g)
{
if (g->IsValid())
{
multi.addGeometry(g);
}
else
{
multi.addGeometryDirectly( g->Simplify(0.0) );
}
}
};
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment