Skip to content

Commit

Permalink
[Geometry checker] Store feature pool directly in LayerFeature instea…
Browse files Browse the repository at this point in the history
…d of copying layerToMapUnits and layerToMapTransform
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent c14cdbb commit 9cbaebe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Expand Up @@ -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();
Expand All @@ -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(); }

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

Expand Down
12 changes: 6 additions & 6 deletions src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.h
Expand Up @@ -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;
Expand Down

0 comments on commit 9cbaebe

Please sign in to comment.