Skip to content
Permalink
Browse files
Removed ewkt conversion functions
  • Loading branch information
domi4484 committed Jan 10, 2022
1 parent d583bc0 commit d7a58c6cc30d1b84f7dd268986f1479429cc76e6
@@ -773,12 +773,12 @@
Qgis.TemporalIntervalMatchMethod.__doc__ = 'Method to use when resolving a temporal range to a data provider layer or band.\n\n.. versionadded:: 3.22\n\n' + '* ``MatchUsingWholeRange``: ' + Qgis.TemporalIntervalMatchMethod.MatchUsingWholeRange.__doc__ + '\n' + '* ``MatchExactUsingStartOfRange``: ' + Qgis.TemporalIntervalMatchMethod.MatchExactUsingStartOfRange.__doc__ + '\n' + '* ``MatchExactUsingEndOfRange``: ' + Qgis.TemporalIntervalMatchMethod.MatchExactUsingEndOfRange.__doc__ + '\n' + '* ``FindClosestMatchToStartOfRange``: ' + Qgis.TemporalIntervalMatchMethod.FindClosestMatchToStartOfRange.__doc__ + '\n' + '* ``FindClosestMatchToEndOfRange``: ' + Qgis.TemporalIntervalMatchMethod.FindClosestMatchToEndOfRange.__doc__
# --
Qgis.TemporalIntervalMatchMethod.baseClass = Qgis
QgsCoordinateTransform.TransformDirection = Qgis.TransformDirection
# monkey patching scoped based enum
QgsCoordinateTransform.ForwardTransform = Qgis.TransformDirection.Forward
QgsCoordinateTransform.ForwardTransform.is_monkey_patched = True
QgsCoordinateTransform.ForwardTransform.__doc__ = "Forward transform (from source to destination)"
QgsCoordinateTransform.ReverseTransform = Qgis.TransformDirection.Reverse
Qgis.CoordinateType.XY.__doc__ = "Coordinate defined by X and Y values"
Qgis.CoordinateType.Point.__doc__ = "Coordinate defined by a point"
Qgis.CoordinateType.__doc__ = 'Types of coordinate definitions\n\n.. versionadded:: 3.22\n\n' + '* ``XY``: ' + Qgis.CoordinateType.XY.__doc__ + '\n' + '* ``Point``: ' + Qgis.CoordinateType.Point.__doc__
# --
Qgis.CoordinateType.baseClass = Qgis
QgsCoordinateTransform.ReverseTransform.is_monkey_patched = True
QgsCoordinateTransform.ReverseTransform.__doc__ = "Reverse/inverse transform (from destination to source)"
Qgis.TransformDirection.__doc__ = 'Indicates the direction (forward or inverse) of a transform.\n\n.. versionadded:: 3.22\n\n' + '* ``ForwardTransform``: ' + Qgis.TransformDirection.Forward.__doc__ + '\n' + '* ``ReverseTransform``: ' + Qgis.TransformDirection.Reverse.__doc__

This file was deleted.

@@ -161,39 +161,14 @@ Construct a new QgsReferencedGeometry from referenced ``point``
static QgsReferencedGeometry fromReferencedRect( const QgsReferencedRectangle &rectangle );
%Docstring
Construct a new QgsReferencedGeometry from referenced ``rectangle``
%End

static QgsReferencedGeometry fromEwkt( const QString &ewkt );
%Docstring
Creates a new geometry from a EWKT string

.. note::

Assumes a string in the format SRID={EPSG Id};WKT

.. seealso:: :py:func:`asEwkt`

.. versionadded:: 3.22
%End

QString asEwkt( int precision = 17 ) const;
%Docstring
Exports the geometry to EWKT

:param precision: number of decimal places for coordinates

:return: the EWKT string in format SRID={EPSG Id};WKT

.. seealso:: :py:func:`fromEwkt`

.. versionadded:: 3.22
%End

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsReferencedGeometry: %1 (%2)>" ).arg( sipCpp->asWkt(), sipCpp->crs().authid() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};


@@ -20,9 +20,6 @@ Contains constants and enums relating to labeling.
%TypeHeaderCode
#include "qgslabeling.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

enum LinePlacementFlag
@@ -43,12 +40,6 @@ Contains constants and enums relating to labeling.
typedef QFlags<QgsLabeling::PolygonPlacementFlag> PolygonPlacementFlags;


