mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
No more QgsGeometry pointers in the public API
Geometries are passed as const reference and returned by value. This make using the API easier and reduces the risk of ownership problems. The overhead is minimal due to implicit sharing. Fix https://github.com/qgis/qgis3.0_api/issues/68
This commit is contained in:
parent
6896548521
commit
cc877c39eb
@ -496,13 +496,6 @@ not disjoint with existing polygons of the feature
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
int makeDifference( const QgsGeometry *other );
|
||||
%Docstring
|
||||
Changes this geometry such that it does not intersect the other geometry
|
||||
\param other geometry that should not be intersect
|
||||
:return: 0 in case of success
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
QgsGeometry makeDifference( const QgsGeometry &other ) const;
|
||||
%Docstring
|
||||
|
@ -16,7 +16,7 @@ class QgsGeometryValidator : QThread
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
QgsGeometryValidator( const QgsGeometry &geoemtry, QList<QgsGeometry::Error> *errors = 0, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
%Docstring
|
||||
Constructor for QgsGeometryValidator.
|
||||
%End
|
||||
@ -26,7 +26,7 @@ class QgsGeometryValidator : QThread
|
||||
|
||||
void stop();
|
||||
|
||||
static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors /Out/, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
static void validateGeometry( const QgsGeometry &geometry, QList<QgsGeometry::Error> &errors /Out/, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
%Docstring
|
||||
Validate geometry and produce a list of geometry errors
|
||||
%End
|
||||
|
@ -59,7 +59,7 @@ Read rectangle from GML3 Envelope
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
static QDomElement geometryToGML( const QgsGeometry *geometry, QDomDocument &doc,
|
||||
static QDomElement geometryToGML( const QgsGeometry &geometry, QDomDocument &doc,
|
||||
QgsOgcUtils::GMLVersion gmlVersion,
|
||||
const QString &srsName,
|
||||
bool invertAxisOrientation,
|
||||
@ -72,14 +72,14 @@ Read rectangle from GML3 Envelope
|
||||
:rtype: QDomElement
|
||||
%End
|
||||
|
||||
static QDomElement geometryToGML( const QgsGeometry *geometry, QDomDocument &doc, const QString &format, int precision = 17 );
|
||||
static QDomElement geometryToGML( const QgsGeometry &geometry, QDomDocument &doc, const QString &format, int precision = 17 );
|
||||
%Docstring
|
||||
Exports the geometry to GML2 or GML3
|
||||
:return: QDomElement
|
||||
:rtype: QDomElement
|
||||
%End
|
||||
|
||||
static QDomElement geometryToGML( const QgsGeometry *geometry, QDomDocument &doc, int precision = 17 );
|
||||
static QDomElement geometryToGML( const QgsGeometry &geometry, QDomDocument &doc, int precision = 17 );
|
||||
%Docstring
|
||||
Exports the geometry to GML2
|
||||
:return: QDomElement
|
||||
|
@ -415,7 +415,7 @@ Z-Index of label, where labels with a higher z-index are rendered on top of labe
|
||||
|
||||
void calculateLabelSize( const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f = 0, QgsRenderContext *context = 0 );
|
||||
|
||||
void registerFeature( QgsFeature &f, QgsRenderContext &context );
|
||||
void registerFeature( QgsFeature &f, QgsRenderContext &context );
|
||||
|
||||
%Docstring
|
||||
Register a feature for labeling.
|
||||
@ -553,7 +553,7 @@ class QgsPalLabeling
|
||||
%End
|
||||
|
||||
|
||||
static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry = 0 ) /Factory/;
|
||||
static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry() ) /Factory/;
|
||||
%Docstring
|
||||
Prepares a geometry for registration with PAL. Handles reprojection, rotation, clipping, etc.
|
||||
\param geometry geometry to prepare
|
||||
@ -565,7 +565,7 @@ class QgsPalLabeling
|
||||
:rtype: QgsGeometry
|
||||
%End
|
||||
|
||||
static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry = 0 );
|
||||
static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry() );
|
||||
%Docstring
|
||||
Checks whether a geometry requires preparation before registration with PAL
|
||||
\param geometry geometry to prepare
|
||||
@ -599,49 +599,6 @@ class QgsPalLabeling
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
protected:
|
||||
static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
|
||||
%Docstring
|
||||
Update temporary QgsPalLayerSettings with any data defined text style values
|
||||
%End
|
||||
|
||||
static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
|
||||
%Docstring
|
||||
Update temporary QgsPalLayerSettings with any data defined text formatting values
|
||||
%End
|
||||
|
||||
static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
|
||||
%Docstring
|
||||
Update temporary QgsPalLayerSettings with any data defined text buffer values
|
||||
%End
|
||||
|
||||
static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
|
||||
%Docstring
|
||||
Update temporary QgsPalLayerSettings with any data defined shape background values
|
||||
%End
|
||||
|
||||
static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
|
||||
%Docstring
|
||||
Update temporary QgsPalLayerSettings with any data defined drop shadow values
|
||||
%End
|
||||
|
||||
|
||||
static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
|
||||
%Docstring
|
||||
Checks whether a geometry exceeds the minimum required size for a geometry to be labeled.
|
||||
\param context render context
|
||||
\param geom geometry
|
||||
\param minSize minimum size for geometry
|
||||
:return: true if geometry exceeds minimum size
|
||||
.. versionadded:: 2.9
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -556,7 +556,7 @@ Returns a list of available encodings
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QgsGeometry *convertToProviderType( const QgsGeometry &geom ) const /Factory/;
|
||||
QgsGeometry convertToProviderType( const QgsGeometry &geom ) const;
|
||||
%Docstring
|
||||
Converts the geometry to the provider type if possible / necessary
|
||||
:return: the converted geometry or None if no conversion was necessary or possible
|
||||
|
@ -1828,7 +1828,7 @@ void QgsNodeTool::GeometryValidation::start( QgsGeometry &geom, QgsNodeTool *t,
|
||||
if ( settings.value( QStringLiteral( "qgis/digitizing/validate_geometries" ), 1 ).toInt() == 2 )
|
||||
method = QgsGeometry::ValidatorGeos;
|
||||
|
||||
validator = new QgsGeometryValidator( &geom, nullptr, method );
|
||||
validator = new QgsGeometryValidator( geom, nullptr, method );
|
||||
connect( validator, &QgsGeometryValidator::errorFound, tool, &QgsNodeTool::validationErrorFound );
|
||||
connect( validator, &QThread::finished, tool, &QgsNodeTool::validationFinished );
|
||||
validator->start();
|
||||
|
@ -188,7 +188,7 @@ void QgsSelectedFeature::validateGeometry( QgsGeometry *g )
|
||||
QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal;
|
||||
if ( settings.value( QStringLiteral( "qgis/digitizing/validate_geometries" ), 1 ).toInt() == 2 )
|
||||
method = QgsGeometry::ValidatorGeos;
|
||||
mValidator = new QgsGeometryValidator( g, nullptr, method );
|
||||
mValidator = new QgsGeometryValidator( *g, nullptr, method );
|
||||
connect( mValidator, &QgsGeometryValidator::errorFound, this, &QgsSelectedFeature::addError );
|
||||
connect( mValidator, &QThread::finished, this, &QgsSelectedFeature::validationFinished );
|
||||
mValidator->start();
|
||||
|
@ -477,9 +477,3 @@ QgsGeometry QgsMapToolOffsetCurve::convertToSingleLine( const QgsGeometry &geom,
|
||||
}
|
||||
return QgsGeometry();
|
||||
}
|
||||
|
||||
QgsGeometry *QgsMapToolOffsetCurve::convertToMultiLine( QgsGeometry *geom )
|
||||
{
|
||||
Q_UNUSED( geom );
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -72,8 +72,6 @@ class APP_EXPORT QgsMapToolOffsetCurve: public QgsMapToolEdit
|
||||
QgsGeometry linestringFromPolygon( const QgsGeometry &featureGeom, int vertex );
|
||||
//! Returns a single line from a multiline (or does nothing if geometry is already a single line). Deletes the input geometry
|
||||
QgsGeometry convertToSingleLine( const QgsGeometry &geom, int vertex, bool &isMulti );
|
||||
//! Converts offset line back to a multiline if necessary
|
||||
QgsGeometry *convertToMultiLine( QgsGeometry *geom );
|
||||
};
|
||||
|
||||
#endif // QGSMAPTOOLOFFSETCURVE_H
|
||||
|
@ -836,16 +836,16 @@ int QgsGeometry::reshapeGeometry( const QgsLineString &reshapeLineString )
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int QgsGeometry::makeDifference( const QgsGeometry *other )
|
||||
int QgsGeometry::makeDifferenceInPlace( const QgsGeometry &other )
|
||||
{
|
||||
if ( !d->geometry || !other->d->geometry )
|
||||
if ( !d->geometry || !other.d->geometry )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QgsGeos geos( d->geometry );
|
||||
|
||||
QgsAbstractGeometry *diffGeom = geos.intersection( *( other->geometry() ) );
|
||||
QgsAbstractGeometry *diffGeom = geos.intersection( *other.geometry() );
|
||||
if ( !diffGeom )
|
||||
{
|
||||
return 1;
|
||||
@ -1964,7 +1964,7 @@ QgsGeometry QgsGeometry::makeValid()
|
||||
|
||||
void QgsGeometry::validateGeometry( QList<QgsGeometry::Error> &errors, ValidationMethod method )
|
||||
{
|
||||
QgsGeometryValidator::validateGeometry( this, errors, method );
|
||||
QgsGeometryValidator::validateGeometry( *this, errors, method );
|
||||
}
|
||||
|
||||
bool QgsGeometry::isGeosValid() const
|
||||
|
@ -496,8 +496,9 @@ class CORE_EXPORT QgsGeometry
|
||||
/** Changes this geometry such that it does not intersect the other geometry
|
||||
* \param other geometry that should not be intersect
|
||||
* \returns 0 in case of success
|
||||
* \note Not available in Python
|
||||
*/
|
||||
int makeDifference( const QgsGeometry *other );
|
||||
int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
|
||||
|
||||
/** Returns the geometry formed by modifying this geometry such that it does not
|
||||
* intersect the other geometry.
|
||||
|
@ -18,16 +18,14 @@ email : jef at norbit dot de
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
QgsGeometryValidator::QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors, QgsGeometry::ValidationMethod method )
|
||||
QgsGeometryValidator::QgsGeometryValidator( const QgsGeometry &geometry, QList<QgsGeometry::Error> *errors, QgsGeometry::ValidationMethod method )
|
||||
: QThread()
|
||||
, mGeometry( geometry )
|
||||
, mErrors( errors )
|
||||
, mStop( false )
|
||||
, mErrorCount( 0 )
|
||||
, mMethod( method )
|
||||
{
|
||||
Q_ASSERT( g );
|
||||
if ( g )
|
||||
mG = *g;
|
||||
}
|
||||
|
||||
QgsGeometryValidator::~QgsGeometryValidator()
|
||||
@ -357,9 +355,9 @@ void QgsGeometryValidator::addError( const QgsGeometry::Error &e )
|
||||
*mErrors << e;
|
||||
}
|
||||
|
||||
void QgsGeometryValidator::validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors, QgsGeometry::ValidationMethod method )
|
||||
void QgsGeometryValidator::validateGeometry( const QgsGeometry &geometry, QList<QgsGeometry::Error> &errors, QgsGeometry::ValidationMethod method )
|
||||
{
|
||||
QgsGeometryValidator *gv = new QgsGeometryValidator( g, &errors, method );
|
||||
QgsGeometryValidator *gv = new QgsGeometryValidator( geometry, &errors, method );
|
||||
connect( gv, &QgsGeometryValidator::errorFound, gv, &QgsGeometryValidator::addError );
|
||||
gv->run();
|
||||
gv->wait();
|
||||
|
@ -33,14 +33,14 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
|
||||
/**
|
||||
* Constructor for QgsGeometryValidator.
|
||||
*/
|
||||
QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = nullptr, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
QgsGeometryValidator( const QgsGeometry &geoemtry, QList<QgsGeometry::Error> *errors = nullptr, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
~QgsGeometryValidator();
|
||||
|
||||
void run() override;
|
||||
void stop();
|
||||
|
||||
//! Validate geometry and produce a list of geometry errors
|
||||
static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
static void validateGeometry( const QgsGeometry &geometry, QList<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
|
||||
|
||||
signals:
|
||||
void errorFound( const QgsGeometry::Error & );
|
||||
@ -57,7 +57,7 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
|
||||
bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside );
|
||||
bool pointInRing( const QgsPolyline &ring, const QgsPointXY &p );
|
||||
|
||||
QgsGeometry mG;
|
||||
QgsGeometry mGeometry;
|
||||
QList<QgsGeometry::Error> *mErrors;
|
||||
bool mStop;
|
||||
int mErrorCount;
|
||||
|
@ -1122,12 +1122,12 @@ QDomElement QgsOgcUtils::rectangleToGMLEnvelope( QgsRectangle *env, QDomDocument
|
||||
return envElem;
|
||||
}
|
||||
|
||||
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocument &doc, const QString &format, int precision )
|
||||
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocument &doc, const QString &format, int precision )
|
||||
{
|
||||
return geometryToGML( geometry, doc, ( format == QLatin1String( "GML2" ) ) ? GML_2_1_2 : GML_3_2_1, QString(), false, QString(), precision );
|
||||
}
|
||||
|
||||
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocument &doc,
|
||||
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocument &doc,
|
||||
GMLVersion gmlVersion,
|
||||
const QString &srsName,
|
||||
bool invertAxisOrientation,
|
||||
@ -1146,7 +1146,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocumen
|
||||
|
||||
bool hasZValue = false;
|
||||
|
||||
QByteArray wkb( geometry->exportToWkb() );
|
||||
QByteArray wkb( geometry.exportToWkb() );
|
||||
QgsConstWkbPtr wkbPtr( wkb );
|
||||
try
|
||||
{
|
||||
@ -1161,7 +1161,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocumen
|
||||
|
||||
if ( gmlVersion != GML_2_1_2 )
|
||||
{
|
||||
switch ( geometry->wkbType() )
|
||||
switch ( geometry.wkbType() )
|
||||
{
|
||||
case QgsWkbTypes::Point25D:
|
||||
case QgsWkbTypes::Point:
|
||||
@ -1185,7 +1185,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocumen
|
||||
|
||||
try
|
||||
{
|
||||
switch ( geometry->wkbType() )
|
||||
switch ( geometry.wkbType() )
|
||||
{
|
||||
case QgsWkbTypes::Point25D:
|
||||
case QgsWkbTypes::Point:
|
||||
@ -1501,7 +1501,7 @@ QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocumen
|
||||
}
|
||||
}
|
||||
|
||||
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry *geometry, QDomDocument &doc, int precision )
|
||||
QDomElement QgsOgcUtils::geometryToGML( const QgsGeometry &geometry, QDomDocument &doc, int precision )
|
||||
{
|
||||
return geometryToGML( geometry, doc, QStringLiteral( "GML2" ), precision );
|
||||
}
|
||||
@ -2572,7 +2572,7 @@ QDomElement QgsOgcUtilsExprToFilter::expressionFunctionToOgcFilter( const QgsExp
|
||||
}
|
||||
QString wkt = static_cast<const QgsExpressionNodeLiteral *>( firstFnArg )->value().toString();
|
||||
QgsGeometry geom = QgsGeometry::fromWkt( wkt );
|
||||
otherGeomElem = QgsOgcUtils::geometryToGML( &geom, mDoc, mGMLVersion, mSrsName, mInvertAxisOrientation,
|
||||
otherGeomElem = QgsOgcUtils::geometryToGML( geom, mDoc, mGMLVersion, mSrsName, mInvertAxisOrientation,
|
||||
QStringLiteral( "qgis_id_geom_%1" ).arg( mGeomId ) );
|
||||
mGeomId ++;
|
||||
}
|
||||
@ -3043,7 +3043,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
|
||||
QString wkt = static_cast<const QgsSQLStatement::NodeLiteral *>( firstFnArg )->value().toString();
|
||||
QgsGeometry geom = QgsGeometry::fromWkt( wkt );
|
||||
QDomElement geomElem = QgsOgcUtils::geometryToGML( &geom, mDoc, mGMLVersion, srsName, axisInversion,
|
||||
QDomElement geomElem = QgsOgcUtils::geometryToGML( geom, mDoc, mGMLVersion, srsName, axisInversion,
|
||||
QStringLiteral( "qgis_id_geom_%1" ).arg( mGeomId ) );
|
||||
mGeomId ++;
|
||||
if ( geomElem.isNull() )
|
||||
|
@ -80,7 +80,7 @@ class CORE_EXPORT QgsOgcUtils
|
||||
\returns QDomElement
|
||||
\since QGIS 2.16
|
||||
*/
|
||||
static QDomElement geometryToGML( const QgsGeometry *geometry, QDomDocument &doc,
|
||||
static QDomElement geometryToGML( const QgsGeometry &geometry, QDomDocument &doc,
|
||||
QgsOgcUtils::GMLVersion gmlVersion,
|
||||
const QString &srsName,
|
||||
bool invertAxisOrientation,
|
||||
@ -90,12 +90,12 @@ class CORE_EXPORT QgsOgcUtils
|
||||
/** Exports the geometry to GML2 or GML3
|
||||
\returns QDomElement
|
||||
*/
|
||||
static QDomElement geometryToGML( const QgsGeometry *geometry, QDomDocument &doc, const QString &format, int precision = 17 );
|
||||
static QDomElement geometryToGML( const QgsGeometry &geometry, QDomDocument &doc, const QString &format, int precision = 17 );
|
||||
|
||||
/** Exports the geometry to GML2
|
||||
\returns QDomElement
|
||||
*/
|
||||
static QDomElement geometryToGML( const QgsGeometry *geometry, QDomDocument &doc, int precision = 17 );
|
||||
static QDomElement geometryToGML( const QgsGeometry &geometry, QDomDocument &doc, int precision = 17 );
|
||||
|
||||
/** Exports the rectangle to GML2 Box
|
||||
\returns QDomElement
|
||||
|
@ -991,7 +991,7 @@ QDomElement QgsPalLayerSettings::writeXml( QDomDocument &doc, const QgsReadWrite
|
||||
|
||||
bool QgsPalLayerSettings::checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const
|
||||
{
|
||||
return QgsPalLabeling::checkMinimumSizeMM( ct, &geom, minSize );
|
||||
return QgsPalLabeling::checkMinimumSizeMM( ct, geom, minSize );
|
||||
}
|
||||
|
||||
void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f, QgsRenderContext *context )
|
||||
@ -1133,7 +1133,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, QString t
|
||||
#endif
|
||||
}
|
||||
|
||||
void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **labelFeature, QgsGeometry *obstacleGeometry )
|
||||
void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **labelFeature, QgsGeometry obstacleGeometry )
|
||||
{
|
||||
// either used in QgsPalLabeling (palLayer is set) or in QgsLabelingEngine (labelFeature is set)
|
||||
Q_ASSERT( labelFeature );
|
||||
@ -1450,9 +1450,9 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
||||
if ( geom.type() == QgsWkbTypes::PolygonGeometry && fitInPolygonOnly )
|
||||
{
|
||||
permissibleZone = geom;
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( permissibleZone, context, ct, doClip ? &extentGeom : nullptr ) )
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( permissibleZone, context, ct, doClip ? extentGeom : QgsGeometry() ) )
|
||||
{
|
||||
permissibleZone = QgsPalLabeling::prepareGeometry( permissibleZone, context, ct, doClip ? &extentGeom : nullptr );
|
||||
permissibleZone = QgsPalLabeling::prepareGeometry( permissibleZone, context, ct, doClip ? extentGeom : QgsGeometry() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1465,22 +1465,20 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
||||
}
|
||||
|
||||
GEOSGeometry *geos_geom_clone = nullptr;
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, doClip ? &extentGeom : nullptr ) )
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, doClip ? extentGeom : QgsGeometry() ) )
|
||||
{
|
||||
geom = QgsPalLabeling::prepareGeometry( geom, context, ct, doClip ? &extentGeom : nullptr );
|
||||
geom = QgsPalLabeling::prepareGeometry( geom, context, ct, doClip ? extentGeom : QgsGeometry() );
|
||||
|
||||
if ( geom.isNull() )
|
||||
return;
|
||||
}
|
||||
geos_geom_clone = geom.exportToGeos();
|
||||
|
||||
std::unique_ptr<QgsGeometry> scopedObstacleGeom;
|
||||
if ( isObstacle )
|
||||
{
|
||||
if ( obstacleGeometry && QgsPalLabeling::geometryRequiresPreparation( *obstacleGeometry, context, ct, doClip ? &extentGeom : nullptr ) )
|
||||
if ( !obstacleGeometry.isNull() && QgsPalLabeling::geometryRequiresPreparation( obstacleGeometry, context, ct, doClip ? extentGeom : QgsGeometry() ) )
|
||||
{
|
||||
scopedObstacleGeom.reset( new QgsGeometry( QgsPalLabeling::prepareGeometry( *obstacleGeometry, context, ct, doClip ? &extentGeom : nullptr ) ) );
|
||||
obstacleGeometry = scopedObstacleGeom.get();
|
||||
obstacleGeometry = QgsGeometry( QgsPalLabeling::prepareGeometry( obstacleGeometry, context, ct, doClip ? extentGeom : QgsGeometry() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1518,7 +1516,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
||||
GEOSGeometry *geosObstacleGeomClone = nullptr;
|
||||
if ( obstacleGeometry )
|
||||
{
|
||||
geosObstacleGeomClone = obstacleGeometry->exportToGeos();
|
||||
geosObstacleGeomClone = obstacleGeometry.exportToGeos();
|
||||
}
|
||||
|
||||
|
||||
@ -1828,8 +1826,8 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
||||
if ( geom.type() == QgsWkbTypes::PointGeometry )
|
||||
{
|
||||
//register symbol size
|
||||
( *labelFeature )->setSymbolSize( QSizeF( obstacleGeometry->boundingBox().width(),
|
||||
obstacleGeometry->boundingBox().height() ) );
|
||||
( *labelFeature )->setSymbolSize( QSizeF( obstacleGeometry.boundingBox().width(),
|
||||
obstacleGeometry.boundingBox().height() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1951,14 +1949,14 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
||||
lf->setDataDefinedValues( dataDefinedValues );
|
||||
}
|
||||
|
||||
void QgsPalLayerSettings::registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, QgsGeometry *obstacleGeometry )
|
||||
void QgsPalLayerSettings::registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, const QgsGeometry &obstacleGeometry )
|
||||
{
|
||||
mCurFeat = &f;
|
||||
|
||||
QgsGeometry geom;
|
||||
if ( obstacleGeometry )
|
||||
{
|
||||
geom = *obstacleGeometry;
|
||||
geom = obstacleGeometry;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1984,9 +1982,9 @@ void QgsPalLayerSettings::registerObstacleFeature( QgsFeature &f, QgsRenderConte
|
||||
GEOSGeometry *geos_geom_clone = nullptr;
|
||||
std::unique_ptr<QgsGeometry> scopedPreparedGeom;
|
||||
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, &extentGeom ) )
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, extentGeom ) )
|
||||
{
|
||||
geom = QgsPalLabeling::prepareGeometry( geom, context, ct, &extentGeom );
|
||||
geom = QgsPalLabeling::prepareGeometry( geom, context, ct, extentGeom );
|
||||
}
|
||||
geos_geom_clone = geom.exportToGeos();
|
||||
|
||||
@ -2781,7 +2779,7 @@ bool QgsPalLabeling::staticWillUseLayer( QgsVectorLayer *layer )
|
||||
}
|
||||
|
||||
|
||||
bool QgsPalLabeling::geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry )
|
||||
bool QgsPalLabeling::geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry )
|
||||
{
|
||||
if ( geometry.isNull() )
|
||||
{
|
||||
@ -2798,7 +2796,7 @@ bool QgsPalLabeling::geometryRequiresPreparation( const QgsGeometry &geometry, Q
|
||||
return true;
|
||||
|
||||
//requires clip
|
||||
if ( clipGeometry && !clipGeometry->boundingBox().contains( geometry.boundingBox() ) )
|
||||
if ( !clipGeometry.isNull() && !clipGeometry.boundingBox().contains( geometry.boundingBox() ) )
|
||||
return true;
|
||||
|
||||
//requires fixing
|
||||
@ -2841,7 +2839,7 @@ QStringList QgsPalLabeling::splitToGraphemes( const QString &text )
|
||||
return graphemes;
|
||||
}
|
||||
|
||||
QgsGeometry QgsPalLabeling::prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry )
|
||||
QgsGeometry QgsPalLabeling::prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry )
|
||||
{
|
||||
if ( geometry.isNull() )
|
||||
{
|
||||
@ -2904,11 +2902,11 @@ QgsGeometry QgsPalLabeling::prepareGeometry( const QgsGeometry &geometry, QgsRen
|
||||
geom = bufferGeom;
|
||||
}
|
||||
|
||||
if ( clipGeometry &&
|
||||
( ( qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry->boundingBox().contains( geom.boundingBox() ) )
|
||||
|| ( !qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry->contains( geom ) ) ) )
|
||||
if ( !clipGeometry.isNull() &&
|
||||
( ( qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry.boundingBox().contains( geom.boundingBox() ) )
|
||||
|| ( !qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry.contains( geom ) ) ) )
|
||||
{
|
||||
QgsGeometry clipGeom = geom.intersection( *clipGeometry ); // creates new geometry
|
||||
QgsGeometry clipGeom = geom.intersection( clipGeometry ); // creates new geometry
|
||||
if ( clipGeom.isNull() )
|
||||
{
|
||||
return QgsGeometry();
|
||||
@ -2919,19 +2917,19 @@ QgsGeometry QgsPalLabeling::prepareGeometry( const QgsGeometry &geometry, QgsRen
|
||||
return geom;
|
||||
}
|
||||
|
||||
bool QgsPalLabeling::checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize )
|
||||
bool QgsPalLabeling::checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize )
|
||||
{
|
||||
if ( minSize <= 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !geom )
|
||||
if ( geom.isNull() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsWkbTypes::GeometryType featureType = geom->type();
|
||||
QgsWkbTypes::GeometryType featureType = geom.type();
|
||||
if ( featureType == QgsWkbTypes::PointGeometry ) //minimum size does not apply to point features
|
||||
{
|
||||
return true;
|
||||
@ -2940,7 +2938,7 @@ bool QgsPalLabeling::checkMinimumSizeMM( const QgsRenderContext &context, const
|
||||
double mapUnitsPerMM = context.mapToPixel().mapUnitsPerPixel() * context.scaleFactor();
|
||||
if ( featureType == QgsWkbTypes::LineGeometry )
|
||||
{
|
||||
double length = geom->length();
|
||||
double length = geom.length();
|
||||
if ( length >= 0.0 )
|
||||
{
|
||||
return ( length >= ( minSize * mapUnitsPerMM ) );
|
||||
@ -2948,7 +2946,7 @@ bool QgsPalLabeling::checkMinimumSizeMM( const QgsRenderContext &context, const
|
||||
}
|
||||
else if ( featureType == QgsWkbTypes::PolygonGeometry )
|
||||
{
|
||||
double area = geom->area();
|
||||
double area = geom.area();
|
||||
if ( area >= 0.0 )
|
||||
{
|
||||
return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
|
||||
|
@ -542,7 +542,7 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
*/
|
||||
void registerFeature( QgsFeature &f, QgsRenderContext &context,
|
||||
QgsLabelFeature **labelFeature SIP_PYARGREMOVE = nullptr,
|
||||
QgsGeometry *obstacleGeometry SIP_PYARGREMOVE = nullptr );
|
||||
QgsGeometry obstacleGeometry SIP_PYARGREMOVE = QgsGeometry() );
|
||||
|
||||
/** Read settings from a DOM element
|
||||
* \since QGIS 2.12
|
||||
@ -660,7 +660,7 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
|
||||
/** Registers a feature as an obstacle only (no label rendered)
|
||||
*/
|
||||
void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, QgsGeometry *obstacleGeometry = nullptr );
|
||||
void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, const QgsGeometry &obstacleGeometry = QgsGeometry() );
|
||||
|
||||
QMap<Property, QVariant> dataDefinedValues;
|
||||
|
||||
@ -750,7 +750,7 @@ class CORE_EXPORT QgsPalLabeling
|
||||
* \returns prepared geometry
|
||||
* \since QGIS 2.9
|
||||
*/
|
||||
static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry = nullptr ) SIP_FACTORY;
|
||||
static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry() ) SIP_FACTORY;
|
||||
|
||||
/** Checks whether a geometry requires preparation before registration with PAL
|
||||
* \param geometry geometry to prepare
|
||||
@ -760,7 +760,7 @@ class CORE_EXPORT QgsPalLabeling
|
||||
* \returns true if geometry requires preparation
|
||||
* \since QGIS 2.9
|
||||
*/
|
||||
static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry = nullptr );
|
||||
static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry() );
|
||||
|
||||
/** Splits a text string to a list of separate lines, using a specified wrap character.
|
||||
* The text string will be split on either newline characters or the wrap character.
|
||||
@ -780,7 +780,7 @@ class CORE_EXPORT QgsPalLabeling
|
||||
*/
|
||||
static QStringList splitToGraphemes( const QString &text );
|
||||
|
||||
protected:
|
||||
private:
|
||||
//! Update temporary QgsPalLayerSettings with any data defined text style values
|
||||
static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
|
||||
const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
|
||||
@ -811,7 +811,7 @@ class CORE_EXPORT QgsPalLabeling
|
||||
* \returns true if geometry exceeds minimum size
|
||||
* \since QGIS 2.9
|
||||
*/
|
||||
static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
|
||||
static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
|
||||
|
||||
friend class QgsPalLayerSettings;
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ bool QgsRuleBasedLabelProvider::prepare( const QgsRenderContext &context, QSet<Q
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsRuleBasedLabelProvider::registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry )
|
||||
void QgsRuleBasedLabelProvider::registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry )
|
||||
{
|
||||
// will register the feature to relevant sub-providers
|
||||
mRules->rootRule()->registerFeature( feature, context, mSubProviders, obstacleGeometry );
|
||||
@ -303,7 +303,7 @@ void QgsRuleBasedLabeling::Rule::prepare( const QgsRenderContext &context, QSet<
|
||||
}
|
||||
}
|
||||
|
||||
QgsRuleBasedLabeling::Rule::RegisterResult QgsRuleBasedLabeling::Rule::registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsRuleBasedLabeling::RuleToProviderMap &subProviders, QgsGeometry *obstacleGeometry )
|
||||
QgsRuleBasedLabeling::Rule::RegisterResult QgsRuleBasedLabeling::Rule::registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsRuleBasedLabeling::RuleToProviderMap &subProviders, const QgsGeometry &obstacleGeometry )
|
||||
{
|
||||
if ( !isFilterOK( feature, context )
|
||||
|| !isScaleOK( context.rendererScale() ) )
|
||||
|
@ -262,7 +262,7 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling
|
||||
|
||||
//! register individual features
|
||||
//! \note not available in Python bindings
|
||||
RegisterResult registerFeature( QgsFeature &feature, QgsRenderContext &context, RuleToProviderMap &subProviders, QgsGeometry *obstacleGeometry = nullptr ) SIP_SKIP;
|
||||
RegisterResult registerFeature( QgsFeature &feature, QgsRenderContext &context, RuleToProviderMap &subProviders, const QgsGeometry &obstacleGeometry = QgsGeometry() ) SIP_SKIP;
|
||||
|
||||
/**
|
||||
* Returns true if this rule or any of its children requires advanced composition effects
|
||||
@ -364,7 +364,7 @@ class CORE_EXPORT QgsRuleBasedLabelProvider : public QgsVectorLayerLabelProvider
|
||||
|
||||
virtual bool prepare( const QgsRenderContext &context, QSet<QString> &attributeNames ) override;
|
||||
|
||||
virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry = nullptr ) override;
|
||||
virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() ) override;
|
||||
|
||||
//! create a label provider
|
||||
virtual QgsVectorLayerLabelProvider *createProvider( QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings );
|
||||
|
@ -700,17 +700,17 @@ QSet<QgsMapLayerDependency> QgsVectorDataProvider::dependencies() const
|
||||
return QSet<QgsMapLayerDependency>();
|
||||
}
|
||||
|
||||
QgsGeometry *QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geom ) const
|
||||
QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geom ) const
|
||||
{
|
||||
if ( geom.isNull() )
|
||||
{
|
||||
return nullptr;
|
||||
return QgsGeometry();
|
||||
}
|
||||
|
||||
QgsAbstractGeometry *geometry = geom.geometry();
|
||||
if ( !geometry )
|
||||
{
|
||||
return nullptr;
|
||||
return QgsGeometry();
|
||||
}
|
||||
|
||||
QgsWkbTypes::Type providerGeomType = wkbType();
|
||||
@ -718,7 +718,7 @@ QgsGeometry *QgsVectorDataProvider::convertToProviderType( const QgsGeometry &ge
|
||||
//geom is already in the provider geometry type
|
||||
if ( geometry->wkbType() == providerGeomType )
|
||||
{
|
||||
return nullptr;
|
||||
return QgsGeometry();
|
||||
}
|
||||
|
||||
QgsAbstractGeometry *outputGeom = nullptr;
|
||||
@ -794,9 +794,9 @@ QgsGeometry *QgsVectorDataProvider::convertToProviderType( const QgsGeometry &ge
|
||||
|
||||
if ( outputGeom )
|
||||
{
|
||||
return new QgsGeometry( outputGeom );
|
||||
return QgsGeometry( outputGeom );
|
||||
}
|
||||
return nullptr;
|
||||
return QgsGeometry();
|
||||
}
|
||||
|
||||
void QgsVectorDataProvider::setNativeTypes( const QList<NativeType> &nativeTypes )
|
||||
|
@ -551,7 +551,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
|
||||
* Converts the geometry to the provider type if possible / necessary
|
||||
* \returns the converted geometry or nullptr if no conversion was necessary or possible
|
||||
*/
|
||||
QgsGeometry *convertToProviderType( const QgsGeometry &geom ) const SIP_FACTORY;
|
||||
QgsGeometry convertToProviderType( const QgsGeometry &geom ) const;
|
||||
|
||||
/**
|
||||
* Set the list of native types supported by this provider.
|
||||
|
@ -159,7 +159,7 @@ bool QgsVectorLayerDiagramProvider::prepare( const QgsRenderContext &context, QS
|
||||
}
|
||||
|
||||
|
||||
void QgsVectorLayerDiagramProvider::registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry )
|
||||
void QgsVectorLayerDiagramProvider::registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry )
|
||||
{
|
||||
QgsLabelFeature *label = registerDiagram( feature, context, obstacleGeometry );
|
||||
if ( label )
|
||||
@ -167,7 +167,7 @@ void QgsVectorLayerDiagramProvider::registerFeature( QgsFeature &feature, QgsRen
|
||||
}
|
||||
|
||||
|
||||
QgsLabelFeature *QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature &feat, QgsRenderContext &context, QgsGeometry *obstacleGeometry )
|
||||
QgsLabelFeature *QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature &feat, QgsRenderContext &context, const QgsGeometry &obstacleGeometry )
|
||||
{
|
||||
const QgsMapSettings &mapSettings = mEngine->mapSettings();
|
||||
|
||||
@ -209,9 +209,9 @@ QgsLabelFeature *QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature &fea
|
||||
|
||||
GEOSGeometry *geomCopy = nullptr;
|
||||
std::unique_ptr<QgsGeometry> scopedPreparedGeom;
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, mSettings.coordinateTransform(), &extentGeom ) )
|
||||
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, mSettings.coordinateTransform(), extentGeom ) )
|
||||
{
|
||||
scopedPreparedGeom.reset( new QgsGeometry( QgsPalLabeling::prepareGeometry( geom, context, mSettings.coordinateTransform(), &extentGeom ) ) );
|
||||
scopedPreparedGeom.reset( new QgsGeometry( QgsPalLabeling::prepareGeometry( geom, context, mSettings.coordinateTransform(), extentGeom ) ) );
|
||||
QgsGeometry *preparedGeom = scopedPreparedGeom.get();
|
||||
if ( preparedGeom->isNull() )
|
||||
return nullptr;
|
||||
@ -227,14 +227,14 @@ QgsLabelFeature *QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature &fea
|
||||
|
||||
GEOSGeometry *geosObstacleGeomClone = nullptr;
|
||||
std::unique_ptr<QgsGeometry> scopedObstacleGeom;
|
||||
if ( isObstacle && obstacleGeometry && QgsPalLabeling::geometryRequiresPreparation( *obstacleGeometry, context, mSettings.coordinateTransform(), &extentGeom ) )
|
||||
if ( isObstacle && obstacleGeometry && QgsPalLabeling::geometryRequiresPreparation( obstacleGeometry, context, mSettings.coordinateTransform(), extentGeom ) )
|
||||
{
|
||||
QgsGeometry preparedObstacleGeom = QgsPalLabeling::prepareGeometry( *obstacleGeometry, context, mSettings.coordinateTransform(), &extentGeom );
|
||||
QgsGeometry preparedObstacleGeom = QgsPalLabeling::prepareGeometry( obstacleGeometry, context, mSettings.coordinateTransform(), extentGeom );
|
||||
geosObstacleGeomClone = preparedObstacleGeom.exportToGeos();
|
||||
}
|
||||
else if ( mSettings.isObstacle() && obstacleGeometry )
|
||||
else if ( mSettings.isObstacle() && !obstacleGeometry.isNull() )
|
||||
{
|
||||
geosObstacleGeomClone = obstacleGeometry->exportToGeos();
|
||||
geosObstacleGeomClone = obstacleGeometry.exportToGeos();
|
||||
}
|
||||
|
||||
double diagramWidth = 0;
|
||||
|
@ -91,13 +91,13 @@ class CORE_EXPORT QgsVectorLayerDiagramProvider : public QgsAbstractLabelProvide
|
||||
* the feature's original geometry will be used as an obstacle for labels. Ownership of obstacleGeometry
|
||||
* is transferred.
|
||||
*/
|
||||
virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry = nullptr );
|
||||
virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
|
||||
|
||||
protected:
|
||||
//! initialization method - called from constructors
|
||||
void init();
|
||||
//! helper method to register one diagram feautre
|
||||
QgsLabelFeature *registerDiagram( QgsFeature &feat, QgsRenderContext &context, QgsGeometry *obstacleGeometry = nullptr );
|
||||
QgsLabelFeature *registerDiagram( QgsFeature &feat, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -226,14 +226,14 @@ QList<QgsLabelFeature *> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCo
|
||||
QgsFeature fet;
|
||||
while ( fit.nextFeature( fet ) )
|
||||
{
|
||||
std::unique_ptr<QgsGeometry> obstacleGeometry;
|
||||
QgsGeometry obstacleGeometry;
|
||||
if ( mRenderer )
|
||||
{
|
||||
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, ctx );
|
||||
if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
|
||||
{
|
||||
//point feature, use symbol bounds as obstacle
|
||||
obstacleGeometry.reset( QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, ctx, symbols ) );
|
||||
obstacleGeometry = QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, ctx, symbols );
|
||||
}
|
||||
if ( !symbols.isEmpty() )
|
||||
{
|
||||
@ -241,7 +241,7 @@ QList<QgsLabelFeature *> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCo
|
||||
}
|
||||
}
|
||||
ctx.expressionContext().setFeature( fet );
|
||||
registerFeature( fet, ctx, obstacleGeometry.get() );
|
||||
registerFeature( fet, ctx, obstacleGeometry );
|
||||
}
|
||||
|
||||
if ( ctx.expressionContext().lastScope() == symbolScope )
|
||||
@ -253,7 +253,7 @@ QList<QgsLabelFeature *> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCo
|
||||
return mLabels;
|
||||
}
|
||||
|
||||
void QgsVectorLayerLabelProvider::registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry )
|
||||
void QgsVectorLayerLabelProvider::registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry )
|
||||
{
|
||||
QgsLabelFeature *label = nullptr;
|
||||
mSettings.registerFeature( feature, context, &label, obstacleGeometry );
|
||||
@ -261,10 +261,10 @@ void QgsVectorLayerLabelProvider::registerFeature( QgsFeature &feature, QgsRende
|
||||
mLabels << label;
|
||||
}
|
||||
|
||||
QgsGeometry *QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols )
|
||||
QgsGeometry QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols )
|
||||
{
|
||||
if ( !fet.hasGeometry() || fet.geometry().type() != QgsWkbTypes::PointGeometry )
|
||||
return nullptr;
|
||||
return QgsGeometry();
|
||||
|
||||
bool isMultiPoint = fet.geometry().geometry()->nCoordinates() > 1;
|
||||
QgsAbstractGeometry *obstacleGeom = nullptr;
|
||||
@ -333,7 +333,7 @@ QgsGeometry *QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &
|
||||
}
|
||||
}
|
||||
|
||||
return new QgsGeometry( obstacleGeom );
|
||||
return QgsGeometry( obstacleGeom );
|
||||
}
|
||||
|
||||
void QgsVectorLayerLabelProvider::drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const
|
||||
|
@ -71,7 +71,7 @@ class CORE_EXPORT QgsVectorLayerLabelProvider : public QgsAbstractLabelProvider
|
||||
* symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set,
|
||||
* the feature's original geometry will be used as an obstacle for labels.
|
||||
*/
|
||||
virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry = nullptr );
|
||||
virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
|
||||
|
||||
/** Returns the geometry for a point feature which should be used as an obstacle for labels. This
|
||||
* obstacle geometry will respect the dimensions and offsets of the symbol used to render the
|
||||
@ -81,7 +81,7 @@ class CORE_EXPORT QgsVectorLayerLabelProvider : public QgsAbstractLabelProvider
|
||||
* \param symbols symbols rendered for point feature
|
||||
* \since QGIS 2.14
|
||||
*/
|
||||
static QgsGeometry *getPointObstacleGeometry( QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols );
|
||||
static QgsGeometry getPointObstacleGeometry( QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols );
|
||||
|
||||
protected:
|
||||
//! initialization method - called from constructors
|
||||
|
@ -294,12 +294,12 @@ void QgsVectorLayerRenderer::drawRenderer( QgsFeatureIterator &fit )
|
||||
// new labeling engine
|
||||
if ( mContext.labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
|
||||
{
|
||||
std::unique_ptr<QgsGeometry> obstacleGeometry;
|
||||
QgsGeometry obstacleGeometry;
|
||||
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, mContext );
|
||||
|
||||
if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
|
||||
{
|
||||
obstacleGeometry.reset( QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, mContext, symbols ) );
|
||||
obstacleGeometry = QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, mContext, symbols );
|
||||
}
|
||||
|
||||
if ( !symbols.isEmpty() )
|
||||
@ -309,11 +309,11 @@ void QgsVectorLayerRenderer::drawRenderer( QgsFeatureIterator &fit )
|
||||
|
||||
if ( mLabelProvider )
|
||||
{
|
||||
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
|
||||
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry );
|
||||
}
|
||||
if ( mDiagramProvider )
|
||||
{
|
||||
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
|
||||
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -378,12 +378,12 @@ void QgsVectorLayerRenderer::drawRendererLevels( QgsFeatureIterator &fit )
|
||||
// new labeling engine
|
||||
if ( mContext.labelingEngine() )
|
||||
{
|
||||
std::unique_ptr<QgsGeometry> obstacleGeometry;
|
||||
QgsGeometry obstacleGeometry;
|
||||
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, mContext );
|
||||
|
||||
if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
|
||||
{
|
||||
obstacleGeometry.reset( QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, mContext, symbols ) );
|
||||
obstacleGeometry = QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, mContext, symbols );
|
||||
}
|
||||
|
||||
if ( !symbols.isEmpty() )
|
||||
@ -393,11 +393,11 @@ void QgsVectorLayerRenderer::drawRendererLevels( QgsFeatureIterator &fit )
|
||||
|
||||
if ( mLabelProvider )
|
||||
{
|
||||
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
|
||||
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry );
|
||||
}
|
||||
if ( mDiagramProvider )
|
||||
{
|
||||
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
|
||||
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ void QgsMapToolCapture::validateGeometry()
|
||||
delete mGeomErrorMarkers.takeFirst();
|
||||
}
|
||||
|
||||
std::unique_ptr<QgsGeometry> g;
|
||||
QgsGeometry geom;
|
||||
|
||||
switch ( mCaptureMode )
|
||||
{
|
||||
@ -647,7 +647,7 @@ void QgsMapToolCapture::validateGeometry()
|
||||
case CaptureLine:
|
||||
if ( size() < 2 || ( mCaptureMode == CaptureSegment && size() > 2 ) )
|
||||
return;
|
||||
g.reset( new QgsGeometry( mCaptureCurve.curveToLine() ) );
|
||||
geom = QgsGeometry( mCaptureCurve.curveToLine() );
|
||||
break;
|
||||
case CapturePolygon:
|
||||
if ( size() < 3 )
|
||||
@ -656,17 +656,17 @@ void QgsMapToolCapture::validateGeometry()
|
||||
exteriorRing->close();
|
||||
QgsPolygonV2 *polygon = new QgsPolygonV2();
|
||||
polygon->setExteriorRing( exteriorRing );
|
||||
g.reset( new QgsGeometry( polygon ) );
|
||||
geom = QgsGeometry( polygon );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !g )
|
||||
if ( !geom )
|
||||
return;
|
||||
|
||||
QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal;
|
||||
if ( settings.value( QStringLiteral( "qgis/digitizing/validate_geometries" ), 1 ).toInt() == 2 )
|
||||
method = QgsGeometry::ValidatorGeos;
|
||||
mValidator = new QgsGeometryValidator( g.get(), nullptr, method );
|
||||
mValidator = new QgsGeometryValidator( geom, nullptr, method );
|
||||
connect( mValidator, &QgsGeometryValidator::errorFound, this, &QgsMapToolCapture::addError );
|
||||
connect( mValidator, &QThread::finished, this, &QgsMapToolCapture::validationFinished );
|
||||
mValidator->start();
|
||||
|
@ -2633,8 +2633,8 @@ void QgsPostgresProvider::appendGeomParam( const QgsGeometry &geom, QStringList
|
||||
|
||||
QString param;
|
||||
|
||||
std::unique_ptr<QgsGeometry> convertedGeom( convertToProviderType( geom ) );
|
||||
QByteArray wkb( convertedGeom ? convertedGeom->exportToWkb() : geom.exportToWkb() );
|
||||
QgsGeometry convertedGeom( convertToProviderType( geom ) );
|
||||
QByteArray wkb( convertedGeom ? convertedGeom.exportToWkb() : geom.exportToWkb() );
|
||||
const unsigned char *buf = reinterpret_cast< const unsigned char * >( wkb.constData() );
|
||||
int wkbSize = wkb.length();
|
||||
|
||||
|
@ -829,7 +829,7 @@ bool QgsWFSProvider::addFeatures( QgsFeatureList &flist )
|
||||
{
|
||||
the_geom.convertToMultiType();
|
||||
}
|
||||
QDomElement gmlElem = QgsOgcUtils::geometryToGML( &the_geom, transactionDoc );
|
||||
QDomElement gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc );
|
||||
if ( !gmlElem.isNull() )
|
||||
{
|
||||
gmlElem.setAttribute( QStringLiteral( "srsName" ), crs().authid() );
|
||||
@ -987,7 +987,7 @@ bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
|
||||
nameElem.appendChild( nameText );
|
||||
propertyElem.appendChild( nameElem );
|
||||
QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Value" ) );
|
||||
QDomElement gmlElem = QgsOgcUtils::geometryToGML( &geomIt.value(), transactionDoc );
|
||||
QDomElement gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc );
|
||||
gmlElem.setAttribute( QStringLiteral( "srsName" ), crs().authid() );
|
||||
valueElem.appendChild( gmlElem );
|
||||
propertyElem.appendChild( valueElem );
|
||||
|
@ -1064,12 +1064,12 @@ namespace QgsWfs
|
||||
if ( geometryName == QLatin1String( "EXTENT" ) )
|
||||
{
|
||||
QgsGeometry bbox = QgsGeometry::fromRect( geom.boundingBox() );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( &bbox, doc, prec );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( bbox, doc, prec );
|
||||
}
|
||||
else if ( geometryName == QLatin1String( "CENTROID" ) )
|
||||
{
|
||||
QgsGeometry centroid = geom.centroid();
|
||||
gmlElem = QgsOgcUtils::geometryToGML( ¢roid, doc, prec );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( centroid, doc, prec );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1146,12 +1146,12 @@ namespace QgsWfs
|
||||
if ( geometryName == QLatin1String( "EXTENT" ) )
|
||||
{
|
||||
QgsGeometry bbox = QgsGeometry::fromRect( geom.boundingBox() );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( &bbox, doc, QStringLiteral( "GML3" ), prec );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( bbox, doc, QStringLiteral( "GML3" ), prec );
|
||||
}
|
||||
else if ( geometryName == QLatin1String( "CENTROID" ) )
|
||||
{
|
||||
QgsGeometry centroid = geom.centroid();
|
||||
gmlElem = QgsOgcUtils::geometryToGML( ¢roid, doc, QStringLiteral( "GML3" ), prec );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( centroid, doc, QStringLiteral( "GML3" ), prec );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2673,11 +2673,11 @@ namespace QgsWms
|
||||
QDomElement gmlElem;
|
||||
if ( version < 3 )
|
||||
{
|
||||
gmlElem = QgsOgcUtils::geometryToGML( &geom, doc, 8 );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, 8 );
|
||||
}
|
||||
else
|
||||
{
|
||||
gmlElem = QgsOgcUtils::geometryToGML( &geom, doc, QStringLiteral( "GML3" ), 8 );
|
||||
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, QStringLiteral( "GML3" ), 8 );
|
||||
}
|
||||
|
||||
if ( !gmlElem.isNull() )
|
||||
|
@ -214,10 +214,10 @@ void TestQgsOgcUtils::testGeometryToGML()
|
||||
QDomElement ogcElem;
|
||||
|
||||
// Test GML2
|
||||
QDomElement elemInvalid = QgsOgcUtils::geometryToGML( 0, doc );
|
||||
QDomElement elemInvalid = QgsOgcUtils::geometryToGML( QgsGeometry(), doc );
|
||||
QVERIFY( elemInvalid.isNull() );
|
||||
|
||||
QDomElement elemPoint = QgsOgcUtils::geometryToGML( &geomPoint, doc );
|
||||
QDomElement elemPoint = QgsOgcUtils::geometryToGML( geomPoint, doc );
|
||||
QVERIFY( !elemPoint.isNull() );
|
||||
|
||||
doc.appendChild( elemPoint );
|
||||
@ -226,7 +226,7 @@ void TestQgsOgcUtils::testGeometryToGML()
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
doc.removeChild( elemPoint );
|
||||
|
||||
QDomElement elemLine = QgsOgcUtils::geometryToGML( &geomLine, doc );
|
||||
QDomElement elemLine = QgsOgcUtils::geometryToGML( geomLine, doc );
|
||||
QVERIFY( !elemLine.isNull() );
|
||||
|
||||
doc.appendChild( elemLine );
|
||||
@ -236,10 +236,10 @@ void TestQgsOgcUtils::testGeometryToGML()
|
||||
doc.removeChild( elemLine );
|
||||
|
||||
// Test GML3
|
||||
elemInvalid = QgsOgcUtils::geometryToGML( 0, doc, QStringLiteral( "GML3" ) );
|
||||
elemInvalid = QgsOgcUtils::geometryToGML( QgsGeometry(), doc, QStringLiteral( "GML3" ) );
|
||||
QVERIFY( elemInvalid.isNull() );
|
||||
|
||||
elemPoint = QgsOgcUtils::geometryToGML( &geomPoint, doc, QStringLiteral( "GML3" ) );
|
||||
elemPoint = QgsOgcUtils::geometryToGML( geomPoint, doc, QStringLiteral( "GML3" ) );
|
||||
QVERIFY( !elemPoint.isNull() );
|
||||
|
||||
doc.appendChild( elemPoint );
|
||||
@ -248,7 +248,7 @@ void TestQgsOgcUtils::testGeometryToGML()
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
doc.removeChild( elemPoint );
|
||||
|
||||
elemLine = QgsOgcUtils::geometryToGML( &geomLine, doc, QStringLiteral( "GML3" ) );
|
||||
elemLine = QgsOgcUtils::geometryToGML( geomLine, doc, QStringLiteral( "GML3" ) );
|
||||
QVERIFY( !elemLine.isNull() );
|
||||
|
||||
doc.appendChild( elemLine );
|
||||
|
Loading…
x
Reference in New Issue
Block a user