QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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
19
21#include "qgsgeocoder.h"
22#include "qgsgeocodercontext.h"
23#include "qgsgeocoderresult.h"
24#include "qgsvectorlayer.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
31
32QgsBatchNominatimGeocodeAlgorithm::QgsBatchNominatimGeocodeAlgorithm()
33 : QgsBatchGeocodeAlgorithm( &mNominatimGeocoder )
34{}
35
36QString QgsBatchNominatimGeocodeAlgorithm::name() const
37{
38 return u"batchnominatimgeocoder"_s;
39}
40
41QString QgsBatchNominatimGeocodeAlgorithm::displayName() const
42{
43 return QObject::tr( "Batch Nominatim geocoder" );
44}
45
46QStringList QgsBatchNominatimGeocodeAlgorithm::tags() const
47{
48 return QObject::tr( "geocode,nominatim,batch,bulk,address,match" ).split( ',' );
49}
50
51QgsCoordinateReferenceSystem QgsBatchNominatimGeocodeAlgorithm::outputCrs( const QgsCoordinateReferenceSystem &inputCrs ) const
52{
53 mOutputCrs = inputCrs.isValid() ? inputCrs : QgsCoordinateReferenceSystem( u"EPSG:4326"_s );
54 return mOutputCrs;
55}
56
57QgsBatchNominatimGeocodeAlgorithm *QgsBatchNominatimGeocodeAlgorithm::createInstance() const
58{
59 return new QgsBatchNominatimGeocodeAlgorithm();
60}
61
62QString QgsBatchNominatimGeocodeAlgorithm::shortHelpString() const
63{
64 return QObject::tr(
65 "This algorithm performs batch geocoding using the <a href=\"https://nominatim.qgis.org/\">Nominatim</a> service against an input layer string field.\n\n"
66 "The output layer will have a point geometry reflecting the geocoded location as well as a number of attributes associated to the geocoded location."
67 );
68}
69
70QString QgsBatchNominatimGeocodeAlgorithm::shortDescription() const
71{
72 return QObject::tr( "Geocodes features in a vector layer using the Nominatim service." );
73}
74
75bool QgsBatchNominatimGeocodeAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
76{
77 feedback->pushInfo(
78 QObject::tr(
79 "The Nominatim geocoder data is made available by OpenStreetMap Foundation and contributors. "
80 "It is provided under the ODbL license which requires to share alike. Visit https://nominatim.org/ to learn more."
81 )
82 );
83 return QgsBatchGeocodeAlgorithm::prepareAlgorithm( parameters, context, feedback );
84}
85
A base class for batch geocoder algorithms, which takes a QgsGeocoderInterface object and exposes it ...
bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) override
Prepares the algorithm to run using the specified parameters.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.