Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename QgsGeometry::fromPoint to QgsGeometry::fromPointXY
Also introduces the from[Geometry]XY for QgsGeometryFactory
  • Loading branch information
m-kuhn committed Oct 30, 2017
1 parent 82e6d12 commit e0025b6
Show file tree
Hide file tree
Showing 61 changed files with 198 additions and 198 deletions.
2 changes: 1 addition & 1 deletion python/core/geometry/qgsgeometry.sip
Expand Up @@ -145,7 +145,7 @@ Copy constructor will prompt a deep copy of the object
Creates a new geometry from a WKT string
:rtype: QgsGeometry
%End
static QgsGeometry fromPoint( const QgsPointXY &point );
static QgsGeometry fromPointXY( const QgsPointXY &point );
%Docstring
Creates a new geometry from a QgsPointXY object
:rtype: QgsGeometry
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/CheckValidity.py
Expand Up @@ -152,7 +152,7 @@ def doCheck(self, method, parameters, context, feedback):
reasons = []
for error in errors:
errFeat = QgsFeature()
error_geom = QgsGeometry.fromPoint(error.where())
error_geom = QgsGeometry.fromPointXY(error.where())
errFeat.setGeometry(error_geom)
errFeat.setAttributes([error.what()])
if error_output_sink:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/HubDistancePoints.py
Expand Up @@ -144,7 +144,7 @@ def processAlgorithm(self, parameters, context, feedback):
feat = QgsFeature()
feat.setAttributes(attributes)

feat.setGeometry(QgsGeometry.fromPoint(src))
feat.setGeometry(QgsGeometry.fromPointXY(src))

sink.addFeature(feat, QgsFeatureSink.FastInsert)
feedback.setProgress(int(current * total))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/PointsFromLines.py
Expand Up @@ -192,7 +192,7 @@ def buildLine(self, startX, startY, endX, endY, geoTransform, writer, feature):
def createPoint(self, pX, pY, geoTransform, writer, feature):
(x, y) = raster.pixelToMap(pX, pY, geoTransform)

feature.setGeometry(QgsGeometry.fromPoint(QgsPointXY(x, y)))
feature.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(x, y)))
feature['id'] = self.fid
feature['line_id'] = self.lineId
feature['point_id'] = self.pointId
Expand Down
Expand Up @@ -148,7 +148,7 @@ def processAlgorithm(self, parameters, context, feedback):

# generate random point
p = QgsPointXY(rx, ry)
geom = QgsGeometry.fromPoint(p)
geom = QgsGeometry.fromPointXY(p)
if vector.checkMinDistance(p, index, minDistance, points):
f = QgsFeature(nPoints)
f.initAttributes(1)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/RandomPointsExtent.py
Expand Up @@ -125,7 +125,7 @@ def processAlgorithm(self, parameters, context, feedback):
ry = bbox.yMinimum() + bbox.height() * random.random()

p = QgsPointXY(rx, ry)
geom = QgsGeometry.fromPoint(p)
geom = QgsGeometry.fromPointXY(p)
if geom.within(extent) and \
vector.checkMinDistance(p, index, minDistance, points):
f = QgsFeature(nPoints)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/RandomPointsLayer.py
Expand Up @@ -122,7 +122,7 @@ def processAlgorithm(self, parameters, context, feedback):
ry = bbox.yMinimum() + bbox.height() * random.random()

p = QgsPointXY(rx, ry)
geom = QgsGeometry.fromPoint(p)
geom = QgsGeometry.fromPointXY(p)
ids = sourceIndex.intersects(geom.buffer(5, 5).boundingBox())
if len(ids) > 0 and \
vector.checkMinDistance(p, index, minDistance, points):
Expand Down
Expand Up @@ -168,7 +168,7 @@ def processAlgorithm(self, parameters, context, feedback):
ry = bbox.yMinimum() + bbox.height() * random.random()

p = QgsPointXY(rx, ry)
geom = QgsGeometry.fromPoint(p)
geom = QgsGeometry.fromPointXY(p)
if geom.within(fGeom) and \
vector.checkMinDistance(p, index, minDistance, points):
f = QgsFeature(nPoints)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/qgis/RegularPoints.py
Expand Up @@ -134,11 +134,11 @@ def processAlgorithm(self, parameters, context, feedback):
break

