Skip to content
Permalink
Browse files

Rename QgsPolygon to QgsPolygonXY

  • Loading branch information
m-kuhn committed Oct 29, 2017
1 parent 48f26e5 commit becf86cf6cdf463439bdc461af36d92688e22f61
Showing with 142 additions and 142 deletions.
  1. +12 −12 python/core/geometry/qgsgeometry.sip
  2. +1 −1 python/core/symbology/qgssymbol.sip
  3. +1 −1 src/app/qgsmaptooldeletepart.cpp
  4. +4 −4 src/app/qgsmaptooldeletering.cpp
  5. +2 −2 src/app/qgsmaptoolfillring.cpp
  6. +2 −2 src/app/qgsmaptooloffsetcurve.cpp
  7. +2 −2 src/app/qgsmaptoolselectutils.cpp
  8. +1 −1 src/app/qgsmaptoolsimplify.cpp
  9. +23 −23 src/core/geometry/qgsgeometry.cpp
  10. +14 −14 src/core/geometry/qgsgeometry.h
  11. +1 −1 src/core/geometry/qgsgeometryfactory.cpp
  12. +3 −3 src/core/geometry/qgsgeometryfactory.h
  13. +1 −1 src/core/geometry/qgsrectangle.cpp
  14. +1 −1 src/core/qgsgeometryvalidator.cpp
  15. +1 −1 src/core/qgsgeometryvalidator.h
  16. +3 −3 src/core/qgsogcutils.cpp
  17. +1 −1 src/core/qgstracer.cpp
  18. +2 −2 src/core/qgsvectorlayereditutils.cpp
  19. +1 −1 src/core/symbology/qgsinvertedpolygonrenderer.cpp
  20. +1 −1 src/core/symbology/qgsinvertedpolygonrenderer.h
  21. +1 −1 src/core/symbology/qgssymbol.h
  22. +3 −3 src/core/symbology/qgssymbollayerutils.cpp
  23. +1 −1 src/gui/qgshighlight.cpp
  24. +1 −1 src/gui/qgshighlight.h
  25. +3 −3 src/gui/qgsrubberband.cpp
  26. +3 −3 src/plugins/topology/topolTest.cpp
  27. +2 −2 src/providers/grass/qgis.v.in.cpp
  28. +1 −1 src/providers/grass/qgsgrassgislib.cpp
  29. +1 −1 tests/src/app/testqgsattributetable.cpp
  30. +1 −1 tests/src/app/testqgsfieldcalculator.cpp
  31. +2 −2 tests/src/app/testqgsmaptoolidentifyaction.cpp
  32. +1 −1 tests/src/app/testqgsnodetool.cpp
  33. +1 −1 tests/src/core/testqgscadutils.cpp
  34. +1 −1 tests/src/core/testqgsdistancearea.cpp
  35. +7 −7 tests/src/core/testqgsexpression.cpp
  36. +24 −24 tests/src/core/testqgsgeometry.cpp
  37. +5 −5 tests/src/core/testqgsgml.cpp
  38. +1 −1 tests/src/core/testqgsmaprendererjob.cpp
  39. +2 −2 tests/src/core/testqgspointlocator.cpp
  40. +1 −1 tests/src/core/testqgssnappingutils.cpp
  41. +3 −3 tests/src/core/testqgsvectorfilewriter.cpp
@@ -19,7 +19,7 @@ typedef QVector<QgsPointXY> QgsPolylineXY;

typedef QVector<QgsPoint> QgsPolyline;

typedef QVector<QVector<QgsPointXY>> QgsPolygon;
typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;

typedef QVector<QgsPointXY> QgsMultiPoint;

@@ -189,7 +189,7 @@ Creates a new geometry from a QgsMultiPoint object
Creates a new geometry from a QgsMultiPolyline object
:rtype: QgsGeometry
%End
static QgsGeometry fromPolygon( const QgsPolygon &polygon );
static QgsGeometry fromPolygon( const QgsPolygonXY &polygon );
%Docstring
Creates a new geometry from a QgsPolygon
:rtype: QgsGeometry
@@ -1144,11 +1144,11 @@ Returns an extruded version of this geometry.
:rtype: QgsPolylineXY
%End

QgsPolygon asPolygon() const;
QgsPolygonXY asPolygon() const;
%Docstring
Returns contents of the geometry as a polygon
if wkbType is WKBPolygon, otherwise an empty list
:rtype: QgsPolygon
:rtype: QgsPolygonXY
%End

QgsMultiPoint asMultiPoint() const;
@@ -1430,20 +1430,20 @@ Returns an extruded version of this geometry.
:rtype: QgsPolylineXY
%End

