/
qgsgeocoder.h
94 lines (80 loc) · 3.33 KB
/
qgsgeocoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/***************************************************************************
qgsgeocoder.h
---------------
Date : August 2020
Copyright : (C) 2020 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 QGSGEOCODER_H
#define QGSGEOCODER_H
#include "qgis_core.h"
#include "qgsgeocoderresult.h"
#include "qgsgeometry.h"
#include "qgsfields.h"
class QgsFeature;
class QgsGeocoderContext;
/**
* \ingroup core
* Interface for geocoders.
*
* QgsGeocoderInterface implementations are able to take either a QgsFeature or a free-form string
* and calculate the corresponding geometry of the feature.
*
* \since QGIS 3.18
*/
class CORE_EXPORT QgsGeocoderInterface
{
public:
//! Capability flags for the geocoder.
enum class Flag
{
GeocodesStrings = 1 << 0, //!< Can geocode string input values
GeocodesFeatures = 1 << 1, //!< Can geocode QgsFeature input values
};
Q_DECLARE_FLAGS( Flags, Flag )
virtual ~QgsGeocoderInterface() = default;
/**
* Returns the geocoder's capability flags.
*/
virtual Flags flags() const = 0;
/**
* Geocodes a \a feature.
*
* If implemented by the geocoder (i.e. flags() returns the QgsGeocoderInterface::Flag::GeocodesFeatures flag), a list of matching results will be returned.
*
* The optional \a feedback argument can be used to provider cancellation support.
*/
virtual QList< QgsGeocoderResult > geocodeFeature( const QgsFeature &feature, const QgsGeocoderContext &context, QgsFeedback *feedback = nullptr ) const;
/**
* Returns a set of newly created fields which will be appended to existing features during the geocode
* operation.
*
* These fields will include any extra content returned by the geocoder, such as fields for accuracy of the
* match or correct attribute values.
*/
virtual QgsFields appendedFields() const;
/**
* Returns the WKB type of geometries returned by the geocoder.
*
* If this is not known in advance then QgsWkbTypes::Unknown should be returned (e.g.
* in the case that a geocoder may return different geometry types depending on the
* quality of the match).
*/
virtual QgsWkbTypes::Type wkbType() const;
/**
* Geocodes a \a string.
*
* If implemented by the geocoder (i.e. flags() returns the QgsGeocoderInterface::Flag::GeocodesStrings flag), a list of matching results will be returned.
*
* The optional \a feedback argument can be used to provider cancellation support.
*/
virtual QList< QgsGeocoderResult > geocodeString( const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback = nullptr ) const;
};
#endif // QGSGEOCODER_H