Skip to content

Commit

Permalink
deprecate addTopologicalPoints methods with QgsPointXY
Browse files Browse the repository at this point in the history
deprecate other methods
  • Loading branch information
lbartoletti authored and nyalldawson committed Oct 3, 2019
1 parent 575ecff commit 2e529e1
Show file tree
Hide file tree
Showing 20 changed files with 360 additions and 116 deletions.
16 changes: 14 additions & 2 deletions python/core/auto_generated/geometry/qgsgeometry.sip.in
Expand Up @@ -16,7 +16,7 @@

typedef QVector<QgsPointXY> QgsPolylineXY;

typedef QVector<QgsPoint> QgsPolyline;
typedef QgsPointSequence QgsPolyline;

typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;

Expand Down Expand Up @@ -839,7 +839,19 @@ Rotate this geometry around the Z axis
:return: OperationResult a result code: success or reason of failure
%End

OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries /Out/, bool topological, QVector<QgsPointXY> &topologyTestPoints /Out/ );
OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries /Out/, bool topological, QgsPointSequence &topologyTestPoints /Out/ ) /Deprecated/;
%Docstring
Splits this geometry according to a given line.

:param splitLine: the line that splits the geometry
\param[out] newGeometries list of new geometries that have been created with the split
:param topological: ``True`` if topological editing is enabled
\param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset

:return: OperationResult a result code: success or reason of failure
%End

OperationResult splitGeometry( const QgsPointSequence &splitLine, QVector<QgsGeometry> &newGeometries /Out/, bool topological, QgsPointSequence &topologyTestPoints /Out/ );
%Docstring
Splits this geometry according to a given line.

Expand Down
109 changes: 105 additions & 4 deletions python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -1234,7 +1234,32 @@ Deletes the selected features
:return: ``True`` in case of success and ``False`` otherwise
%End

QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = 0 );
QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = 0 ) /Deprecated/;
%Docstring
Adds a ring to polygon/multipolygon features

:param ring: ring to add
:param featureId: if specified, feature ID for feature ring was added to will be stored in this parameter

:return: QgsGeometry.OperationResult
- Success
- LayerNotEditable
- AddRingNotInExistingFeature
- InvalidInputGeometryType
- AddRingNotClosed
- AddRingNotValid
- AddRingCrossesExistingRings

.. note::

Calls to addRing() are only valid for layers in which edits have been enabled
by a call to startEditing(). Changes made to features using this method are not committed
to the underlying data provider until a commitChanges() call is made. Any uncommitted
changes can be discarded by calling rollBack().
%End


QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, QgsFeatureId *featureId = 0 );
%Docstring
Adds a ring to polygon/multipolygon features

Expand Down Expand Up @@ -1300,6 +1325,32 @@ Adds a new part polygon to a multipart feature
- InvalidBaseGeometry
- InvalidInputGeometryType

.. note::

Calls to addPart() are only valid for layers in which edits have been enabled
by a call to startEditing(). Changes made to features using this method are not committed
to the underlying data provider until a commitChanges() call is made. Any uncommitted
changes can be discarded by calling rollBack().
%End

QgsGeometry::OperationResult addPart( const QVector<QgsPointXY> &ring ) /PyName=addPartV2,Deprecated/;
%Docstring
Adds a new part polygon to a multipart feature

:return: QgsGeometry.OperationResult
- Success
- LayerNotEditable
- SelectionIsEmpty
- SelectionIsGreaterThanOne
- AddPartSelectedGeometryNotFound
- AddPartNotMultiGeometry
- InvalidBaseGeometry
- InvalidInputGeometryType

.. note::

available in Python bindings as addPartV2

.. note::

Calls to addPart() are only valid for layers in which edits have been enabled
Expand Down Expand Up @@ -1367,7 +1418,31 @@ Translates feature by dx, dy
changes can be discarded by calling rollBack().
%End

QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) /Deprecated/;
%Docstring
Splits parts cut by the given line

:param splitLine: line that splits the layer features
:param topologicalEditing: ``True`` if topological editing is enabled

:return: QgsGeometry.OperationResult
- Success
- NothingHappened
- LayerNotEditable
- InvalidInputGeometryType
- InvalidBaseGeometry
- GeometryEngineError
- SplitCannotSplitPoint

.. note::

Calls to splitParts() are only valid for layers in which edits have been enabled
by a call to startEditing(). Changes made to features using this method are not committed
to the underlying data provider until a commitChanges() call is made. Any uncommitted
changes can be discarded by calling rollBack().
%End

QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
%Docstring
Splits parts cut by the given line

Expand All @@ -1391,7 +1466,31 @@ Splits parts cut by the given line
changes can be discarded by calling rollBack().
%End

QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) /Deprecated/;
%Docstring
Splits features cut by the given line

:param splitLine: line that splits the layer features
:param topologicalEditing: ``True`` if topological editing is enabled

:return: QgsGeometry.OperationResult
- Success
- NothingHappened
- LayerNotEditable
- InvalidInputGeometryType
- InvalidBaseGeometry
- GeometryEngineError
- SplitCannotSplitPoint

.. note::

Calls to splitFeatures() are only valid for layers in which edits have been enabled
by a call to startEditing(). Changes made to features using this method are not committed
to the underlying data provider until a commitChanges() call is made. Any uncommitted
changes can be discarded by calling rollBack().
%End

QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
%Docstring
Splits features cut by the given line

Expand Down Expand Up @@ -1435,7 +1534,7 @@ Adds topological points for every vertex of the geometry.
changes can be discarded by calling rollBack().
%End

int addTopologicalPoints( const QgsPointXY &p );
int addTopologicalPoints( const QgsPointXY &p ) /Deprecated/;
%Docstring
Adds a vertex to segments which intersect point ``p`` but don't
already have a vertex there. If a feature already has a vertex at position ``p``,
Expand All @@ -1452,6 +1551,8 @@ editing.
by a call to startEditing(). Changes made to features using this method are not committed
to the underlying data provider until a commitChanges() call is made. Any uncommitted
changes can be discarded by calling rollBack().

.. deprecated:: in QGIS 3.10 - will be removed in QGIS 4.0
%End

int addTopologicalPoints( const QgsPoint &p );
Expand Down
6 changes: 3 additions & 3 deletions python/core/auto_generated/qgsvectorlayereditutils.sip.in
Expand Up @@ -60,7 +60,7 @@ Deletes a vertex from a feature.
.. versionadded:: 2.14
%End

QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = 0 );
QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = 0 );
%Docstring
Adds a ring to polygon/multipolygon features

Expand Down Expand Up @@ -140,7 +140,7 @@ Translates feature by dx, dy
:return: 0 in case of success
%End

QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
%Docstring
Splits parts cut by the given line

Expand All @@ -156,7 +156,7 @@ Splits parts cut by the given line
- QgsGeometry.SplitCannotSplitPoint
%End

QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
%Docstring
Splits features cut by the given line

Expand Down
6 changes: 4 additions & 2 deletions python/gui/auto_generated/qgsmaptoolcapture.sip.in
Expand Up @@ -213,14 +213,16 @@ Number of points digitized
:return: Number of points
%End

QVector<QgsPointXY> points() const;
QgsPointSequence points() const;
%Docstring
List of digitized points

:return: List of points

.. versionadded:: 3.10
%End

void setPoints( const QVector<QgsPointXY> &pointList );
void setPoints( const QgsPointSequence &pointList );
%Docstring
Set the points on which to work

Expand Down
4 changes: 3 additions & 1 deletion python/gui/auto_generated/qgsmaptooledit.sip.in
Expand Up @@ -68,10 +68,12 @@ Returns the current vector layer of the map canvas or 0
InvalidLayer,
};

TopologicalResult addTopologicalPoints( const QVector<QgsPointXY> &vertices );
TopologicalResult addTopologicalPoints( const QVector<QgsPointXY> &vertices ) /Deprecated/;
%Docstring
Adds a list of ``vertices`` to other features to keep topology up to date, e.g. to neighbouring polygons.
The ``vertices`` list specifies a set of topological points to add, in the layer's coordinate reference system.

.. deprecated:: in QGIS 3.10 - will be removed in QGIS 4.0
%End

TopologicalResult addTopologicalPoints( const QVector<QgsPoint> &vertices );
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/processing/qgsalgorithmsplitwithlines.cpp
Expand Up @@ -178,7 +178,7 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
{
for ( const QgsGeometry &splitGeom : qgis::as_const( splittingLines ) )
{
QVector<QgsPointXY> splitterPList;
QgsPointSequence splitterPList;
QVector< QgsGeometry > outGeoms;

// use prepared geometries for faster intersection tests
Expand Down Expand Up @@ -207,14 +207,14 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
{
for ( const QgsPoint &pt : ring )
{
splitterPList << QgsPointXY( pt );
splitterPList << pt;
}
}
}
}

