Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename QgsPolygon to QgsPolygonXY
  • Loading branch information
m-kuhn committed Oct 30, 2017
1 parent 48f26e5 commit becf86c
Show file tree
Hide file tree
Showing 41 changed files with 142 additions and 142 deletions.
24 changes: 12 additions & 12 deletions python/core/geometry/qgsgeometry.sip
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion python/core/symbology/qgssymbol.sip
Expand Up @@ -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/;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooldeletepart.cpp
Expand Up @@ -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 ) )
{
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmaptooldeletering.cpp
Expand Up @@ -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 ) )
Expand All @@ -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 ) )
{
Expand Down Expand Up @@ -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() )
Expand All @@ -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() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolfillring.cpp
Expand Up @@ -125,7 +125,7 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
return;
}

g = QgsGeometry::fromPolygon( QgsPolygon() << pointList.toVector() );
g = QgsGeometry::fromPolygon( QgsPolygonXY() << pointList.toVector() );
}
else
{
Expand Down Expand Up @@ -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 ) )
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptooloffsetcurve.cpp
Expand Up @@ -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 )
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolselectutils.cpp
Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolsimplify.cpp
Expand Up @@ -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();
}
Expand Down
46 changes: 23 additions & 23 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );

Expand All @@ -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();
Expand All @@ -1361,10 +1361,10 @@ QgsPolygon QgsGeometry::asPolygon() const

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

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

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

QgsPolygon poly;
QgsPolygonXY poly;
convertPolygon( *polygon, poly );
mp.append( poly );
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 )
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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() )
Expand Down Expand Up @@ -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();
Expand All @@ -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 );
}
Expand Down

0 comments on commit becf86c

Please sign in to comment.