QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsalgorithmbatchnominatimgeocode.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmbatchnominatimgeocode.cpp
3  ------------------
4  begin : December 2020
5  copyright : (C) 2020 by Mathieu Pellerin
6  email : nirvn dot asia at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
20 #include "qgsgeocoder.h"
21 #include "qgsgeocoderresult.h"
22 #include "qgsgeocodercontext.h"
23 #include "qgsvectorlayer.h"
24 
26 
27 QgsBatchNominatimGeocodeAlgorithm::QgsBatchNominatimGeocodeAlgorithm()
28  : QgsBatchGeocodeAlgorithm( &mNominatimGeocoder )
29 {
30 }
31 
32 QString QgsBatchNominatimGeocodeAlgorithm::name() const
33 {
34  return QStringLiteral( "batchnominatimgeocoder" );
35 }
36 
37 QString QgsBatchNominatimGeocodeAlgorithm::displayName() const
38 {
39  return QObject::tr( "Batch Nominatim geocoder" );
40 }
41 
42 QStringList QgsBatchNominatimGeocodeAlgorithm::tags() const
43 {
44  return QObject::tr( "geocode,nominatim,batch,bulk,address,match" ).split( ',' );
45 }
46 
48 {
49  mOutputCrs = inputCrs.isValid() ? inputCrs : QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
50  return mOutputCrs;
51 }
52 
53 QgsBatchNominatimGeocodeAlgorithm *QgsBatchNominatimGeocodeAlgorithm::createInstance() const
54 {
55  return new QgsBatchNominatimGeocodeAlgorithm();
56 }
57 
58 QString QgsBatchNominatimGeocodeAlgorithm::shortHelpString() const
59 {
60  return QObject::tr( "This algorithm performs batch geocoding using the <a href=\"#\">Nominatim</a> service against an input layer string field.\n\n"
61  "The output layer will have a point geometry reflecting the geocoded location as well as a number of attributes associated to the geocoded location." );
62 }
63 
64 bool QgsBatchNominatimGeocodeAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
65 {
66  feedback->pushInfo( QObject::tr( "The Nominatim geocoder data is made available by OpenStreetMap Foundation and contributors. "
67  "It is provided under the ODbL license which requires to share alike. Visit https://nominatim.org/ to learn more." ) );
68  return QgsBatchGeocodeAlgorithm::prepareAlgorithm( parameters, context, feedback );
69 }
70 
outputCrs
const QgsCoordinateReferenceSystem & outputCrs
Definition: qgswfsgetfeature.cpp:115
qgsalgorithmbatchnominatimgeocode.h
qgsgeocoder.h
QgsProcessingFeedback
Base class for providing feedback from a processing algorithm.
Definition: qgsprocessingfeedback.h:37
QgsProcessingFeedback::pushInfo
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
Definition: qgsprocessingfeedback.cpp:77
QgsBatchGeocodeAlgorithm
A base class for batch geocoder algorithms, which takes a QgsGeocoderInterface object and exposes it ...
Definition: qgsalgorithmbatchgeocode.h:68
qgsgeocoderresult.h
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:46
QgsCoordinateReferenceSystem::isValid
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Definition: qgscoordinatereferencesystem.cpp:977
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
qgsvectorlayer.h
QgsBatchGeocodeAlgorithm::prepareAlgorithm
bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) override
Prepares the algorithm to run using the specified parameters.
Definition: qgsalgorithmbatchgeocode.cpp:79
qgsalgorithmbatchgeocode.h
qgsgeocodercontext.h