enum class CoordinateType
{
XY,
Point
};

};

QFlags<QgsLabeling::LinePlacementFlag> operator|(QgsLabeling::LinePlacementFlag f1, QFlags<QgsLabeling::LinePlacementFlag> f2);
@@ -420,7 +420,7 @@ Set unit for rotation of labels.

int priority;

QgsLabeling::CoordinateType placementCoordinateType() const;
Qgis::CoordinateType placementCoordinateType() const;
%Docstring
Coordinates type for data defined placement.

@@ -429,7 +429,7 @@ Coordinates type for data defined placement.
.. versionadded:: 3.22
%End

void setPlacementCoordinateType( QgsLabeling::CoordinateType placementCoordinateType );
void setPlacementCoordinateType( Qgis::CoordinateType placementCoordinateType );
%Docstring
Set coordinates type for data defined placement.

@@ -554,10 +554,10 @@ The development version
FindClosestMatchToEndOfRange
};

enum class TransformDirection
{
Forward,
Reverse
enum class CoordinateType
{
XY,
Point
};

enum class MapSettingsFlag
@@ -714,15 +714,15 @@ bool QgsMapToolLabel::currentLabelDataDefinedPosition( double &x, bool &xSuccess
QgsAttributes attributes = f.attributes();
switch ( mCurrentLabel.settings.placementCoordinateType() )
{
case QgsLabeling::CoordinateType::XY:
case Qgis::CoordinateType::XY:
{
if ( !attributes.at( xCol ).isNull() )
x = attributes.at( xCol ).toDouble( &xSuccess );
if ( !attributes.at( yCol ).isNull() )
y = attributes.at( yCol ).toDouble( &ySuccess );
}
break;
case QgsLabeling::CoordinateType::Point:
case Qgis::CoordinateType::Point:
{
if ( !attributes.at( pointCol ).isNull() )
{
@@ -809,7 +809,7 @@ bool QgsMapToolLabel::changeCurrentLabelDataDefinedPosition( const QVariant &x,
{
switch ( mCurrentLabel.settings.placementCoordinateType() )
{
case QgsLabeling::CoordinateType::XY:
case Qgis::CoordinateType::XY:
{
QString xColName = dataDefinedColumnName( QgsPalLayerSettings::PositionX, mCurrentLabel.settings, mCurrentLabel.layer );
QString yColName = dataDefinedColumnName( QgsPalLayerSettings::PositionY, mCurrentLabel.settings, mCurrentLabel.layer );
@@ -821,7 +821,7 @@ bool QgsMapToolLabel::changeCurrentLabelDataDefinedPosition( const QVariant &x,
return false;
}
break;
case QgsLabeling::CoordinateType::Point:
case Qgis::CoordinateType::Point:
{
QString pointColName = dataDefinedColumnName( QgsPalLayerSettings::PositionPoint, mCurrentLabel.settings, mCurrentLabel.layer );
int pointCol = mCurrentLabel.layer->fields().lookupField( pointColName );
@@ -979,7 +979,7 @@ bool QgsMapToolLabel::labelMoveable( QgsVectorLayer *vlayer, const QgsPalLayerSe

switch ( mCurrentLabel.settings.placementCoordinateType() )
{
case QgsLabeling::CoordinateType::XY:
case Qgis::CoordinateType::XY:
{
QString xColName = dataDefinedColumnName( QgsPalLayerSettings::PositionX, settings, vlayer );
QString yColName = dataDefinedColumnName( QgsPalLayerSettings::PositionY, settings, vlayer );
@@ -989,7 +989,7 @@ bool QgsMapToolLabel::labelMoveable( QgsVectorLayer *vlayer, const QgsPalLayerSe
return false;
}
break;
case QgsLabeling::CoordinateType::Point:
case Qgis::CoordinateType::Point:
{
QString pointColName = dataDefinedColumnName( QgsPalLayerSettings::PositionPoint, settings, vlayer );
pointCol = vlayer->fields().lookupField( pointColName );
@@ -188,7 +188,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
{
switch ( mCurrentLabel.settings.placementCoordinateType() )
{
case QgsLabeling::CoordinateType::XY:
case Qgis::CoordinateType::XY:
{
mPalProperties.clear();
mPalProperties << QgsPalLayerSettings::PositionX;
@@ -214,7 +214,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
yCol = indexes[ QgsPalLayerSettings::PositionY ];
}
break;
case QgsLabeling::CoordinateType::Point:
case Qgis::CoordinateType::Point:
{
mPalProperties.clear();
mPalProperties << QgsPalLayerSettings::PositionPoint;
@@ -251,7 +251,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )

bool usesAuxFields = vlayer->fields().fieldOrigin( xCol ) == QgsFields::OriginJoin
&& vlayer->fields().fieldOrigin( yCol ) == QgsFields::OriginJoin;
if ( mCurrentLabel.settings.placementCoordinateType() == QgsLabeling::CoordinateType::Point
if ( mCurrentLabel.settings.placementCoordinateType() == Qgis::CoordinateType::Point
&& !mCurrentLabel.pos.isDiagram )
usesAuxFields = vlayer->fields().fieldOrigin( pointCol ) == QgsFields::OriginJoin;

@@ -366,7 +366,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )

bool success = false;
if ( !isCalloutMove
&& vlayer->labeling()->settings().placementCoordinateType() != QgsLabeling::CoordinateType::XY )
&& vlayer->labeling()->settings().placementCoordinateType() != Qgis::CoordinateType::XY )
{
success = changeCurrentLabelDataDefinedPosition( xPosNew, yPosNew );
}
@@ -17,8 +17,6 @@

#include "qgsreferencedgeometry.h"

#include <QRegularExpression>

QgsReferencedGeometryBase::QgsReferencedGeometryBase( const QgsCoordinateReferenceSystem &crs )
: mCrs( crs )
{}
@@ -67,33 +65,3 @@ QgsReferencedGeometry QgsReferencedGeometry::fromReferencedRect( const QgsRefere
{
return QgsReferencedGeometry( QgsGeometry::fromRect( rectangle ), rectangle.crs() );
}

QgsReferencedGeometry QgsReferencedGeometry::fromEwkt( const QString &ewkt )
{
Ewkt ewktinfo = parseEwkt( ewkt );

if ( ewktinfo.srid < 0 )
return QgsReferencedGeometry();

QgsGeometry geom = QgsGeometry::fromWkt( ewktinfo.wkt );
return QgsReferencedGeometry( geom, QgsCoordinateReferenceSystem::fromEpsgId( ewktinfo.srid ) );
}

QString QgsReferencedGeometry::asEwkt( int precision ) const
{
return QStringLiteral( "SRID=%1;%2" ).arg( crs().postgisSrid() ).arg( asWkt( precision ) );
}

QgsReferencedGeometry::Ewkt QgsReferencedGeometry::parseEwkt( const QString &ewkt )
{
thread_local const QRegularExpression regularExpressionSRID( "^SRID=(\\d+);" );

QRegularExpressionMatch regularExpressionMatch = regularExpressionSRID.match( ewkt );
if ( !regularExpressionMatch.hasMatch() )
return Ewkt();

Ewkt ewktStruct;
ewktStruct.wkt = ewkt.mid( regularExpressionMatch.captured( 0 ).size() );
ewktStruct.srid = regularExpressionMatch.captured( 1 ).toInt();
return ewktStruct;
}
@@ -183,36 +183,6 @@ class CORE_EXPORT QgsReferencedGeometry : public QgsGeometry, public QgsReferenc
*/
static QgsReferencedGeometry fromReferencedRect( const QgsReferencedRectangle &rectangle );

/**
* Creates a new geometry from a EWKT string
*
* \note Assumes a string in the format SRID={EPSG Id};WKT
*
* \see asEwkt()
* \since QGIS 3.22
*/
static QgsReferencedGeometry fromEwkt( const QString &ewkt );

/**
* Exports the geometry to EWKT
*
* \param precision number of decimal places for coordinates
* \returns the EWKT string in format SRID={EPSG Id};WKT
*
* \see fromEwkt()
* \since QGIS 3.22
*/
QString asEwkt( int precision = 17 ) const;

private:

struct Ewkt
{
QString wkt;
int srid = -1;
};
static Ewkt parseEwkt( const QString &ewkt );

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
@@ -18,7 +18,6 @@

#include "qgis_core.h"
#include "qgis_sip.h"
#include <QObject>
#include <QFlags>

/**
@@ -31,8 +30,6 @@
*/
class CORE_EXPORT QgsLabeling
{
Q_GADGET

public:

/**
@@ -59,18 +56,6 @@ class CORE_EXPORT QgsLabeling
};
Q_DECLARE_FLAGS( PolygonPlacementFlags, PolygonPlacementFlag )

/**
* Types of coordinate definitions
*
* \since QGIS 3.22
*/
enum class CoordinateType : int
{
XY, //!< Coordinate defined by X and Y values
Point //!< Coordinate defined by a point
};
Q_ENUM( CoordinateType )

};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabeling::LinePlacementFlags )
@@ -621,12 +621,12 @@ void QgsPalLayerSettings::setRotationUnit( QgsUnitTypes::AngleUnit angleUnit )
mRotationUnit = angleUnit;
}

QgsLabeling::CoordinateType QgsPalLayerSettings::placementCoordinateType() const
Qgis::CoordinateType QgsPalLayerSettings::placementCoordinateType() const
{
return mPlacementCoordinateType;
}

void QgsPalLayerSettings::setPlacementCoordinateType( QgsLabeling::CoordinateType placementCoordinateType )
void QgsPalLayerSettings::setPlacementCoordinateType( Qgis::CoordinateType placementCoordinateType )
{
mPlacementCoordinateType = placementCoordinateType;
}
@@ -854,7 +854,7 @@ void QgsPalLayerSettings::readFromLayerCustomProperties( QgsVectorLayer *layer )
{
repeatDistanceMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/repeatDistanceMapUnitScale" ) ).toString() );
}
mPlacementCoordinateType = layer->customEnumProperty( QStringLiteral( "labeling/placementCoordinateType" ), QgsLabeling::CoordinateType::XY );
mPlacementCoordinateType = layer->customEnumProperty( QStringLiteral( "labeling/placementCoordinateType" ), Qgis::CoordinateType::XY );

// rendering
double scalemn = layer->customProperty( QStringLiteral( "labeling/scaleMin" ), QVariant( 0 ) ).toDouble();
@@ -1105,7 +1105,7 @@ void QgsPalLayerSettings::readXml( const QDomElement &elem, const QgsReadWriteCo

layerType = qgsEnumKeyToValue( placementElem.attribute( QStringLiteral( "layerType" ) ), QgsWkbTypes::UnknownGeometry );

mPlacementCoordinateType = qgsEnumKeyToValue( placementElem.attribute( QStringLiteral( "coordinateType" ), qgsEnumValueToKey( QgsLabeling::CoordinateType::XY ) ), QgsLabeling::CoordinateType::XY );
mPlacementCoordinateType = qgsEnumKeyToValue( placementElem.attribute( QStringLiteral( "coordinateType" ), qgsEnumValueToKey( Qgis::CoordinateType::XY ) ), Qgis::CoordinateType::XY );

// rendering
QDomElement renderingElem = elem.firstChildElement( QStringLiteral( "rendering" ) );
@@ -2399,7 +2399,7 @@ std::unique_ptr<QgsLabelFeature> QgsPalLayerSettings::registerFeatureWithDetails
bool ddPosition = false;
switch ( mPlacementCoordinateType )
{
case QgsLabeling::CoordinateType::XY:
case Qgis::CoordinateType::XY:
{
if ( mDataDefinedProperties.isActive( QgsPalLayerSettings::PositionX )
&& mDataDefinedProperties.isActive( QgsPalLayerSettings::PositionY )
@@ -2416,7 +2416,7 @@ std::unique_ptr<QgsLabelFeature> QgsPalLayerSettings::registerFeatureWithDetails
}
}
break;
case QgsLabeling::CoordinateType::Point:
case Qgis::CoordinateType::Point:
{
if ( mDataDefinedProperties.isActive( QgsPalLayerSettings::PositionPoint )
&& !mDataDefinedProperties.value( QgsPalLayerSettings::PositionPoint, context.expressionContext() ).isNull() )
@@ -2431,12 +2431,7 @@ std::unique_ptr<QgsLabelFeature> QgsPalLayerSettings::registerFeatureWithDetails
}
else if ( !pointAsVariant.toString().isEmpty() )
{
if ( !point.fromWkt( pointAsVariant.toString() ) )
{
QgsReferencedGeometry referencedGeometryPoint = QgsReferencedGeometry::fromEwkt( pointAsVariant.toString() );
if ( !referencedGeometryPoint.isNull() )
point = QgsPoint( referencedGeometryPoint.asPoint() );
}
point.fromWkt( pointAsVariant.toString() );
}

if ( !point.isEmpty() )

0 comments on commit d7a58c6

Please sign in to comment.