Skip to content
Permalink
Browse files

[Geometry checker] Store feature pool directly in LayerFeature instea…

…d of copying layerToMapUnits and layerToMapTransform
  • Loading branch information
manisandro committed Jun 29, 2017
1 parent c14cdbb commit 9cbaebedd13acd1865766319c05d0e45d867d7de
@@ -26,10 +26,8 @@
namespace QgsGeometryCheckerUtils
{
LayerFeature::LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, bool useMapCrs )
: mLayer( pool->getLayer() )
: mFeaturePool( pool )
, mFeature( feature )
, mLayerToMapUnits( pool->getLayerToMapUnits() )
, mLayerToMapTransform( pool->getLayerToMapTransform() )
, mMapCrs( useMapCrs )
{
mGeometry = feature.geometry().geometry()->clone();
@@ -42,6 +40,9 @@ namespace QgsGeometryCheckerUtils
{
delete mGeometry;
}
const QgsVectorLayer &LayerFeature::layer() const { return *mFeaturePool->getLayer(); }
double LayerFeature::layerToMapUnits() const { return mFeaturePool->getLayerToMapUnits(); }
const QgsCoordinateTransform &LayerFeature::layerToMapTransform() const { return mFeaturePool->getLayerToMapTransform(); }

/////////////////////////////////////////////////////////////////////////////

@@ -54,18 +54,18 @@ namespace QgsGeometryCheckerUtils
public:
LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, bool useMapCrs );
~LayerFeature();
const QgsVectorLayer &layer() const { return *mLayer; }
const QgsFeature &feature() const { return mFeature; }
double layerToMapUnits() const { return mLayerToMapUnits; }
const QgsCoordinateTransform &layerToMapTransform() const { return mLayerToMapTransform; }
const QgsVectorLayer &layer() const;
double layerToMapUnits() const;
const QgsCoordinateTransform &layerToMapTransform() const;
const QgsAbstractGeometry *geometry() const { return mGeometry; }
QString geometryCrs() const { return mMapCrs ? mLayerToMapTransform.destinationCrs().authid() : mLayerToMapTransform.sourceCrs().authid(); }
QString id() const { return QString( "%1:%2" ).arg( mLayer->id() ).arg( mFeature.id() ); }
QString geometryCrs() const { return mMapCrs ? layerToMapTransform().destinationCrs().authid() : layerToMapTransform().sourceCrs().authid(); }
QString id() const { return QString( "%1:%2" ).arg( layer().name() ).arg( mFeature.id() ); }
bool operator==( const LayerFeature &other ) const { return layer().id() == other.layer().id() && feature().id() == other.feature().id(); }
bool operator!=( const LayerFeature &other ) const { return layer().id() != other.layer().id() || feature().id() != other.feature().id(); }

private:
const QgsVectorLayer *mLayer = nullptr;
const QgsFeaturePool *mFeaturePool;
QgsFeature mFeature;
double mLayerToMapUnits;
QgsCoordinateTransform mLayerToMapTransform;

0 comments on commit 9cbaebe

Please sign in to comment.
You can’t perform that action at this time.