if randomize:
geom = QgsGeometry().fromPoint(QgsPointXY(
geom = QgsGeometry().fromPointXY(QgsPointXY(
uniform(x - (pSpacing / 2.0), x + (pSpacing / 2.0)),
uniform(y - (pSpacing / 2.0), y + (pSpacing / 2.0))))
else:
geom = QgsGeometry().fromPoint(QgsPointXY(x, y))
geom = QgsGeometry().fromPointXY(QgsPointXY(x, y))

if extent_engine.intersects(geom.constGet()):
f.setAttribute('id', count)
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmlineintersection.cpp
Expand Up @@ -204,7 +204,7 @@ QVariantMap QgsLineIntersectionAlgorithm::processAlgorithm( const QVariantMap &p

for ( const QgsPointXY &j : qgis::as_const( points ) )
{
outFeature.setGeometry( QgsGeometry::fromPoint( j ) );
outFeature.setGeometry( QgsGeometry::fromPointXY( j ) );
outFeature.setAttributes( outAttributes );
sink->addFeature( outFeature, QgsFeatureSink::FastInsert );
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmmeancoordinates.cpp
Expand Up @@ -196,7 +196,7 @@ QVariantMap QgsMeanCoordinatesAlgorithm::processAlgorithm( const QVariantMap &pa
double cy = it.value().at( 1 ) / it.value().at( 2 );

QgsPointXY meanPoint( cx, cy );
outFeat.setGeometry( QgsGeometry::fromPoint( meanPoint ) );
outFeat.setGeometry( QgsGeometry::fromPointXY( meanPoint ) );

QgsAttributes attributes;
attributes << cx << cy;
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodeeditor.cpp
Expand Up @@ -373,7 +373,7 @@ void QgsNodeEditor::zoomToNode( int idx )
//close polygon
ext.append( ext.first() );
QgsGeometry extGeom( QgsGeometry::fromQPolygonF( ext ) );
QgsGeometry nodeGeom( QgsGeometry::fromPoint( tCenter ) );
QgsGeometry nodeGeom( QgsGeometry::fromPointXY( tCenter ) );
if ( !nodeGeom.within( extGeom ) )
{
mCanvas->setCenter( tCenter );
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodetool.cpp
Expand Up @@ -827,7 +827,7 @@ void QgsNodeTool::updateVertexBand( const QgsPointLocator::Match &m )
{
if ( m.hasVertex() && m.layer() )
{
mVertexBand->setToGeometry( QgsGeometry::fromPoint( m.point() ), nullptr );
mVertexBand->setToGeometry( QgsGeometry::fromPointXY( m.point() ), nullptr );
mVertexBand->setVisible( true );
bool isCircular = false;
if ( m.layer() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -152,7 +152,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
QgsGeometry g;
if ( layerWKBType == QgsWkbTypes::Point )
{
g = QgsGeometry::fromPoint( savePoint );
g = QgsGeometry::fromPointXY( savePoint );
}
else if ( layerWKBType == QgsWkbTypes::Point25D )
{
Expand All @@ -171,7 +171,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
else
{
// if layer supports more types (mCheckGeometryType is false)
g = QgsGeometry::fromPoint( savePoint );
g = QgsGeometry::fromPointXY( savePoint );
}

f.setGeometry( g );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptooldeletepart.cpp
Expand Up @@ -135,13 +135,13 @@ QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fi
if ( !g.isMultipart() )
{
fid = match.featureId();
return QgsGeometry::fromPoint( match.point() );
return QgsGeometry::fromPointXY( match.point() );
}
if ( g.wkbType() == QgsWkbTypes::MultiPoint || g.wkbType() == QgsWkbTypes::MultiPoint25D )
{
fid = match.featureId();
partNum = snapVertex;
return QgsGeometry::fromPoint( match.point() );
return QgsGeometry::fromPointXY( match.point() );
}
if ( g.wkbType() == QgsWkbTypes::MultiLineString || g.wkbType() == QgsWkbTypes::MultiLineString25D )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoollabel.cpp
Expand Up @@ -111,7 +111,7 @@ void QgsMapToolLabel::createRubberBands()
fixPoint = s.mapToLayerCoordinates( vlayer, fixPoint );
}

QgsGeometry pointGeom = QgsGeometry::fromPoint( fixPoint );
QgsGeometry pointGeom = QgsGeometry::fromPointXY( fixPoint );
mFixPointRubberBand = new QgsRubberBand( mCanvas, QgsWkbTypes::LineGeometry );
mFixPointRubberBand->setColor( QColor( 0, 0, 255, 65 ) );
mFixPointRubberBand->setToGeometry( pointGeom, vlayer );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -84,7 +84,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setSubsetOfAttributes( QgsAttributeList() ) );

//find the closest feature
QgsGeometry pointGeometry = QgsGeometry::fromPoint( layerCoords );
QgsGeometry pointGeometry = QgsGeometry::fromPointXY( layerCoords );
if ( pointGeometry.isNull() )
{
cadDockWidget()->clear();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -221,7 +221,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setSubsetOfAttributes( QgsAttributeList() ) );

//find the closest feature
QgsGeometry pointGeometry = QgsGeometry::fromPoint( layerCoords );
QgsGeometry pointGeometry = QgsGeometry::fromPointXY( layerCoords );
if ( pointGeometry.isNull() )
{
return;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolsimplify.cpp
Expand Up @@ -298,7 +298,7 @@ void QgsMapToolSimplify::selectOneFeature( QPoint canvasPoint )
layerCoords.x() + r, layerCoords.y() + r );
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setSubsetOfAttributes( QgsAttributeList() ) );

QgsGeometry geometry = QgsGeometry::fromPoint( layerCoords );
QgsGeometry geometry = QgsGeometry::fromPointXY( layerCoords );
double minDistance = DBL_MAX;
double currentDistance;
QgsFeature minDistanceFeature;
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermap.cpp
Expand Up @@ -1728,7 +1728,7 @@ QgsExpressionContext QgsComposerMap::createExpressionContext() const
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent" ), QVariant::fromValue( QgsGeometry::fromRect( extent ) ), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent_width" ), extent.width(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent_height" ), extent.height(), true ) );
QgsGeometry centerPoint = QgsGeometry::fromPoint( extent.center() );
QgsGeometry centerPoint = QgsGeometry::fromPointXY( extent.center() );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent_center" ), QVariant::fromValue( centerPoint ), true ) );

if ( mComposition )
Expand Down
8 changes: 4 additions & 4 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -156,9 +156,9 @@ QgsGeometry QgsGeometry::fromWkt( const QString &wkt )
return QgsGeometry( std::move( geom ) );
}

QgsGeometry QgsGeometry::fromPoint( const QgsPointXY &point )
QgsGeometry QgsGeometry::fromPointXY( const QgsPointXY &point )
{
std::unique_ptr< QgsAbstractGeometry > geom( QgsGeometryFactory::fromPoint( point ) );
std::unique_ptr< QgsAbstractGeometry > geom( QgsGeometryFactory::fromPointXY( point ) );
if ( geom )
{
return QgsGeometry( geom.release() );
Expand All @@ -168,7 +168,7 @@ QgsGeometry QgsGeometry::fromPoint( const QgsPointXY &point )

QgsGeometry QgsGeometry::fromPolylineXY( const QgsPolylineXY &polyline )
{
std::unique_ptr< QgsAbstractGeometry > geom = QgsGeometryFactory::fromPolyline( polyline );
std::unique_ptr< QgsAbstractGeometry > geom = QgsGeometryFactory::fromPolylineXY( polyline );
if ( geom )
{
return QgsGeometry( std::move( geom ) );
Expand Down Expand Up @@ -2813,7 +2813,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
QgsMultiPointXY multiPoint = asMultiPoint();
if ( multiPoint.count() == 1 )
{
return fromPoint( multiPoint[0] );
return fromPointXY( multiPoint[0] );
}
}
return QgsGeometry();
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometry.h
Expand Up @@ -213,7 +213,7 @@ class CORE_EXPORT QgsGeometry
//! Creates a new geometry from a WKT string
static QgsGeometry fromWkt( const QString &wkt );
//! Creates a new geometry from a QgsPointXY object
static QgsGeometry fromPoint( const QgsPointXY &point );
static QgsGeometry fromPointXY( const QgsPointXY &point );
//! Creates a new geometry from a QgsMultiPointXY object
static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );

Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsgeometryfactory.cpp
Expand Up @@ -132,7 +132,7 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::geomFromWkt( const QStr
return geom;
}

std::unique_ptr< QgsAbstractGeometry > QgsGeometryFactory::fromPoint( const QgsPointXY &point )
std::unique_ptr< QgsAbstractGeometry > QgsGeometryFactory::fromPointXY( const QgsPointXY &point )
{
return qgis::make_unique< QgsPoint >( point.x(), point.y() );
}
Expand All @@ -149,7 +149,7 @@ std::unique_ptr<QgsMultiPoint> QgsGeometryFactory::fromMultiPointXY( const QgsMu
return mp;
}

std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::fromPolyline( const QgsPolylineXY &polyline )
std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::fromPolylineXY( const QgsPolylineXY &polyline )
{
return linestringFromPolyline( polyline );
}
Expand All @@ -159,7 +159,7 @@ std::unique_ptr<QgsMultiLineString> QgsGeometryFactory::fromMultiPolylineXY( con
std::unique_ptr< QgsMultiLineString > mLine = qgis::make_unique< QgsMultiLineString >();
for ( int i = 0; i < multiline.size(); ++i )
{
mLine->addGeometry( fromPolyline( multiline.at( i ) ).release() );
mLine->addGeometry( fromPolylineXY( multiline.at( i ) ).release() );
}
return mLine;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometryfactory.h
Expand Up @@ -65,11 +65,11 @@ class CORE_EXPORT QgsGeometryFactory
static std::unique_ptr< QgsAbstractGeometry > geomFromWkt( const QString &text );

//! Construct geometry from a point
static std::unique_ptr< QgsAbstractGeometry > fromPoint( const QgsPointXY &point );
static std::unique_ptr< QgsAbstractGeometry > fromPointXY( const QgsPointXY &point );
//! Construct geometry from a multipoint
static std::unique_ptr<QgsMultiPoint> fromMultiPointXY( const QgsMultiPointXY &multipoint );
//! Construct geometry from a polyline
static std::unique_ptr< QgsAbstractGeometry > fromPolyline( const QgsPolylineXY &polyline );
static std::unique_ptr< QgsAbstractGeometry > fromPolylineXY( const QgsPolylineXY &polyline );
//! Construct geometry from a multipolyline
static std::unique_ptr<QgsMultiLineString> fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
//! Construct geometry from a polygon
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpressioncontext.cpp
Expand Up @@ -921,7 +921,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::mapSettingsScope( const Qg
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent" ), QVariant::fromValue( extent ), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent_width" ), mapSettings.visibleExtent().width(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent_height" ), mapSettings.visibleExtent().height(), true ) );
QgsGeometry centerPoint = QgsGeometry::fromPoint( mapSettings.visibleExtent().center() );
QgsGeometry centerPoint = QgsGeometry::fromPointXY( mapSettings.visibleExtent().center() );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_extent_center" ), QVariant::fromValue( centerPoint ), true ) );

scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs" ), mapSettings.destinationCrs().authid(), true ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspointlocator.cpp
Expand Up @@ -194,7 +194,7 @@ class QgsPointLocator_VisitorArea : public IVisitor
QgsPointLocator_VisitorArea( QgsPointLocator *pl, const QgsPointXY &origPt, QgsPointLocator::MatchList &list )
: mLocator( pl )
, mList( list )
, mGeomPt( QgsGeometry::fromPoint( origPt ) )
, mGeomPt( QgsGeometry::fromPointXY( origPt ) )
{}

void visitNode( const INode &n ) override { Q_UNUSED( n ); }
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/topology/topolTest.cpp
Expand Up @@ -321,7 +321,7 @@ ErrorList topolTest::checkDanglingLines( double tolerance, QgsVectorLayer *layer
if ( repetitions == 1 )
{

QgsGeometry conflictGeom = QgsGeometry::fromPoint( p );
QgsGeometry conflictGeom = QgsGeometry::fromPointXY( p );
if ( isExtent )
{
if ( canvasExtentPoly.disjoint( conflictGeom ) )
Expand Down Expand Up @@ -807,7 +807,7 @@ ErrorList topolTest::checkPseudos( double tolerance, QgsVectorLayer *layer1, Qgs

if ( repetitions == 2 )
{
QgsGeometry conflictGeom = QgsGeometry::fromPoint( p );
QgsGeometry conflictGeom = QgsGeometry::fromPointXY( p );

if ( isExtent )
{
Expand Down Expand Up @@ -1253,8 +1253,8 @@ ErrorList topolTest::checkPointCoveredByLineEnds( double tolerance, QgsVectorLay
continue;
}
QgsPolylineXY g2Line = g2.asPolyline();
QgsGeometry startPoint = QgsGeometry::fromPoint( g2Line.at( 0 ) );
QgsGeometry endPoint = QgsGeometry::fromPoint( g2Line.last() );
QgsGeometry startPoint = QgsGeometry::fromPointXY( g2Line.at( 0 ) );
QgsGeometry endPoint = QgsGeometry::fromPointXY( g2Line.last() );
touched = g1.intersects( startPoint ) || g1.intersects( endPoint );

if ( touched )
Expand Down Expand Up @@ -1316,8 +1316,8 @@ ErrorList topolTest::checkyLineEndsCoveredByPoints( double tolerance, QgsVectorL
QgsGeometry g1 = it->feature.geometry();

QgsPolylineXY g1Polyline = g1.asPolyline();
QgsGeometry startPoint = QgsGeometry::fromPoint( g1Polyline.at( 0 ) );
QgsGeometry endPoint = QgsGeometry::fromPoint( g1Polyline.last() );
QgsGeometry startPoint = QgsGeometry::fromPointXY( g1Polyline.at( 0 ) );
QgsGeometry endPoint = QgsGeometry::fromPointXY( g1Polyline.last() );

QgsRectangle bb = g1.boundingBox();
QList<QgsFeatureId> crossingIds;
Expand Down
Expand Up @@ -436,7 +436,7 @@ QgsGeometry QgsDelimitedTextFeatureIterator::loadGeometryXY( const QStringList &

if ( ok && wantGeometry( pt ) )
{
return QgsGeometry::fromPoint( pt );
return QgsGeometry::fromPointXY( pt );
}
return QgsGeometry();
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Expand Up @@ -514,7 +514,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
{
QgsFeature f;
f.setId( mFile->recordId() );
f.setGeometry( QgsGeometry::fromPoint( pt ) );
f.setGeometry( QgsGeometry::fromPointXY( pt ) );
mSpatialIndex->insertFeature( f );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgis.v.in.cpp
Expand Up @@ -393,7 +393,7 @@ int main( int argc, char **argv )
}
QgsPointXY point( x, y );
QgsFeature feature( area );
feature.setGeometry( QgsGeometry::fromPoint( point ) );
feature.setGeometry( QgsGeometry::fromPointXY( point ) );
feature.setValid( true );
centroids.insert( area, feature );
spatialIndex.insertFeature( feature );
Expand Down
2 changes: 1 addition & 1 deletion tests/src/app/testqgsnodetool.cpp
Expand Up @@ -162,7 +162,7 @@ void TestQgsNodeTool::initTestCase()
polygonF1.setGeometry( QgsGeometry::fromPolygonXY( polygon1 ) );

QgsFeature pointF1;
pointF1.setGeometry( QgsGeometry::fromPoint( QgsPointXY( 2, 3 ) ) );
pointF1.setGeometry( QgsGeometry::fromPointXY( QgsPointXY( 2, 3 ) ) );

mLayerLine->startEditing();
mLayerLine->addFeature( lineF1 );
Expand Down

0 comments on commit e0025b6

Please sign in to comment.