Skip to content

Commit

Permalink
PalLabelling: Reproject geometries before evaluating mininum size
Browse files Browse the repository at this point in the history
Followup 2b096e0
  • Loading branch information
m-kuhn committed Jun 3, 2015
1 parent d53d30d commit 385529e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
3 changes: 1 addition & 2 deletions python/core/qgspallabeling.sip
Expand Up @@ -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
Expand Down
25 changes: 12 additions & 13 deletions src/core/qgspallabeling.cpp
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions src/core/qgspallabeling.h
Expand Up @@ -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
Expand Down

0 comments on commit 385529e

Please sign in to comment.