-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
port Minimum bounding geometry algorithm to C++ #62594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
port Minimum bounding geometry algorithm to C++ #62594
Conversation
🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. 🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
5a37812
to
2031a99
Compare
src/analysis/processing/qgsalgorithmminimumboundinggeometry.cpp
Outdated
Show resolved
Hide resolved
src/analysis/processing/qgsalgorithmminimumboundinggeometry.cpp
Outdated
Show resolved
Hide resolved
if ( !geometryHash.contains( fieldValue ) ) | ||
{ | ||
geometryHash.insert( fieldValue, QVector<QgsGeometry>() << f.geometry() ); | ||
} | ||
else | ||
{ | ||
geometryHash.insert( fieldValue, geometryHash[fieldValue] << f.geometry() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !geometryHash.contains( fieldValue ) ) | |
{ | |
geometryHash.insert( fieldValue, QVector<QgsGeometry>() << f.geometry() ); | |
} | |
else | |
{ | |
geometryHash.insert( fieldValue, geometryHash[fieldValue] << f.geometry() ); | |
auto geometryHashIt = geometryHash.constFind( fieldValue ); | |
if ( geometryHashIt == geometryHash.constEnd() ) | |
{ | |
geometryHash.insert( fieldValue, QVector<QgsGeometry>() << f.geometry() ); | |
} | |
else | |
{ | |
geometryHash.insert( fieldValue, geometryHashIt.value() << f.geometry() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me, that we need to use non-const find()
here as we modify iterator value in the else
branch.
If not done (afaict, not yet in the help text), should we also cover the situation where a group or layer would contain one singlepart point feature, as done in #62300? |
2031a99
to
e93e8f0
Compare
auto boundsHashIt = boundsHash.constFind( fieldValue ); | ||
if ( boundsHashIt == boundsHash.constEnd() ) | ||
{ | ||
boundsHash.insert( fieldValue, f.geometry().boundingBox() ); | ||
} | ||
else | ||
{ | ||
QgsRectangle r = boundsHashIt.value(); | ||
r.combineExtentWith( f.geometry().boundingBox() ); | ||
boundsHash.insert( fieldValue, r ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work?
auto boundsHashIt = boundsHash.constFind( fieldValue ); | |
if ( boundsHashIt == boundsHash.constEnd() ) | |
{ | |
boundsHash.insert( fieldValue, f.geometry().boundingBox() ); | |
} | |
else | |
{ | |
QgsRectangle r = boundsHashIt.value(); | |
r.combineExtentWith( f.geometry().boundingBox() ); | |
boundsHash.insert( fieldValue, r ); | |
auto boundsHashIt = boundsHash.find( fieldValue ); | |
if ( boundsHashIt == boundsHash.end() ) | |
{ | |
boundsHash.insert( fieldValue, f.geometry().boundingBox() ); | |
} | |
else | |
{ | |
boundsHashIt.value().combineExtentWith( f.geometry().boundingBox() ); |
auto geometryHashIt = geometryHash.find( fieldValue ); | ||
if ( geometryHashIt == geometryHash.constEnd() ) | ||
{ | ||
geometryHash.insert( fieldValue, QVector<QgsGeometry>() << f.geometry() ); | ||
} | ||
else | ||
{ | ||
geometryHash.insert( fieldValue, geometryHashIt.value() << f.geometry() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto geometryHashIt = geometryHash.find( fieldValue ); | |
if ( geometryHashIt == geometryHash.constEnd() ) | |
{ | |
geometryHash.insert( fieldValue, QVector<QgsGeometry>() << f.geometry() ); | |
} | |
else | |
{ | |
geometryHash.insert( fieldValue, geometryHashIt.value() << f.geometry() ); | |
auto geometryHashIt = geometryHash.find( fieldValue ); | |
if ( geometryHashIt == geometryHash.end() ) | |
{ | |
geometryHash.insert( fieldValue, QVector<QgsGeometry>() << f.geometry() ); | |
} | |
else | |
{ | |
geometryHashIt.value().append( f.geometry() ); |
QgsFeature feature = createFeature( feedback, i, geometryType, it.value(), it.key() ); | ||
if ( !sink->addFeature( feature, QgsFeatureSink::FastInsert ) ) | ||
throw QgsProcessingException( writeFeatureError( sink.get(), parameters, QStringLiteral( "OUTPUT" ) ) ); | ||
geometryHash.insert( it.key(), QVector<QgsGeometry>() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually this is going to cause issues -- we can't modify geometryHash while we're iterating over it. What's this used for anyway? Aren't we finished with the hash when we're creating the features?
Description
Port Processing Minimum bounding geometry algorithm from Python to C++.