-
Notifications
You must be signed in to change notification settings - Fork 2
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
Ref functions #62
base: refFunctions
Are you sure you want to change the base?
Ref functions #62
Changes from 1 commit
4368205
78d5400
5b203a6
8b26b46
8c4a04c
8a25613
d493303
35bba7f
32b7a00
cd58105
d370b50
569f1a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4913,8 +4913,8 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress | |||||
QgsSpatialIndex spatialIndex; | ||||||
std::shared_ptr<QgsVectorLayer> cachedTarget; | ||||||
|
||||||
QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( targetLayerValue, parent ); | ||||||
if ( !layer ) // No layer, no joy | ||||||
QgsVectorLayer *targetLayer = QgsExpressionUtils::getVectorLayer( targetLayerValue, parent ); | ||||||
if ( !targetLayer ) // No layer, no joy | ||||||
{ | ||||||
parent->setEvalErrorString( QObject::tr( "Layer '%1' could not be loaded." ).arg( targetLayerValue.toString() ) ); | ||||||
return QVariant(); | ||||||
|
@@ -4930,6 +4930,12 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress | |||||
request.setFilterExpression( filterString ); //filter cached features | ||||||
} | ||||||
|
||||||
if (targetLayer->crs().authid() != sourceLayer->crs().authid()) | ||||||
{ | ||||||
QgsCoordinateTransformContext TransformContext; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "real" transform context is available from the expression context.
Suggested change
|
||||||
request.setDestinationCrs(sourceLayer->crs(), TransformContext); //if crs are not the same, cached target will be reprojected to source crs | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A new project for self overlay and different crs test |
||||||
} | ||||||
|
||||||
node = QgsExpressionUtils::getNode( values.at( 3 ), parent ); //in expressions overlay functions throw the exception: Eval Error: Cannot convert '' to int | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that further optional parameters have to be interpreted as an expression and then converted to int. The result is a bit tricky, but goes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it is the proper way to do this.... |
||||||
ENSURE_NO_EVAL_ERROR | ||||||
QVariant limitValue = node->eval( parent, context ); | ||||||
|
@@ -4953,13 +4959,13 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress | |||||
} | ||||||
*/ | ||||||
|
||||||
const QString cacheBase { QStringLiteral( "%1:%2" ).arg( layer->id(), subExpression ) }; | ||||||
const QString cacheBase { QStringLiteral( "%1:%2" ).arg( targetLayer->id(), subExpression ) }; | ||||||
const QString cacheLayer { QStringLiteral( "ovrlaylyr:%1" ).arg( cacheBase ) }; | ||||||
const QString cacheIndex { QStringLiteral( "ovrlayidx:%1" ).arg( cacheBase ) }; | ||||||
|
||||||
if ( !context->hasCachedValue( cacheLayer ) ) // should check for same crs. if not the same we could think to reproject target layer before charging cache | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good thinking! Added this to the todo list (but it should be done in the call to |
||||||
{ | ||||||
cachedTarget.reset( layer->materialize( request ) ); | ||||||
cachedTarget.reset( targetLayer->materialize( request ) ); | ||||||
if ( layerCanBeCached ) | ||||||
context->setCachedValue( cacheLayer, QVariant::fromValue( cachedTarget ) ); | ||||||
} | ||||||
|
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.
Better compare CRS directly (and not only authid)