void QgsComposerLabel::refreshExpressionContext() { if ( !mComposition ) return; QgsVectorLayer *layer = nullptr; if ( mComposition->atlasComposition().enabled() ) { layer = mComposition->atlasComposition().coverageLayer(); } //setup distance area conversion if ( layer ) { mDistanceArea->setSourceCrs( layer->crs() ); } else { //set to composition's reference map's crs QgsComposerMap *referenceMap = mComposition->referenceMap(); if ( referenceMap ) mDistanceArea->setSourceCrs( referenceMap->crs() ); } mDistanceArea->setEllipsoid( mComposition->project()->ellipsoid() ); contentChanged(); update(); }
void QgsLayoutItemHtml::setExpressionContext( const QgsFeature &feature, QgsVectorLayer *layer ) { mExpressionFeature = feature; mExpressionLayer = layer; //setup distance area conversion if ( layer ) { mDistanceArea.setSourceCrs( layer->crs() ); } else if ( mLayout ) { #if 0 //TODO //set to composition's mapsettings' crs QgsComposerMap *referenceMap = mComposition->referenceMap(); if ( referenceMap ) mDistanceArea->setSourceCrs( referenceMap->crs() ); #endif } if ( mLayout ) { mDistanceArea.setEllipsoid( mLayout->project()->ellipsoid() ); } // create JSON representation of feature QgsJsonExporter exporter( layer ); exporter.setIncludeRelated( true ); mAtlasFeatureJSON = exporter.exportFeature( feature ); }