Skip to content
Permalink
Browse files

PalLabelling: Reproject geometries before evaluating mininum size

Followup 2b096e0
  • Loading branch information
m-kuhn committed Jun 3, 2015
1 parent d53d30d commit 385529ef7b1002b00bebb7637e2d96c5432b6bd9
Showing with 15 additions and 18 deletions.
  1. +1 −2 python/core/qgspallabeling.sip
  2. +12 −13 src/core/qgspallabeling.cpp
  3. +2 −3 src/core/qgspallabeling.h
@@ -747,12 +747,11 @@ class QgsPalLabeling : QgsLabelingEngineInterface
* @param geometry geometry to prepare
* @param context render context
* @param ct coordinate transform
* @param minSize minimum allowable size for feature for registration with PAL
* @param clipGeometry geometry to clip features to, if applicable
* @returns prepared geometry
* @note added in QGIS 2.9
*/
static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, double minSize = 0, QgsGeometry *clipGeometry = 0 ) /Factory/;
static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 ) /Factory/;

/** Checks whether a geometry requires preparation before registration with PAL
* @param geometry geometry to prepare
@@ -1730,24 +1730,25 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
}

const GEOSGeometry* geos_geom = 0;
QScopedPointer<QgsGeometry> preparedGeom;
const QgsGeometry* preparedGeom = geom;
QScopedPointer<QgsGeometry> scpoedPreparedGeom;

if ( minFeatureSize > 0 && !checkMinimumSizeMM( context, geom, minFeatureSize ) )
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, doClip ? extentGeom : 0 ) )
{
return;
}
else if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, doClip ? extentGeom : 0 ) )
{
preparedGeom.reset( QgsPalLabeling::prepareGeometry( geom, context, ct, minFeatureSize, doClip ? extentGeom : 0 ) );
if ( !preparedGeom.data() )
scpoedPreparedGeom.reset( QgsPalLabeling::prepareGeometry( geom, context, ct, doClip ? extentGeom : 0 ) );
if ( !scpoedPreparedGeom.data() )
return;
geos_geom = preparedGeom.data()->asGeos();
preparedGeom = scpoedPreparedGeom.data();
geos_geom = scpoedPreparedGeom.data()->asGeos();
}
else
{
geos_geom = geom->asGeos();
}

if ( minFeatureSize > 0 && !checkMinimumSizeMM( context, preparedGeom, minFeatureSize ) )
return;

if ( geos_geom == NULL )
return; // invalid geometry

@@ -3398,10 +3399,8 @@ QStringList QgsPalLabeling::splitToGraphemes( const QString &text )
return graphemes;
}

QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const QgsRenderContext& context, const QgsCoordinateTransform* ct, double minSize, QgsGeometry* clipGeometry )
QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const QgsRenderContext& context, const QgsCoordinateTransform* ct, QgsGeometry* clipGeometry )
{
Q_UNUSED( minSize );

if ( !geometry )
{
return 0;
@@ -3562,7 +3561,7 @@ void QgsPalLabeling::registerDiagramFeature( const QString& layerID, QgsFeature&
QScopedPointer<QgsGeometry> preparedGeom;
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, layerIt.value().ct, extentGeom.data() ) )
{
preparedGeom.reset( QgsPalLabeling::prepareGeometry( geom, context, layerIt.value().ct, 0, extentGeom.data() ) );
preparedGeom.reset( QgsPalLabeling::prepareGeometry( geom, context, layerIt.value().ct, extentGeom.data() ) );
if ( !preparedGeom.data() )
return;
geos_geom = preparedGeom.data()->asGeos();
@@ -817,12 +817,11 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
* @param geometry geometry to prepare
* @param context render context
* @param ct coordinate transform
* @param minSize minimum allowable size for feature for registration with PAL
* @param clipGeometry geometry to clip features to, if applicable
* @returns prepared geometry
* @returns prepared geometry, the caller takes ownership
* @note added in QGIS 2.9
*/
static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, double minSize = 0, QgsGeometry *clipGeometry = 0 );
static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );

/** Checks whether a geometry requires preparation before registration with PAL
* @param geometry geometry to prepare

0 comments on commit 385529e

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