Skip to content
Permalink
Browse files

Rename QgsMultiPoint to QgsMultiPointXY

  • Loading branch information
m-kuhn committed Oct 29, 2017
1 parent becf86c commit 29e65ed0871e6cce130bff4c65583859090a4383
@@ -21,7 +21,7 @@ typedef QVector<QgsPoint> QgsPolyline;

typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;

typedef QVector<QgsPointXY> QgsMultiPoint;
typedef QVector<QgsPointXY> QgsMultiPointXY;

typedef QVector<QVector<QgsPointXY>> QgsMultiPolyline;

@@ -150,9 +150,9 @@ Creates a new geometry from a WKT string
Creates a new geometry from a QgsPointXY object
:rtype: QgsGeometry
%End
static QgsGeometry fromMultiPoint( const QgsMultiPoint &multipoint );
static QgsGeometry fromMultiPoint( const QgsMultiPointXY &multipoint );
%Docstring
Creates a new geometry from a QgsMultiPoint object
Creates a new geometry from a QgsMultiPointXY object
:rtype: QgsGeometry
%End

@@ -1151,11 +1151,11 @@ Returns an extruded version of this geometry.
:rtype: QgsPolygonXY
%End

QgsMultiPoint asMultiPoint() const;
QgsMultiPointXY asMultiPoint() const;
%Docstring
Returns contents of the geometry as a multi point
if wkbType is WKBMultiPoint, otherwise an empty list
:rtype: QgsMultiPoint
:rtype: QgsMultiPointXY
%End

QgsMultiPolyline asMultiPolyline() const;
@@ -180,7 +180,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p
QgsGeometry tmpGeom = inFeatureB.geometry();
if ( engine->intersects( tmpGeom.constGet() ) )
{
QgsMultiPoint points;
QgsMultiPointXY points;
QgsGeometry intersectGeom = inGeom.intersection( tmpGeom );
QgsAttributes outAttributes;
for ( int a : qgis::as_const( fieldsAIndices ) )
@@ -113,7 +113,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const
}

