Skip to content
Permalink
Browse files

Rename QgsMultiPolygon to QgsMultiPolygonXY

  • Loading branch information
m-kuhn committed Oct 29, 2017
1 parent b790874 commit 9a57bae6f43c3821d22f74b48442bea6334206db
@@ -25,7 +25,7 @@ typedef QVector<QgsPointXY> QgsMultiPointXY;

typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;

typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygon;
typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;



@@ -194,7 +194,7 @@ Creates a new geometry from a QgsMultiPolylineXY object
Creates a new geometry from a QgsPolygon
:rtype: QgsGeometry
%End
static QgsGeometry fromMultiPolygon( const QgsMultiPolygon &multipoly );
static QgsGeometry fromMultiPolygon( const QgsMultiPolygonXY &multipoly );
%Docstring
Creates a new geometry from a QgsMultiPolygon
:rtype: QgsGeometry
@@ -1165,11 +1165,11 @@ Returns an extruded version of this geometry.
:rtype: QgsMultiPolylineXY
%End

QgsMultiPolygon asMultiPolygon() const;
QgsMultiPolygonXY asMultiPolygon() const;
%Docstring
Returns contents of the geometry as a multi polygon
if wkbType is WKBMultiPolygon, otherwise an empty list
:rtype: QgsMultiPolygon
:rtype: QgsMultiPolygonXY
%End

