Repository navigation
Add gdal vector combine, gdal vector dissolve (round 2) - #13985
Conversation
didn't you mean OGRFeature::Clone() at https://github.com/OSGeo/gdal/pull/13985/changes#diff-797ee50b80770e22f9baa077b51445205e94c696b84d9ad34e791f7463a4dae3R168 (can't see a OGRGeometry::Clone() use) . As far as I can see the GetNextProcessedFeature() method can be called several times on the same source feature in case of multiple iteration loops.
yes, could be worth removing that raw pointer array. I'm undecided if we need a CPLVector, and which pattern it should follow: similar to CPLString that inherits from std::string (but that causes some pains on Windows as it is CPL_DLL because it re-exports std::string symbols), or using a decorator/proxy design pattern, that is have a std::vector member variable and mimic std::vector API. Probably the later |
4014e31 to
606d3aa
Compare
|
I like combine better than collect |
|
combine sounds good |
|
Combine feels good. Maybe worth mentioning that |
9756196 to
6936024
Compare
6936024 to
83393c9
Compare
Yes, I was wondering if we could identify contexts where there is guaranteed to be only one iteration loop (intermediate step of a pipeline?) and steal the constructed feature. But a simpler approach is probably to rework this (later) such that |
that guarantee only holds if the |
This PR resurrects #13330 but makes some significant changes.
gdal vector combineFor
gdal vector collect, the default behavior is now to combine input multipart geometries rather than putting them into a nested collection. For example,POINT (3 8)andMULTIPOINT (2 6)becomeMULTIPOINT (3 8, 2 6)rather than the PostGIS result ofThe behavior change is motivated by usability -- without the change, for example, I cannot run:
because Shapefile does not support GeometryCollections. If I instead write to a GeoPackage the pipeline completes but the result does not display in QGIS.
A flag (
--keep-nested) is added to get PostGIS-style nested output. The name could probably be improved.gdal vector dissolveThe previously-discussed behavior about running "LineMerge" after "Union" is implemented.
Side notes
I don't love the use of
OGRGeometry::Clone()inGDALVectorCollectOutputLayer. It would be nice to figure out a pattern whereGetNextFeaturecan return a moved feature in a context where the layer will only be consumed once. Maybe it's not worth the complexity though.Even though it is very simple, the implementation of
OGRGeometryCollection::addGeometryComponentsfelt painful with the manual management ofpapoGeoms. I think it is worth replacing this and other similar cases with either astd::vector(just wrap methods that modify it in a try/catch forstd::bad_alloc?) or adding aCPLVectortemplate that wrapsstd::vectorand converts the exceptions to error codes. In addition to being easier on the eyes this would remove the inefficient pattern ofNreallocations to addNelements to a container. Curious if there's any input on that.