static QgsPolygon createPolygonFromQPolygonF( const QPolygonF &polygon ) /Factory/;
static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) /Factory/;
%Docstring
Creates a QgsPolygon from a QPolygonF.
Creates a QgsPolygonXYfrom a QPolygonF.
\param polygon source polygon
:return: QgsPolygon
.. seealso:: createPolylineFromQPolygonF
:rtype: QgsPolygon
:rtype: QgsPolygonXY
%End


static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * DBL_EPSILON );
%Docstring
Compares two geometry objects for equality within a specified tolerance.
The objects can be of type QgsPolylineXY, QgsPolygon or QgsMultiPolygon.
The objects can be of type QgsPolylineXY, QgsPolygonXYor QgsMultiPolygon.
The 2 types should match.
\param p1 first geometry object
\param p2 second geometry object
@@ -1507,10 +1507,10 @@ Returns an extruded version of this geometry.
sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
{
QgsPolygon *p0;
QgsPolygon *p1;
p0 = reinterpret_cast<QgsPolygon *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
p1 = reinterpret_cast<QgsPolygon *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
QgsPolygonXY *p0;
QgsPolygonXY *p1;
p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
if ( sipIsErr )
{
sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
@@ -344,7 +344,7 @@ Generate symbol as image

static void _getPolygon( QPolygonF &pts, QList<QPolygonF> &holes, QgsRenderContext &context, const QgsPolygonV2 &polygon, bool clipToExtent = true );
%Docstring
Creates a polygon in screen coordinates from a QgsPolygon in map coordinates
Creates a polygon in screen coordinates from a QgsPolygonXYin map coordinates
%End

QgsSymbolLayerList cloneLayers() const /Factory/;
@@ -178,7 +178,7 @@ QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fi
QgsMultiPolygon mpolygon = g.asMultiPolygon();
for ( int part = 0; part < mpolygon.count(); part++ ) // go through the polygons
{
const QgsPolygon &polygon = mpolygon[part];
const QgsPolygonXY &polygon = mpolygon[part];
QgsGeometry partGeo = QgsGeometry::fromPolygon( polygon );
if ( partGeo.contains( &layerCoords ) )
{
@@ -127,7 +127,7 @@ QgsGeometry QgsMapToolDeleteRing::ringUnderPoint( const QgsPointXY &p, QgsFeatur
QgsGeometry g;
QgsGeometry ringGeom;
QgsMultiPolygon pol;
QgsPolygon tempPol;
QgsPolygonXYtempPol;
QgsGeometry tempGeom;
double area = std::numeric_limits<double>::max();
while ( fit.nextFeature( f ) )
@@ -151,7 +151,7 @@ QgsGeometry QgsMapToolDeleteRing::ringUnderPoint( const QgsPointXY &p, QgsFeatur
{
for ( int j = 1; j < pol[i].size(); ++j )
{
tempPol = QgsPolygon() << pol[i][j];
tempPol = QgsPolygonXY() << pol[i][j];
tempGeom = QgsGeometry::fromPolygon( tempPol );
if ( tempGeom.area() < area && tempGeom.contains( &p ) )
{
@@ -202,7 +202,7 @@ void QgsMapToolDeleteRing::deleteRing( QgsFeatureId fId, int beforeVertexNr, Qgs

int QgsMapToolDeleteRing::ringNumInPolygon( const QgsGeometry &g, int vertexNr )
{
QgsPolygon polygon = g.asPolygon();
QgsPolygonXYpolygon = g.asPolygon();
for ( int ring = 0; ring < polygon.count(); ring++ )
{
if ( vertexNr < polygon[ring].count() )
@@ -218,7 +218,7 @@ int QgsMapToolDeleteRing::ringNumInMultiPolygon( const QgsGeometry &g, int verte
QgsMultiPolygon mpolygon = g.asMultiPolygon();
for ( int part = 0; part < mpolygon.count(); part++ )
{
const QgsPolygon &polygon = mpolygon[part];
const QgsPolygonXY &polygon = mpolygon[part];
for ( int ring = 0; ring < polygon.count(); ring++ )
{
if ( vertexNr < polygon[ring].count() )
@@ -125,7 +125,7 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
return;
}

g = QgsGeometry::fromPolygon( QgsPolygon() << pointList.toVector() );
g = QgsGeometry::fromPolygon( QgsPolygonXY() << pointList.toVector() );
}
else
{
@@ -216,7 +216,7 @@ QgsGeometry QgsMapToolFillRing::ringUnderPoint( const QgsPointXY &p, QgsFeatureI
{
for ( int j = 1; j < pol[i].size(); ++j )
{
QgsPolygon tempPol = QgsPolygon() << pol[i][j];
QgsPolygonXYtempPol = QgsPolygonXY() << pol[i][j];
QgsGeometry tempGeom = QgsGeometry::fromPolygon( tempPol );
if ( tempGeom.area() < area && tempGeom.contains( &p ) )
{
@@ -412,7 +412,7 @@ QgsGeometry QgsMapToolOffsetCurve::linestringFromPolygon( const QgsGeometry &fea

if ( geomType == QgsWkbTypes::Polygon || geomType == QgsWkbTypes::Polygon25D )
{
QgsPolygon polygon = featureGeom.asPolygon();
QgsPolygonXYpolygon = featureGeom.asPolygon();
multiPoly.append( polygon );
}
else if ( geomType == QgsWkbTypes::MultiPolygon || geomType == QgsWkbTypes::MultiPolygon25D )
@@ -428,7 +428,7 @@ QgsGeometry QgsMapToolOffsetCurve::linestringFromPolygon( const QgsGeometry &fea
QgsMultiPolygon::const_iterator multiPolyIt = multiPoly.constBegin();
for ( ; multiPolyIt != multiPoly.constEnd(); ++multiPolyIt )
{
QgsPolygon::const_iterator polyIt = multiPolyIt->constBegin();
QgsPolygonXY::const_iterator polyIt = multiPolyIt->constBegin();
for ( ; polyIt != multiPolyIt->constEnd(); ++polyIt )
{
currentVertex += polyIt->size();
@@ -182,12 +182,12 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas,
{
// convert add more points to the edges of the rectangle
// improve transformation result
QgsPolygon poly( selectGeomTrans.asPolygon() );
QgsPolygonXYpoly( selectGeomTrans.asPolygon() );
if ( poly.size() == 1 && poly.at( 0 ).size() == 5 )
{
const QgsPolylineXY &ringIn = poly.at( 0 );

QgsPolygon newpoly( 1 );
QgsPolygonXYnewpoly( 1 );
newpoly[0].resize( 41 );
QgsPolylineXY &ringOut = newpoly[0];

@@ -154,7 +154,7 @@ int QgsMapToolSimplify::vertexCount( const QgsGeometry &g ) const
int count = 0;
if ( g.isMultipart() )
{
Q_FOREACH ( const QgsPolygon &polygon, g.asMultiPolygon() )
Q_FOREACH ( const QgsPolygonXY &polygon, g.asMultiPolygon() )
Q_FOREACH ( const QgsPolylineXY &ring, polygon )
count += ring.count();
}
@@ -181,7 +181,7 @@ QgsGeometry QgsGeometry::fromPolyline( const QgsPolyline &polyline )
return QgsGeometry( qgis::make_unique< QgsLineString >( polyline ) );
}

QgsGeometry QgsGeometry::fromPolygon( const QgsPolygon &polygon )
QgsGeometry QgsGeometry::fromPolygon( const QgsPolygonXY &polygon )
{
std::unique_ptr< QgsPolygonV2 > geom = QgsGeometryFactory::fromPolygon( polygon );
if ( geom )
@@ -230,7 +230,7 @@ QgsGeometry QgsGeometry::fromRect( const QgsRectangle &rect )
ring.append( QgsPointXY( rect.xMinimum(), rect.yMaximum() ) );
ring.append( QgsPointXY( rect.xMinimum(), rect.yMinimum() ) );

QgsPolygon polygon;
QgsPolygonXY polygon;
polygon.append( ring );

return fromPolygon( polygon );
@@ -1335,10 +1335,10 @@ QgsPolylineXY QgsGeometry::asPolyline() const
return polyLine;
}

QgsPolygon QgsGeometry::asPolygon() const
QgsPolygonXY QgsGeometry::asPolygon() const
{
if ( !d->geometry )
return QgsPolygon();
return QgsPolygonXY();

bool doSegmentation = ( QgsWkbTypes::flatType( d->geometry->wkbType() ) == QgsWkbTypes::CurvePolygon );

@@ -1349,7 +1349,7 @@ QgsPolygon QgsGeometry::asPolygon() const
QgsCurvePolygon *curvePoly = qgsgeometry_cast<QgsCurvePolygon *>( d->geometry.get() );
if ( !curvePoly )
{
return QgsPolygon();
return QgsPolygonXY();
}
segmentized.reset( curvePoly->toPolygon() );
p = segmentized.get();
@@ -1361,10 +1361,10 @@ QgsPolygon QgsGeometry::asPolygon() const

if ( !p )
{
return QgsPolygon();
return QgsPolygonXY();
}

QgsPolygon polygon;
QgsPolygonXY polygon;
convertPolygon( *p, polygon );

return polygon;
@@ -1474,7 +1474,7 @@ QgsMultiPolygon QgsGeometry::asMultiPolygon() const
}
}

QgsPolygon poly;
QgsPolygonXY poly;
convertPolygon( *polygon, poly );
mp.append( poly );
}
@@ -2129,7 +2129,7 @@ QPolygonF QgsGeometry::asQPolygonF() const
}
else if ( type == QgsWkbTypes::Polygon || type == QgsWkbTypes::Polygon25D )
{
QgsPolygon polygon = asPolygon();
QgsPolygonXY polygon = asPolygon();
if ( polygon.empty() )
return result;
polyline = polygon.at( 0 );
@@ -2519,7 +2519,7 @@ void QgsGeometry::convertToPolyline( const QgsPointSequence &input, QgsPolylineX
}
}

void QgsGeometry::convertPolygon( const QgsPolygonV2 &input, QgsPolygon &output )
void QgsGeometry::convertPolygon( const QgsPolygonV2 &input, QgsPolygonXY &output )
{
output.clear();
QgsCoordinateSequence coords = input.coordinateSequence();
@@ -2557,9 +2557,9 @@ QgsGeometry QgsGeometry::fromQPolygonF( const QPolygonF &polygon )
}
}

QgsPolygon QgsGeometry::createPolygonFromQPolygonF( const QPolygonF &polygon )
QgsPolygonXY QgsGeometry::createPolygonFromQPolygonF( const QPolygonF &polygon )
{
QgsPolygon result;
QgsPolygonXY result;
result << createPolylineFromQPolygonF( polygon );
return result;
}
@@ -2587,7 +2587,7 @@ bool QgsGeometry::compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2, dou
return true;
}

bool QgsGeometry::compare( const QgsPolygon &p1, const QgsPolygon &p2, double epsilon )
bool QgsGeometry::compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2, double epsilon )
{
if ( p1.count() != p2.count() )
return false;
@@ -2856,7 +2856,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
{
const QgsMultiPolygon multiPolygon = asMultiPolygon();
QgsMultiPoint multiPoint;
for ( const QgsPolygon &poly : multiPolygon )
for ( const QgsPolygonXY &poly : multiPolygon )
for ( const QgsPolylineXY &line : poly )
for ( const QgsPointXY &pt : line )
multiPoint << pt;
@@ -2865,7 +2865,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
// input geometry is not multipart: make a multipoint from polygon
else
{
const QgsPolygon polygon = asPolygon();
const QgsPolygonXY polygon = asPolygon();
QgsMultiPoint multiPoint;
for ( const QgsPolylineXY &line : polygon )
for ( const QgsPointXY &pt : line )
@@ -2932,7 +2932,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
{
const QgsMultiPolygon multiPolygon = asMultiPolygon();
QgsMultiPolyline multiLine;
for ( const QgsPolygon &poly : multiPolygon )
for ( const QgsPolygonXY &poly : multiPolygon )
for ( const QgsPolylineXY &line : poly )
multiLine << line;

@@ -2950,15 +2950,15 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
// input geometry is single polygon
else
{
QgsPolygon polygon = asPolygon();
QgsPolygonXY polygon = asPolygon();
// if polygon has rings
if ( polygon.count() > 1 )
{
// cannot fit a polygon with rings in a single line layer
// TODO: would it be better to remove rings?
if ( destMultipart )
{
const QgsPolygon polygon = asPolygon();
const QgsPolygonXY polygon = asPolygon();
QgsMultiPolyline multiLine;
for ( const QgsPolylineXY &line : polygon )
multiLine << line;
@@ -3002,7 +3002,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
if ( multiPoint.last() != multiPoint.first() )
multiPoint << multiPoint.first();

QgsPolygon polygon = QgsPolygon() << multiPoint;
QgsPolygonXY polygon = QgsPolygonXY() << multiPoint;
if ( destMultipart )
return fromMultiPolygon( QgsMultiPolygon() << polygon );
else
@@ -3027,7 +3027,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
// add closing node
if ( ( *multiLineIt ).first() != ( *multiLineIt ).last() )
*multiLineIt << ( *multiLineIt ).first();
multiPolygon << ( QgsPolygon() << *multiLineIt );
multiPolygon << ( QgsPolygonXY() << *multiLineIt );
}
// check that polygons were inserted
if ( !multiPolygon.isEmpty() )
@@ -3061,11 +3061,11 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
// destination is multipart
if ( destMultipart )
{
return fromMultiPolygon( QgsMultiPolygon() << ( QgsPolygon() << line ) );
return fromMultiPolygon( QgsMultiPolygon() << ( QgsPolygonXY() << line ) );
}
else
{
return fromPolygon( QgsPolygon() << line );
return fromPolygon( QgsPolygonXY() << line );
}
}
return QgsGeometry();
@@ -3084,7 +3084,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
if ( destMultipart )
{
// destination is multipart => makes a multipoint with a single polygon
QgsPolygon polygon = asPolygon();
QgsPolygonXY polygon = asPolygon();
if ( !polygon.isEmpty() )
return fromMultiPolygon( QgsMultiPolygon() << polygon );
}

0 comments on commit becf86c

Please sign in to comment.
You can’t perform that action at this time.