QList<QgsGeometry> asGeometryCollection() const;
@@ -1534,10 +1534,10 @@ Returns an extruded version of this geometry.
sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
{
QgsMultiPolygon *p0;
QgsMultiPolygon *p1;
p0 = reinterpret_cast<QgsMultiPolygon *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
p1 = reinterpret_cast<QgsMultiPolygon *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
QgsMultiPolygonXY *p0;
QgsMultiPolygonXY *p1;
p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
if ( sipIsErr )
{
sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
@@ -175,7 +175,7 @@ QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fi
fid = f.id();
return geomPart;
}
QgsMultiPolygon mpolygon = g.asMultiPolygon();
QgsMultiPolygonXY mpolygon = g.asMultiPolygon();
for ( int part = 0; part < mpolygon.count(); part++ ) // go through the polygons
{
const QgsPolygonXY &polygon = mpolygon[part];
@@ -126,7 +126,7 @@ QgsGeometry QgsMapToolDeleteRing::ringUnderPoint( const QgsPointXY &p, QgsFeatur
QgsFeature f;
QgsGeometry g;
QgsGeometry ringGeom;
QgsMultiPolygon pol;
QgsMultiPolygonXY pol;
QgsPolygonXYtempPol;
QgsGeometry tempGeom;
double area = std::numeric_limits<double>::max();
@@ -137,7 +137,7 @@ QgsGeometry QgsMapToolDeleteRing::ringUnderPoint( const QgsPointXY &p, QgsFeatur
continue;
if ( g.wkbType() == QgsWkbTypes::Polygon || g.wkbType() == QgsWkbTypes::Polygon25D )
{
pol = QgsMultiPolygon() << g.asPolygon();
pol = QgsMultiPolygonXY() << g.asPolygon();
}
else
{
@@ -215,7 +215,7 @@ int QgsMapToolDeleteRing::ringNumInPolygon( const QgsGeometry &g, int vertexNr )

int QgsMapToolDeleteRing::ringNumInMultiPolygon( const QgsGeometry &g, int vertexNr, int &partNum )
{
QgsMultiPolygon mpolygon = g.asMultiPolygon();
QgsMultiPolygonXY mpolygon = g.asMultiPolygon();
for ( int part = 0; part < mpolygon.count(); part++ )
{
const QgsPolygonXY &polygon = mpolygon[part];
@@ -199,10 +199,10 @@ QgsGeometry QgsMapToolFillRing::ringUnderPoint( const QgsPointXY &p, QgsFeatureI
if ( g.isNull() )
continue;

QgsMultiPolygon pol;
QgsMultiPolygonXY pol;
if ( g.wkbType() == QgsWkbTypes::Polygon || g.wkbType() == QgsWkbTypes::Polygon25D )
{
pol = QgsMultiPolygon() << g.asPolygon();
pol = QgsMultiPolygonXY() << g.asPolygon();
}
else
{
@@ -408,7 +408,7 @@ QgsGeometry QgsMapToolOffsetCurve::linestringFromPolygon( const QgsGeometry &fea

QgsWkbTypes::Type geomType = featureGeom.wkbType();
int currentVertex = 0;
QgsMultiPolygon multiPoly;
QgsMultiPolygonXY multiPoly;

if ( geomType == QgsWkbTypes::Polygon || geomType == QgsWkbTypes::Polygon25D )
{
@@ -425,7 +425,7 @@ QgsGeometry QgsMapToolOffsetCurve::linestringFromPolygon( const QgsGeometry &fea
return QgsGeometry();
}

QgsMultiPolygon::const_iterator multiPolyIt = multiPoly.constBegin();
QgsMultiPolygonXY::const_iterator multiPolyIt = multiPoly.constBegin();
for ( ; multiPolyIt != multiPoly.constEnd(); ++multiPolyIt )
{
QgsPolygonXY::const_iterator polyIt = multiPolyIt->constBegin();
@@ -211,7 +211,7 @@ QgsGeometry QgsGeometry::fromMultiPolyline( const QgsMultiPolylineXY &multiline
return QgsGeometry();
}

QgsGeometry QgsGeometry::fromMultiPolygon( const QgsMultiPolygon &multipoly )
QgsGeometry QgsGeometry::fromMultiPolygon( const QgsMultiPolygonXY &multipoly )
{
std::unique_ptr< QgsMultiPolygonV2 > geom = QgsGeometryFactory::fromMultiPolygon( multipoly );
if ( geom )
@@ -1438,26 +1438,26 @@ QgsMultiPolylineXY QgsGeometry::asMultiPolyline() const
return mpl;
}

QgsMultiPolygon QgsGeometry::asMultiPolygon() const
QgsMultiPolygonXY QgsGeometry::asMultiPolygon() const
{
if ( !d->geometry )
{
return QgsMultiPolygon();
return QgsMultiPolygonXY();
}

QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( d->geometry.get() );
if ( !geomCollection )
{
return QgsMultiPolygon();
return QgsMultiPolygonXY();
}

int nPolygons = geomCollection->numGeometries();
if ( nPolygons < 1 )
{
return QgsMultiPolygon();
return QgsMultiPolygonXY();
}

QgsMultiPolygon mp;
QgsMultiPolygonXY mp;
for ( int i = 0; i < nPolygons; ++i )
{
const QgsPolygonV2 *polygon = qgsgeometry_cast<const QgsPolygonV2 *>( geomCollection->geometryN( i ) );
@@ -2601,7 +2601,7 @@ bool QgsGeometry::compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2, doubl
}


bool QgsGeometry::compare( const QgsMultiPolygon &p1, const QgsMultiPolygon &p2, double epsilon )
bool QgsGeometry::compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2, double epsilon )
{
if ( p1.count() != p2.count() )
return false;
@@ -2854,7 +2854,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
// input geometry is multipart: make a multipoint from multipolygon
if ( isMultipart() )
{
const QgsMultiPolygon multiPolygon = asMultiPolygon();
const QgsMultiPolygonXY multiPolygon = asMultiPolygon();
QgsMultiPointXY multiPoint;
for ( const QgsPolygonXY &poly : multiPolygon )
for ( const QgsPolylineXY &line : poly )
@@ -2930,7 +2930,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
// input geometry is multipolygon
if ( isMultipart() )
{
const QgsMultiPolygon multiPolygon = asMultiPolygon();
const QgsMultiPolygonXY multiPolygon = asMultiPolygon();
QgsMultiPolylineXY multiLine;
for ( const QgsPolygonXY &poly : multiPolygon )
for ( const QgsPolylineXY &line : poly )
@@ -3004,7 +3004,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const

QgsPolygonXY polygon = QgsPolygonXY() << multiPoint;
if ( destMultipart )
return fromMultiPolygon( QgsMultiPolygon() << polygon );
return fromMultiPolygon( QgsMultiPolygonXY() << polygon );
else
return fromPolygon( polygon );
}
@@ -3015,7 +3015,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
if ( isMultipart() )
{
QgsMultiPolylineXY multiLine = asMultiPolyline();
QgsMultiPolygon multiPolygon;
QgsMultiPolygonXY multiPolygon;
for ( QgsMultiPolylineXY::iterator multiLineIt = multiLine.begin(); multiLineIt != multiLine.end(); ++multiLineIt )
{
// do not create polygon for a 1 segment line
@@ -3061,7 +3061,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
// destination is multipart
if ( destMultipart )
{
return fromMultiPolygon( QgsMultiPolygon() << ( QgsPolygonXY() << line ) );
return fromMultiPolygon( QgsMultiPolygonXY() << ( QgsPolygonXY() << line ) );
}
else
{
@@ -3086,11 +3086,11 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
// destination is multipart => makes a multipoint with a single polygon
QgsPolygonXY polygon = asPolygon();
if ( !polygon.isEmpty() )
return fromMultiPolygon( QgsMultiPolygon() << polygon );
return fromMultiPolygon( QgsMultiPolygonXY() << polygon );
}
else
{
QgsMultiPolygon multiPolygon = asMultiPolygon();
QgsMultiPolygonXY multiPolygon = asMultiPolygon();
if ( multiPolygon.count() == 1 )
{
// destination is singlepart => make a single part if possible
@@ -87,9 +87,9 @@ typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;

//! A collection of QgsPolygons that share a common collection of attributes
#ifndef SIP_RUN
typedef QVector<QgsPolygonXY> QgsMultiPolygon;
typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
#else
typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygon;
typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
#endif

class QgsRectangle;
@@ -246,7 +246,7 @@ class CORE_EXPORT QgsGeometry
//! Creates a new geometry from a QgsPolygon
static QgsGeometry fromPolygon( const QgsPolygonXY &polygon );
//! Creates a new geometry from a QgsMultiPolygon
static QgsGeometry fromMultiPolygon( const QgsMultiPolygon &multipoly );
static QgsGeometry fromMultiPolygon( const QgsMultiPolygonXY &multipoly );
//! Creates a new geometry from a QgsRectangle
static QgsGeometry fromRect( const QgsRectangle &rect );
//! Creates a new multipart geometry from a list of QgsGeometry objects
@@ -1170,7 +1170,7 @@ class CORE_EXPORT QgsGeometry
* Returns contents of the geometry as a multi polygon
* if wkbType is WKBMultiPolygon, otherwise an empty list
*/
QgsMultiPolygon asMultiPolygon() const;
QgsMultiPolygonXY asMultiPolygon() const;

/**
* Return contents of the geometry as a list of geometries
@@ -1463,7 +1463,7 @@ class CORE_EXPORT QgsGeometry
* tolerance
* \since QGIS 2.9
*/
static bool compare( const QgsMultiPolygon &p1, const QgsMultiPolygon &p2,
static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
#else

@@ -1560,10 +1560,10 @@ class CORE_EXPORT QgsGeometry
sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
{
QgsMultiPolygon *p0;
QgsMultiPolygon *p1;
p0 = reinterpret_cast<QgsMultiPolygon *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
p1 = reinterpret_cast<QgsMultiPolygon *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
QgsMultiPolygonXY *p0;
QgsMultiPolygonXY *p1;
p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
if ( sipIsErr )
{
sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
@@ -187,7 +187,7 @@ std::unique_ptr<QgsPolygonV2> QgsGeometryFactory::fromPolygon( const QgsPolygonX
return poly;
}

std::unique_ptr< QgsMultiPolygonV2 > QgsGeometryFactory::fromMultiPolygon( const QgsMultiPolygon &multipoly )
std::unique_ptr< QgsMultiPolygonV2 > QgsGeometryFactory::fromMultiPolygon( const QgsMultiPolygonXY &multipoly )
{
std::unique_ptr< QgsMultiPolygonV2 > mp = qgis::make_unique< QgsMultiPolygonV2 >();
for ( int i = 0; i < multipoly.size(); ++i )
@@ -40,7 +40,7 @@ typedef QVector<QgsPointXY> QgsPolylineXY;
typedef QVector<QgsPolylineXY> QgsPolygonXY;
typedef QVector<QgsPointXY> QgsMultiPointXY;
typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
typedef QVector<QgsPolygonXY> QgsMultiPolygon;
typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;

/**
* \ingroup core
@@ -75,7 +75,7 @@ class CORE_EXPORT QgsGeometryFactory
//! Construct geometry from a polygon
static std::unique_ptr<QgsPolygonV2> fromPolygon( const QgsPolygonXY &polygon );
//! Construct geometry from a multipolygon
static std::unique_ptr<QgsMultiPolygonV2> fromMultiPolygon( const QgsMultiPolygon &multipoly );
static std::unique_ptr<QgsMultiPolygonV2> fromMultiPolygon( const QgsMultiPolygonXY &multipoly );
//! Return empty geometry from wkb type
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType( QgsWkbTypes::Type t );

@@ -282,7 +282,7 @@ void QgsGeometryValidator::run()
}
else if ( flatType == QgsWkbTypes::MultiPolygon )
{
QgsMultiPolygon mp = mGeometry.asMultiPolygon();
QgsMultiPolygonXY mp = mGeometry.asMultiPolygon();
for ( int i = 0; !mStop && i < mp.size(); i++ )
{
validatePolygon( i, mp[i] );
@@ -633,7 +633,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiLineString( const QDomElement &geom
QgsGeometry QgsOgcUtils::geometryFromGMLMultiPolygon( const QDomElement &geometryElement )
{
//first list: different polygons, second list: different rings, third list: different points
QgsMultiPolygon multiPolygonPoints;
QgsMultiPolygonXY multiPolygonPoints;
QDomElement currentPolygonMemberElement;
QDomNodeList polygonList;
QDomElement currentPolygonElement;
@@ -777,7 +777,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPolygon( const QDomElement &geometr

int size = 1 + 2 * sizeof( int );
//calculate the wkb size
for ( QgsMultiPolygon::const_iterator it = multiPolygonPoints.constBegin(); it != multiPolygonPoints.constEnd(); ++it )
for ( QgsMultiPolygonXY::const_iterator it = multiPolygonPoints.constBegin(); it != multiPolygonPoints.constEnd(); ++it )
{
size += 1 + 2 * sizeof( int );
for ( QgsPolygonXY::const_iterator iter = it->begin(); iter != it->end(); ++iter )
@@ -805,7 +805,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPolygon( const QDomElement &geometr

type = QgsWkbTypes::Polygon;

for ( QgsMultiPolygon::const_iterator it = multiPolygonPoints.constBegin(); it != multiPolygonPoints.constEnd(); ++it )
for ( QgsMultiPolygonXY::const_iterator it = multiPolygonPoints.constBegin(); it != multiPolygonPoints.constEnd(); ++it )
{
memcpy( &( wkb )[wkbPosition], &e, 1 );
wkbPosition += 1;
@@ -578,7 +578,7 @@ int QgsVectorLayerEditUtils::addTopologicalPoints( const QgsGeometry &geom )
case QgsWkbTypes::MultiPolygon25D:
case QgsWkbTypes::MultiPolygon:
{
QgsMultiPolygon multiPolygon = geom.asMultiPolygon();
QgsMultiPolygonXY multiPolygon = geom.asMultiPolygon();
QgsPolygonXY currentPolygon;
QgsPolylineXY currentRing;

@@ -252,7 +252,7 @@ void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext &context )
return;
}

QgsMultiPolygon finalMulti; //avoid expensive allocation for list for every feature
QgsMultiPolygonXY finalMulti; //avoid expensive allocation for list for every feature
QgsPolygonXY newPoly;

Q_FOREACH ( const CombinedFeature &cit, mFeaturesCategories )
@@ -284,7 +284,7 @@ void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext &context )
finalMulti.append( mExtentPolygon );
Q_FOREACH ( const QgsGeometry &geom, cit.geometries )
{
QgsMultiPolygon multi;
QgsMultiPolygonXY multi;
QgsWkbTypes::Type type = QgsWkbTypes::flatType( geom.constGet()->wkbType() );

if ( ( type == QgsWkbTypes::Polygon ) || ( type == QgsWkbTypes::CurvePolygon ) )
@@ -803,7 +803,7 @@ QList<QPolygonF> offsetLine( QPolygonF polyline, double dist, QgsWkbTypes::Geome
}
else if ( QgsWkbTypes::flatType( tempGeometry.wkbType() ) == QgsWkbTypes::MultiPolygon )
{
QgsMultiPolygon tempMPolygon = tempGeometry.asMultiPolygon();
QgsMultiPolygonXY tempMPolygon = tempGeometry.asMultiPolygon();
resultLine.reserve( tempMPolygon.count() );
for ( int part = 0; part < tempMPolygon.count(); ++part )
{
@@ -311,7 +311,7 @@ void QgsHighlight::paint( QPainter *p )
}
else
{
QgsMultiPolygon m = mGeometry->asMultiPolygon();
QgsMultiPolygonXY m = mGeometry->asMultiPolygon();
for ( int i = 0; i < m.size(); i++ )
{
paintPolygon( p, m[i] );
@@ -334,7 +334,7 @@ void QgsRubberBand::addGeometry( const QgsGeometry &geometry, const QgsCoordinat
case QgsWkbTypes::MultiPolygon25D:
{

const QgsMultiPolygon multipoly = geom.asMultiPolygon();
const QgsMultiPolygonXY multipoly = geom.asMultiPolygon();
for ( const QgsPolygonXY &poly : multipoly )
{
if ( poly.empty() )

0 comments on commit 9a57bae

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