mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Rename QgsGeometry::geometry as QgsGeometry::get()
Because feature.geometry().geometry() is confusing, and impossible to search for in python code (e.g. is input.geometry() a QgsGeometry or a QgsAbstractGeometry?) But more importantantly: also add a const version QgsGeometry::constGet(). The non-const version is slow, since it now forces a detach to avoid corrupting geometries (since QgsGeometry is shared, it's not safe to directly access its primitive QgsAbstractGeometry and start messing with it without first detaching). This is a big risk in the 2.x API which could potentially corrupt feature geometries with unexpected outcomes. Update all uses to constGet where possible.
This commit is contained in:
parent
a89dfde91b
commit
70361063d8
@ -269,7 +269,7 @@ class QgsAbstractGeometry
|
|||||||
:rtype: bool
|
:rtype: bool
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) = 0;
|
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const = 0;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns the vertices adjacent to a specified ``vertex`` within a geometry.
|
Returns the vertices adjacent to a specified ``vertex`` within a geometry.
|
||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
|
@ -102,7 +102,7 @@ class QgsCurve: QgsAbstractGeometry
|
|||||||
|
|
||||||
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;
|
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;
|
||||||
|
|
||||||
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
|
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;
|
||||||
|
|
||||||
virtual int vertexNumberFromVertexId( QgsVertexId id ) const;
|
virtual int vertexNumberFromVertexId( QgsVertexId id ) const;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ Adds an interior ring to the geometry (takes ownership)
|
|||||||
|
|
||||||
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;
|
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;
|
||||||
|
|
||||||
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
|
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;
|
||||||
|
|
||||||
virtual bool hasCurvedSegments() const;
|
virtual bool hasCurvedSegments() const;
|
||||||
|
|
||||||
|
@ -84,19 +84,50 @@ Copy constructor will prompt a deep copy of the object
|
|||||||
|
|
||||||
~QgsGeometry();
|
~QgsGeometry();
|
||||||
|
|
||||||
QgsAbstractGeometry *geometry() const;
|
const QgsAbstractGeometry *constGet() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns the underlying geometry store.
|
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
|
||||||
.. versionadded:: 2.10
|
|
||||||
.. seealso:: setGeometry
|
This is much faster then calling the non-const get() method.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
In QGIS 2.x this method was named geometry().
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
.. seealso:: primitive()
|
||||||
|
.. seealso:: set()
|
||||||
:rtype: QgsAbstractGeometry
|
:rtype: QgsAbstractGeometry
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setGeometry( QgsAbstractGeometry *geometry /Transfer/ );
|
QgsAbstractGeometry *get();
|
||||||
|
%Docstring
|
||||||
|
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
|
||||||
|
|
||||||
|
This method can be slow to call, as it may trigger a detachment of the geometry
|
||||||
|
and a deep copy. Where possible, use constGet() instead.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
In QGIS 2.x this method was named geometry().
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
.. seealso:: constGet()
|
||||||
|
.. seealso:: set()
|
||||||
|
:rtype: QgsAbstractGeometry
|
||||||
|
%End
|
||||||
|
|
||||||
|
void set( QgsAbstractGeometry *geometry /Transfer/ );
|
||||||
%Docstring
|
%Docstring
|
||||||
Sets the underlying geometry store. Ownership of geometry is transferred.
|
Sets the underlying geometry store. Ownership of geometry is transferred.
|
||||||
.. versionadded:: 2.10
|
|
||||||
.. seealso:: geometry
|
.. note::
|
||||||
|
|
||||||
|
In QGIS 2.x this method was named setGeometry().
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
.. seealso:: get()
|
||||||
|
.. seealso:: constGet()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
@ -53,7 +53,7 @@ class QgsGeometryCollection: QgsAbstractGeometry
|
|||||||
|
|
||||||
virtual QgsAbstractGeometry *boundary() const /Factory/;
|
virtual QgsAbstractGeometry *boundary() const /Factory/;
|
||||||
|
|
||||||
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
|
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;
|
||||||
|
|
||||||
virtual int vertexNumberFromVertexId( QgsVertexId id ) const;
|
virtual int vertexNumberFromVertexId( QgsVertexId id ) const;
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ class QgsPoint: QgsAbstractGeometry
|
|||||||
|
|
||||||
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;
|
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;
|
||||||
|
|
||||||
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
|
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;
|
||||||
|
|
||||||
|
|
||||||
virtual double vertexAngle( QgsVertexId vertex ) const;
|
virtual double vertexAngle( QgsVertexId vertex ) const;
|
||||||
|
@ -165,9 +165,9 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QgsMultiPolyline mpl;
|
QgsMultiPolyline mpl;
|
||||||
if ( QgsWkbTypes::flatType( feature.geometry().geometry()->wkbType() ) == QgsWkbTypes::MultiLineString )
|
if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::MultiLineString )
|
||||||
mpl = feature.geometry().asMultiPolyline();
|
mpl = feature.geometry().asMultiPolyline();
|
||||||
else if ( QgsWkbTypes::flatType( feature.geometry().geometry()->wkbType() ) == QgsWkbTypes::LineString )
|
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
|
||||||
mpl.push_back( feature.geometry().asPolyline() );
|
mpl.push_back( feature.geometry().asPolyline() );
|
||||||
|
|
||||||
QgsMultiPolyline::iterator mplIt;
|
QgsMultiPolyline::iterator mplIt;
|
||||||
@ -308,9 +308,9 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
|
|||||||
|
|
||||||
// begin features segments and add arc to the Graph;
|
// begin features segments and add arc to the Graph;
|
||||||
QgsMultiPolyline mpl;
|
QgsMultiPolyline mpl;
|
||||||
if ( QgsWkbTypes::flatType( feature.geometry().geometry()->wkbType() ) == QgsWkbTypes::MultiLineString )
|
if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::MultiLineString )
|
||||||
mpl = feature.geometry().asMultiPolyline();
|
mpl = feature.geometry().asMultiPolyline();
|
||||||
else if ( QgsWkbTypes::flatType( feature.geometry().geometry()->wkbType() ) == QgsWkbTypes::LineString )
|
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
|
||||||
mpl.push_back( feature.geometry().asPolyline() );
|
mpl.push_back( feature.geometry().asPolyline() );
|
||||||
|
|
||||||
QgsMultiPolyline::iterator mplIt;
|
QgsMultiPolyline::iterator mplIt;
|
||||||
|
@ -97,7 +97,7 @@ QgsFeature QgsBoundaryAlgorithm::processFeature( const QgsFeature &feature, QgsP
|
|||||||
if ( feature.hasGeometry() )
|
if ( feature.hasGeometry() )
|
||||||
{
|
{
|
||||||
QgsGeometry inputGeometry = feature.geometry();
|
QgsGeometry inputGeometry = feature.geometry();
|
||||||
QgsGeometry outputGeometry = QgsGeometry( inputGeometry.geometry()->boundary() );
|
QgsGeometry outputGeometry = QgsGeometry( inputGeometry.constGet()->boundary() );
|
||||||
if ( !outputGeometry )
|
if ( !outputGeometry )
|
||||||
{
|
{
|
||||||
feedback->reportError( QObject::tr( "No boundary for feature %1 (possibly a closed linestring?)'" ).arg( feature.id() ) );
|
feedback->reportError( QObject::tr( "No boundary for feature %1 (possibly a closed linestring?)'" ).arg( feature.id() ) );
|
||||||
|
@ -109,7 +109,7 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap ¶meters, Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use prepared geometries for faster intersection tests
|
// use prepared geometries for faster intersection tests
|
||||||
std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( combinedClipGeom.geometry() ) );
|
std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( combinedClipGeom.constGet() ) );
|
||||||
engine->prepareGeometry();
|
engine->prepareGeometry();
|
||||||
|
|
||||||
QgsFeatureIds testedFeatureIds;
|
QgsFeatureIds testedFeatureIds;
|
||||||
@ -154,15 +154,15 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap ¶meters, Q
|
|||||||
}
|
}
|
||||||
testedFeatureIds.insert( inputFeature.id() );
|
testedFeatureIds.insert( inputFeature.id() );
|
||||||
|
|
||||||
if ( !engine->intersects( inputFeature.geometry().geometry() ) )
|
if ( !engine->intersects( inputFeature.geometry().constGet() ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QgsGeometry newGeometry;
|
QgsGeometry newGeometry;
|
||||||
if ( !engine->contains( inputFeature.geometry().geometry() ) )
|
if ( !engine->contains( inputFeature.geometry().constGet() ) )
|
||||||
{
|
{
|
||||||
QgsGeometry currentGeometry = inputFeature.geometry();
|
QgsGeometry currentGeometry = inputFeature.geometry();
|
||||||
newGeometry = combinedClipGeom.intersection( currentGeometry );
|
newGeometry = combinedClipGeom.intersection( currentGeometry );
|
||||||
if ( newGeometry.wkbType() == QgsWkbTypes::Unknown || QgsWkbTypes::flatType( newGeometry.geometry()->wkbType() ) == QgsWkbTypes::GeometryCollection )
|
if ( newGeometry.wkbType() == QgsWkbTypes::Unknown || QgsWkbTypes::flatType( newGeometry.wkbType() ) == QgsWkbTypes::GeometryCollection )
|
||||||
{
|
{
|
||||||
QgsGeometry intCom = inputFeature.geometry().combine( newGeometry );
|
QgsGeometry intCom = inputFeature.geometry().combine( newGeometry );
|
||||||
QgsGeometry intSym = inputFeature.geometry().symDifference( newGeometry );
|
QgsGeometry intSym = inputFeature.geometry().symDifference( newGeometry );
|
||||||
|
@ -76,8 +76,8 @@ QgsFeature QgsConvexHullAlgorithm::processFeature( const QgsFeature &feature, Qg
|
|||||||
if ( outputGeometry )
|
if ( outputGeometry )
|
||||||
{
|
{
|
||||||
QgsAttributes attrs = f.attributes();
|
QgsAttributes attrs = f.attributes();
|
||||||
attrs << outputGeometry.geometry()->area()
|
attrs << outputGeometry.constGet()->area()
|
||||||
<< outputGeometry.geometry()->perimeter();
|
<< outputGeometry.constGet()->perimeter();
|
||||||
f.setAttributes( attrs );
|
f.setAttributes( attrs );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ QgsFeature QgsDropMZValuesAlgorithm::processFeature( const QgsFeature &feature,
|
|||||||
QgsFeature f = feature;
|
QgsFeature f = feature;
|
||||||
if ( f.hasGeometry() )
|
if ( f.hasGeometry() )
|
||||||
{
|
{
|
||||||
std::unique_ptr< QgsAbstractGeometry > newGeom( f.geometry().geometry()->clone() );
|
std::unique_ptr< QgsAbstractGeometry > newGeom( f.geometry().constGet()->clone() );
|
||||||
if ( mDropM )
|
if ( mDropM )
|
||||||
newGeom->dropMValue();
|
newGeom->dropMValue();
|
||||||
if ( mDropZ )
|
if ( mDropZ )
|
||||||
|
@ -136,7 +136,7 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,
|
|||||||
|
|
||||||
if ( !engine )
|
if ( !engine )
|
||||||
{
|
{
|
||||||
engine.reset( QgsGeometry::createGeometryEngine( f.geometry().geometry() ) );
|
engine.reset( QgsGeometry::createGeometryEngine( f.geometry().constGet() ) );
|
||||||
engine->prepareGeometry();
|
engine->prepareGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,31 +146,31 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,
|
|||||||
switch ( predicate )
|
switch ( predicate )
|
||||||
{
|
{
|
||||||
case Intersects:
|
case Intersects:
|
||||||
isMatch = engine->intersects( testFeature.geometry().geometry() );
|
isMatch = engine->intersects( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
case Contains:
|
case Contains:
|
||||||
isMatch = engine->contains( testFeature.geometry().geometry() );
|
isMatch = engine->contains( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
case Disjoint:
|
case Disjoint:
|
||||||
if ( engine->intersects( testFeature.geometry().geometry() ) )
|
if ( engine->intersects( testFeature.geometry().constGet() ) )
|
||||||
{
|
{
|
||||||
disjointSet.remove( testFeature.id() );
|
disjointSet.remove( testFeature.id() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IsEqual:
|
case IsEqual:
|
||||||
isMatch = engine->isEqual( testFeature.geometry().geometry() );
|
isMatch = engine->isEqual( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
case Touches:
|
case Touches:
|
||||||
isMatch = engine->touches( testFeature.geometry().geometry() );
|
isMatch = engine->touches( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
case Overlaps:
|
case Overlaps:
|
||||||
isMatch = engine->overlaps( testFeature.geometry().geometry() );
|
isMatch = engine->overlaps( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
case Within:
|
case Within:
|
||||||
isMatch = engine->within( testFeature.geometry().geometry() );
|
isMatch = engine->within( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
case Crosses:
|
case Crosses:
|
||||||
isMatch = engine->crosses( testFeature.geometry().geometry() );
|
isMatch = engine->crosses( testFeature.geometry().constGet() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( isMatch )
|
if ( isMatch )
|
||||||
|
@ -83,7 +83,7 @@ QgsFeature QgsFixGeometriesAlgorithm::processFeature( const QgsFeature &feature,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( outputGeometry.wkbType() == QgsWkbTypes::Unknown ||
|
if ( outputGeometry.wkbType() == QgsWkbTypes::Unknown ||
|
||||||
QgsWkbTypes::flatType( outputGeometry.geometry()->wkbType() ) == QgsWkbTypes::GeometryCollection )
|
QgsWkbTypes::flatType( outputGeometry.wkbType() ) == QgsWkbTypes::GeometryCollection )
|
||||||
{
|
{
|
||||||
// keep only the parts of the geometry collection with correct type
|
// keep only the parts of the geometry collection with correct type
|
||||||
const QList< QgsGeometry > tmpGeometries = outputGeometry.asGeometryCollection();
|
const QList< QgsGeometry > tmpGeometries = outputGeometry.asGeometryCollection();
|
||||||
|
@ -177,9 +177,9 @@ QVariantMap QgsJoinWithLinesAlgorithm::processAlgorithm( const QVariantMap ¶
|
|||||||
{
|
{
|
||||||
QgsPoint p;
|
QgsPoint p;
|
||||||
if ( feature.geometry().type() == QgsWkbTypes::PointGeometry && !feature.geometry().isMultipart() )
|
if ( feature.geometry().type() == QgsWkbTypes::PointGeometry && !feature.geometry().isMultipart() )
|
||||||
p = *static_cast< QgsPoint *>( feature.geometry().geometry() );
|
p = *static_cast< const QgsPoint *>( feature.geometry().constGet() );
|
||||||
else
|
else
|
||||||
p = *static_cast< QgsPoint *>( feature.geometry().pointOnSurface().geometry() );
|
p = *static_cast< const QgsPoint *>( feature.geometry().pointOnSurface().constGet() );
|
||||||
if ( hasZ && !p.is3D() )
|
if ( hasZ && !p.is3D() )
|
||||||
p.addZValue( 0 );
|
p.addZValue( 0 );
|
||||||
if ( hasM && !p.isMeasure() )
|
if ( hasM && !p.isMeasure() )
|
||||||
|
@ -161,7 +161,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p
|
|||||||
if ( !lines.empty() )
|
if ( !lines.empty() )
|
||||||
{
|
{
|
||||||
// use prepared geometries for faster intersection tests
|
// use prepared geometries for faster intersection tests
|
||||||
std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( inGeom.geometry() ) );
|
std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( inGeom.constGet() ) );
|
||||||
engine->prepareGeometry();
|
engine->prepareGeometry();
|
||||||
|
|
||||||
QgsFeatureRequest request = QgsFeatureRequest().setFilterFids( lines );
|
QgsFeatureRequest request = QgsFeatureRequest().setFilterFids( lines );
|
||||||
@ -178,7 +178,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p
|
|||||||
}
|
}
|
||||||
|
|
||||||
QgsGeometry tmpGeom = inFeatureB.geometry();
|
QgsGeometry tmpGeom = inFeatureB.geometry();
|
||||||
if ( engine->intersects( tmpGeom.geometry() ) )
|
if ( engine->intersects( tmpGeom.constGet() ) )
|
||||||
{
|
{
|
||||||
QgsMultiPoint points;
|
QgsMultiPoint points;
|
||||||
QgsGeometry intersectGeom = inGeom.intersection( tmpGeom );
|
QgsGeometry intersectGeom = inGeom.intersection( tmpGeom );
|
||||||
|
@ -164,7 +164,7 @@ QVariantMap QgsMeanCoordinatesAlgorithm::processAlgorithm( const QVariantMap &pa
|
|||||||
|
|
||||||
QgsVertexId vid;
|
QgsVertexId vid;
|
||||||
QgsPoint pt;
|
QgsPoint pt;
|
||||||
const QgsAbstractGeometry *g = feat.geometry().geometry();
|
const QgsAbstractGeometry *g = feat.geometry().constGet();
|
||||||
// NOTE - should this be including the duplicate nodes for closed rings? currently it is,
|
// NOTE - should this be including the duplicate nodes for closed rings? currently it is,
|
||||||
// but I suspect that the expected behavior would be to NOT include these
|
// but I suspect that the expected behavior would be to NOT include these
|
||||||
while ( g->nextVertex( vid, pt ) )
|
while ( g->nextVertex( vid, pt ) )
|
||||||
|
@ -140,11 +140,11 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
|
|||||||
QgsGeometry splitGeom = splitGeoms.value( line );
|
QgsGeometry splitGeom = splitGeoms.value( line );
|
||||||
if ( !engine )
|
if ( !engine )
|
||||||
{
|
{
|
||||||
engine.reset( QgsGeometry::createGeometryEngine( inGeom.geometry() ) );
|
engine.reset( QgsGeometry::createGeometryEngine( inGeom.constGet() ) );
|
||||||
engine->prepareGeometry();
|
engine->prepareGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( engine->intersects( splitGeom.geometry() ) )
|
if ( engine->intersects( splitGeom.constGet() ) )
|
||||||
{
|
{
|
||||||
QList< QgsGeometry > splitGeomParts = splitGeom.asGeometryCollection();
|
QList< QgsGeometry > splitGeomParts = splitGeom.asGeometryCollection();
|
||||||
splittingLines.append( splitGeomParts );
|
splittingLines.append( splitGeomParts );
|
||||||
@ -159,7 +159,7 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
|
|||||||
QList< QgsGeometry > outGeoms;
|
QList< QgsGeometry > outGeoms;
|
||||||
|
|
||||||
// use prepared geometries for faster intersection tests
|
// use prepared geometries for faster intersection tests
|
||||||
std::unique_ptr< QgsGeometryEngine > splitGeomEngine( QgsGeometry::createGeometryEngine( splitGeom.geometry() ) );
|
std::unique_ptr< QgsGeometryEngine > splitGeomEngine( QgsGeometry::createGeometryEngine( splitGeom.constGet() ) );
|
||||||
splitGeomEngine->prepareGeometry();
|
splitGeomEngine->prepareGeometry();
|
||||||
while ( !inGeoms.empty() )
|
while ( !inGeoms.empty() )
|
||||||
{
|
{
|
||||||
@ -172,12 +172,12 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
|
|||||||
if ( !inGeom )
|
if ( !inGeom )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( splitGeomEngine->intersects( inGeom.geometry() ) )
|
if ( splitGeomEngine->intersects( inGeom.constGet() ) )
|
||||||
{
|
{
|
||||||
QgsGeometry before = inGeom;
|
QgsGeometry before = inGeom;
|
||||||
if ( splitterPList.empty() )
|
if ( splitterPList.empty() )
|
||||||
{
|
{
|
||||||
const QgsCoordinateSequence sequence = splitGeom.geometry()->coordinateSequence();
|
const QgsCoordinateSequence sequence = splitGeom.constGet()->coordinateSequence();
|
||||||
for ( const QgsRingSequence &part : sequence )
|
for ( const QgsRingSequence &part : sequence )
|
||||||
{
|
{
|
||||||
for ( const QgsPointSequence &ring : part )
|
for ( const QgsPointSequence &ring : part )
|
||||||
@ -237,12 +237,12 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
|
|||||||
bool passed = true;
|
bool passed = true;
|
||||||
if ( QgsWkbTypes::geometryType( aGeom.wkbType() ) == QgsWkbTypes::LineGeometry )
|
if ( QgsWkbTypes::geometryType( aGeom.wkbType() ) == QgsWkbTypes::LineGeometry )
|
||||||
{
|
{
|
||||||
int numPoints = aGeom.geometry()->nCoordinates();
|
int numPoints = aGeom.constGet()->nCoordinates();
|
||||||
|
|
||||||
if ( numPoints <= 2 )
|
if ( numPoints <= 2 )
|
||||||
{
|
{
|
||||||
if ( numPoints == 2 )
|
if ( numPoints == 2 )
|
||||||
passed = !static_cast< QgsCurve * >( aGeom.geometry() )->isClosed(); // tests if vertex 0 = vertex 1
|
passed = !static_cast< const QgsCurve * >( aGeom.constGet() )->isClosed(); // tests if vertex 0 = vertex 1
|
||||||
else
|
else
|
||||||
passed = false; // sometimes splitting results in lines of zero length
|
passed = false; // sometimes splitting results in lines of zero length
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ QVariantMap QgsTransectAlgorithm::processAlgorithm( const QVariantMap ¶meter
|
|||||||
QgsGeometry inputGeometry = feat.geometry();
|
QgsGeometry inputGeometry = feat.geometry();
|
||||||
|
|
||||||
inputGeometry.convertToMultiType();
|
inputGeometry.convertToMultiType();
|
||||||
const QgsMultiLineString *multiLine = static_cast< QgsMultiLineString * >( inputGeometry.geometry() );
|
const QgsMultiLineString *multiLine = static_cast< const QgsMultiLineString * >( inputGeometry.constGet() );
|
||||||
for ( int id = 0; id < multiLine->numGeometries(); ++id )
|
for ( int id = 0; id < multiLine->numGeometries(); ++id )
|
||||||
{
|
{
|
||||||
const QgsLineString *line = static_cast< const QgsLineString * >( multiLine->geometryN( id ) );
|
const QgsLineString *line = static_cast< const QgsLineString * >( multiLine->geometryN( id ) );
|
||||||
|
@ -109,7 +109,7 @@ void QgsFeaturePool::updateFeature( QgsFeature &feature )
|
|||||||
get( feature.id(), origFeature );
|
get( feature.id(), origFeature );
|
||||||
|
|
||||||
QgsGeometryMap geometryMap;
|
QgsGeometryMap geometryMap;
|
||||||
geometryMap.insert( feature.id(), QgsGeometry( feature.geometry().geometry()->clone() ) );
|
geometryMap.insert( feature.id(), QgsGeometry( feature.geometry().constGet()->clone() ) );
|
||||||
QgsChangedAttributesMap changedAttributesMap;
|
QgsChangedAttributesMap changedAttributesMap;
|
||||||
QgsAttributeMap attribMap;
|
QgsAttributeMap attribMap;
|
||||||
for ( int i = 0, n = feature.attributes().size(); i < n; ++i )
|
for ( int i = 0, n = feature.attributes().size(); i < n; ++i )
|
||||||
|
@ -73,7 +73,7 @@ void QgsGeometryAngleCheck::fixError( QgsGeometryCheckError *error, int method,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeometry = feature.geometry();
|
QgsGeometry featureGeometry = feature.geometry();
|
||||||
QgsAbstractGeometry *geometry = featureGeometry.geometry();
|
QgsAbstractGeometry *geometry = featureGeometry.get();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if point still exists
|
// Check if point still exists
|
||||||
|
@ -49,7 +49,7 @@ void QgsGeometryAreaCheck::fixError( QgsGeometryCheckError *error, int method, c
|
|||||||
}
|
}
|
||||||
double layerToMapUnits = featurePool->getLayerToMapUnits();
|
double layerToMapUnits = featurePool->getLayerToMapUnits();
|
||||||
QgsGeometry g = feature.geometry();
|
QgsGeometry g = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = g.geometry();
|
const QgsAbstractGeometry *geom = g.constGet();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if polygon still exists
|
// Check if polygon still exists
|
||||||
@ -111,7 +111,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
|
|||||||
int mergePartIdx = -1;
|
int mergePartIdx = -1;
|
||||||
bool matchFound = false;
|
bool matchFound = false;
|
||||||
QgsGeometry featureGeometry = feature.geometry();
|
QgsGeometry featureGeometry = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeometry.geometry();
|
const QgsAbstractGeometry *geom = featureGeometry.constGet();
|
||||||
|
|
||||||
// Search for touching neighboring geometries
|
// Search for touching neighboring geometries
|
||||||
for ( QgsFeatureId testId : featurePool->getIntersects( featureGeometry.boundingBox() ) )
|
for ( QgsFeatureId testId : featurePool->getIntersects( featureGeometry.boundingBox() ) )
|
||||||
@ -122,7 +122,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QgsGeometry testFeatureGeom = testFeature.geometry();
|
QgsGeometry testFeatureGeom = testFeature.geometry();
|
||||||
QgsAbstractGeometry *testGeom = testFeatureGeom.geometry();
|
const QgsAbstractGeometry *testGeom = testFeatureGeom.constGet();
|
||||||
for ( int testPartIdx = 0, nTestParts = testGeom->partCount(); testPartIdx < nTestParts; ++testPartIdx )
|
for ( int testPartIdx = 0, nTestParts = testGeom->partCount(); testPartIdx < nTestParts; ++testPartIdx )
|
||||||
{
|
{
|
||||||
if ( testId == feature.id() && testPartIdx == partIdx )
|
if ( testId == feature.id() && testPartIdx == partIdx )
|
||||||
@ -141,8 +141,8 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( dynamic_cast<QgsGeometryCollection *>( testGeom ) )
|
if ( dynamic_cast<const QgsGeometryCollection *>( testGeom ) )
|
||||||
val = static_cast<QgsGeometryCollection *>( testGeom )->geometryN( testPartIdx )->area();
|
val = static_cast<const QgsGeometryCollection *>( testGeom )->geometryN( testPartIdx )->area();
|
||||||
else
|
else
|
||||||
val = testGeom->area();
|
val = testGeom->area();
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
|
|||||||
|
|
||||||
// Merge geometries
|
// Merge geometries
|
||||||
QgsGeometry mergeFeatureGeom = mergeFeature.geometry();
|
QgsGeometry mergeFeatureGeom = mergeFeature.geometry();
|
||||||
QgsAbstractGeometry *mergeGeom = mergeFeatureGeom.geometry();
|
const QgsAbstractGeometry *mergeGeom = mergeFeatureGeom.constGet();
|
||||||
QSharedPointer<QgsGeometryEngine> geomEngine = QgsGeometryCheckerUtils::createGeomEngine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), mContext->reducedTolerance );
|
QSharedPointer<QgsGeometryEngine> geomEngine = QgsGeometryCheckerUtils::createGeomEngine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), mContext->reducedTolerance );
|
||||||
QgsAbstractGeometry *combinedGeom = geomEngine->combine( QgsGeometryCheckerUtils::getGeomPart( geom, partIdx ), &errMsg );
|
QgsAbstractGeometry *combinedGeom = geomEngine->combine( QgsGeometryCheckerUtils::getGeomPart( geom, partIdx ), &errMsg );
|
||||||
if ( !combinedGeom || combinedGeom->isEmpty() || !QgsWkbTypes::isSingleType( combinedGeom->wkbType() ) )
|
if ( !combinedGeom || combinedGeom->isEmpty() || !QgsWkbTypes::isSingleType( combinedGeom->wkbType() ) )
|
||||||
|
@ -157,10 +157,9 @@ void QgsGeometryCheck::replaceFeatureGeometryPart( const QString &layerId, QgsFe
|
|||||||
{
|
{
|
||||||
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
QgsAbstractGeometry *geom = featureGeom.get();
|
||||||
if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
|
if ( QgsGeometryCollection *geomCollection = dynamic_cast< QgsGeometryCollection *>( geom ) )
|
||||||
{
|
{
|
||||||
QgsGeometryCollection *geomCollection = static_cast<QgsGeometryCollection *>( geom );
|
|
||||||
geomCollection->removeGeometry( partIdx );
|
geomCollection->removeGeometry( partIdx );
|
||||||
geomCollection->addGeometry( newPartGeom );
|
geomCollection->addGeometry( newPartGeom );
|
||||||
changes[layerId][feature.id()].append( Change( ChangePart, ChangeRemoved, QgsVertexId( partIdx ) ) );
|
changes[layerId][feature.id()].append( Change( ChangePart, ChangeRemoved, QgsVertexId( partIdx ) ) );
|
||||||
@ -179,7 +178,7 @@ void QgsGeometryCheck::deleteFeatureGeometryPart( const QString &layerId, QgsFea
|
|||||||
{
|
{
|
||||||
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
QgsAbstractGeometry *geom = featureGeom.get();
|
||||||
if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
|
if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
|
||||||
{
|
{
|
||||||
static_cast<QgsGeometryCollection *>( geom )->removeGeometry( partIdx );
|
static_cast<QgsGeometryCollection *>( geom )->removeGeometry( partIdx );
|
||||||
@ -206,7 +205,7 @@ void QgsGeometryCheck::deleteFeatureGeometryRing( const QString &layerId, QgsFea
|
|||||||
{
|
{
|
||||||
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *partGeom = QgsGeometryCheckerUtils::getGeomPart( featureGeom.geometry(), partIdx );
|
QgsAbstractGeometry *partGeom = QgsGeometryCheckerUtils::getGeomPart( featureGeom.get(), partIdx );
|
||||||
if ( dynamic_cast<QgsCurvePolygon *>( partGeom ) )
|
if ( dynamic_cast<QgsCurvePolygon *>( partGeom ) )
|
||||||
{
|
{
|
||||||
// If we delete the exterior ring of a polygon, it makes no sense to keep the interiors
|
// If we delete the exterior ring of a polygon, it makes no sense to keep the interiors
|
||||||
|
@ -31,7 +31,7 @@ namespace QgsGeometryCheckerUtils
|
|||||||
, mFeature( feature )
|
, mFeature( feature )
|
||||||
, mMapCrs( useMapCrs )
|
, mMapCrs( useMapCrs )
|
||||||
{
|
{
|
||||||
mGeometry = feature.geometry().geometry()->clone();
|
mGeometry = feature.geometry().constGet()->clone();
|
||||||
if ( useMapCrs && !mFeaturePool->getLayerToMapTransform().isShortCircuited() )
|
if ( useMapCrs && !mFeaturePool->getLayerToMapTransform().isShortCircuited() )
|
||||||
{
|
{
|
||||||
mGeometry->transform( mFeaturePool->getLayerToMapTransform() );
|
mGeometry->transform( mFeaturePool->getLayerToMapTransform() );
|
||||||
@ -124,7 +124,7 @@ namespace QgsGeometryCheckerUtils
|
|||||||
if ( mParent->mProgressCounter )
|
if ( mParent->mProgressCounter )
|
||||||
mParent->mProgressCounter->fetchAndAddRelaxed( 1 );
|
mParent->mProgressCounter->fetchAndAddRelaxed( 1 );
|
||||||
QgsFeature feature;
|
QgsFeature feature;
|
||||||
if ( featurePool->get( *mFeatureIt, feature ) && feature.geometry() && feature.geometry().geometry() )
|
if ( featurePool->get( *mFeatureIt, feature ) && feature.geometry() && feature.geometry().constGet() )
|
||||||
{
|
{
|
||||||
delete mCurrentFeature;
|
delete mCurrentFeature;
|
||||||
mCurrentFeature = new LayerFeature( mParent->mFeaturePools[*mLayerIt], feature, mParent->mUseMapCrs );
|
mCurrentFeature = new LayerFeature( mParent->mFeaturePools[*mLayerIt], feature, mParent->mUseMapCrs );
|
||||||
|
@ -47,7 +47,7 @@ void QgsGeometryDegeneratePolygonCheck::fixError( QgsGeometryCheckError *error,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeometry = feature.geometry();
|
QgsGeometry featureGeometry = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeometry.geometry();
|
const QgsAbstractGeometry *geom = featureGeometry.constGet();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if ring still exists
|
// Check if ring still exists
|
||||||
|
@ -55,7 +55,7 @@ void QgsGeometryDuplicateNodesCheck::fixError( QgsGeometryCheckError *error, int
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
QgsAbstractGeometry *geom = featureGeom.get();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if point still exists
|
// Check if point still exists
|
||||||
|
@ -74,7 +74,7 @@ void QgsGeometryFollowBoundariesCheck::collectErrors( QList<QgsGeometryCheckErro
|
|||||||
QgsFeature refFeature;
|
QgsFeature refFeature;
|
||||||
while ( refFeatureIt.nextFeature( refFeature ) )
|
while ( refFeatureIt.nextFeature( refFeature ) )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *refGeom = refFeature.geometry().geometry();
|
const QgsAbstractGeometry *refGeom = refFeature.geometry().constGet();
|
||||||
QSharedPointer<QgsGeometryEngine> refgeomEngine = QgsGeometryCheckerUtils::createGeomEngine( refGeom, mContext->tolerance );
|
QSharedPointer<QgsGeometryEngine> refgeomEngine = QgsGeometryCheckerUtils::createGeomEngine( refGeom, mContext->tolerance );
|
||||||
QScopedPointer<QgsAbstractGeometry> reducedRefGeom( refgeomEngine->buffer( -mContext->tolerance, 0 ) );
|
QScopedPointer<QgsAbstractGeometry> reducedRefGeom( refgeomEngine->buffer( -mContext->tolerance, 0 ) );
|
||||||
if ( !( geomEngine->contains( reducedRefGeom.data() ) || geomEngine->disjoint( reducedRefGeom.data() ) ) )
|
if ( !( geomEngine->contains( reducedRefGeom.data() ) || geomEngine->disjoint( reducedRefGeom.data() ) ) )
|
||||||
|
@ -168,7 +168,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError *err, Chan
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeom = testFeature.geometry();
|
QgsGeometry featureGeom = testFeature.geometry();
|
||||||
QgsAbstractGeometry *testGeom = featureGeom.geometry();
|
const QgsAbstractGeometry *testGeom = featureGeom.constGet();
|
||||||
for ( int iPart = 0, nParts = testGeom->partCount(); iPart < nParts; ++iPart )
|
for ( int iPart = 0, nParts = testGeom->partCount(); iPart < nParts; ++iPart )
|
||||||
{
|
{
|
||||||
double len = QgsGeometryCheckerUtils::sharedEdgeLength( errLayerGeom, QgsGeometryCheckerUtils::getGeomPart( testGeom, iPart ), mContext->reducedTolerance );
|
double len = QgsGeometryCheckerUtils::sharedEdgeLength( errLayerGeom, QgsGeometryCheckerUtils::getGeomPart( testGeom, iPart ), mContext->reducedTolerance );
|
||||||
@ -194,7 +194,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError *err, Chan
|
|||||||
QgsAbstractGeometry *errLayerGeom = errGeometry->clone();
|
QgsAbstractGeometry *errLayerGeom = errGeometry->clone();
|
||||||
errLayerGeom->transform( featurePool->getLayerToMapTransform(), QgsCoordinateTransform::ReverseTransform );
|
errLayerGeom->transform( featurePool->getLayerToMapTransform(), QgsCoordinateTransform::ReverseTransform );
|
||||||
QgsGeometry mergeFeatureGeom = mergeFeature.geometry();
|
QgsGeometry mergeFeatureGeom = mergeFeature.geometry();
|
||||||
QgsAbstractGeometry *mergeGeom = mergeFeatureGeom.geometry();
|
const QgsAbstractGeometry *mergeGeom = mergeFeatureGeom.constGet();
|
||||||
QSharedPointer<QgsGeometryEngine> geomEngine = QgsGeometryCheckerUtils::createGeomEngine( errLayerGeom, mContext->reducedTolerance );
|
QSharedPointer<QgsGeometryEngine> geomEngine = QgsGeometryCheckerUtils::createGeomEngine( errLayerGeom, mContext->reducedTolerance );
|
||||||
QgsAbstractGeometry *combinedGeom = geomEngine->combine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), &errMsg );
|
QgsAbstractGeometry *combinedGeom = geomEngine->combine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), &errMsg );
|
||||||
delete errLayerGeom;
|
delete errLayerGeom;
|
||||||
|
@ -53,7 +53,7 @@ void QgsGeometryHoleCheck::fixError( QgsGeometryCheckError *error, int method, c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
const QgsAbstractGeometry *geom = featureGeom.constGet();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if ring still exists
|
// Check if ring still exists
|
||||||
|
@ -41,7 +41,7 @@ void QgsGeometryMultipartCheck::fixError( QgsGeometryCheckError *error, int meth
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
const QgsAbstractGeometry *geom = featureGeom.constGet();
|
||||||
|
|
||||||
// Check if error still applies
|
// Check if error still applies
|
||||||
if ( geom->partCount() > 1 || !QgsWkbTypes::isMultiType( geom->wkbType() ) )
|
if ( geom->partCount() > 1 || !QgsWkbTypes::isMultiType( geom->wkbType() ) )
|
||||||
|
@ -65,7 +65,7 @@ void QgsGeometrySegmentLengthCheck::fixError( QgsGeometryCheckError *error, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
const QgsAbstractGeometry *geom = featureGeom.constGet();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if point still exists
|
// Check if point still exists
|
||||||
|
@ -90,7 +90,7 @@ void QgsGeometrySelfIntersectionCheck::fixError( QgsGeometryCheckError *error, i
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
QgsAbstractGeometry *geom = featureGeom.get();
|
||||||
QgsVertexId vidx = error->vidx();
|
QgsVertexId vidx = error->vidx();
|
||||||
|
|
||||||
// Check if ring still exists
|
// Check if ring still exists
|
||||||
|
@ -48,7 +48,7 @@ void QgsGeometryTypeCheck::fixError( QgsGeometryCheckError *error, int method, c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QgsGeometry featureGeom = feature.geometry();
|
QgsGeometry featureGeom = feature.geometry();
|
||||||
QgsAbstractGeometry *geom = featureGeom.geometry();
|
const QgsAbstractGeometry *geom = featureGeom.constGet();
|
||||||
|
|
||||||
// Check if error still applies
|
// Check if error still applies
|
||||||
QgsWkbTypes::Type type = QgsWkbTypes::flatType( geom->wkbType() );
|
QgsWkbTypes::Type type = QgsWkbTypes::flatType( geom->wkbType() );
|
||||||
|
@ -505,17 +505,17 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl
|
|||||||
( mode == EndPointPreferClosest || mode == EndPointPreferNodes || mode == EndPointToEndPoint ) )
|
( mode == EndPointPreferClosest || mode == EndPointPreferNodes || mode == EndPointToEndPoint ) )
|
||||||
return geometry;
|
return geometry;
|
||||||
|
|
||||||
QgsPoint center = qgsgeometry_cast< const QgsPoint * >( geometry.geometry() ) ? *static_cast< const QgsPoint * >( geometry.geometry() ) :
|
QgsPoint center = qgsgeometry_cast< const QgsPoint * >( geometry.constGet() ) ? *static_cast< const QgsPoint * >( geometry.constGet() ) :
|
||||||
QgsPoint( geometry.geometry()->boundingBox().center() );
|
QgsPoint( geometry.constGet()->boundingBox().center() );
|
||||||
|
|
||||||
QgsSnapIndex refSnapIndex( center, 10 * snapTolerance );
|
QgsSnapIndex refSnapIndex( center, 10 * snapTolerance );
|
||||||
Q_FOREACH ( const QgsGeometry &geom, referenceGeometries )
|
Q_FOREACH ( const QgsGeometry &geom, referenceGeometries )
|
||||||
{
|
{
|
||||||
refSnapIndex.addGeometry( geom.geometry() );
|
refSnapIndex.addGeometry( geom.constGet() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snap geometries
|
// Snap geometries
|
||||||
QgsAbstractGeometry *subjGeom = geometry.geometry()->clone();
|
QgsAbstractGeometry *subjGeom = geometry.constGet()->clone();
|
||||||
QList < QList< QList<PointFlag> > > subjPointFlags;
|
QList < QList< QList<PointFlag> > > subjPointFlags;
|
||||||
|
|
||||||
// Pass 1: snap vertices of subject geometry to reference vertices
|
// Pass 1: snap vertices of subject geometry to reference vertices
|
||||||
@ -619,16 +619,16 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl
|
|||||||
// Pass 2: add missing vertices to subject geometry
|
// Pass 2: add missing vertices to subject geometry
|
||||||
Q_FOREACH ( const QgsGeometry &refGeom, referenceGeometries )
|
Q_FOREACH ( const QgsGeometry &refGeom, referenceGeometries )
|
||||||
{
|
{
|
||||||
for ( int iPart = 0, nParts = refGeom.geometry()->partCount(); iPart < nParts; ++iPart )
|
for ( int iPart = 0, nParts = refGeom.constGet()->partCount(); iPart < nParts; ++iPart )
|
||||||
{
|
{
|
||||||
for ( int iRing = 0, nRings = refGeom.geometry()->ringCount( iPart ); iRing < nRings; ++iRing )
|
for ( int iRing = 0, nRings = refGeom.constGet()->ringCount( iPart ); iRing < nRings; ++iRing )
|
||||||
{
|
{
|
||||||
for ( int iVert = 0, nVerts = polyLineSize( refGeom.geometry(), iPart, iRing ); iVert < nVerts; ++iVert )
|
for ( int iVert = 0, nVerts = polyLineSize( refGeom.constGet(), iPart, iRing ); iVert < nVerts; ++iVert )
|
||||||
{
|
{
|
||||||
|
|
||||||
QgsSnapIndex::PointSnapItem *snapPoint = nullptr;
|
QgsSnapIndex::PointSnapItem *snapPoint = nullptr;
|
||||||
QgsSnapIndex::SegmentSnapItem *snapSegment = nullptr;
|
QgsSnapIndex::SegmentSnapItem *snapSegment = nullptr;
|
||||||
QgsPoint point = refGeom.geometry()->vertexAt( QgsVertexId( iPart, iRing, iVert ) );
|
QgsPoint point = refGeom.constGet()->vertexAt( QgsVertexId( iPart, iRing, iVert ) );
|
||||||
if ( subjSnapIndex->getSnapItem( point, snapTolerance, &snapPoint, &snapSegment ) )
|
if ( subjSnapIndex->getSnapItem( point, snapTolerance, &snapPoint, &snapSegment ) )
|
||||||
{
|
{
|
||||||
// Snap to segment, unless a subject point was already snapped to the reference point
|
// Snap to segment, unless a subject point was already snapped to the reference point
|
||||||
|
@ -2672,7 +2672,7 @@ bool QgsDwgImporter::expandInserts( QString &error )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray wkb = g.geometry()->asWkb();
|
QByteArray wkb = g.constGet()->asWkb();
|
||||||
if ( OGR_G_CreateFromWkb( ( unsigned char * ) wkb.constData(), nullptr, &ogrG, wkb.size() ) != OGRERR_NONE )
|
if ( OGR_G_CreateFromWkb( ( unsigned char * ) wkb.constData(), nullptr, &ogrG, wkb.size() ) != OGRERR_NONE )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( QString( "%1/%2: could not create ogr geometry" ).arg( name ).arg( fid ) );
|
QgsDebugMsg( QString( "%1/%2: could not create ogr geometry" ).arg( name ).arg( fid ) );
|
||||||
|
@ -54,12 +54,12 @@ uint qHash( const Vertex &v )
|
|||||||
//! Find out whether vertex at the given index is an endpoint (assuming linear geometry)
|
//! Find out whether vertex at the given index is an endpoint (assuming linear geometry)
|
||||||
static bool isEndpointAtVertexIndex( const QgsGeometry &geom, int vertexIndex )
|
static bool isEndpointAtVertexIndex( const QgsGeometry &geom, int vertexIndex )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *g = geom.geometry();
|
const QgsAbstractGeometry *g = geom.constGet();
|
||||||
if ( QgsCurve *curve = dynamic_cast<QgsCurve *>( g ) )
|
if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve *>( g ) )
|
||||||
{
|
{
|
||||||
return vertexIndex == 0 || vertexIndex == curve->numPoints() - 1;
|
return vertexIndex == 0 || vertexIndex == curve->numPoints() - 1;
|
||||||
}
|
}
|
||||||
else if ( QgsMultiCurve *multiCurve = dynamic_cast<QgsMultiCurve *>( g ) )
|
else if ( const QgsMultiCurve *multiCurve = qgsgeometry_cast<const QgsMultiCurve *>( g ) )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < multiCurve->numGeometries(); ++i )
|
for ( int i = 0; i < multiCurve->numGeometries(); ++i )
|
||||||
{
|
{
|
||||||
@ -83,17 +83,17 @@ static bool isEndpointAtVertexIndex( const QgsGeometry &geom, int vertexIndex )
|
|||||||
//! Return index of vertex adjacent to the given endpoint. Assuming linear geometries.
|
//! Return index of vertex adjacent to the given endpoint. Assuming linear geometries.
|
||||||
int adjacentVertexIndexToEndpoint( const QgsGeometry &geom, int vertexIndex )
|
int adjacentVertexIndexToEndpoint( const QgsGeometry &geom, int vertexIndex )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *g = geom.geometry();
|
const QgsAbstractGeometry *g = geom.constGet();
|
||||||
if ( QgsCurve *curve = dynamic_cast<QgsCurve *>( g ) )
|
if ( const QgsCurve *curve = qgsgeometry_cast<const QgsCurve *>( g ) )
|
||||||
{
|
{
|
||||||
return vertexIndex == 0 ? 1 : curve->numPoints() - 2;
|
return vertexIndex == 0 ? 1 : curve->numPoints() - 2;
|
||||||
}
|
}
|
||||||
else if ( QgsMultiCurve *multiCurve = dynamic_cast<QgsMultiCurve *>( g ) )
|
else if ( const QgsMultiCurve *multiCurve = qgsgeometry_cast<const QgsMultiCurve *>( g ) )
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for ( int i = 0; i < multiCurve->numGeometries(); ++i )
|
for ( int i = 0; i < multiCurve->numGeometries(); ++i )
|
||||||
{
|
{
|
||||||
QgsCurve *part = qgsgeometry_cast<QgsCurve *>( multiCurve->geometryN( i ) );
|
const QgsCurve *part = qgsgeometry_cast<const QgsCurve *>( multiCurve->geometryN( i ) );
|
||||||
Q_ASSERT( part );
|
Q_ASSERT( part );
|
||||||
if ( vertexIndex < part->numPoints() )
|
if ( vertexIndex < part->numPoints() )
|
||||||
return vertexIndex == 0 ? offset + 1 : offset + part->numPoints() - 2;
|
return vertexIndex == 0 ? offset + 1 : offset + part->numPoints() - 2;
|
||||||
@ -125,7 +125,7 @@ static QgsGeometry geometryToMultiPoint( const QgsGeometry &geom )
|
|||||||
{
|
{
|
||||||
QgsMultiPointV2 *multiPoint = new QgsMultiPointV2();
|
QgsMultiPointV2 *multiPoint = new QgsMultiPointV2();
|
||||||
QgsGeometry outputGeom( multiPoint );
|
QgsGeometry outputGeom( multiPoint );
|
||||||
QgsAbstractGeometry *g = geom.geometry();
|
const QgsAbstractGeometry *g = geom.constGet();
|
||||||
for ( int i = 0; i < g->partCount(); ++i )
|
for ( int i = 0; i < g->partCount(); ++i )
|
||||||
for ( int j = 0; j < g->ringCount( i ); ++j )
|
for ( int j = 0; j < g->ringCount( i ); ++j )
|
||||||
for ( int k = 0; k < g->vertexCount( i, j ); ++k )
|
for ( int k = 0; k < g->vertexCount( i, j ); ++k )
|
||||||
@ -180,7 +180,7 @@ class MatchCollectingFilter : public QgsPointLocator::MatchFilter
|
|||||||
QgsGeometry matchGeom = nodetool->cachedGeometry( match.layer(), match.featureId() );
|
QgsGeometry matchGeom = nodetool->cachedGeometry( match.layer(), match.featureId() );
|
||||||
QgsVertexId vid;
|
QgsVertexId vid;
|
||||||
QgsPoint pt;
|
QgsPoint pt;
|
||||||
while ( matchGeom.geometry()->nextVertex( vid, pt ) )
|
while ( matchGeom.constGet()->nextVertex( vid, pt ) )
|
||||||
{
|
{
|
||||||
int vindex = matchGeom.vertexNrFromVertexId( vid );
|
int vindex = matchGeom.vertexNrFromVertexId( vid );
|
||||||
if ( pt.x() == match.point().x() && pt.y() == match.point().y() && vindex != match.vertexIndex() )
|
if ( pt.x() == match.point().x() && pt.y() == match.point().y() && vindex != match.vertexIndex() )
|
||||||
@ -435,7 +435,7 @@ void QgsNodeTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
|
|||||||
while ( fi.nextFeature( f ) )
|
while ( fi.nextFeature( f ) )
|
||||||
{
|
{
|
||||||
QgsGeometry g = f.geometry();
|
QgsGeometry g = f.geometry();
|
||||||
for ( int i = 0; i < g.geometry()->nCoordinates(); ++i )
|
for ( int i = 0; i < g.constGet()->nCoordinates(); ++i )
|
||||||
{
|
{
|
||||||
QgsPointXY pt = g.vertexAt( i );
|
QgsPointXY pt = g.vertexAt( i );
|
||||||
if ( layerRect.contains( pt ) )
|
if ( layerRect.contains( pt ) )
|
||||||
@ -828,8 +828,8 @@ void QgsNodeTool::mouseMoveNotDragging( QgsMapMouseEvent *e )
|
|||||||
QgsGeometry geom = cachedGeometry( m.layer(), m.featureId() );
|
QgsGeometry geom = cachedGeometry( m.layer(), m.featureId() );
|
||||||
mFeatureBandMarkers->setToGeometry( geometryToMultiPoint( geom ), m.layer() );
|
mFeatureBandMarkers->setToGeometry( geometryToMultiPoint( geom ), m.layer() );
|
||||||
mFeatureBandMarkers->setVisible( true );
|
mFeatureBandMarkers->setVisible( true );
|
||||||
if ( QgsWkbTypes::isCurvedType( geom.geometry()->wkbType() ) )
|
if ( QgsWkbTypes::isCurvedType( geom.wkbType() ) )
|
||||||
geom = QgsGeometry( geom.geometry()->segmentize() );
|
geom = QgsGeometry( geom.constGet()->segmentize() );
|
||||||
mFeatureBand->setToGeometry( geom, m.layer() );
|
mFeatureBand->setToGeometry( geom, m.layer() );
|
||||||
mFeatureBand->setVisible( true );
|
mFeatureBand->setVisible( true );
|
||||||
mFeatureBandLayer = m.layer();
|
mFeatureBandLayer = m.layer();
|
||||||
@ -994,7 +994,7 @@ void QgsNodeTool::deleteNodeEditorSelection()
|
|||||||
if ( mSelectedFeature->geometry()->type() == QgsWkbTypes::LineGeometry )
|
if ( mSelectedFeature->geometry()->type() == QgsWkbTypes::LineGeometry )
|
||||||
{
|
{
|
||||||
// for lines we don't wrap around vertex selection when deleting nodes from end of line
|
// for lines we don't wrap around vertex selection when deleting nodes from end of line
|
||||||
nextVertexToSelect = std::min( nextVertexToSelect, mSelectedFeature->geometry()->geometry()->nCoordinates() - 1 );
|
nextVertexToSelect = std::min( nextVertexToSelect, mSelectedFeature->geometry()->constGet()->nCoordinates() - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
_safeSelectVertex( *mSelectedFeature, nextVertexToSelect );
|
_safeSelectVertex( *mSelectedFeature, nextVertexToSelect );
|
||||||
@ -1398,7 +1398,7 @@ void QgsNodeTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocator:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAbstractGeometry *geomTmp = geom.geometry()->clone();
|
QgsAbstractGeometry *geomTmp = geom.constGet()->clone();
|
||||||
|
|
||||||
// add/move vertex
|
// add/move vertex
|
||||||
if ( addingVertex )
|
if ( addingVertex )
|
||||||
@ -1425,7 +1425,7 @@ void QgsNodeTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocator:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
geom.setGeometry( geomTmp );
|
geom.set( geomTmp );
|
||||||
|
|
||||||
NodeEdits edits; // dict { layer : { fid : geom } }
|
NodeEdits edits; // dict { layer : { fid : geom } }
|
||||||
edits[dragLayer][dragFid] = geom;
|
edits[dragLayer][dragFid] = geom;
|
||||||
@ -1582,7 +1582,7 @@ void QgsNodeTool::deleteVertex()
|
|||||||
QgsVertexId vid;
|
QgsVertexId vid;
|
||||||
if ( geom.vertexIdFromVertexNr( vertexIds[i], vid ) )
|
if ( geom.vertexIdFromVertexNr( vertexIds[i], vid ) )
|
||||||
{
|
{
|
||||||
int ringVertexCount = geom.geometry()->vertexCount( vid.part, vid.ring );
|
int ringVertexCount = geom.constGet()->vertexCount( vid.part, vid.ring );
|
||||||
if ( vid.vertex == ringVertexCount - 1 )
|
if ( vid.vertex == ringVertexCount - 1 )
|
||||||
{
|
{
|
||||||
// this is the last vertex of the ring - remove the first vertex from the list
|
// this is the last vertex of the ring - remove the first vertex from the list
|
||||||
|
@ -274,7 +274,7 @@ void QgsSelectedFeature::createVertexMap()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QgsAbstractGeometry *geom = mGeometry->geometry();
|
const QgsAbstractGeometry *geom = mGeometry->constGet();
|
||||||
if ( !geom )
|
if ( !geom )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -154,7 +154,7 @@ void QgsMapToolAddPart::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
|
|||||||
QgsGeometry *geom = new QgsGeometry( cp );
|
QgsGeometry *geom = new QgsGeometry( cp );
|
||||||
geom->avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() );
|
geom->avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() );
|
||||||
|
|
||||||
const QgsCurvePolygon *cpGeom = qgsgeometry_cast<const QgsCurvePolygon *>( geom->geometry() );
|
const QgsCurvePolygon *cpGeom = qgsgeometry_cast<const QgsCurvePolygon *>( geom->constGet() );
|
||||||
if ( !cpGeom )
|
if ( !cpGeom )
|
||||||
{
|
{
|
||||||
stopCapturing();
|
stopCapturing();
|
||||||
|
@ -83,7 +83,7 @@ void QgsSelectByFormDialog::zoomToFeatures( const QString &filter )
|
|||||||
while ( features.nextFeature( feat ) )
|
while ( features.nextFeature( feat ) )
|
||||||
{
|
{
|
||||||
QgsGeometry geom = feat.geometry();
|
QgsGeometry geom = feat.geometry();
|
||||||
if ( geom.isNull() || geom.geometry()->isEmpty() )
|
if ( geom.isNull() || geom.constGet()->isEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QgsRectangle r = mMapCanvas->mapSettings().layerExtentToOutputExtent( mLayer, geom.boundingBox() );
|
QgsRectangle r = mMapCanvas->mapSettings().layerExtentToOutputExtent( mLayer, geom.boundingBox() );
|
||||||
|
@ -3677,7 +3677,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
|
|||||||
if ( !fet->hasGeometry() )
|
if ( !fet->hasGeometry() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::unique_ptr<QgsAbstractGeometry> geom( fet->geometry().geometry()->clone() );
|
std::unique_ptr<QgsAbstractGeometry> geom( fet->geometry().constGet()->clone() );
|
||||||
if ( ct.isValid() )
|
if ( ct.isValid() )
|
||||||
{
|
{
|
||||||
geom->transform( ct );
|
geom->transform( ct );
|
||||||
|
@ -780,7 +780,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value )
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return tr( "<i><empty geometry></i>" );
|
return tr( "<i><empty geometry></i>" );
|
||||||
else
|
else
|
||||||
return tr( "<i><geometry: %1></i>" ).arg( QgsWkbTypes::displayString( geom.geometry()->wkbType() ) );
|
return tr( "<i><geometry: %1></i>" ).arg( QgsWkbTypes::displayString( geom.constGet()->wkbType() ) );
|
||||||
}
|
}
|
||||||
else if ( !value.isValid() )
|
else if ( !value.isValid() )
|
||||||
{
|
{
|
||||||
|
@ -1632,7 +1632,7 @@ static QVariant fcnGeomZ( const QVariantList &values, const QgsExpressionContext
|
|||||||
//if single point, return the point's z coordinate
|
//if single point, return the point's z coordinate
|
||||||
if ( geom.type() == QgsWkbTypes::PointGeometry && !geom.isMultipart() )
|
if ( geom.type() == QgsWkbTypes::PointGeometry && !geom.isMultipart() )
|
||||||
{
|
{
|
||||||
QgsPoint *point = qgsgeometry_cast< QgsPoint * >( geom.geometry() );
|
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( geom.constGet() );
|
||||||
if ( point )
|
if ( point )
|
||||||
return point->z();
|
return point->z();
|
||||||
}
|
}
|
||||||
@ -1649,7 +1649,7 @@ static QVariant fcnGeomM( const QVariantList &values, const QgsExpressionContext
|
|||||||
//if single point, return the point's m value
|
//if single point, return the point's m value
|
||||||
if ( geom.type() == QgsWkbTypes::PointGeometry && !geom.isMultipart() )
|
if ( geom.type() == QgsWkbTypes::PointGeometry && !geom.isMultipart() )
|
||||||
{
|
{
|
||||||
QgsPoint *point = qgsgeometry_cast< QgsPoint * >( geom.geometry() );
|
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( geom.constGet() );
|
||||||
if ( point )
|
if ( point )
|
||||||
return point->m();
|
return point->m();
|
||||||
}
|
}
|
||||||
@ -1674,7 +1674,7 @@ static QVariant fcnPointN( const QVariantList &values, const QgsExpressionContex
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPoint point = geom.geometry()->vertexAt( vId );
|
QgsPoint point = geom.constGet()->vertexAt( vId );
|
||||||
return QVariant::fromValue( QgsGeometry( new QgsPoint( point ) ) );
|
return QVariant::fromValue( QgsGeometry( new QgsPoint( point ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1691,7 +1691,7 @@ static QVariant fcnStartPoint( const QVariantList &values, const QgsExpressionCo
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPoint point = geom.geometry()->vertexAt( vId );
|
QgsPoint point = geom.constGet()->vertexAt( vId );
|
||||||
return QVariant::fromValue( QgsGeometry( new QgsPoint( point ) ) );
|
return QVariant::fromValue( QgsGeometry( new QgsPoint( point ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1703,12 +1703,12 @@ static QVariant fcnEndPoint( const QVariantList &values, const QgsExpressionCont
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsVertexId vId;
|
QgsVertexId vId;
|
||||||
if ( !geom.vertexIdFromVertexNr( geom.geometry()->nCoordinates() - 1, vId ) )
|
if ( !geom.vertexIdFromVertexNr( geom.constGet()->nCoordinates() - 1, vId ) )
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPoint point = geom.geometry()->vertexAt( vId );
|
QgsPoint point = geom.constGet()->vertexAt( vId );
|
||||||
return QVariant::fromValue( QgsGeometry( new QgsPoint( point ) ) );
|
return QVariant::fromValue( QgsGeometry( new QgsPoint( point ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1727,7 +1727,7 @@ static QVariant fcnNodesToPoints( const QVariantList &values, const QgsExpressio
|
|||||||
|
|
||||||
QgsMultiPointV2 *mp = new QgsMultiPointV2();
|
QgsMultiPointV2 *mp = new QgsMultiPointV2();
|
||||||
|
|
||||||
const QgsCoordinateSequence sequence = geom.geometry()->coordinateSequence();
|
const QgsCoordinateSequence sequence = geom.constGet()->coordinateSequence();
|
||||||
for ( const QgsRingSequence &part : sequence )
|
for ( const QgsRingSequence &part : sequence )
|
||||||
{
|
{
|
||||||
for ( const QgsPointSequence &ring : part )
|
for ( const QgsPointSequence &ring : part )
|
||||||
@ -1755,7 +1755,7 @@ static QVariant fcnSegmentsToLines( const QVariantList &values, const QgsExpress
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const QList< QgsLineString * > linesToProcess = QgsGeometryUtils::extractLineStrings( geom.geometry() );
|
const QList< QgsLineString * > linesToProcess = QgsGeometryUtils::extractLineStrings( geom.constGet() );
|
||||||
|
|
||||||
//OK, now we have a complete list of segmentized lines from the geometry
|
//OK, now we have a complete list of segmentized lines from the geometry
|
||||||
QgsMultiLineString *ml = new QgsMultiLineString();
|
QgsMultiLineString *ml = new QgsMultiLineString();
|
||||||
@ -1782,7 +1782,7 @@ static QVariant fcnInteriorRingN( const QVariantList &values, const QgsExpressio
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsCurvePolygon *curvePolygon = qgsgeometry_cast< QgsCurvePolygon * >( geom.geometry() );
|
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( geom.constGet() );
|
||||||
if ( !curvePolygon )
|
if ( !curvePolygon )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -1804,7 +1804,7 @@ static QVariant fcnGeometryN( const QVariantList &values, const QgsExpressionCon
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsGeometryCollection *collection = qgsgeometry_cast< QgsGeometryCollection * >( geom.geometry() );
|
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( geom.constGet() );
|
||||||
if ( !collection )
|
if ( !collection )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -1826,7 +1826,7 @@ static QVariant fcnBoundary( const QVariantList &values, const QgsExpressionCont
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsAbstractGeometry *boundary = geom.geometry()->boundary();
|
QgsAbstractGeometry *boundary = geom.constGet()->boundary();
|
||||||
if ( !boundary )
|
if ( !boundary )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -1951,7 +1951,7 @@ static QVariant fcnMakeLine( const QVariantList &values, const QgsExpressionCont
|
|||||||
if ( geom.type() != QgsWkbTypes::PointGeometry || geom.isMultipart() )
|
if ( geom.type() != QgsWkbTypes::PointGeometry || geom.isMultipart() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QgsPoint *point = qgsgeometry_cast< QgsPoint * >( geom.geometry() );
|
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( geom.constGet() );
|
||||||
if ( !point )
|
if ( !point )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1974,7 +1974,7 @@ static QVariant fcnMakePolygon( const QVariantList &values, const QgsExpressionC
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsPolygonV2 *polygon = new QgsPolygonV2();
|
QgsPolygonV2 *polygon = new QgsPolygonV2();
|
||||||
polygon->setExteriorRing( qgsgeometry_cast< QgsCurve * >( outerRing.geometry()->clone() ) );
|
polygon->setExteriorRing( qgsgeometry_cast< QgsCurve * >( outerRing.constGet()->clone() ) );
|
||||||
|
|
||||||
for ( int i = 1; i < values.count(); ++i )
|
for ( int i = 1; i < values.count(); ++i )
|
||||||
{
|
{
|
||||||
@ -1985,7 +1985,7 @@ static QVariant fcnMakePolygon( const QVariantList &values, const QgsExpressionC
|
|||||||
if ( ringGeom.type() != QgsWkbTypes::LineGeometry || ringGeom.isMultipart() || ringGeom.isNull() )
|
if ( ringGeom.type() != QgsWkbTypes::LineGeometry || ringGeom.isMultipart() || ringGeom.isNull() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
polygon->addInteriorRing( qgsgeometry_cast< QgsCurve * >( ringGeom.geometry()->clone() ) );
|
polygon->addInteriorRing( qgsgeometry_cast< QgsCurve * >( ringGeom.constGet()->clone() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant::fromValue( QgsGeometry( polygon ) );
|
return QVariant::fromValue( QgsGeometry( polygon ) );
|
||||||
@ -2006,7 +2006,7 @@ static QVariant fcnMakeTriangle( const QVariantList &values, const QgsExpression
|
|||||||
if ( geom.type() != QgsWkbTypes::PointGeometry || geom.isMultipart() )
|
if ( geom.type() != QgsWkbTypes::PointGeometry || geom.isMultipart() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsPoint *point = qgsgeometry_cast< QgsPoint * >( geom.geometry() );
|
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( geom.constGet() );
|
||||||
if ( !point )
|
if ( !point )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -2035,7 +2035,7 @@ static QVariant fcnMakeCircle( const QVariantList &values, const QgsExpressionCo
|
|||||||
parent->setEvalErrorString( QObject::tr( "Segment must be greater than 2" ) );
|
parent->setEvalErrorString( QObject::tr( "Segment must be greater than 2" ) );
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
QgsPoint *point = qgsgeometry_cast< QgsPoint * >( geom.geometry() );
|
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( geom.constGet() );
|
||||||
QgsCircle circ( *point, radius );
|
QgsCircle circ( *point, radius );
|
||||||
return QVariant::fromValue( QgsGeometry( circ.toPolygon( segment ) ) );
|
return QVariant::fromValue( QgsGeometry( circ.toPolygon( segment ) ) );
|
||||||
}
|
}
|
||||||
@ -2058,7 +2058,7 @@ static QVariant fcnMakeEllipse( const QVariantList &values, const QgsExpressionC
|
|||||||
parent->setEvalErrorString( QObject::tr( "Segment must be greater than 2" ) );
|
parent->setEvalErrorString( QObject::tr( "Segment must be greater than 2" ) );
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
QgsPoint *point = qgsgeometry_cast< QgsPoint * >( geom.geometry() );
|
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( geom.constGet() );
|
||||||
QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
|
QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
|
||||||
return QVariant::fromValue( QgsGeometry( elp.toPolygon( segment ) ) );
|
return QVariant::fromValue( QgsGeometry( elp.toPolygon( segment ) ) );
|
||||||
}
|
}
|
||||||
@ -2093,8 +2093,8 @@ static QVariant fcnMakeRegularPolygon( const QVariantList &values, const QgsExpr
|
|||||||
parent->setEvalErrorString( QObject::tr( "Option can be 0 (inscribed) or 1 (circumscribed)" ) );
|
parent->setEvalErrorString( QObject::tr( "Option can be 0 (inscribed) or 1 (circumscribed)" ) );
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
QgsPoint *center = qgsgeometry_cast< QgsPoint * >( pt1.geometry() );
|
const QgsPoint *center = qgsgeometry_cast< const QgsPoint * >( pt1.constGet() );
|
||||||
QgsPoint *corner = qgsgeometry_cast< QgsPoint * >( pt2.geometry() );
|
const QgsPoint *corner = qgsgeometry_cast< const QgsPoint * >( pt2.constGet() );
|
||||||
|
|
||||||
QgsRegularPolygon rp = QgsRegularPolygon( *center, *corner, nbEdges, option );
|
QgsRegularPolygon rp = QgsRegularPolygon( *center, *corner, nbEdges, option );
|
||||||
|
|
||||||
@ -2112,9 +2112,9 @@ static QVariant pointAt( const QVariantList &values, const QgsExpressionContext
|
|||||||
|
|
||||||
if ( idx < 0 )
|
if ( idx < 0 )
|
||||||
{
|
{
|
||||||
idx += g.geometry()->nCoordinates();
|
idx += g.constGet()->nCoordinates();
|
||||||
}
|
}
|
||||||
if ( idx < 0 || idx >= g.geometry()->nCoordinates() )
|
if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
|
||||||
{
|
{
|
||||||
parent->setEvalErrorString( QObject::tr( "Index is out of range" ) );
|
parent->setEvalErrorString( QObject::tr( "Index is out of range" ) );
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -2221,7 +2221,7 @@ static QVariant fcnGeomPerimeter( const QVariantList &, const QgsExpressionConte
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().geometry()->perimeter() );
|
return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2239,7 +2239,7 @@ static QVariant fcnPerimeter( const QVariantList &values, const QgsExpressionCon
|
|||||||
static QVariant fcnGeomNumPoints( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
static QVariant fcnGeomNumPoints( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||||
{
|
{
|
||||||
QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
||||||
return QVariant( geom.isNull() ? 0 : geom.geometry()->nCoordinates() );
|
return QVariant( geom.isNull() ? 0 : geom.constGet()->nCoordinates() );
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant fcnGeomNumGeometries( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
static QVariant fcnGeomNumGeometries( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||||
@ -2248,7 +2248,7 @@ static QVariant fcnGeomNumGeometries( const QVariantList &values, const QgsExpre
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
return QVariant( geom.geometry()->partCount() );
|
return QVariant( geom.constGet()->partCount() );
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant fcnGeomNumInteriorRings( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
static QVariant fcnGeomNumInteriorRings( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||||
@ -2258,17 +2258,17 @@ static QVariant fcnGeomNumInteriorRings( const QVariantList &values, const QgsEx
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsCurvePolygon *curvePolygon = qgsgeometry_cast< QgsCurvePolygon * >( geom.geometry() );
|
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( geom.constGet() );
|
||||||
if ( curvePolygon )
|
if ( curvePolygon )
|
||||||
return QVariant( curvePolygon->numInteriorRings() );
|
return QVariant( curvePolygon->numInteriorRings() );
|
||||||
|
|
||||||
QgsGeometryCollection *collection = qgsgeometry_cast< QgsGeometryCollection * >( geom.geometry() );
|
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( geom.constGet() );
|
||||||
if ( collection )
|
if ( collection )
|
||||||
{
|
{
|
||||||
//find first CurvePolygon in collection
|
//find first CurvePolygon in collection
|
||||||
for ( int i = 0; i < collection->numGeometries(); ++i )
|
for ( int i = 0; i < collection->numGeometries(); ++i )
|
||||||
{
|
{
|
||||||
curvePolygon = qgsgeometry_cast< QgsCurvePolygon *>( collection->geometryN( i ) );
|
curvePolygon = qgsgeometry_cast< const QgsCurvePolygon *>( collection->geometryN( i ) );
|
||||||
if ( !curvePolygon )
|
if ( !curvePolygon )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -2286,13 +2286,13 @@ static QVariant fcnGeomNumRings( const QVariantList &values, const QgsExpression
|
|||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsCurvePolygon *curvePolygon = qgsgeometry_cast< QgsCurvePolygon * >( geom.geometry() );
|
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( geom.constGet() );
|
||||||
if ( curvePolygon )
|
if ( curvePolygon )
|
||||||
return QVariant( curvePolygon->ringCount() );
|
return QVariant( curvePolygon->ringCount() );
|
||||||
|
|
||||||
bool foundPoly = false;
|
bool foundPoly = false;
|
||||||
int ringCount = 0;
|
int ringCount = 0;
|
||||||
QgsGeometryCollection *collection = qgsgeometry_cast< QgsGeometryCollection * >( geom.geometry() );
|
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( geom.constGet() );
|
||||||
if ( collection )
|
if ( collection )
|
||||||
{
|
{
|
||||||
//find CurvePolygons in collection
|
//find CurvePolygons in collection
|
||||||
@ -2363,7 +2363,7 @@ static QVariant fcnIsClosed( const QVariantList &values, const QgsExpressionCont
|
|||||||
if ( fGeom.isNull() )
|
if ( fGeom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsCurve *curve = qgsgeometry_cast< QgsCurve * >( fGeom.geometry() );
|
const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( fGeom.constGet() );
|
||||||
if ( !curve )
|
if ( !curve )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -2381,19 +2381,19 @@ static QVariant fcnRelate( const QVariantList &values, const QgsExpressionContex
|
|||||||
if ( fGeom.isNull() || sGeom.isNull() )
|
if ( fGeom.isNull() || sGeom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
std::unique_ptr<QgsGeometryEngine> engine( QgsGeometry::createGeometryEngine( fGeom.geometry() ) );
|
std::unique_ptr<QgsGeometryEngine> engine( QgsGeometry::createGeometryEngine( fGeom.constGet() ) );
|
||||||
|
|
||||||
if ( values.length() == 2 )
|
if ( values.length() == 2 )
|
||||||
{
|
{
|
||||||
//two geometry arguments, return relation
|
//two geometry arguments, return relation
|
||||||
QString result = engine->relate( sGeom.geometry() );
|
QString result = engine->relate( sGeom.constGet() );
|
||||||
return QVariant::fromValue( result );
|
return QVariant::fromValue( result );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//three arguments, test pattern
|
//three arguments, test pattern
|
||||||
QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
|
QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
|
||||||
bool result = engine->relatePattern( sGeom.geometry(), pattern );
|
bool result = engine->relatePattern( sGeom.constGet(), pattern );
|
||||||
return QVariant::fromValue( result );
|
return QVariant::fromValue( result );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2578,7 +2578,7 @@ static QVariant fcnReverse( const QVariantList &values, const QgsExpressionConte
|
|||||||
if ( fGeom.isNull() )
|
if ( fGeom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsCurve *curve = qgsgeometry_cast< QgsCurve * >( fGeom.geometry() );
|
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( fGeom.constGet() );
|
||||||
if ( !curve )
|
if ( !curve )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -2593,7 +2593,7 @@ static QVariant fcnExteriorRing( const QVariantList &values, const QgsExpression
|
|||||||
if ( fGeom.isNull() )
|
if ( fGeom.isNull() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QgsCurvePolygon *curvePolygon = qgsgeometry_cast< QgsCurvePolygon * >( fGeom.geometry() );
|
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( fGeom.constGet() );
|
||||||
if ( !curvePolygon || !curvePolygon->exteriorRing() )
|
if ( !curvePolygon || !curvePolygon->exteriorRing() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -2677,8 +2677,8 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
|
|||||||
QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
||||||
QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
|
QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
|
||||||
|
|
||||||
const QgsPoint *pt1 = qgsgeometry_cast<const QgsPoint *>( fGeom1.geometry() );
|
const QgsPoint *pt1 = qgsgeometry_cast<const QgsPoint *>( fGeom1.constGet() );
|
||||||
const QgsPoint *pt2 = qgsgeometry_cast<const QgsPoint *>( fGeom2.geometry() );
|
const QgsPoint *pt2 = qgsgeometry_cast<const QgsPoint *>( fGeom2.constGet() );
|
||||||
|
|
||||||
if ( !pt1 || !pt2 )
|
if ( !pt1 || !pt2 )
|
||||||
{
|
{
|
||||||
@ -2749,7 +2749,7 @@ static QVariant fcnProject( const QVariantList &values, const QgsExpressionConte
|
|||||||
double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
|
double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
|
||||||
double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
|
double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
|
||||||
|
|
||||||
const QgsPoint *p = static_cast<const QgsPoint *>( geom.geometry() );
|
const QgsPoint *p = static_cast<const QgsPoint *>( geom.constGet() );
|
||||||
QgsPoint newPoint = p->project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
|
QgsPoint newPoint = p->project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
|
||||||
|
|
||||||
return QVariant::fromValue( QgsGeometry( new QgsPoint( newPoint ) ) );
|
return QVariant::fromValue( QgsGeometry( new QgsPoint( newPoint ) ) );
|
||||||
@ -2760,8 +2760,8 @@ static QVariant fcnInclination( const QVariantList &values, const QgsExpressionC
|
|||||||
QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
||||||
QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
|
QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
|
||||||
|
|
||||||
const QgsPoint *pt1 = qgsgeometry_cast<const QgsPoint *>( fGeom1.geometry() );
|
const QgsPoint *pt1 = qgsgeometry_cast<const QgsPoint *>( fGeom1.constGet() );
|
||||||
const QgsPoint *pt2 = qgsgeometry_cast<const QgsPoint *>( fGeom2.geometry() );
|
const QgsPoint *pt2 = qgsgeometry_cast<const QgsPoint *>( fGeom2.constGet() );
|
||||||
|
|
||||||
if ( ( fGeom1.type() != QgsWkbTypes::PointGeometry ) || ( fGeom2.type() != QgsWkbTypes::PointGeometry ) ||
|
if ( ( fGeom1.type() != QgsWkbTypes::PointGeometry ) || ( fGeom2.type() != QgsWkbTypes::PointGeometry ) ||
|
||||||
!pt1 || !pt2 )
|
!pt1 || !pt2 )
|
||||||
@ -2785,7 +2785,7 @@ static QVariant fcnExtrude( const QVariantList &values, const QgsExpressionConte
|
|||||||
|
|
||||||
QgsGeometry geom = fGeom.extrude( x, y );
|
QgsGeometry geom = fGeom.extrude( x, y );
|
||||||
|
|
||||||
QVariant result = geom.geometry() ? QVariant::fromValue( geom ) : QVariant();
|
QVariant result = geom.constGet() ? QVariant::fromValue( geom ) : QVariant();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2829,7 +2829,7 @@ static QVariant fcnOrderParts( const QVariantList &values, const QgsExpressionCo
|
|||||||
unconstedContext = new QgsExpressionContext();
|
unconstedContext = new QgsExpressionContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsGeometryCollection *collection = qgsgeometry_cast<QgsGeometryCollection *>( fGeom.geometry() );
|
const QgsGeometryCollection *collection = qgsgeometry_cast<const QgsGeometryCollection *>( fGeom.constGet() );
|
||||||
Q_ASSERT( collection ); // Should have failed the multipart check above
|
Q_ASSERT( collection ); // Should have failed the multipart check above
|
||||||
|
|
||||||
QgsFeatureRequest::OrderBy orderBy;
|
QgsFeatureRequest::OrderBy orderBy;
|
||||||
@ -2846,7 +2846,7 @@ static QVariant fcnOrderParts( const QVariantList &values, const QgsExpressionCo
|
|||||||
|
|
||||||
sorter.sortFeatures( partFeatures, unconstedContext );
|
sorter.sortFeatures( partFeatures, unconstedContext );
|
||||||
|
|
||||||
QgsGeometryCollection *orderedGeom = qgsgeometry_cast<QgsGeometryCollection *>( fGeom.geometry()->clone() );
|
QgsGeometryCollection *orderedGeom = qgsgeometry_cast<QgsGeometryCollection *>( fGeom.constGet()->clone() );
|
||||||
|
|
||||||
Q_ASSERT( orderedGeom );
|
Q_ASSERT( orderedGeom );
|
||||||
|
|
||||||
@ -2855,7 +2855,7 @@ static QVariant fcnOrderParts( const QVariantList &values, const QgsExpressionCo
|
|||||||
|
|
||||||
for ( const QgsFeature &feature : qgis::as_const( partFeatures ) )
|
for ( const QgsFeature &feature : qgis::as_const( partFeatures ) )
|
||||||
{
|
{
|
||||||
orderedGeom->addGeometry( feature.geometry().geometry()->clone() );
|
orderedGeom->addGeometry( feature.geometry().constGet()->clone() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant result = QVariant::fromValue( QgsGeometry( orderedGeom ) );
|
QVariant result = QVariant::fromValue( QgsGeometry( orderedGeom ) );
|
||||||
|
@ -298,7 +298,7 @@ class CORE_EXPORT QgsAbstractGeometry
|
|||||||
* Returns the vertices adjacent to a specified \a vertex within a geometry.
|
* Returns the vertices adjacent to a specified \a vertex within a geometry.
|
||||||
* \since QGIS 3.0
|
* \since QGIS 3.0
|
||||||
*/
|
*/
|
||||||
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) = 0;
|
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the sequence of geometries, rings and nodes.
|
* Retrieves the sequence of geometries, rings and nodes.
|
||||||
|
@ -78,7 +78,7 @@ bool QgsCurve::nextVertex( QgsVertexId &id, QgsPoint &vertex ) const
|
|||||||
return pointAt( id.vertex, vertex, id.type );
|
return pointAt( id.vertex, vertex, id.type );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsCurve::adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex )
|
void QgsCurve::adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex ) const
|
||||||
{
|
{
|
||||||
int n = numPoints();
|
int n = numPoints();
|
||||||
if ( vertex.vertex < 0 || vertex.vertex >= n )
|
if ( vertex.vertex < 0 || vertex.vertex >= n )
|
||||||
|
@ -103,7 +103,7 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry
|
|||||||
|
|
||||||
QgsCoordinateSequence coordinateSequence() const override;
|
QgsCoordinateSequence coordinateSequence() const override;
|
||||||
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
|
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
|
||||||
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) override;
|
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
|
||||||
int vertexNumberFromVertexId( QgsVertexId id ) const override;
|
int vertexNumberFromVertexId( QgsVertexId id ) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -844,7 +844,7 @@ void ringAdjacentVertices( const QgsCurve *curve, QgsVertexId vertex, QgsVertexI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsCurvePolygon::adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex )
|
void QgsCurvePolygon::adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex ) const
|
||||||
{
|
{
|
||||||
if ( !mExteriorRing || vertex.ring < 0 || vertex.ring >= 1 + mInteriorRings.size() )
|
if ( !mExteriorRing || vertex.ring < 0 || vertex.ring >= 1 + mInteriorRings.size() )
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
|
|||||||
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, bool *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
|
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, bool *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
|
||||||
|
|
||||||
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
|
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
|
||||||
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) override;
|
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
|
||||||
bool hasCurvedSegments() const override;
|
bool hasCurvedSegments() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,12 +120,18 @@ void QgsGeometry::reset( std::unique_ptr<QgsAbstractGeometry> newGeometry )
|
|||||||
d->geometry = std::move( newGeometry );
|
d->geometry = std::move( newGeometry );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAbstractGeometry *QgsGeometry::geometry() const
|
const QgsAbstractGeometry *QgsGeometry::constGet() const
|
||||||
{
|
{
|
||||||
return d->geometry.get();
|
return d->geometry.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsGeometry::setGeometry( QgsAbstractGeometry *geometry )
|
QgsAbstractGeometry *QgsGeometry::get()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->geometry.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsGeometry::set( QgsAbstractGeometry *geometry )
|
||||||
{
|
{
|
||||||
if ( d->geometry.get() == geometry )
|
if ( d->geometry.get() == geometry )
|
||||||
{
|
{
|
||||||
@ -872,7 +878,7 @@ int QgsGeometry::makeDifferenceInPlace( const QgsGeometry &other )
|
|||||||
QgsGeos geos( d->geometry.get() );
|
QgsGeos geos( d->geometry.get() );
|
||||||
|
|
||||||
mLastError.clear();
|
mLastError.clear();
|
||||||
std::unique_ptr< QgsAbstractGeometry > diffGeom( geos.intersection( other.geometry(), &mLastError ) );
|
std::unique_ptr< QgsAbstractGeometry > diffGeom( geos.intersection( other.constGet(), &mLastError ) );
|
||||||
if ( !diffGeom )
|
if ( !diffGeom )
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
@ -892,7 +898,7 @@ QgsGeometry QgsGeometry::makeDifference( const QgsGeometry &other ) const
|
|||||||
QgsGeos geos( d->geometry.get() );
|
QgsGeos geos( d->geometry.get() );
|
||||||
|
|
||||||
mLastError.clear();
|
mLastError.clear();
|
||||||
std::unique_ptr< QgsAbstractGeometry > diffGeom( geos.intersection( other.geometry(), &mLastError ) );
|
std::unique_ptr< QgsAbstractGeometry > diffGeom( geos.intersection( other.constGet(), &mLastError ) );
|
||||||
if ( !diffGeom )
|
if ( !diffGeom )
|
||||||
{
|
{
|
||||||
QgsGeometry result;
|
QgsGeometry result;
|
||||||
@ -932,10 +938,10 @@ QgsGeometry QgsGeometry::orientedMinimumBoundingBox( double &area, double &angle
|
|||||||
QgsPoint pt1;
|
QgsPoint pt1;
|
||||||
QgsPoint pt2;
|
QgsPoint pt2;
|
||||||
// get first point
|
// get first point
|
||||||
hull.geometry()->nextVertex( vertexId, pt0 );
|
hull.constGet()->nextVertex( vertexId, pt0 );
|
||||||
pt1 = pt0;
|
pt1 = pt0;
|
||||||
double prevAngle = 0.0;
|
double prevAngle = 0.0;
|
||||||
while ( hull.geometry()->nextVertex( vertexId, pt2 ) )
|
while ( hull.constGet()->nextVertex( vertexId, pt2 ) )
|
||||||
{
|
{
|
||||||
double currentAngle = QgsGeometryUtils::lineAngle( pt1.x(), pt1.y(), pt2.x(), pt2.y() );
|
double currentAngle = QgsGeometryUtils::lineAngle( pt1.x(), pt1.y(), pt2.x(), pt2.y() );
|
||||||
double rotateAngle = 180.0 / M_PI * ( currentAngle - prevAngle );
|
double rotateAngle = 180.0 / M_PI * ( currentAngle - prevAngle );
|
||||||
@ -945,9 +951,9 @@ QgsGeometry QgsGeometry::orientedMinimumBoundingBox( double &area, double &angle
|
|||||||
t.rotate( rotateAngle );
|
t.rotate( rotateAngle );
|
||||||
t.translate( -pt0.x(), -pt0.y() );
|
t.translate( -pt0.x(), -pt0.y() );
|
||||||
|
|
||||||
hull.geometry()->transform( t );
|
hull.get()->transform( t );
|
||||||
|
|
||||||
QgsRectangle bounds = hull.geometry()->boundingBox();
|
QgsRectangle bounds = hull.constGet()->boundingBox();
|
||||||
double currentArea = bounds.width() * bounds.height();
|
double currentArea = bounds.width() * bounds.height();
|
||||||
if ( currentArea < area )
|
if ( currentArea < area )
|
||||||
{
|
{
|
||||||
@ -1047,7 +1053,7 @@ QgsGeometry QgsGeometry::minimalEnclosingCircle( QgsPointXY ¢er, double &rad
|
|||||||
center = QgsPointXY( circ.center() );
|
center = QgsPointXY( circ.center() );
|
||||||
radius = circ.radius();
|
radius = circ.radius();
|
||||||
QgsGeometry geom;
|
QgsGeometry geom;
|
||||||
geom.setGeometry( circ.toPolygon( segments ) );
|
geom.set( circ.toPolygon( segments ) );
|
||||||
return geom;
|
return geom;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1816,7 +1822,7 @@ QgsGeometry QgsGeometry::voronoiDiagram( const QgsGeometry &extent, double toler
|
|||||||
|
|
||||||
QgsGeos geos( d->geometry.get() );
|
QgsGeos geos( d->geometry.get() );
|
||||||
mLastError.clear();
|
mLastError.clear();
|
||||||
QgsGeometry result = geos.voronoiDiagram( extent.geometry(), tolerance, edgesOnly, &mLastError );
|
QgsGeometry result = geos.voronoiDiagram( extent.constGet(), tolerance, edgesOnly, &mLastError );
|
||||||
result.mLastError = mLastError;
|
result.mLastError = mLastError;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1873,7 +1879,7 @@ QgsGeometry QgsGeometry::interpolate( double distance ) const
|
|||||||
if ( type() == QgsWkbTypes::PolygonGeometry )
|
if ( type() == QgsWkbTypes::PolygonGeometry )
|
||||||
line = QgsGeometry( d->geometry->boundary() );
|
line = QgsGeometry( d->geometry->boundary() );
|
||||||
|
|
||||||
QgsGeos geos( line.geometry() );
|
QgsGeos geos( line.constGet() );
|
||||||
mLastError.clear();
|
mLastError.clear();
|
||||||
std::unique_ptr< QgsAbstractGeometry > result( geos.interpolate( distance, &mLastError ) );
|
std::unique_ptr< QgsAbstractGeometry > result( geos.interpolate( distance, &mLastError ) );
|
||||||
if ( !result )
|
if ( !result )
|
||||||
@ -1918,7 +1924,7 @@ double QgsGeometry::interpolateAngle( double distance ) const
|
|||||||
|
|
||||||
QgsVertexId previous;
|
QgsVertexId previous;
|
||||||
QgsVertexId next;
|
QgsVertexId next;
|
||||||
if ( !QgsGeometryUtils::verticesAtDistance( *segmentized.geometry(), distance, previous, next ) )
|
if ( !QgsGeometryUtils::verticesAtDistance( *segmentized.constGet(), distance, previous, next ) )
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
if ( previous == next )
|
if ( previous == next )
|
||||||
@ -1927,33 +1933,33 @@ double QgsGeometry::interpolateAngle( double distance ) const
|
|||||||
QgsVertexId v2 = previous;
|
QgsVertexId v2 = previous;
|
||||||
QgsVertexId v1;
|
QgsVertexId v1;
|
||||||
QgsVertexId v3;
|
QgsVertexId v3;
|
||||||
segmentized.geometry()->adjacentVertices( v2, v1, v3 );
|
segmentized.constGet()->adjacentVertices( v2, v1, v3 );
|
||||||
if ( v1.isValid() && v3.isValid() )
|
if ( v1.isValid() && v3.isValid() )
|
||||||
{
|
{
|
||||||
QgsPoint p1 = segmentized.geometry()->vertexAt( v1 );
|
QgsPoint p1 = segmentized.constGet()->vertexAt( v1 );
|
||||||
QgsPoint p2 = segmentized.geometry()->vertexAt( v2 );
|
QgsPoint p2 = segmentized.constGet()->vertexAt( v2 );
|
||||||
QgsPoint p3 = segmentized.geometry()->vertexAt( v3 );
|
QgsPoint p3 = segmentized.constGet()->vertexAt( v3 );
|
||||||
double angle1 = QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
double angle1 = QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
||||||
double angle2 = QgsGeometryUtils::lineAngle( p2.x(), p2.y(), p3.x(), p3.y() );
|
double angle2 = QgsGeometryUtils::lineAngle( p2.x(), p2.y(), p3.x(), p3.y() );
|
||||||
return QgsGeometryUtils::averageAngle( angle1, angle2 );
|
return QgsGeometryUtils::averageAngle( angle1, angle2 );
|
||||||
}
|
}
|
||||||
else if ( v3.isValid() )
|
else if ( v3.isValid() )
|
||||||
{
|
{
|
||||||
QgsPoint p1 = segmentized.geometry()->vertexAt( v2 );
|
QgsPoint p1 = segmentized.constGet()->vertexAt( v2 );
|
||||||
QgsPoint p2 = segmentized.geometry()->vertexAt( v3 );
|
QgsPoint p2 = segmentized.constGet()->vertexAt( v3 );
|
||||||
return QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
return QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsPoint p1 = segmentized.geometry()->vertexAt( v1 );
|
QgsPoint p1 = segmentized.constGet()->vertexAt( v1 );
|
||||||
QgsPoint p2 = segmentized.geometry()->vertexAt( v2 );
|
QgsPoint p2 = segmentized.constGet()->vertexAt( v2 );
|
||||||
return QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
return QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsPoint p1 = segmentized.geometry()->vertexAt( previous );
|
QgsPoint p1 = segmentized.constGet()->vertexAt( previous );
|
||||||
QgsPoint p2 = segmentized.geometry()->vertexAt( next );
|
QgsPoint p2 = segmentized.constGet()->vertexAt( next );
|
||||||
return QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
return QgsGeometryUtils::lineAngle( p1.x(), p1.y(), p2.x(), p2.y() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2152,7 +2158,7 @@ bool QgsGeometry::deletePart( int partNum )
|
|||||||
|
|
||||||
if ( !isMultipart() && partNum < 1 )
|
if ( !isMultipart() && partNum < 1 )
|
||||||
{
|
{
|
||||||
setGeometry( nullptr );
|
set( nullptr );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2250,7 +2256,7 @@ QgsGeometry QgsGeometry::polygonize( const QList<QgsGeometry> &geometryList )
|
|||||||
{
|
{
|
||||||
if ( !( g.isNull() ) )
|
if ( !( g.isNull() ) )
|
||||||
{
|
{
|
||||||
geomV2List.append( g.geometry() );
|
geomV2List.append( g.constGet() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3107,7 +3113,7 @@ QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry )
|
|||||||
in >> byteArray;
|
in >> byteArray;
|
||||||
if ( byteArray.isEmpty() )
|
if ( byteArray.isEmpty() )
|
||||||
{
|
{
|
||||||
geometry.setGeometry( nullptr );
|
geometry.set( nullptr );
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,18 +164,42 @@ class CORE_EXPORT QgsGeometry
|
|||||||
~QgsGeometry();
|
~QgsGeometry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the underlying geometry store.
|
* Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
|
||||||
* \since QGIS 2.10
|
*
|
||||||
* \see setGeometry
|
* This is much faster then calling the non-const get() method.
|
||||||
|
*
|
||||||
|
* \note In QGIS 2.x this method was named geometry().
|
||||||
|
*
|
||||||
|
* \since QGIS 3.0
|
||||||
|
* \see primitive()
|
||||||
|
* \see set()
|
||||||
*/
|
*/
|
||||||
QgsAbstractGeometry *geometry() const;
|
const QgsAbstractGeometry *constGet() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
|
||||||
|
*
|
||||||
|
* This method can be slow to call, as it may trigger a detachment of the geometry
|
||||||
|
* and a deep copy. Where possible, use constGet() instead.
|
||||||
|
*
|
||||||
|
* \note In QGIS 2.x this method was named geometry().
|
||||||
|
*
|
||||||
|
* \since QGIS 3.0
|
||||||
|
* \see constGet()
|
||||||
|
* \see set()
|
||||||
|
*/
|
||||||
|
QgsAbstractGeometry *get();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the underlying geometry store. Ownership of geometry is transferred.
|
* Sets the underlying geometry store. Ownership of geometry is transferred.
|
||||||
* \since QGIS 2.10
|
*
|
||||||
* \see geometry
|
* \note In QGIS 2.x this method was named setGeometry().
|
||||||
|
*
|
||||||
|
* \since QGIS 3.0
|
||||||
|
* \see get()
|
||||||
|
* \see constGet()
|
||||||
*/
|
*/
|
||||||
void setGeometry( QgsAbstractGeometry *geometry SIP_TRANSFER );
|
void set( QgsAbstractGeometry *geometry SIP_TRANSFER );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the geometry is null (ie, contains no underlying geometry
|
* Returns true if the geometry is null (ie, contains no underlying geometry
|
||||||
|
@ -80,7 +80,7 @@ QgsAbstractGeometry *QgsGeometryCollection::boundary() const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsGeometryCollection::adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex )
|
void QgsGeometryCollection::adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex ) const
|
||||||
{
|
{
|
||||||
if ( vertex.part < 0 || vertex.part >= mGeometries.count() )
|
if ( vertex.part < 0 || vertex.part >= mGeometries.count() )
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
|
|||||||
QString geometryType() const override;
|
QString geometryType() const override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
QgsAbstractGeometry *boundary() const override SIP_FACTORY;
|
QgsAbstractGeometry *boundary() const override SIP_FACTORY;
|
||||||
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) override;
|
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
|
||||||
int vertexNumberFromVertexId( QgsVertexId id ) const override;
|
int vertexNumberFromVertexId( QgsVertexId id ) const override;
|
||||||
|
|
||||||
//! Adds a geometry and takes ownership. Returns true in case of success.
|
//! Adds a geometry and takes ownership. Returns true in case of success.
|
||||||
|
@ -341,7 +341,7 @@ QgsAbstractGeometry *QgsGeos::combine( const QList<QgsGeometry> &geomList, QStri
|
|||||||
if ( !g )
|
if ( !g )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
geosGeometries << asGeos( g.geometry(), mPrecision ).release();
|
geosGeometries << asGeos( g.constGet(), mPrecision ).release();
|
||||||
}
|
}
|
||||||
|
|
||||||
geos::unique_ptr geomUnion;
|
geos::unique_ptr geomUnion;
|
||||||
@ -2043,7 +2043,7 @@ QgsGeometry QgsGeos::closestPoint( const QgsGeometry &other, QString *errorMsg )
|
|||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
geos::unique_ptr otherGeom( asGeos( other.geometry(), mPrecision ) );
|
geos::unique_ptr otherGeom( asGeos( other.constGet(), mPrecision ) );
|
||||||
if ( !otherGeom )
|
if ( !otherGeom )
|
||||||
{
|
{
|
||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
@ -2077,7 +2077,7 @@ QgsGeometry QgsGeos::shortestLine( const QgsGeometry &other, QString *errorMsg )
|
|||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
geos::unique_ptr otherGeom( asGeos( other.geometry(), mPrecision ) );
|
geos::unique_ptr otherGeom( asGeos( other.constGet(), mPrecision ) );
|
||||||
if ( !otherGeom )
|
if ( !otherGeom )
|
||||||
{
|
{
|
||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
QgsInternalGeometryEngine::QgsInternalGeometryEngine( const QgsGeometry &geometry )
|
QgsInternalGeometryEngine::QgsInternalGeometryEngine( const QgsGeometry &geometry )
|
||||||
: mGeometry( geometry.geometry() )
|
: mGeometry( geometry.constGet() )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ bool QgsPoint::nextVertex( QgsVertexId &id, QgsPoint &vertex ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsPoint::adjacentVertices( QgsVertexId, QgsVertexId &previousVertex, QgsVertexId &nextVertex )
|
void QgsPoint::adjacentVertices( QgsVertexId, QgsVertexId &previousVertex, QgsVertexId &nextVertex ) const
|
||||||
{
|
{
|
||||||
previousVertex = QgsVertexId();
|
previousVertex = QgsVertexId();
|
||||||
nextVertex = QgsVertexId();
|
nextVertex = QgsVertexId();
|
||||||
|
@ -415,7 +415,7 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
|
|||||||
|
|
||||||
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, bool *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
|
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, bool *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
|
||||||
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
|
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
|
||||||
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) override;
|
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Angle undefined. Always returns 0.0
|
* Angle undefined. Always returns 0.0
|
||||||
|
@ -52,7 +52,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour
|
|||||||
if ( !mFilterRect.isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect )
|
if ( !mFilterRect.isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect )
|
||||||
{
|
{
|
||||||
mSelectRectGeom = QgsGeometry::fromRect( mFilterRect );
|
mSelectRectGeom = QgsGeometry::fromRect( mFilterRect );
|
||||||
mSelectRectEngine.reset( QgsGeometry::createGeometryEngine( mSelectRectGeom.geometry() ) );
|
mSelectRectEngine.reset( QgsGeometry::createGeometryEngine( mSelectRectGeom.constGet() ) );
|
||||||
mSelectRectEngine->prepareGeometry();
|
mSelectRectEngine->prepareGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ bool QgsMemoryFeatureIterator::nextFeatureUsingList( QgsFeature &feature )
|
|||||||
if ( !mFilterRect.isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect )
|
if ( !mFilterRect.isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect )
|
||||||
{
|
{
|
||||||
// do exact check in case we're doing intersection
|
// do exact check in case we're doing intersection
|
||||||
if ( mSource->mFeatures.value( *mFeatureIdListIterator ).hasGeometry() && mSelectRectEngine->intersects( mSource->mFeatures.value( *mFeatureIdListIterator ).geometry().geometry() ) )
|
if ( mSource->mFeatures.value( *mFeatureIdListIterator ).hasGeometry() && mSelectRectEngine->intersects( mSource->mFeatures.value( *mFeatureIdListIterator ).geometry().constGet() ) )
|
||||||
hasFeature = true;
|
hasFeature = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -166,7 +166,7 @@ bool QgsMemoryFeatureIterator::nextFeatureTraverseAll( QgsFeature &feature )
|
|||||||
if ( mRequest.flags() & QgsFeatureRequest::ExactIntersect )
|
if ( mRequest.flags() & QgsFeatureRequest::ExactIntersect )
|
||||||
{
|
{
|
||||||
// using exact test when checking for intersection
|
// using exact test when checking for intersection
|
||||||
if ( mSelectIterator->hasGeometry() && mSelectRectEngine->intersects( mSelectIterator->geometry().geometry() ) )
|
if ( mSelectIterator->hasGeometry() && mSelectRectEngine->intersects( mSelectIterator->geometry().constGet() ) )
|
||||||
hasFeature = true;
|
hasFeature = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -180,7 +180,7 @@ double QgsDistanceArea::measureArea( const QgsGeometry &geometry ) const
|
|||||||
if ( geometry.isNull() )
|
if ( geometry.isNull() )
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
const QgsAbstractGeometry *geomV2 = geometry.geometry();
|
const QgsAbstractGeometry *geomV2 = geometry.constGet();
|
||||||
return measure( geomV2, Area );
|
return measure( geomV2, Area );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ double QgsDistanceArea::measureLength( const QgsGeometry &geometry ) const
|
|||||||
if ( geometry.isNull() )
|
if ( geometry.isNull() )
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
const QgsAbstractGeometry *geomV2 = geometry.geometry();
|
const QgsAbstractGeometry *geomV2 = geometry.constGet();
|
||||||
return measure( geomV2, Length );
|
return measure( geomV2, Length );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ double QgsDistanceArea::measurePerimeter( const QgsGeometry &geometry ) const
|
|||||||
if ( geometry.isNull() )
|
if ( geometry.isNull() )
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
const QgsAbstractGeometry *geomV2 = geometry.geometry();
|
const QgsAbstractGeometry *geomV2 = geometry.constGet();
|
||||||
if ( !geomV2 || geomV2->dimension() < 2 )
|
if ( !geomV2 || geomV2->dimension() < 2 )
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -93,7 +93,7 @@ QString QgsJsonExporter::exportFeature( const QgsFeature &feature, const QVarian
|
|||||||
}
|
}
|
||||||
QgsRectangle box = geom.boundingBox();
|
QgsRectangle box = geom.boundingBox();
|
||||||
|
|
||||||
if ( QgsWkbTypes::flatType( geom.geometry()->wkbType() ) != QgsWkbTypes::Point )
|
if ( QgsWkbTypes::flatType( geom.wkbType() ) != QgsWkbTypes::Point )
|
||||||
{
|
{
|
||||||
s += QStringLiteral( " \"bbox\":[%1, %2, %3, %4],\n" ).arg( qgsDoubleToString( box.xMinimum(), mPrecision ),
|
s += QStringLiteral( " \"bbox\":[%1, %2, %3, %4],\n" ).arg( qgsDoubleToString( box.xMinimum(), mPrecision ),
|
||||||
qgsDoubleToString( box.yMinimum(), mPrecision ),
|
qgsDoubleToString( box.yMinimum(), mPrecision ),
|
||||||
|
@ -133,7 +133,7 @@ void QgsMapHitTest::runHitTestLayer( QgsVectorLayer *vl, SymbolSet &usedSymbols,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
request.setFilterRect( transformedPolygon.boundingBox() );
|
request.setFilterRect( transformedPolygon.boundingBox() );
|
||||||
polygonEngine.reset( QgsGeometry::createGeometryEngine( transformedPolygon.geometry() ) );
|
polygonEngine.reset( QgsGeometry::createGeometryEngine( transformedPolygon.constGet() ) );
|
||||||
polygonEngine->prepareGeometry();
|
polygonEngine->prepareGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ void QgsMapHitTest::runHitTestLayer( QgsVectorLayer *vl, SymbolSet &usedSymbols,
|
|||||||
// filter out elements outside of the polygon
|
// filter out elements outside of the polygon
|
||||||
if ( f.geometry() && polygonEngine )
|
if ( f.geometry() && polygonEngine )
|
||||||
{
|
{
|
||||||
if ( !polygonEngine->intersects( f.geometry().geometry() ) )
|
if ( !polygonEngine->intersects( f.geometry().constGet() ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -269,11 +269,11 @@ QgsGeometry QgsMapToPixelSimplifier::simplifyGeometry(
|
|||||||
{
|
{
|
||||||
const QgsPolygonV2 &srcPolygon = dynamic_cast<const QgsPolygonV2 &>( geometry );
|
const QgsPolygonV2 &srcPolygon = dynamic_cast<const QgsPolygonV2 &>( geometry );
|
||||||
std::unique_ptr<QgsPolygonV2> polygon( new QgsPolygonV2() );
|
std::unique_ptr<QgsPolygonV2> polygon( new QgsPolygonV2() );
|
||||||
polygon->setExteriorRing( qgsgeometry_cast<QgsCurve *>( simplifyGeometry( simplifyFlags, simplifyAlgorithm, srcPolygon.exteriorRing()->wkbType(), *srcPolygon.exteriorRing(), envelope, map2pixelTol, true ).geometry()->clone() ) );
|
polygon->setExteriorRing( qgsgeometry_cast<QgsCurve *>( simplifyGeometry( simplifyFlags, simplifyAlgorithm, srcPolygon.exteriorRing()->wkbType(), *srcPolygon.exteriorRing(), envelope, map2pixelTol, true ).constGet()->clone() ) );
|
||||||
for ( int i = 0; i < srcPolygon.numInteriorRings(); ++i )
|
for ( int i = 0; i < srcPolygon.numInteriorRings(); ++i )
|
||||||
{
|
{
|
||||||
const QgsCurve *sub = srcPolygon.interiorRing( i );
|
const QgsCurve *sub = srcPolygon.interiorRing( i );
|
||||||
polygon->addInteriorRing( qgsgeometry_cast<QgsCurve *>( simplifyGeometry( simplifyFlags, simplifyAlgorithm, sub->wkbType(), *sub, envelope, map2pixelTol, true ).geometry()->clone() ) );
|
polygon->addInteriorRing( qgsgeometry_cast<QgsCurve *>( simplifyGeometry( simplifyFlags, simplifyAlgorithm, sub->wkbType(), *sub, envelope, map2pixelTol, true ).constGet()->clone() ) );
|
||||||
}
|
}
|
||||||
return QgsGeometry( polygon.release() );
|
return QgsGeometry( polygon.release() );
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ QgsGeometry QgsMapToPixelSimplifier::simplifyGeometry(
|
|||||||
for ( int i = 0; i < numGeoms; ++i )
|
for ( int i = 0; i < numGeoms; ++i )
|
||||||
{
|
{
|
||||||
const QgsAbstractGeometry *sub = srcCollection.geometryN( i );
|
const QgsAbstractGeometry *sub = srcCollection.geometryN( i );
|
||||||
collection->addGeometry( simplifyGeometry( simplifyFlags, simplifyAlgorithm, sub->wkbType(), *sub, envelope, map2pixelTol, false ).geometry()->clone() );
|
collection->addGeometry( simplifyGeometry( simplifyFlags, simplifyAlgorithm, sub->wkbType(), *sub, envelope, map2pixelTol, false ).constGet()->clone() );
|
||||||
}
|
}
|
||||||
return QgsGeometry( collection.release() );
|
return QgsGeometry( collection.release() );
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ QgsGeometry QgsMapToPixelSimplifier::simplify( const QgsGeometry &geometry ) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool isaLinearRing = flatType == QgsWkbTypes::Polygon;
|
const bool isaLinearRing = flatType == QgsWkbTypes::Polygon;
|
||||||
const int numPoints = geometry.geometry()->nCoordinates();
|
const int numPoints = geometry.constGet()->nCoordinates();
|
||||||
|
|
||||||
if ( numPoints <= ( isaLinearRing ? 6 : 3 ) )
|
if ( numPoints <= ( isaLinearRing ? 6 : 3 ) )
|
||||||
{
|
{
|
||||||
@ -335,5 +335,5 @@ QgsGeometry QgsMapToPixelSimplifier::simplify( const QgsGeometry &geometry ) con
|
|||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return simplifyGeometry( mSimplifyFlags, mSimplifyAlgorithm, geometry.wkbType(), *geometry.geometry(), envelope, mTolerance, false );
|
return simplifyGeometry( mSimplifyFlags, mSimplifyAlgorithm, geometry.wkbType(), *geometry.constGet(), envelope, mTolerance, false );
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1494,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
|||||||
if ( ( geom.type() == QgsWkbTypes::PolygonGeometry )
|
if ( ( geom.type() == QgsWkbTypes::PolygonGeometry )
|
||||||
&& ( placement == Line || placement == PerimeterCurved ) )
|
&& ( placement == Line || placement == PerimeterCurved ) )
|
||||||
{
|
{
|
||||||
geom = QgsGeometry( geom.geometry()->boundary() );
|
geom = QgsGeometry( geom.constGet()->boundary() );
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOSGeometry *geos_geom_clone = nullptr;
|
GEOSGeometry *geos_geom_clone = nullptr;
|
||||||
@ -1779,8 +1779,8 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
|
|||||||
if ( QgsPalLabeling::geometryRequiresPreparation( ddPoint, context, ct ) )
|
if ( QgsPalLabeling::geometryRequiresPreparation( ddPoint, context, ct ) )
|
||||||
{
|
{
|
||||||
ddPoint = QgsPalLabeling::prepareGeometry( ddPoint, context, ct );
|
ddPoint = QgsPalLabeling::prepareGeometry( ddPoint, context, ct );
|
||||||
xPos = static_cast< QgsPoint * >( ddPoint.geometry() )->x();
|
xPos = static_cast< const QgsPoint * >( ddPoint.constGet() )->x();
|
||||||
yPos = static_cast< QgsPoint * >( ddPoint.geometry() )->y();
|
yPos = static_cast< const QgsPoint * >( ddPoint.constGet() )->y();
|
||||||
}
|
}
|
||||||
|
|
||||||
xPos += xdiff;
|
xPos += xdiff;
|
||||||
|
@ -414,16 +414,16 @@ void extractLinework( const QgsGeometry &g, QgsMultiPolyline &mpl )
|
|||||||
QgsGeometry geom = g;
|
QgsGeometry geom = g;
|
||||||
// segmentize curved geometries - we will use noding algorithm from GEOS
|
// segmentize curved geometries - we will use noding algorithm from GEOS
|
||||||
// to find all intersections a bit later (so we need them segmentized anyway)
|
// to find all intersections a bit later (so we need them segmentized anyway)
|
||||||
if ( QgsWkbTypes::isCurvedType( g.geometry()->wkbType() ) )
|
if ( QgsWkbTypes::isCurvedType( g.wkbType() ) )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *segmentizedGeomV2 = g.geometry()->segmentize();
|
QgsAbstractGeometry *segmentizedGeomV2 = g.constGet()->segmentize();
|
||||||
if ( !segmentizedGeomV2 )
|
if ( !segmentizedGeomV2 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
geom = QgsGeometry( segmentizedGeomV2 );
|
geom = QgsGeometry( segmentizedGeomV2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( QgsWkbTypes::flatType( geom.geometry()->wkbType() ) )
|
switch ( QgsWkbTypes::flatType( geom.wkbType() ) )
|
||||||
{
|
{
|
||||||
case QgsWkbTypes::LineString:
|
case QgsWkbTypes::LineString:
|
||||||
mpl << geom.asPolyline();
|
mpl << geom.asPolyline();
|
||||||
|
@ -692,7 +692,7 @@ QgsGeometry QgsVectorDataProvider::convertToProviderType( const QgsGeometry &geo
|
|||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAbstractGeometry *geometry = geom.geometry();
|
const QgsAbstractGeometry *geometry = geom.constGet();
|
||||||
if ( !geometry )
|
if ( !geometry )
|
||||||
{
|
{
|
||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
|
@ -2109,13 +2109,13 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature &feature )
|
|||||||
QgsGeometry geom = feature.geometry();
|
QgsGeometry geom = feature.geometry();
|
||||||
|
|
||||||
// turn single geometry to multi geometry if needed
|
// turn single geometry to multi geometry if needed
|
||||||
if ( QgsWkbTypes::flatType( geom.geometry()->wkbType() ) != QgsWkbTypes::flatType( mWkbType ) &&
|
if ( QgsWkbTypes::flatType( geom.wkbType() ) != QgsWkbTypes::flatType( mWkbType ) &&
|
||||||
QgsWkbTypes::flatType( geom.geometry()->wkbType() ) == QgsWkbTypes::flatType( QgsWkbTypes::singleType( mWkbType ) ) )
|
QgsWkbTypes::flatType( geom.wkbType() ) == QgsWkbTypes::flatType( QgsWkbTypes::singleType( mWkbType ) ) )
|
||||||
{
|
{
|
||||||
geom.convertToMultiType();
|
geom.convertToMultiType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( geom.geometry()->wkbType() != mWkbType )
|
if ( geom.wkbType() != mWkbType )
|
||||||
{
|
{
|
||||||
OGRGeometryH mGeom2 = nullptr;
|
OGRGeometryH mGeom2 = nullptr;
|
||||||
|
|
||||||
@ -2127,10 +2127,10 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature &feature )
|
|||||||
//so the exported WKB has a different type to what the OGRGeometry is expecting.
|
//so the exported WKB has a different type to what the OGRGeometry is expecting.
|
||||||
//possibly this is handled already in OGR, but it should be fixed regardless by actually converting
|
//possibly this is handled already in OGR, but it should be fixed regardless by actually converting
|
||||||
//geom to the correct WKB type
|
//geom to the correct WKB type
|
||||||
QgsWkbTypes::Type wkbType = geom.geometry()->wkbType();
|
QgsWkbTypes::Type wkbType = geom.wkbType();
|
||||||
if ( wkbType >= QgsWkbTypes::PointZ && wkbType <= QgsWkbTypes::MultiPolygonZ )
|
if ( wkbType >= QgsWkbTypes::PointZ && wkbType <= QgsWkbTypes::MultiPolygonZ )
|
||||||
{
|
{
|
||||||
QgsWkbTypes::Type wkbType25d = static_cast<QgsWkbTypes::Type>( geom.geometry()->wkbType() - QgsWkbTypes::PointZ + QgsWkbTypes::Point25D );
|
QgsWkbTypes::Type wkbType25d = static_cast<QgsWkbTypes::Type>( geom.wkbType() - QgsWkbTypes::PointZ + QgsWkbTypes::Point25D );
|
||||||
mGeom2 = createEmptyGeometry( wkbType25d );
|
mGeom2 = createEmptyGeometry( wkbType25d );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2145,7 +2145,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature &feature )
|
|||||||
//
|
//
|
||||||
// Btw. OGRGeometry must be exactly of the type of the geometry which it will receive
|
// Btw. OGRGeometry must be exactly of the type of the geometry which it will receive
|
||||||
// i.e. Polygons can't be imported to OGRMultiPolygon
|
// i.e. Polygons can't be imported to OGRMultiPolygon
|
||||||
mGeom2 = createEmptyGeometry( geom.geometry()->wkbType() );
|
mGeom2 = createEmptyGeometry( geom.wkbType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !mGeom2 )
|
if ( !mGeom2 )
|
||||||
@ -2431,7 +2431,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fet.hasGeometry() && QgsWkbTypes::isMultiType( fet.geometry().geometry()->wkbType() ) )
|
if ( fet.hasGeometry() && QgsWkbTypes::isMultiType( fet.geometry().wkbType() ) )
|
||||||
{
|
{
|
||||||
destWkbType = QgsWkbTypes::multiType( destWkbType );
|
destWkbType = QgsWkbTypes::multiType( destWkbType );
|
||||||
break;
|
break;
|
||||||
@ -2526,7 +2526,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer,
|
|||||||
req.setFilterRect( filterRect );
|
req.setFilterRect( filterRect );
|
||||||
}
|
}
|
||||||
filterRectGeometry = QgsGeometry::fromRect( options.filterExtent );
|
filterRectGeometry = QgsGeometry::fromRect( options.filterExtent );
|
||||||
filterRectEngine.reset( QgsGeometry::createGeometryEngine( filterRectGeometry.geometry() ) );
|
filterRectEngine.reset( QgsGeometry::createGeometryEngine( filterRectGeometry.constGet() ) );
|
||||||
filterRectEngine->prepareGeometry();
|
filterRectEngine->prepareGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2613,7 +2613,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fet.hasGeometry() && filterRectEngine && !filterRectEngine->intersects( fet.geometry().geometry() ) )
|
if ( fet.hasGeometry() && filterRectEngine && !filterRectEngine->intersects( fet.geometry().constGet() ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( attributes.empty() && options.skipAttributeCreation )
|
if ( attributes.empty() && options.skipAttributeCreation )
|
||||||
|
@ -105,10 +105,10 @@ QgsVectorLayer::EditResult QgsVectorLayerEditUtils::deleteVertex( QgsFeatureId f
|
|||||||
if ( !geometry.deleteVertex( vertex ) )
|
if ( !geometry.deleteVertex( vertex ) )
|
||||||
return QgsVectorLayer::EditFailed;
|
return QgsVectorLayer::EditFailed;
|
||||||
|
|
||||||
if ( geometry.geometry() && geometry.geometry()->nCoordinates() == 0 )
|
if ( geometry.constGet() && geometry.constGet()->nCoordinates() == 0 )
|
||||||
{
|
{
|
||||||
//last vertex deleted, set geometry to null
|
//last vertex deleted, set geometry to null
|
||||||
geometry.setGeometry( nullptr );
|
geometry.set( nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
mLayer->editBuffer()->changeGeometry( featureId, geometry );
|
mLayer->editBuffer()->changeGeometry( featureId, geometry );
|
||||||
|
@ -266,16 +266,16 @@ QgsGeometry QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &f
|
|||||||
if ( !fet.hasGeometry() || fet.geometry().type() != QgsWkbTypes::PointGeometry )
|
if ( !fet.hasGeometry() || fet.geometry().type() != QgsWkbTypes::PointGeometry )
|
||||||
return QgsGeometry();
|
return QgsGeometry();
|
||||||
|
|
||||||
bool isMultiPoint = fet.geometry().geometry()->nCoordinates() > 1;
|
bool isMultiPoint = fet.geometry().constGet()->nCoordinates() > 1;
|
||||||
QgsAbstractGeometry *obstacleGeom = nullptr;
|
QgsAbstractGeometry *obstacleGeom = nullptr;
|
||||||
if ( isMultiPoint )
|
if ( isMultiPoint )
|
||||||
obstacleGeom = new QgsMultiPolygonV2();
|
obstacleGeom = new QgsMultiPolygonV2();
|
||||||
|
|
||||||
// for each point
|
// for each point
|
||||||
for ( int i = 0; i < fet.geometry().geometry()->nCoordinates(); ++i )
|
for ( int i = 0; i < fet.geometry().constGet()->nCoordinates(); ++i )
|
||||||
{
|
{
|
||||||
QRectF bounds;
|
QRectF bounds;
|
||||||
QgsPoint p = fet.geometry().geometry()->vertexAt( QgsVertexId( i, 0, 0 ) );
|
QgsPoint p = fet.geometry().constGet()->vertexAt( QgsVertexId( i, 0, 0 ) );
|
||||||
double x = p.x();
|
double x = p.x();
|
||||||
double y = p.y();
|
double y = p.y();
|
||||||
double z = 0; // dummy variable for coordinate transforms
|
double z = 0; // dummy variable for coordinate transforms
|
||||||
|
@ -3415,8 +3415,8 @@ void QgsCentroidFillSymbolLayer::renderPolygon( const QPolygonF &points, QList<Q
|
|||||||
|
|
||||||
if ( context.geometryPartCount() > 1 )
|
if ( context.geometryPartCount() > 1 )
|
||||||
{
|
{
|
||||||
QgsGeometry geom = feature->geometry();
|
const QgsGeometry geom = feature->geometry();
|
||||||
const QgsGeometryCollection *geomCollection = static_cast<const QgsGeometryCollection *>( geom.geometry() );
|
const QgsGeometryCollection *geomCollection = static_cast<const QgsGeometryCollection *>( geom.constGet() );
|
||||||
|
|
||||||
double area = 0;
|
double area = 0;
|
||||||
double areaBiggest = 0;
|
double areaBiggest = 0;
|
||||||
|
@ -285,7 +285,7 @@ void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext &context )
|
|||||||
Q_FOREACH ( const QgsGeometry &geom, cit.geometries )
|
Q_FOREACH ( const QgsGeometry &geom, cit.geometries )
|
||||||
{
|
{
|
||||||
QgsMultiPolygon multi;
|
QgsMultiPolygon multi;
|
||||||
QgsWkbTypes::Type type = QgsWkbTypes::flatType( geom.geometry()->wkbType() );
|
QgsWkbTypes::Type type = QgsWkbTypes::flatType( geom.constGet()->wkbType() );
|
||||||
|
|
||||||
if ( ( type == QgsWkbTypes::Polygon ) || ( type == QgsWkbTypes::CurvePolygon ) )
|
if ( ( type == QgsWkbTypes::Polygon ) || ( type == QgsWkbTypes::CurvePolygon ) )
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ void QgsPointDistanceRenderer::drawGroup( const ClusteredGroup &group, QgsRender
|
|||||||
QgsMultiPointV2 *groupMultiPoint = new QgsMultiPointV2();
|
QgsMultiPointV2 *groupMultiPoint = new QgsMultiPointV2();
|
||||||
Q_FOREACH ( const GroupedFeature &f, group )
|
Q_FOREACH ( const GroupedFeature &f, group )
|
||||||
{
|
{
|
||||||
groupMultiPoint->addGeometry( f.feature.geometry().geometry()->clone() );
|
groupMultiPoint->addGeometry( f.feature.geometry().constGet()->clone() );
|
||||||
}
|
}
|
||||||
QgsGeometry groupGeom( groupMultiPoint );
|
QgsGeometry groupGeom( groupMultiPoint );
|
||||||
QgsGeometry centroid = groupGeom.centroid();
|
QgsGeometry centroid = groupGeom.centroid();
|
||||||
|
@ -674,7 +674,7 @@ class ExpressionContextScopePopper
|
|||||||
|
|
||||||
void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker, int currentVertexMarkerType, int currentVertexMarkerSize )
|
void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker, int currentVertexMarkerType, int currentVertexMarkerSize )
|
||||||
{
|
{
|
||||||
QgsGeometry geom = feature.geometry();
|
const QgsGeometry geom = feature.geometry();
|
||||||
if ( geom.isNull() )
|
if ( geom.isNull() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -682,14 +682,14 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
|
|
||||||
QgsGeometry segmentizedGeometry = geom;
|
QgsGeometry segmentizedGeometry = geom;
|
||||||
bool usingSegmentizedGeometry = false;
|
bool usingSegmentizedGeometry = false;
|
||||||
context.setGeometry( geom.geometry() );
|
context.setGeometry( geom.constGet() );
|
||||||
|
|
||||||
bool tileMapRendering = context.testFlag( QgsRenderContext::RenderMapTile );
|
bool tileMapRendering = context.testFlag( QgsRenderContext::RenderMapTile );
|
||||||
|
|
||||||
//convert curve types to normal point/line/polygon ones
|
//convert curve types to normal point/line/polygon ones
|
||||||
if ( QgsWkbTypes::isCurvedType( geom.geometry()->wkbType() ) )
|
if ( QgsWkbTypes::isCurvedType( geom.constGet()->wkbType() ) )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *g = geom.geometry()->segmentize( context.segmentationTolerance(), context.segmentationToleranceType() );
|
QgsAbstractGeometry *g = geom.constGet()->segmentize( context.segmentationTolerance(), context.segmentationToleranceType() );
|
||||||
if ( !g )
|
if ( !g )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -698,7 +698,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
usingSegmentizedGeometry = true;
|
usingSegmentizedGeometry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSymbolRenderContext->setGeometryPartCount( segmentizedGeometry.geometry()->partCount() );
|
mSymbolRenderContext->setGeometryPartCount( segmentizedGeometry.constGet()->partCount() );
|
||||||
mSymbolRenderContext->setGeometryPartNum( 1 );
|
mSymbolRenderContext->setGeometryPartNum( 1 );
|
||||||
|
|
||||||
ExpressionContextScopePopper scopePopper;
|
ExpressionContextScopePopper scopePopper;
|
||||||
@ -729,7 +729,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
segmentizedGeometry = simplifier.simplify( segmentizedGeometry );
|
segmentizedGeometry = simplifier.simplify( segmentizedGeometry );
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( QgsWkbTypes::flatType( segmentizedGeometry.geometry()->wkbType() ) )
|
switch ( QgsWkbTypes::flatType( segmentizedGeometry.constGet()->wkbType() ) )
|
||||||
{
|
{
|
||||||
case QgsWkbTypes::Point:
|
case QgsWkbTypes::Point:
|
||||||
{
|
{
|
||||||
@ -739,7 +739,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QgsPoint *point = static_cast< const QgsPoint * >( segmentizedGeometry.geometry() );
|
const QgsPoint *point = static_cast< const QgsPoint * >( segmentizedGeometry.constGet() );
|
||||||
const QPointF pt = _getPoint( context, *point );
|
const QPointF pt = _getPoint( context, *point );
|
||||||
static_cast<QgsMarkerSymbol *>( this )->renderPoint( pt, &feature, context, layer, selected );
|
static_cast<QgsMarkerSymbol *>( this )->renderPoint( pt, &feature, context, layer, selected );
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
QgsDebugMsg( "linestring can be drawn only with line symbol!" );
|
QgsDebugMsg( "linestring can be drawn only with line symbol!" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const QgsCurve &curve = dynamic_cast<const QgsCurve &>( *segmentizedGeometry.geometry() );
|
const QgsCurve &curve = dynamic_cast<const QgsCurve &>( *segmentizedGeometry.constGet() );
|
||||||
const QPolygonF pts = _getLineString( context, curve, !tileMapRendering && clipFeaturesToExtent() );
|
const QPolygonF pts = _getLineString( context, curve, !tileMapRendering && clipFeaturesToExtent() );
|
||||||
static_cast<QgsLineSymbol *>( this )->renderPolyline( pts, &feature, context, layer, selected );
|
static_cast<QgsLineSymbol *>( this )->renderPolyline( pts, &feature, context, layer, selected );
|
||||||
|
|
||||||
@ -784,7 +784,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
QgsDebugMsg( "polygon can be drawn only with fill symbol!" );
|
QgsDebugMsg( "polygon can be drawn only with fill symbol!" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const QgsPolygonV2 &polygon = dynamic_cast<const QgsPolygonV2 &>( *segmentizedGeometry.geometry() );
|
const QgsPolygonV2 &polygon = dynamic_cast<const QgsPolygonV2 &>( *segmentizedGeometry.constGet() );
|
||||||
if ( !polygon.exteriorRing() )
|
if ( !polygon.exteriorRing() )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( "cannot render polygon with no exterior ring" );
|
QgsDebugMsg( "cannot render polygon with no exterior ring" );
|
||||||
@ -813,7 +813,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QgsMultiPointV2 &mp = static_cast< const QgsMultiPointV2 & >( *segmentizedGeometry.geometry() );
|
const QgsMultiPointV2 &mp = static_cast< const QgsMultiPointV2 & >( *segmentizedGeometry.constGet() );
|
||||||
|
|
||||||
if ( drawVertexMarker && !usingSegmentizedGeometry )
|
if ( drawVertexMarker && !usingSegmentizedGeometry )
|
||||||
{
|
{
|
||||||
@ -846,7 +846,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QgsGeometryCollection &geomCollection = dynamic_cast<const QgsGeometryCollection &>( *segmentizedGeometry.geometry() );
|
const QgsGeometryCollection &geomCollection = dynamic_cast<const QgsGeometryCollection &>( *segmentizedGeometry.constGet() );
|
||||||
|
|
||||||
const unsigned int num = geomCollection.numGeometries();
|
const unsigned int num = geomCollection.numGeometries();
|
||||||
for ( unsigned int i = 0; i < num; ++i )
|
for ( unsigned int i = 0; i < num; ++i )
|
||||||
@ -886,7 +886,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
QPolygonF pts;
|
QPolygonF pts;
|
||||||
QList<QPolygonF> holes;
|
QList<QPolygonF> holes;
|
||||||
|
|
||||||
const QgsGeometryCollection &geomCollection = dynamic_cast<const QgsGeometryCollection &>( *segmentizedGeometry.geometry() );
|
const QgsGeometryCollection &geomCollection = dynamic_cast<const QgsGeometryCollection &>( *segmentizedGeometry.constGet() );
|
||||||
const unsigned int num = geomCollection.numGeometries();
|
const unsigned int num = geomCollection.numGeometries();
|
||||||
|
|
||||||
// Sort components by approximate area (probably a bit faster than using
|
// Sort components by approximate area (probably a bit faster than using
|
||||||
@ -939,7 +939,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
}
|
}
|
||||||
case QgsWkbTypes::GeometryCollection:
|
case QgsWkbTypes::GeometryCollection:
|
||||||
{
|
{
|
||||||
const QgsGeometryCollection &geomCollection = dynamic_cast<const QgsGeometryCollection &>( *segmentizedGeometry.geometry() );
|
const QgsGeometryCollection &geomCollection = dynamic_cast<const QgsGeometryCollection &>( *segmentizedGeometry.constGet() );
|
||||||
if ( geomCollection.numGeometries() == 0 )
|
if ( geomCollection.numGeometries() == 0 )
|
||||||
{
|
{
|
||||||
// skip noise from empty geometry collections from simplification
|
// skip noise from empty geometry collections from simplification
|
||||||
@ -951,7 +951,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
default:
|
default:
|
||||||
QgsDebugMsg( QString( "feature %1: unsupported wkb type %2/%3 for rendering" )
|
QgsDebugMsg( QString( "feature %1: unsupported wkb type %2/%3 for rendering" )
|
||||||
.arg( feature.id() )
|
.arg( feature.id() )
|
||||||
.arg( QgsWkbTypes::displayString( geom.geometry()->wkbType() ) )
|
.arg( QgsWkbTypes::displayString( geom.constGet()->wkbType() ) )
|
||||||
.arg( geom.wkbType(), 0, 16 ) );
|
.arg( geom.wkbType(), 0, 16 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +973,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
|
|||||||
QgsVertexId vertexId;
|
QgsVertexId vertexId;
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
QPointF mapPoint;
|
QPointF mapPoint;
|
||||||
while ( geom.geometry()->nextVertex( vertexId, vertexPoint ) )
|
while ( geom.constGet()->nextVertex( vertexId, vertexPoint ) )
|
||||||
{
|
{
|
||||||
//transform
|
//transform
|
||||||
x = vertexPoint.x();
|
x = vertexPoint.x();
|
||||||
|
@ -146,7 +146,7 @@ void QgsExpressionSelectionDialog::mButtonZoomToFeatures_clicked()
|
|||||||
while ( features.nextFeature( feat ) )
|
while ( features.nextFeature( feat ) )
|
||||||
{
|
{
|
||||||
QgsGeometry geom = feat.geometry();
|
QgsGeometry geom = feat.geometry();
|
||||||
if ( geom.isNull() || geom.geometry()->isEmpty() )
|
if ( geom.isNull() || geom.constGet()->isEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QgsRectangle r = mMapCanvas->mapSettings().layerExtentToOutputExtent( mLayer, geom.boundingBox() );
|
QgsRectangle r = mMapCanvas->mapSettings().layerExtentToOutputExtent( mLayer, geom.boundingBox() );
|
||||||
|
@ -1018,7 +1018,7 @@ bool QgsMapCanvas::boundingBoxOfFeatureIds( const QgsFeatureIds &ids, QgsVectorL
|
|||||||
{
|
{
|
||||||
errorMsg = tr( "Feature does not have a geometry" );
|
errorMsg = tr( "Feature does not have a geometry" );
|
||||||
}
|
}
|
||||||
else if ( geom.geometry()->isEmpty() )
|
else if ( geom.constGet()->isEmpty() )
|
||||||
{
|
{
|
||||||
errorMsg = tr( "Feature geometry is empty" );
|
errorMsg = tr( "Feature geometry is empty" );
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ int QgsMapToolCapture::fetchLayerPoint( const QgsPointLocator::Match &match, Qgs
|
|||||||
QgsVertexId vId;
|
QgsVertexId vId;
|
||||||
if ( !f.geometry().vertexIdFromVertexNr( match.vertexIndex(), vId ) )
|
if ( !f.geometry().vertexIdFromVertexNr( match.vertexIndex(), vId ) )
|
||||||
return 2;
|
return 2;
|
||||||
layerPoint = f.geometry().geometry()->vertexAt( vId );
|
layerPoint = f.geometry().constGet()->vertexAt( vId );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -376,14 +376,14 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
|
|||||||
if ( feature->hasGeometry() )
|
if ( feature->hasGeometry() )
|
||||||
{
|
{
|
||||||
geometryType = feature->geometry().type();
|
geometryType = feature->geometry().type();
|
||||||
wkbType = feature->geometry().geometry()->wkbType();
|
wkbType = feature->geometry().wkbType();
|
||||||
//find closest vertex to clicked point
|
//find closest vertex to clicked point
|
||||||
closestPoint = QgsGeometryUtils::closestVertex( *feature->geometry().geometry(), QgsPoint( layerPoint.x(), layerPoint.y() ), vId );
|
closestPoint = QgsGeometryUtils::closestVertex( *feature->geometry().constGet(), QgsPoint( layerPoint.x(), layerPoint.y() ), vId );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( QgsWkbTypes::isMultiType( wkbType ) )
|
if ( QgsWkbTypes::isMultiType( wkbType ) )
|
||||||
{
|
{
|
||||||
QString str = QLocale::system().toString( static_cast<const QgsGeometryCollection *>( feature->geometry().geometry() )->numGeometries() );
|
QString str = QLocale::system().toString( static_cast<const QgsGeometryCollection *>( feature->geometry().constGet() )->numGeometries() );
|
||||||
derivedAttributes.insert( tr( "Parts" ), str );
|
derivedAttributes.insert( tr( "Parts" ), str );
|
||||||
str = QLocale::system().toString( vId.part + 1 );
|
str = QLocale::system().toString( vId.part + 1 );
|
||||||
derivedAttributes.insert( tr( "Part number" ), str );
|
derivedAttributes.insert( tr( "Part number" ), str );
|
||||||
@ -396,7 +396,7 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
|
|||||||
QString str = formatDistance( dist );
|
QString str = formatDistance( dist );
|
||||||
derivedAttributes.insert( tr( "Length" ), str );
|
derivedAttributes.insert( tr( "Length" ), str );
|
||||||
|
|
||||||
const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( feature->geometry().geometry() );
|
const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( feature->geometry().constGet() );
|
||||||
if ( curve )
|
if ( curve )
|
||||||
{
|
{
|
||||||
str = QLocale::system().toString( curve->nCoordinates() );
|
str = QLocale::system().toString( curve->nCoordinates() );
|
||||||
@ -431,11 +431,11 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
|
|||||||
str = formatDistance( perimeter );
|
str = formatDistance( perimeter );
|
||||||
derivedAttributes.insert( tr( "Perimeter" ), str );
|
derivedAttributes.insert( tr( "Perimeter" ), str );
|
||||||
|
|
||||||
str = QLocale::system().toString( feature->geometry().geometry()->nCoordinates() );
|
str = QLocale::system().toString( feature->geometry().constGet()->nCoordinates() );
|
||||||
derivedAttributes.insert( tr( "Vertices" ), str );
|
derivedAttributes.insert( tr( "Vertices" ), str );
|
||||||
|
|
||||||
//add details of closest vertex to identify point
|
//add details of closest vertex to identify point
|
||||||
closestVertexAttributes( *feature->geometry().geometry(), vId, layer, derivedAttributes );
|
closestVertexAttributes( *feature->geometry().constGet(), vId, layer, derivedAttributes );
|
||||||
}
|
}
|
||||||
else if ( geometryType == QgsWkbTypes::PointGeometry &&
|
else if ( geometryType == QgsWkbTypes::PointGeometry &&
|
||||||
QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
|
QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
|
||||||
@ -449,12 +449,12 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
|
|||||||
|
|
||||||
if ( QgsWkbTypes::hasZ( wkbType ) )
|
if ( QgsWkbTypes::hasZ( wkbType ) )
|
||||||
{
|
{
|
||||||
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().geometry() )->z(), 'g', 10 );
|
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->z(), 'g', 10 );
|
||||||
derivedAttributes.insert( QStringLiteral( "Z" ), str );
|
derivedAttributes.insert( QStringLiteral( "Z" ), str );
|
||||||
}
|
}
|
||||||
if ( QgsWkbTypes::hasM( wkbType ) )
|
if ( QgsWkbTypes::hasM( wkbType ) )
|
||||||
{
|
{
|
||||||
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().geometry() )->m(), 'g', 10 );
|
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->m(), 'g', 10 );
|
||||||
derivedAttributes.insert( QStringLiteral( "M" ), str );
|
derivedAttributes.insert( QStringLiteral( "M" ), str );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1206,7 +1206,7 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
|
|||||||
}
|
}
|
||||||
QgsFeature feature = mEditBuffer->addedFeatures().value( fid );
|
QgsFeature feature = mEditBuffer->addedFeatures().value( fid );
|
||||||
QgsGeometry featureGeometry = feature.geometry();
|
QgsGeometry featureGeometry = feature.geometry();
|
||||||
geometry = featureGeometry.geometry();
|
geometry = featureGeometry.constGet();
|
||||||
if ( !geometry )
|
if ( !geometry )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( "geometry is null" );
|
QgsDebugMsg( "geometry is null" );
|
||||||
@ -1222,7 +1222,7 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
|
|||||||
if ( wkbType == QgsWkbTypes::Polygon )
|
if ( wkbType == QgsWkbTypes::Polygon )
|
||||||
{
|
{
|
||||||
QgsGeometry addedFeatureGeom = addedFeatures[fid].geometry();
|
QgsGeometry addedFeatureGeom = addedFeatures[fid].geometry();
|
||||||
const QgsPolygonV2 *polygon = dynamic_cast<const QgsPolygonV2 *>( addedFeatureGeom.geometry() );
|
const QgsPolygonV2 *polygon = dynamic_cast<const QgsPolygonV2 *>( addedFeatureGeom.constGet() );
|
||||||
if ( polygon )
|
if ( polygon )
|
||||||
{
|
{
|
||||||
QgsLineString *lineString = polygon->exteriorRing()->curveToLine();
|
QgsLineString *lineString = polygon->exteriorRing()->curveToLine();
|
||||||
@ -1662,7 +1662,7 @@ void QgsGrassProvider::onGeometryChanged( QgsFeatureId fid, const QgsGeometry &g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPoints( mPoints, geom.geometry() );
|
setPoints( mPoints, geom.constGet() );
|
||||||
|
|
||||||
mLayer->map()->lockReadWrite();
|
mLayer->map()->lockReadWrite();
|
||||||
// Vect_rewrite_line may delete/write the line with a new id
|
// Vect_rewrite_line may delete/write the line with a new id
|
||||||
|
@ -1254,7 +1254,7 @@ namespace QgsWfs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *abstractGeom = geom.geometry();
|
const QgsAbstractGeometry *abstractGeom = geom.constGet();
|
||||||
if ( abstractGeom )
|
if ( abstractGeom )
|
||||||
{
|
{
|
||||||
gmlElem = abstractGeom->asGML2( doc, prec, "http://www.opengis.net/gml" );
|
gmlElem = abstractGeom->asGML2( doc, prec, "http://www.opengis.net/gml" );
|
||||||
@ -1355,7 +1355,7 @@ namespace QgsWfs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *abstractGeom = geom.geometry();
|
const QgsAbstractGeometry *abstractGeom = geom.constGet();
|
||||||
if ( abstractGeom )
|
if ( abstractGeom )
|
||||||
{
|
{
|
||||||
gmlElem = abstractGeom->asGML3( doc, prec, "http://www.opengis.net/gml" );
|
gmlElem = abstractGeom->asGML3( doc, prec, "http://www.opengis.net/gml" );
|
||||||
|
@ -1613,13 +1613,13 @@ namespace QgsWms
|
|||||||
|
|
||||||
if ( segmentizeWktGeometry )
|
if ( segmentizeWktGeometry )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *abstractGeom = geom.geometry();
|
const QgsAbstractGeometry *abstractGeom = geom.constGet();
|
||||||
if ( abstractGeom )
|
if ( abstractGeom )
|
||||||
{
|
{
|
||||||
if ( QgsWkbTypes::isCurvedType( abstractGeom->wkbType() ) )
|
if ( QgsWkbTypes::isCurvedType( abstractGeom->wkbType() ) )
|
||||||
{
|
{
|
||||||
QgsAbstractGeometry *segmentizedGeom = abstractGeom->segmentize();
|
QgsAbstractGeometry *segmentizedGeom = abstractGeom->segmentize();
|
||||||
geom.setGeometry( segmentizedGeom );
|
geom.set( segmentizedGeom );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1911,7 +1911,7 @@ void TestQgsProcessing::parameterExtent()
|
|||||||
QGSCOMPARENEAR( ext.yMinimum(), 30.151856, 0.01 );
|
QGSCOMPARENEAR( ext.yMinimum(), 30.151856, 0.01 );
|
||||||
QGSCOMPARENEAR( ext.yMaximum(), 30.257289, 0.01 );
|
QGSCOMPARENEAR( ext.yMaximum(), 30.257289, 0.01 );
|
||||||
QgsGeometry gExt = QgsProcessingParameters::parameterAsExtentGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:4326" ) );
|
QgsGeometry gExt = QgsProcessingParameters::parameterAsExtentGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:4326" ) );
|
||||||
QCOMPARE( gExt.geometry()->vertexCount(), 85 );
|
QCOMPARE( gExt.constGet()->vertexCount(), 85 );
|
||||||
ext = gExt.boundingBox();
|
ext = gExt.boundingBox();
|
||||||
QGSCOMPARENEAR( ext.xMinimum(), 17.924273, 0.01 );
|
QGSCOMPARENEAR( ext.xMinimum(), 17.924273, 0.01 );
|
||||||
QGSCOMPARENEAR( ext.xMaximum(), 18.045658, 0.01 );
|
QGSCOMPARENEAR( ext.xMaximum(), 18.045658, 0.01 );
|
||||||
@ -1948,7 +1948,7 @@ void TestQgsProcessing::parameterExtent()
|
|||||||
QGSCOMPARENEAR( ext.yMinimum(), 244963, 100 );
|
QGSCOMPARENEAR( ext.yMinimum(), 244963, 100 );
|
||||||
QGSCOMPARENEAR( ext.yMaximum(), 490287, 100 );
|
QGSCOMPARENEAR( ext.yMaximum(), 490287, 100 );
|
||||||
gExt = QgsProcessingParameters::parameterAsExtentGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
|
gExt = QgsProcessingParameters::parameterAsExtentGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
|
||||||
QCOMPARE( gExt.geometry()->vertexCount(), 85 );
|
QCOMPARE( gExt.constGet()->vertexCount(), 85 );
|
||||||
ext = gExt.boundingBox();
|
ext = gExt.boundingBox();
|
||||||
QGSCOMPARENEAR( ext.xMinimum(), 122451, 100 );
|
QGSCOMPARENEAR( ext.xMinimum(), 122451, 100 );
|
||||||
QGSCOMPARENEAR( ext.xMaximum(), 367354, 100 );
|
QGSCOMPARENEAR( ext.xMaximum(), 367354, 100 );
|
||||||
@ -1998,7 +1998,7 @@ void TestQgsProcessing::parameterExtent()
|
|||||||
|
|
||||||
// as reprojected geometry
|
// as reprojected geometry
|
||||||
gExt = QgsProcessingParameters::parameterAsExtentGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
|
gExt = QgsProcessingParameters::parameterAsExtentGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
|
||||||
QCOMPARE( gExt.geometry()->vertexCount(), 85 );
|
QCOMPARE( gExt.constGet()->vertexCount(), 85 );
|
||||||
ext = gExt.boundingBox();
|
ext = gExt.boundingBox();
|
||||||
QGSCOMPARENEAR( ext.xMinimum(), 122451, 100 );
|
QGSCOMPARENEAR( ext.xMinimum(), 122451, 100 );
|
||||||
QGSCOMPARENEAR( ext.xMaximum(), 367354, 100 );
|
QGSCOMPARENEAR( ext.xMaximum(), 367354, 100 );
|
||||||
|
@ -205,14 +205,14 @@ void TestQgisAppClipboard::pasteWkt()
|
|||||||
QgsFeatureList features = mQgisApp->clipboard()->copyOf();
|
QgsFeatureList features = mQgisApp->clipboard()->copyOf();
|
||||||
QCOMPARE( features.length(), 2 );
|
QCOMPARE( features.length(), 2 );
|
||||||
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 0 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
QgsGeometry featureGeom = features.at( 0 ).geometry();
|
QgsGeometry featureGeom = features.at( 0 ).geometry();
|
||||||
const QgsPoint *point = dynamic_cast< QgsPoint * >( featureGeom.geometry() );
|
const QgsPoint *point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
|
||||||
QCOMPARE( point->x(), 125.0 );
|
QCOMPARE( point->x(), 125.0 );
|
||||||
QCOMPARE( point->y(), 10.0 );
|
QCOMPARE( point->y(), 10.0 );
|
||||||
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
|
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 1 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
point = dynamic_cast< QgsPoint * >( features.at( 1 ).geometry().geometry() );
|
point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() );
|
||||||
QCOMPARE( point->x(), 111.0 );
|
QCOMPARE( point->x(), 111.0 );
|
||||||
QCOMPARE( point->y(), 30.0 );
|
QCOMPARE( point->y(), 30.0 );
|
||||||
|
|
||||||
@ -224,15 +224,15 @@ void TestQgisAppClipboard::pasteWkt()
|
|||||||
QCOMPARE( features.length(), 2 );
|
QCOMPARE( features.length(), 2 );
|
||||||
|
|
||||||
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 0 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
featureGeom = features.at( 0 ).geometry();
|
featureGeom = features.at( 0 ).geometry();
|
||||||
point = dynamic_cast< QgsPoint * >( featureGeom.geometry() );
|
point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
|
||||||
QCOMPARE( point->x(), 111.0 );
|
QCOMPARE( point->x(), 111.0 );
|
||||||
QCOMPARE( point->y(), 30.0 );
|
QCOMPARE( point->y(), 30.0 );
|
||||||
|
|
||||||
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
|
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 1 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
point = dynamic_cast< QgsPoint * >( features.at( 1 ).geometry().geometry() );
|
point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() );
|
||||||
QCOMPARE( point->x(), 125.0 );
|
QCOMPARE( point->x(), 125.0 );
|
||||||
QCOMPARE( point->y(), 10.0 );
|
QCOMPARE( point->y(), 10.0 );
|
||||||
|
|
||||||
@ -251,9 +251,9 @@ void TestQgisAppClipboard::pasteGeoJson()
|
|||||||
QgsFeatureList features = mQgisApp->clipboard()->copyOf( fields );
|
QgsFeatureList features = mQgisApp->clipboard()->copyOf( fields );
|
||||||
QCOMPARE( features.length(), 1 );
|
QCOMPARE( features.length(), 1 );
|
||||||
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 0 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
QgsGeometry featureGeom = features.at( 0 ).geometry();
|
QgsGeometry featureGeom = features.at( 0 ).geometry();
|
||||||
const QgsPoint *point = dynamic_cast< QgsPoint * >( featureGeom.geometry() );
|
const QgsPoint *point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
|
||||||
QCOMPARE( point->x(), 125.0 );
|
QCOMPARE( point->x(), 125.0 );
|
||||||
QCOMPARE( point->y(), 10.0 );
|
QCOMPARE( point->y(), 10.0 );
|
||||||
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
|
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
|
||||||
|
@ -116,7 +116,7 @@ void TestQgsConnectionPool::layersFromSameDatasetGPX()
|
|||||||
for ( int i = 0, n = layer1Features.count(); i < n; ++i )
|
for ( int i = 0, n = layer1Features.count(); i < n; ++i )
|
||||||
{
|
{
|
||||||
QgsGeometry featureGeom = layer1Features[i].geometry();
|
QgsGeometry featureGeom = layer1Features[i].geometry();
|
||||||
const QgsPoint *geom = dynamic_cast<const QgsPoint *>( featureGeom.geometry() );
|
const QgsPoint *geom = dynamic_cast<const QgsPoint *>( featureGeom.constGet() );
|
||||||
QVERIFY( geom );
|
QVERIFY( geom );
|
||||||
QVERIFY( qFuzzyCompare( geom->x(), i ) );
|
QVERIFY( qFuzzyCompare( geom->x(), i ) );
|
||||||
QVERIFY( qFuzzyCompare( geom->y(), i ) );
|
QVERIFY( qFuzzyCompare( geom->y(), i ) );
|
||||||
@ -124,7 +124,7 @@ void TestQgsConnectionPool::layersFromSameDatasetGPX()
|
|||||||
for ( int i = 0, n = layer2Features.count(); i < n; ++i )
|
for ( int i = 0, n = layer2Features.count(); i < n; ++i )
|
||||||
{
|
{
|
||||||
QgsGeometry featureGeom = layer2Features[i].geometry();
|
QgsGeometry featureGeom = layer2Features[i].geometry();
|
||||||
const QgsLineString *geom = dynamic_cast<const QgsLineString *>( featureGeom.geometry() );
|
const QgsLineString *geom = dynamic_cast<const QgsLineString *>( featureGeom.constGet() );
|
||||||
QVERIFY( geom );
|
QVERIFY( geom );
|
||||||
int nVtx = geom->vertexCount();
|
int nVtx = geom->vertexCount();
|
||||||
QVERIFY( nVtx == nRoutePts );
|
QVERIFY( nVtx == nRoutePts );
|
||||||
|
@ -322,74 +322,74 @@ void TestQgsGeometry::copy()
|
|||||||
{
|
{
|
||||||
//create a point geometry
|
//create a point geometry
|
||||||
QgsGeometry original( new QgsPoint( 1.0, 2.0 ) );
|
QgsGeometry original( new QgsPoint( 1.0, 2.0 ) );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//implicitly shared copy
|
//implicitly shared copy
|
||||||
QgsGeometry copy( original );
|
QgsGeometry copy( original );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//trigger a detach
|
//trigger a detach
|
||||||
copy.setGeometry( new QgsPoint( 3.0, 4.0 ) );
|
copy.set( new QgsPoint( 3.0, 4.0 ) );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 3.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 3.0 );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 4.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 4.0 );
|
||||||
|
|
||||||
//make sure original was untouched
|
//make sure original was untouched
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsGeometry::assignment()
|
void TestQgsGeometry::assignment()
|
||||||
{
|
{
|
||||||
//create a point geometry
|
//create a point geometry
|
||||||
QgsGeometry original( new QgsPoint( 1.0, 2.0 ) );
|
QgsGeometry original( new QgsPoint( 1.0, 2.0 ) );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//assign to implicitly shared copy
|
//assign to implicitly shared copy
|
||||||
QgsGeometry copy;
|
QgsGeometry copy;
|
||||||
copy = original;
|
copy = original;
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//trigger a detach
|
//trigger a detach
|
||||||
copy.setGeometry( new QgsPoint( 3.0, 4.0 ) );
|
copy.set( new QgsPoint( 3.0, 4.0 ) );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 3.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 3.0 );
|
||||||
QCOMPARE( copy.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 4.0 );
|
QCOMPARE( copy.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 4.0 );
|
||||||
|
|
||||||
//make sure original was untouched
|
//make sure original was untouched
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsGeometry::asVariant()
|
void TestQgsGeometry::asVariant()
|
||||||
{
|
{
|
||||||
//create a point geometry
|
//create a point geometry
|
||||||
QgsGeometry original( new QgsPoint( 1.0, 2.0 ) );
|
QgsGeometry original( new QgsPoint( 1.0, 2.0 ) );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( original.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( original.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//convert to and from a QVariant
|
//convert to and from a QVariant
|
||||||
QVariant var = QVariant::fromValue( original );
|
QVariant var = QVariant::fromValue( original );
|
||||||
QVERIFY( var.isValid() );
|
QVERIFY( var.isValid() );
|
||||||
|
|
||||||
QgsGeometry fromVar = qvariant_cast<QgsGeometry>( var );
|
QgsGeometry fromVar = qvariant_cast<QgsGeometry>( var );
|
||||||
QCOMPARE( fromVar.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( fromVar.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( fromVar.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( fromVar.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//also check copying variant
|
//also check copying variant
|
||||||
QVariant var2 = var;
|
QVariant var2 = var;
|
||||||
QVERIFY( var2.isValid() );
|
QVERIFY( var2.isValid() );
|
||||||
QgsGeometry fromVar2 = qvariant_cast<QgsGeometry>( var2 );
|
QgsGeometry fromVar2 = qvariant_cast<QgsGeometry>( var2 );
|
||||||
QCOMPARE( fromVar2.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( fromVar2.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( fromVar2.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( fromVar2.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
|
|
||||||
//modify original and check detachment
|
//modify original and check detachment
|
||||||
original.setGeometry( new QgsPoint( 3.0, 4.0 ) );
|
original.set( new QgsPoint( 3.0, 4.0 ) );
|
||||||
QgsGeometry fromVar3 = qvariant_cast<QgsGeometry>( var );
|
QgsGeometry fromVar3 = qvariant_cast<QgsGeometry>( var );
|
||||||
QCOMPARE( fromVar3.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
QCOMPARE( fromVar3.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 );
|
||||||
QCOMPARE( fromVar3.geometry()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
QCOMPARE( fromVar3.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).y(), 2.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsGeometry::isEmpty()
|
void TestQgsGeometry::isEmpty()
|
||||||
@ -397,10 +397,10 @@ void TestQgsGeometry::isEmpty()
|
|||||||
QgsGeometry geom;
|
QgsGeometry geom;
|
||||||
QVERIFY( geom.isNull() );
|
QVERIFY( geom.isNull() );
|
||||||
|
|
||||||
geom.setGeometry( new QgsPoint( 1.0, 2.0 ) );
|
geom.set( new QgsPoint( 1.0, 2.0 ) );
|
||||||
QVERIFY( !geom.isNull() );
|
QVERIFY( !geom.isNull() );
|
||||||
|
|
||||||
geom.setGeometry( 0 );
|
geom.set( 0 );
|
||||||
QVERIFY( geom.isNull() );
|
QVERIFY( geom.isNull() );
|
||||||
|
|
||||||
QgsGeometryCollection collection;
|
QgsGeometryCollection collection;
|
||||||
@ -412,10 +412,10 @@ void TestQgsGeometry::operatorBool()
|
|||||||
QgsGeometry geom;
|
QgsGeometry geom;
|
||||||
QVERIFY( !geom );
|
QVERIFY( !geom );
|
||||||
|
|
||||||
geom.setGeometry( new QgsPoint( 1.0, 2.0 ) );
|
geom.set( new QgsPoint( 1.0, 2.0 ) );
|
||||||
QVERIFY( geom );
|
QVERIFY( geom );
|
||||||
|
|
||||||
geom.setGeometry( 0 );
|
geom.set( 0 );
|
||||||
QVERIFY( !geom );
|
QVERIFY( !geom );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15099,10 +15099,10 @@ void TestQgsGeometry::intersectionCheck1()
|
|||||||
{
|
{
|
||||||
QVERIFY( mpPolygonGeometryA.intersects( mpPolygonGeometryB ) );
|
QVERIFY( mpPolygonGeometryA.intersects( mpPolygonGeometryB ) );
|
||||||
|
|
||||||
std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( mpPolygonGeometryA.geometry() ) );
|
std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( mpPolygonGeometryA.constGet() ) );
|
||||||
QVERIFY( engine->intersects( mpPolygonGeometryB.geometry() ) );
|
QVERIFY( engine->intersects( mpPolygonGeometryB.constGet() ) );
|
||||||
engine->prepareGeometry();
|
engine->prepareGeometry();
|
||||||
QVERIFY( engine->intersects( mpPolygonGeometryB.geometry() ) );
|
QVERIFY( engine->intersects( mpPolygonGeometryB.constGet() ) );
|
||||||
|
|
||||||
// should be a single polygon as A intersect B
|
// should be a single polygon as A intersect B
|
||||||
QgsGeometry mypIntersectionGeometry = mpPolygonGeometryA.intersection( mpPolygonGeometryB );
|
QgsGeometry mypIntersectionGeometry = mpPolygonGeometryA.intersection( mpPolygonGeometryB );
|
||||||
@ -15389,7 +15389,7 @@ void TestQgsGeometry::dataStream()
|
|||||||
ds.device()->seek( 0 );
|
ds.device()->seek( 0 );
|
||||||
ds >> resultGeometry;
|
ds >> resultGeometry;
|
||||||
|
|
||||||
QCOMPARE( geom.geometry()->asWkt(), resultGeometry.geometry()->asWkt() );
|
QCOMPARE( geom.constGet()->asWkt(), resultGeometry.constGet()->asWkt() );
|
||||||
|
|
||||||
//also test with geometry without data
|
//also test with geometry without data
|
||||||
std::unique_ptr<QgsGeometry> emptyGeom( new QgsGeometry() );
|
std::unique_ptr<QgsGeometry> emptyGeom( new QgsGeometry() );
|
||||||
@ -15863,7 +15863,7 @@ void TestQgsGeometry::minimalEnclosingCircle()
|
|||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QCOMPARE( center, QgsPointXY( 5, 5 ) );
|
QCOMPARE( center, QgsPointXY( 5, 5 ) );
|
||||||
QCOMPARE( radius, 0.0 );
|
QCOMPARE( radius, 0.0 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
// case 2
|
// case 2
|
||||||
@ -15871,35 +15871,35 @@ void TestQgsGeometry::minimalEnclosingCircle()
|
|||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 5, 6 ), 0.0001 );
|
QGSCOMPARENEARPOINT( center, QgsPointXY( 5, 6 ), 0.0001 );
|
||||||
QGSCOMPARENEAR( radius, sqrt( 2 ) * 2, 0.0001 );
|
QGSCOMPARENEAR( radius, sqrt( 2 ) * 2, 0.0001 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING( 0 5, 2 2, 0 -5, -1 -1 )" ) );
|
geomTest = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING( 0 5, 2 2, 0 -5, -1 -1 )" ) );
|
||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 2 2, 0 -5, -1 -1 )" ) );
|
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 2 2, 0 -5, -1 -1 )" ) );
|
||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 5, 2 2, 0 -5, -1 -1 ))" ) );
|
geomTest = QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 5, 2 2, 0 -5, -1 -1 ))" ) );
|
||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 0 -5, 0 0 )" ) );
|
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 0 -5, 0 0 )" ) );
|
||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
// case 3
|
// case 3
|
||||||
@ -15907,7 +15907,7 @@ void TestQgsGeometry::minimalEnclosingCircle()
|
|||||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0.8333, 0.8333 ), 0.0001 );
|
QGSCOMPARENEARPOINT( center, QgsPointXY( 0.8333, 0.8333 ), 0.0001 );
|
||||||
QGSCOMPARENEAR( radius, 5.8926, 0.0001 );
|
QGSCOMPARENEAR( radius, 5.8926, 0.0001 );
|
||||||
resultTest.setGeometry( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||||
QCOMPARE( result, resultTest );
|
QCOMPARE( result, resultTest );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,8 @@ void TestQgsOgrUtils::ogrGeometryToQgsGeometry()
|
|||||||
|
|
||||||
QgsGeometry geom = QgsOgrUtils::ogrGeometryToQgsGeometry( ogrGeom );
|
QgsGeometry geom = QgsOgrUtils::ogrGeometryToQgsGeometry( ogrGeom );
|
||||||
QVERIFY( !geom.isNull() );
|
QVERIFY( !geom.isNull() );
|
||||||
QCOMPARE( geom.geometry()->wkbType(), QgsWkbTypes::LineString );
|
QCOMPARE( geom.constGet()->wkbType(), QgsWkbTypes::LineString );
|
||||||
QCOMPARE( geom.geometry()->nCoordinates(), 71 );
|
QCOMPARE( geom.constGet()->nCoordinates(), 71 );
|
||||||
|
|
||||||
OGR_F_Destroy( oFeat );
|
OGR_F_Destroy( oFeat );
|
||||||
OGR_DS_Destroy( hDS );
|
OGR_DS_Destroy( hDS );
|
||||||
@ -124,8 +124,8 @@ void TestQgsOgrUtils::readOgrFeatureGeometry()
|
|||||||
|
|
||||||
QgsOgrUtils::readOgrFeatureGeometry( oFeat, f );
|
QgsOgrUtils::readOgrFeatureGeometry( oFeat, f );
|
||||||
QVERIFY( f.hasGeometry() );
|
QVERIFY( f.hasGeometry() );
|
||||||
QCOMPARE( f.geometry().geometry()->wkbType(), QgsWkbTypes::LineString );
|
QCOMPARE( f.geometry().constGet()->wkbType(), QgsWkbTypes::LineString );
|
||||||
QCOMPARE( f.geometry().geometry()->nCoordinates(), 71 );
|
QCOMPARE( f.geometry().constGet()->nCoordinates(), 71 );
|
||||||
|
|
||||||
OGR_F_Destroy( oFeat );
|
OGR_F_Destroy( oFeat );
|
||||||
OGR_DS_Destroy( hDS );
|
OGR_DS_Destroy( hDS );
|
||||||
@ -273,8 +273,8 @@ void TestQgsOgrUtils::readOgrFeature()
|
|||||||
QCOMPARE( f.attribute( "datetime_field" ), QVariant( QDateTime( QDate( 2005, 3, 5 ), QTime( 6, 45, 0 ) ) ) );
|
QCOMPARE( f.attribute( "datetime_field" ), QVariant( QDateTime( QDate( 2005, 3, 5 ), QTime( 6, 45, 0 ) ) ) );
|
||||||
QCOMPARE( f.attribute( "string_field" ), QVariant( "a string" ) );
|
QCOMPARE( f.attribute( "string_field" ), QVariant( "a string" ) );
|
||||||
QVERIFY( f.hasGeometry() );
|
QVERIFY( f.hasGeometry() );
|
||||||
QCOMPARE( f.geometry().geometry()->wkbType(), QgsWkbTypes::LineString );
|
QCOMPARE( f.geometry().constGet()->wkbType(), QgsWkbTypes::LineString );
|
||||||
QCOMPARE( f.geometry().geometry()->nCoordinates(), 71 );
|
QCOMPARE( f.geometry().constGet()->nCoordinates(), 71 );
|
||||||
|
|
||||||
OGR_F_Destroy( oFeat );
|
OGR_F_Destroy( oFeat );
|
||||||
OGR_DS_Destroy( hDS );
|
OGR_DS_Destroy( hDS );
|
||||||
@ -331,9 +331,9 @@ void TestQgsOgrUtils::stringToFeatureList()
|
|||||||
features = QgsOgrUtils::stringToFeatureList( QStringLiteral( "{\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [125, 10]},\"properties\": {\"name\": \"Dinagat Islands\"}}" ), fields, QTextCodec::codecForName( "System" ) );
|
features = QgsOgrUtils::stringToFeatureList( QStringLiteral( "{\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [125, 10]},\"properties\": {\"name\": \"Dinagat Islands\"}}" ), fields, QTextCodec::codecForName( "System" ) );
|
||||||
QCOMPARE( features.length(), 1 );
|
QCOMPARE( features.length(), 1 );
|
||||||
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 0 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
QgsGeometry featureGeom = features.at( 0 ).geometry();
|
QgsGeometry featureGeom = features.at( 0 ).geometry();
|
||||||
const QgsPoint *point = dynamic_cast< QgsPoint * >( featureGeom.geometry() );
|
const QgsPoint *point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
|
||||||
QCOMPARE( point->x(), 125.0 );
|
QCOMPARE( point->x(), 125.0 );
|
||||||
QCOMPARE( point->y(), 10.0 );
|
QCOMPARE( point->y(), 10.0 );
|
||||||
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
|
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
|
||||||
@ -343,16 +343,16 @@ void TestQgsOgrUtils::stringToFeatureList()
|
|||||||
" {\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [110, 20]},\"properties\": {\"name\": \"Henry Gale Island\"}}]}", fields, QTextCodec::codecForName( "System" ) );
|
" {\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [110, 20]},\"properties\": {\"name\": \"Henry Gale Island\"}}]}", fields, QTextCodec::codecForName( "System" ) );
|
||||||
QCOMPARE( features.length(), 2 );
|
QCOMPARE( features.length(), 2 );
|
||||||
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 0 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
featureGeom = features.at( 0 ).geometry();
|
featureGeom = features.at( 0 ).geometry();
|
||||||
point = dynamic_cast< QgsPoint * >( featureGeom.geometry() );
|
point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
|
||||||
QCOMPARE( point->x(), 125.0 );
|
QCOMPARE( point->x(), 125.0 );
|
||||||
QCOMPARE( point->y(), 10.0 );
|
QCOMPARE( point->y(), 10.0 );
|
||||||
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
|
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
|
||||||
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
|
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
|
||||||
QCOMPARE( features.at( 1 ).geometry().geometry()->wkbType(), QgsWkbTypes::Point );
|
QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
|
||||||
featureGeom = features.at( 1 ).geometry();
|
featureGeom = features.at( 1 ).geometry();
|
||||||
point = dynamic_cast< QgsPoint * >( featureGeom.geometry() );
|
point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
|
||||||
QCOMPARE( point->x(), 110.0 );
|
QCOMPARE( point->x(), 110.0 );
|
||||||
QCOMPARE( point->y(), 20.0 );
|
QCOMPARE( point->y(), 20.0 );
|
||||||
QCOMPARE( features.at( 1 ).attribute( "name" ).toString(), QString( "Henry Gale Island" ) );
|
QCOMPARE( features.at( 1 ).attribute( "name" ).toString(), QString( "Henry Gale Island" ) );
|
||||||
|
@ -286,7 +286,7 @@ class TestQgsPointLocator : public QObject
|
|||||||
QgsVectorLayer *vlEmptyGeom = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) );
|
QgsVectorLayer *vlEmptyGeom = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) );
|
||||||
QgsFeature ff( 0 );
|
QgsFeature ff( 0 );
|
||||||
QgsGeometry g;
|
QgsGeometry g;
|
||||||
g.setGeometry( new QgsPolygonV2() );
|
g.set( new QgsPolygonV2() );
|
||||||
ff.setGeometry( g );
|
ff.setGeometry( g );
|
||||||
QgsFeatureList flist;
|
QgsFeatureList flist;
|
||||||
flist << ff;
|
flist << ff;
|
||||||
|
@ -141,21 +141,21 @@ void TestQgsGeometryChecks::testAngleCheck()
|
|||||||
int n1, n2;
|
int n1, n2;
|
||||||
|
|
||||||
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
||||||
n1 = f.geometry().geometry()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
n1 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
||||||
QVERIFY( fixCheckError( errs1[0],
|
QVERIFY( fixCheckError( errs1[0],
|
||||||
QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed,
|
QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed,
|
||||||
{{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) );
|
{{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) );
|
||||||
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
||||||
n2 = f.geometry().geometry()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
n2 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
||||||
QCOMPARE( n1, n2 + 1 );
|
QCOMPARE( n1, n2 + 1 );
|
||||||
|
|
||||||
context->featurePools[errs2[0]->layerId()]->get( errs2[0]->featureId(), f );
|
context->featurePools[errs2[0]->layerId()]->get( errs2[0]->featureId(), f );
|
||||||
n1 = f.geometry().geometry()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring );
|
n1 = f.geometry().constGet()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring );
|
||||||
QVERIFY( fixCheckError( errs2[0],
|
QVERIFY( fixCheckError( errs2[0],
|
||||||
QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed,
|
QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed,
|
||||||
{{errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx()}} ) );
|
{{errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx()}} ) );
|
||||||
context->featurePools[errs2[0]->layerId()]->get( errs2[0]->featureId(), f );
|
context->featurePools[errs2[0]->layerId()]->get( errs2[0]->featureId(), f );
|
||||||
n2 = f.geometry().geometry()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring );
|
n2 = f.geometry().constGet()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring );
|
||||||
QCOMPARE( n1, n2 + 1 );
|
QCOMPARE( n1, n2 + 1 );
|
||||||
|
|
||||||
// Test change tracking
|
// Test change tracking
|
||||||
@ -455,12 +455,12 @@ void TestQgsGeometryChecks::testDuplicateNodesCheck()
|
|||||||
QgsFeature f;
|
QgsFeature f;
|
||||||
|
|
||||||
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
||||||
int n1 = f.geometry().geometry()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
int n1 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
||||||
QVERIFY( fixCheckError( errs1[0],
|
QVERIFY( fixCheckError( errs1[0],
|
||||||
QgsGeometryDuplicateNodesCheck::RemoveDuplicates, QgsGeometryCheckError::StatusFixed,
|
QgsGeometryDuplicateNodesCheck::RemoveDuplicates, QgsGeometryCheckError::StatusFixed,
|
||||||
{{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) );
|
{{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) );
|
||||||
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
||||||
int n2 = f.geometry().geometry()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
int n2 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring );
|
||||||
QCOMPARE( n1, n2 + 1 );
|
QCOMPARE( n1, n2 + 1 );
|
||||||
|
|
||||||
cleanupTestContext( context );
|
cleanupTestContext( context );
|
||||||
@ -562,7 +562,7 @@ void TestQgsGeometryChecks::testHoleCheck()
|
|||||||
{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0, 1 )}
|
{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0, 1 )}
|
||||||
} ) );
|
} ) );
|
||||||
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
||||||
QVERIFY( f.geometry().geometry()->ringCount( 0 ) == 1 );
|
QVERIFY( f.geometry().constGet()->ringCount( 0 ) == 1 );
|
||||||
|
|
||||||
cleanupTestContext( context );
|
cleanupTestContext( context );
|
||||||
}
|
}
|
||||||
@ -867,11 +867,11 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck()
|
|||||||
{errs1[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId()}
|
{errs1[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId()}
|
||||||
} ) );
|
} ) );
|
||||||
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
context->featurePools[errs1[0]->layerId()]->get( errs1[0]->featureId(), f );
|
||||||
QCOMPARE( f.geometry().geometry()->partCount(), 1 );
|
QCOMPARE( f.geometry().constGet()->partCount(), 1 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount(), 4 );
|
QCOMPARE( f.geometry().constGet()->vertexCount(), 4 );
|
||||||
context->featurePools[errs1[0]->layerId()]->get( nextId, f );
|
context->featurePools[errs1[0]->layerId()]->get( nextId, f );
|
||||||
QCOMPARE( f.geometry().geometry()->partCount(), 1 );
|
QCOMPARE( f.geometry().constGet()->partCount(), 1 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount(), 6 );
|
QCOMPARE( f.geometry().constGet()->vertexCount(), 6 );
|
||||||
|
|
||||||
QVERIFY( fixCheckError( errs2[0],
|
QVERIFY( fixCheckError( errs2[0],
|
||||||
QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed,
|
QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed,
|
||||||
@ -881,9 +881,9 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck()
|
|||||||
{errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 )}
|
{errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 )}
|
||||||
} ) );
|
} ) );
|
||||||
context->featurePools[errs2[0]->layerId()]->get( errs2[0]->featureId(), f );
|
context->featurePools[errs2[0]->layerId()]->get( errs2[0]->featureId(), f );
|
||||||
QCOMPARE( f.geometry().geometry()->partCount(), 2 );
|
QCOMPARE( f.geometry().constGet()->partCount(), 2 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount( 0 ), 4 );
|
QCOMPARE( f.geometry().constGet()->vertexCount( 0 ), 4 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount( 1 ), 5 );
|
QCOMPARE( f.geometry().constGet()->vertexCount( 1 ), 5 );
|
||||||
|
|
||||||
nextId = context->featurePools[errs3[0]->layerId()]->getLayer()->featureCount();
|
nextId = context->featurePools[errs3[0]->layerId()]->getLayer()->featureCount();
|
||||||
QVERIFY( fixCheckError( errs3[0],
|
QVERIFY( fixCheckError( errs3[0],
|
||||||
@ -893,11 +893,11 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck()
|
|||||||
{errs3[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId()}
|
{errs3[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId()}
|
||||||
} ) );
|
} ) );
|
||||||
context->featurePools[errs3[0]->layerId()]->get( errs3[0]->featureId(), f );
|
context->featurePools[errs3[0]->layerId()]->get( errs3[0]->featureId(), f );
|
||||||
QCOMPARE( f.geometry().geometry()->partCount(), 1 );
|
QCOMPARE( f.geometry().constGet()->partCount(), 1 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount(), 6 );
|
QCOMPARE( f.geometry().constGet()->vertexCount(), 6 );
|
||||||
context->featurePools[errs3[0]->layerId()]->get( nextId, f );
|
context->featurePools[errs3[0]->layerId()]->get( nextId, f );
|
||||||
QCOMPARE( f.geometry().geometry()->partCount(), 1 );
|
QCOMPARE( f.geometry().constGet()->partCount(), 1 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount(), 4 );
|
QCOMPARE( f.geometry().constGet()->vertexCount(), 4 );
|
||||||
|
|
||||||
QVERIFY( fixCheckError( errs4[0],
|
QVERIFY( fixCheckError( errs4[0],
|
||||||
QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed,
|
QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed,
|
||||||
@ -907,12 +907,12 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck()
|
|||||||
{errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 )}
|
{errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 )}
|
||||||
} ) );
|
} ) );
|
||||||
context->featurePools[errs4[0]->layerId()]->get( errs4[0]->featureId(), f );
|
context->featurePools[errs4[0]->layerId()]->get( errs4[0]->featureId(), f );
|
||||||
QCOMPARE( f.geometry().geometry()->partCount(), 2 );
|
QCOMPARE( f.geometry().constGet()->partCount(), 2 );
|
||||||
QCOMPARE( f.geometry().geometry()->ringCount( 0 ), 1 );
|
QCOMPARE( f.geometry().constGet()->ringCount( 0 ), 1 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount( 0, 0 ), 5 );
|
QCOMPARE( f.geometry().constGet()->vertexCount( 0, 0 ), 5 );
|
||||||
QCOMPARE( f.geometry().geometry()->ringCount( 1 ), 2 );
|
QCOMPARE( f.geometry().constGet()->ringCount( 1 ), 2 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount( 1, 0 ), 5 );
|
QCOMPARE( f.geometry().constGet()->vertexCount( 1, 0 ), 5 );
|
||||||
QCOMPARE( f.geometry().geometry()->vertexCount( 1, 1 ), 5 );
|
QCOMPARE( f.geometry().constGet()->vertexCount( 1, 1 ), 5 );
|
||||||
|
|
||||||
// Test change tracking
|
// Test change tracking
|
||||||
QgsGeometrySelfIntersectionCheckError *err = static_cast<QgsGeometrySelfIntersectionCheckError *>( errs4[0] );
|
QgsGeometrySelfIntersectionCheckError *err = static_cast<QgsGeometrySelfIntersectionCheckError *>( errs4[0] );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user