// convert the geometry to multipoint
QgsMultiPoint multiPoints;
QgsMultiPointXY multiPoints;
if ( !featureGeometry.isMultipart() )
{
QgsPointXY p = featureGeometry.asPoint();
@@ -148,7 +148,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const
Result result = Success;

//loop through all points in multipoint
for ( QgsMultiPoint::const_iterator pointIt = multiPoints.constBegin(); pointIt != multiPoints.constEnd(); ++pointIt )
for ( QgsMultiPointXY::const_iterator pointIt = multiPoints.constBegin(); pointIt != multiPoints.constEnd(); ++pointIt )
{
// avoiding any empty points or out of extent points
if ( !mBounds.contains( *pointIt ) )
@@ -160,7 +160,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else if ( layerWKBType == QgsWkbTypes::MultiPoint )
{
g = QgsGeometry::fromMultiPoint( QgsMultiPoint() << savePoint );
g = QgsGeometry::fromMultiPoint( QgsMultiPointXY() << savePoint );
}
else if ( layerWKBType == QgsWkbTypes::MultiPoint25D )
{
@@ -191,7 +191,7 @@ QgsGeometry QgsGeometry::fromPolygon( const QgsPolygonXY &polygon )
return QgsGeometry();
}

QgsGeometry QgsGeometry::fromMultiPoint( const QgsMultiPoint &multipoint )
QgsGeometry QgsGeometry::fromMultiPoint( const QgsMultiPointXY &multipoint )
{
std::unique_ptr< QgsMultiPointV2 > geom = QgsGeometryFactory::fromMultiPoint( multipoint );
if ( geom )
@@ -983,7 +983,7 @@ QgsGeometry QgsGeometry::orientedMinimumBoundingBox() const
return orientedMinimumBoundingBox( area, angle, width, height );
}

static QgsCircle __recMinimalEnclosingCircle( QgsMultiPoint points, QgsMultiPoint boundary )
static QgsCircle __recMinimalEnclosingCircle( QgsMultiPointXY points, QgsMultiPointXY boundary )
{
auto l_boundary = boundary.length();
QgsCircle circ_mec;
@@ -1046,8 +1046,8 @@ QgsGeometry QgsGeometry::minimalEnclosingCircle( QgsPointXY &center, double &rad
if ( hull.isNull() )
return QgsGeometry();

QgsMultiPoint P = hull.convertToPoint( true ).asMultiPoint();
QgsMultiPoint R;
QgsMultiPointXY P = hull.convertToPoint( true ).asMultiPoint();
QgsMultiPointXY R;

QgsCircle circ = __recMinimalEnclosingCircle( P, R );
center = QgsPointXY( circ.center() );
@@ -1370,21 +1370,21 @@ QgsPolygonXY QgsGeometry::asPolygon() const
return polygon;
}

QgsMultiPoint QgsGeometry::asMultiPoint() const
QgsMultiPointXY QgsGeometry::asMultiPoint() const
{
if ( !d->geometry || QgsWkbTypes::flatType( d->geometry->wkbType() ) != QgsWkbTypes::MultiPoint )
{
return QgsMultiPoint();
return QgsMultiPointXY();
}

const QgsMultiPointV2 *mp = qgsgeometry_cast<QgsMultiPointV2 *>( d->geometry.get() );
if ( !mp )
{
return QgsMultiPoint();
return QgsMultiPointXY();
}

int nPoints = mp->numGeometries();
QgsMultiPoint multiPoint( nPoints );
QgsMultiPointXY multiPoint( nPoints );
for ( int i = 0; i < nPoints; ++i )
{
const QgsPoint *pt = static_cast<const QgsPoint *>( mp->geometryN( i ) );
@@ -2805,12 +2805,12 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
if ( destMultipart )
{
// layer is multipart => make a multipoint with a single point
return fromMultiPoint( QgsMultiPoint() << asPoint() );
return fromMultiPoint( QgsMultiPointXY() << asPoint() );
}
else
{
// destination is singlepart => make a single part if possible
QgsMultiPoint multiPoint = asMultiPoint();
QgsMultiPointXY multiPoint = asMultiPoint();
if ( multiPoint.count() == 1 )
{
return fromPoint( multiPoint[0] );
@@ -2829,7 +2829,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
if ( isMultipart() )
{
const QgsMultiPolyline multiLine = asMultiPolyline();
QgsMultiPoint multiPoint;
QgsMultiPointXY multiPoint;
for ( const QgsPolylineXY &l : multiLine )
for ( const QgsPointXY &p : l )
multiPoint << p;
@@ -2855,7 +2855,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
if ( isMultipart() )
{
const QgsMultiPolygon multiPolygon = asMultiPolygon();
QgsMultiPoint multiPoint;
QgsMultiPointXY multiPoint;
for ( const QgsPolygonXY &poly : multiPolygon )
for ( const QgsPolylineXY &line : poly )
for ( const QgsPointXY &pt : line )
@@ -2866,7 +2866,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
else
{
const QgsPolygonXY polygon = asPolygon();
QgsMultiPoint multiPoint;
QgsMultiPointXY multiPoint;
for ( const QgsPolylineXY &line : polygon )
for ( const QgsPointXY &pt : line )
multiPoint << pt;
@@ -2888,7 +2888,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
if ( !isMultipart() )
return QgsGeometry();

QgsMultiPoint multiPoint = asMultiPoint();
QgsMultiPointXY multiPoint = asMultiPoint();
if ( multiPoint.count() < 2 )
return QgsGeometry();

@@ -2995,7 +2995,7 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
if ( !isMultipart() )
return QgsGeometry();

QgsMultiPoint multiPoint = asMultiPoint();
QgsMultiPointXY multiPoint = asMultiPoint();
if ( multiPoint.count() < 3 )
return QgsGeometry();

@@ -76,7 +76,7 @@ typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
#endif

//! A collection of QgsPoints that share a common collection of attributes
typedef QVector<QgsPointXY> QgsMultiPoint;
typedef QVector<QgsPointXY> QgsMultiPointXY;

//! A collection of QgsPolylines that share a common collection of attributes
#ifndef SIP_RUN
@@ -214,8 +214,8 @@ class CORE_EXPORT QgsGeometry
static QgsGeometry fromWkt( const QString &wkt );
//! Creates a new geometry from a QgsPointXY object
static QgsGeometry fromPoint( const QgsPointXY &point );
//! Creates a new geometry from a QgsMultiPoint object
static QgsGeometry fromMultiPoint( const QgsMultiPoint &multipoint );
//! Creates a new geometry from a QgsMultiPointXY object
static QgsGeometry fromMultiPoint( const QgsMultiPointXY &multipoint );

/**
* Creates a new LineString geometry from a list of QgsPointXY points.
@@ -1158,7 +1158,7 @@ class CORE_EXPORT QgsGeometry
* Returns contents of the geometry as a multi point
* if wkbType is WKBMultiPoint, otherwise an empty list
*/
QgsMultiPoint asMultiPoint() const;
QgsMultiPointXY asMultiPoint() const;

/**
* Returns contents of the geometry as a multi linestring
@@ -137,10 +137,10 @@ std::unique_ptr< QgsAbstractGeometry > QgsGeometryFactory::fromPoint( const QgsP
return qgis::make_unique< QgsPoint >( point.x(), point.y() );
}

std::unique_ptr<QgsMultiPointV2> QgsGeometryFactory::fromMultiPoint( const QgsMultiPoint &multipoint )
std::unique_ptr<QgsMultiPointV2> QgsGeometryFactory::fromMultiPoint( const QgsMultiPointXY &multipoint )
{
std::unique_ptr< QgsMultiPointV2 > mp = qgis::make_unique< QgsMultiPointV2 >();
QgsMultiPoint::const_iterator ptIt = multipoint.constBegin();
QgsMultiPointXY::const_iterator ptIt = multipoint.constBegin();
for ( ; ptIt != multipoint.constEnd(); ++ptIt )
{
QgsPoint *pt = new QgsPoint( ptIt->x(), ptIt->y() );
@@ -38,7 +38,7 @@ class QgsMultiPolygonV2;
#include "qgspointxy.h"
typedef QVector<QgsPointXY> QgsPolylineXY;
typedef QVector<QgsPolylineXY> QgsPolygonXY;
typedef QVector<QgsPointXY> QgsMultiPoint;
typedef QVector<QgsPointXY> QgsMultiPointXY;
typedef QVector<QgsPolylineXY> QgsMultiPolyline;
typedef QVector<QgsPolygonXY> QgsMultiPolygon;

@@ -67,7 +67,7 @@ class CORE_EXPORT QgsGeometryFactory
//! Construct geometry from a point
static std::unique_ptr< QgsAbstractGeometry > fromPoint( const QgsPointXY &point );
//! Construct geometry from a multipoint
static std::unique_ptr<QgsMultiPointV2> fromMultiPoint( const QgsMultiPoint &multipoint );
static std::unique_ptr<QgsMultiPointV2> fromMultiPoint( const QgsMultiPointXY &multipoint );
//! Construct geometry from a polyline
static std::unique_ptr< QgsAbstractGeometry > fromPolyline( const QgsPolylineXY &polyline );
//! Construct geometry from a multipolyline
@@ -71,9 +71,9 @@ void QgsHeatmapRenderer::startRender( QgsRenderContext &context, const QgsFields
initializeValues( context );
}

QgsMultiPoint QgsHeatmapRenderer::convertToMultipoint( const QgsGeometry *geom )
QgsMultiPointXY QgsHeatmapRenderer::convertToMultipoint( const QgsGeometry *geom )
{
QgsMultiPoint multiPoint;
QgsMultiPointXY multiPoint;
if ( !geom->isMultipart() )
{
multiPoint << geom->asPoint();
@@ -137,10 +137,10 @@ bool QgsHeatmapRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &c
}

//convert point to multipoint
QgsMultiPoint multiPoint = convertToMultipoint( &geom );
QgsMultiPointXY multiPoint = convertToMultipoint( &geom );

//loop through all points in multipoint
for ( QgsMultiPoint::const_iterator pointIt = multiPoint.constBegin(); pointIt != multiPoint.constEnd(); ++pointIt )
for ( QgsMultiPointXY::const_iterator pointIt = multiPoint.constBegin(); pointIt != multiPoint.constEnd(); ++pointIt )
{
QgsPointXY pixel = context.mapToPixel().transform( *pointIt );
int pointX = pixel.x() / mRenderQuality;
@@ -207,7 +207,7 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer
double epanechnikovKernel( const double distance, const int bandwidth ) const;
double triangularKernel( const double distance, const int bandwidth ) const;

QgsMultiPoint convertToMultipoint( const QgsGeometry *geom );
QgsMultiPointXY convertToMultipoint( const QgsGeometry *geom );
void initializeValues( QgsRenderContext &context );
void renderImage( QgsRenderContext &context );
};
@@ -276,7 +276,7 @@ void QgsHighlight::paint( QPainter *p )
}
else
{
QgsMultiPoint m = mGeometry->asMultiPoint();
QgsMultiPointXY m = mGeometry->asMultiPoint();
for ( int i = 0; i < m.size(); i++ )
{
paintPoint( p, m[i] );
@@ -276,7 +276,7 @@ void QgsRubberBand::addGeometry( const QgsGeometry &geometry, const QgsCoordinat
case QgsWkbTypes::MultiPoint:
case QgsWkbTypes::MultiPoint25D:
{
const QgsMultiPoint mpt = geom.asMultiPoint();
const QgsMultiPointXY mpt = geom.asMultiPoint();
for ( QgsPointXY pt : mpt )
{
addPoint( pt, false, idx );
@@ -616,7 +616,7 @@ QgsGeometry QgsRubberBand::asGeometry() const

case QgsWkbTypes::PointGeometry:
{
QgsMultiPoint multiPoint;
QgsMultiPointXY multiPoint;

QList< QList<QgsPointXY> >::const_iterator it = mPoints.constBegin();
for ( ; it != mPoints.constEnd(); ++it )
@@ -258,7 +258,7 @@ int main( int argc, char **argv )
}
else if ( geometryType == QgsWkbTypes::MultiPoint )
{
QgsMultiPoint multiPoint = geometry.asMultiPoint();
QgsMultiPointXY multiPoint = geometry.asMultiPoint();
Q_FOREACH ( const QgsPointXY &point, multiPoint )
{
writePoint( map, GV_POINT, point, cats );
@@ -299,7 +299,7 @@ void TestQgsGML::testMultiPointGML2()
QCOMPARE( features.size(), 1 );
QVERIFY( features[0].first->hasGeometry() );
QCOMPARE( features[0].first->geometry().wkbType(), QgsWkbTypes::MultiPoint );
QgsMultiPoint multi = features[0].first->geometry().asMultiPoint();
QgsMultiPointXY multi = features[0].first->geometry().asMultiPoint();
QCOMPARE( multi.size(), 2 );
QCOMPARE( multi[0], QgsPointXY( 10, 20 ) );
QCOMPARE( multi[1], QgsPointXY( 30, 40 ) );

0 comments on commit 29e65ed

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