QVector< QgsGeometry > newGeometries;
QVector<QgsPointXY> topologyTestPoints;
QgsPointSequence topologyTestPoints;
QgsGeometry::OperationResult result = inGeom.splitGeometry( splitterPList, newGeometries, false, topologyTestPoints );

// splitGeometry: If there are several intersections
Expand Down
8 changes: 6 additions & 2 deletions src/app/qgsmaptoolfillring.cpp
Expand Up @@ -23,6 +23,7 @@
#include "qgisapp.h"
#include "qgsvectorlayerutils.h"
#include "qgsmapmouseevent.h"
#include "qgspolygon.h"

#include <limits>

Expand Down Expand Up @@ -88,7 +89,7 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

vlayer->beginEditCommand( tr( "Ring added and filled" ) );

QVector< QgsPointXY > pointList = points();
QgsPointSequence pointList = points();

QgsGeometry::OperationResult addRingReturnCode = vlayer->addRing( pointList, &fid );

Expand Down Expand Up @@ -127,7 +128,10 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
return;
}

g = QgsGeometry::fromPolygonXY( QgsPolygonXY() << pointList );
QgsLineString ext( pointList );
QgsPolygon polygon;
polygon.setExteriorRing( ext.clone() );
g = QgsGeometry( qgis::make_unique< QgsPolygon >( polygon ) );
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -814,6 +814,13 @@ QgsGeometry::OperationResult QgsGeometry::rotate( double rotation, const QgsPoin
}

QgsGeometry::OperationResult QgsGeometry::splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QVector<QgsPointXY> &topologyTestPoints )
{
QgsPointSequence split, topology;
convertPointList( splitLine, split );
convertPointList( topologyTestPoints, topology );
return splitGeometry( split, newGeometries, topological, topology );
}
QgsGeometry::OperationResult QgsGeometry::splitGeometry( const QgsPointSequence &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QgsPointSequence &topologyTestPoints )
{
if ( !d->geometry )
{
Expand All @@ -822,11 +829,10 @@ QgsGeometry::OperationResult QgsGeometry::splitGeometry( const QVector<QgsPointX

QVector<QgsGeometry > newGeoms;
QgsLineString splitLineString( splitLine );
QgsPointSequence tp;

QgsGeos geos( d->geometry.get() );
mLastError.clear();
QgsGeometryEngine::EngineOperationResult result = geos.splitGeometry( splitLineString, newGeoms, topological, tp, &mLastError );
QgsGeometryEngine::EngineOperationResult result = geos.splitGeometry( splitLineString, newGeoms, topological, topologyTestPoints, &mLastError );

if ( result == QgsGeometryEngine::Success )
{
Expand All @@ -835,8 +841,6 @@ QgsGeometry::OperationResult QgsGeometry::splitGeometry( const QVector<QgsPointX
newGeometries = newGeoms;
}

convertPointList( tp, topologyTestPoints );

switch ( result )
{
case QgsGeometryEngine::Success:
Expand Down
14 changes: 12 additions & 2 deletions src/core/geometry/qgsgeometry.h
Expand Up @@ -66,7 +66,7 @@ typedef QVector<QgsPointXY> QgsPolylineXY;
*
* \since QGIS 3.0
*/
typedef QVector<QgsPoint> QgsPolyline;
typedef QgsPointSequence QgsPolyline;

//! Polygon: first item of the list is outer ring, inner rings (if any) start from second item
#ifndef SIP_RUN
Expand Down Expand Up @@ -881,7 +881,17 @@ class CORE_EXPORT QgsGeometry
* \param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset
* \returns OperationResult a result code: success or reason of failure
*/
OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries SIP_OUT, bool topological, QVector<QgsPointXY> &topologyTestPoints SIP_OUT );
Q_DECL_DEPRECATED OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries SIP_OUT, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT ) SIP_DEPRECATED;

/**
* Splits this geometry according to a given line.
* \param splitLine the line that splits the geometry
* \param[out] newGeometries list of new geometries that have been created with the split
* \param topological TRUE if topological editing is enabled
* \param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset
* \returns OperationResult a result code: success or reason of failure
*/
OperationResult splitGeometry( const QgsPointSequence &splitLine, QVector<QgsGeometry> &newGeometries SIP_OUT, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT );

/**
* Replaces a part of this geometry with another line
Expand Down

0 comments on commit 2e529e1

Please sign in to comment.