-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processing] Port point on surface to c++
- Loading branch information
1 parent
0a6024b
commit 871132e
Showing
8 changed files
with
139 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*************************************************************************** | ||
qgsalgorithmpointonsurface.cpp | ||
------------------------ | ||
begin : March 2018 | ||
copyright : (C) 2018 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsalgorithmpointonsurface.h" | ||
|
||
///@cond PRIVATE | ||
|
||
QString QgsPointOnSurfaceAlgorithm::name() const | ||
{ | ||
return QStringLiteral( "pointonsurface" ); | ||
} | ||
|
||
QString QgsPointOnSurfaceAlgorithm::displayName() const | ||
{ | ||
return QObject::tr( "Point on surface" ); | ||
} | ||
|
||
QStringList QgsPointOnSurfaceAlgorithm::tags() const | ||
{ | ||
return QObject::tr( "centroid,inside,within" ).split( ',' ); | ||
} | ||
|
||
QString QgsPointOnSurfaceAlgorithm::group() const | ||
{ | ||
return QObject::tr( "Vector geometry" ); | ||
} | ||
|
||
QString QgsPointOnSurfaceAlgorithm::groupId() const | ||
{ | ||
return QStringLiteral( "vectorgeometry" ); | ||
} | ||
|
||
QString QgsPointOnSurfaceAlgorithm::outputName() const | ||
{ | ||
return QObject::tr( "Point" ); | ||
} | ||
|
||
QString QgsPointOnSurfaceAlgorithm::shortHelpString() const | ||
{ | ||
return QObject::tr( "Returns a point guaranteed to lie on the surface of a geometry." ); | ||
} | ||
|
||
QgsPointOnSurfaceAlgorithm *QgsPointOnSurfaceAlgorithm::createInstance() const | ||
{ | ||
return new QgsPointOnSurfaceAlgorithm(); | ||
} | ||
|
||
QgsFeatureList QgsPointOnSurfaceAlgorithm::processFeature( const QgsFeature &f, QgsProcessingContext &, QgsProcessingFeedback *feedback ) | ||
{ | ||
QgsFeature feature = f; | ||
if ( feature.hasGeometry() ) | ||
{ | ||
QgsGeometry outputGeometry = feature.geometry().pointOnSurface(); | ||
if ( !outputGeometry ) | ||
{ | ||
feedback->pushInfo( QObject::tr( "Error calculating point on surface for feature %1: %2" ).arg( feature.id() ).arg( outputGeometry.lastError() ) ); | ||
} | ||
feature.setGeometry( outputGeometry ); | ||
} | ||
return QgsFeatureList() << feature; | ||
} | ||
|
||
///@endcond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*************************************************************************** | ||
qgsalgorithmpointonsurface.h | ||
---------------------- | ||
begin : March 2018 | ||
copyright : (C) 2018 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSALGORITHMPOINTONSURFACE_H | ||
#define QGSALGORITHMPOINTONSURFACE_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis.h" | ||
#include "qgsprocessingalgorithm.h" | ||
|
||
///@cond PRIVATE | ||
|
||
/** | ||
* Native centroid algorithm. | ||
*/ | ||
class QgsPointOnSurfaceAlgorithm : public QgsProcessingFeatureBasedAlgorithm | ||
{ | ||
|
||
public: | ||
|
||
QgsPointOnSurfaceAlgorithm() = default; | ||
QString name() const override; | ||
QString displayName() const override; | ||
QStringList tags() const override; | ||
QString group() const override; | ||
QString groupId() const override; | ||
QString shortHelpString() const override; | ||
QgsPointOnSurfaceAlgorithm *createInstance() const override SIP_FACTORY; | ||
|
||
protected: | ||
|
||
QString outputName() const override; | ||
QgsProcessing::SourceType outputLayerType() const override { return QgsProcessing::TypeVectorPoint; } | ||
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const override { Q_UNUSED( inputWkbType ); return QgsWkbTypes::Point; } | ||
|
||
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; | ||
}; | ||
|
||
///@endcond PRIVATE | ||
|
||
#endif // QGSALGORITHMPOINTONSURFACE_H | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters