Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE][processing] Add a batch nominatim geocoder algorithm
- Loading branch information
Showing
4 changed files
with
125 additions
and
0 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
59 changes: 59 additions & 0 deletions
59
src/analysis/processing/qgsalgorithmbatchnominatimgeocode.cpp
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,59 @@ | ||
/*************************************************************************** | ||
qgsalgorithmbatchnominatimgeocode.cpp | ||
------------------ | ||
begin : December 2020 | ||
copyright : (C) 2020 by Mathieu Pellerin | ||
email : nirvn dot asia 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 "qgsalgorithmbatchgeocode.h" | ||
#include "qgsalgorithmbatchnominatimgeocode.h" | ||
#include "qgsgeocoder.h" | ||
#include "qgsgeocoderresult.h" | ||
#include "qgsgeocodercontext.h" | ||
#include "qgsvectorlayer.h" | ||
|
||
///@cond PRIVATE | ||
|
||
QgsBatchNominatimGeocodeAlgorithm::QgsBatchNominatimGeocodeAlgorithm() | ||
: QgsBatchGeocodeAlgorithm( &mNominatimGeocoder ) | ||
{ | ||
} | ||
|
||
QString QgsBatchNominatimGeocodeAlgorithm::name() const | ||
{ | ||
return QStringLiteral( "batchnominatimgeocoder" ); | ||
} | ||
|
||
QString QgsBatchNominatimGeocodeAlgorithm::displayName() const | ||
{ | ||
return QObject::tr( "Batch Nominatim geocoder" ); | ||
} | ||
|
||
QStringList QgsBatchNominatimGeocodeAlgorithm::tags() const | ||
{ | ||
return QObject::tr( "geocode,nominatim,batch" ).split( ',' ); | ||
} | ||
|
||
QgsBatchNominatimGeocodeAlgorithm *QgsBatchNominatimGeocodeAlgorithm::createInstance() const | ||
{ | ||
return new QgsBatchNominatimGeocodeAlgorithm(); | ||
} | ||
|
||
bool QgsBatchNominatimGeocodeAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) | ||
{ | ||
feedback->pushInfo( QObject::tr( "The Nominatim geocoder data is made available by OpenStreetMap Foundation and contributors. " | ||
"It is provided under the ODbL license which requires to share alike. Visit https://nominatim.org/ to learn more." ) ); | ||
return QgsBatchGeocodeAlgorithm::prepareAlgorithm( parameters, context, feedback ); | ||
} | ||
|
||
///@endcond |
62 changes: 62 additions & 0 deletions
62
src/analysis/processing/qgsalgorithmbatchnominatimgeocode.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*************************************************************************** | ||
qgsalgorithmbatchnominatimgeocode.h | ||
------------------ | ||
begin : December 2020 | ||
copyright : (C) 2020 by Mathieu Pellerin | ||
email : nirvn dot asia 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 QGSALGORITHMBATCHNOMINATIMGEOCODE_H | ||
#define QGSALGORITHMBATCHNOMINATIMGEOCODE_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis_sip.h" | ||
#include "qgis_analysis.h" | ||
#include "qgsprocessingalgorithm.h" | ||
#include "qgsalgorithmbatchgeocode.h" | ||
#include "qgsnominatimgeocoder.h" | ||
|
||
///@cond PRIVATE | ||
|
||
/** | ||
* Native batch Nominatim geocoder. | ||
*/ | ||
class QgsBatchNominatimGeocodeAlgorithm : public QgsBatchGeocodeAlgorithm | ||
{ | ||
|
||
public: | ||
|
||
/** | ||
* Constructor for QgsBatchNominatimGeocodeAlgorithm. | ||
*/ | ||
QgsBatchNominatimGeocodeAlgorithm(); | ||
|
||
QString name() const override; | ||
QString displayName() const override; | ||
QStringList tags() const override; | ||
QgsBatchNominatimGeocodeAlgorithm *createInstance() const override SIP_FACTORY; | ||
|
||
protected: | ||
bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; | ||
|
||
private: | ||
|
||
QgsNominatimGeocoder mNominatimGeocoder; | ||
|
||
}; | ||
|
||
///@endcond PRIVATE | ||
|
||
#endif // QGSALGORITHMBATCHNOMINATIMGEOCODE_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