Skip to content
Permalink
Browse files

Add interface API for geocoders

  • Loading branch information
nyalldawson committed Oct 29, 2020
1 parent 5ccad91 commit 94f3ea0d14344f24372a40cdaebeeefced4954f3
@@ -105,6 +105,7 @@ IF(WITH_APIDOC)
${CMAKE_SOURCE_DIR}/src/gui/vectortile
${CMAKE_SOURCE_DIR}/src/analysis
${CMAKE_SOURCE_DIR}/src/analysis/mesh
${CMAKE_SOURCE_DIR}/src/analysis/geocoding
${CMAKE_SOURCE_DIR}/src/analysis/interpolation
${CMAKE_SOURCE_DIR}/src/analysis/network
${CMAKE_SOURCE_DIR}/src/analysis/processing
@@ -312,22 +312,22 @@ ENDIF (WITH_SERVER AND WITH_SERVER_PLUGINS)
IF(WITH_ANALYSIS)
INCLUDE_DIRECTORIES(BEFORE
${CMAKE_SOURCE_DIR}/src/analysis
${CMAKE_SOURCE_DIR}/src/analysis/geocoding
${CMAKE_SOURCE_DIR}/src/analysis/processing
${CMAKE_SOURCE_DIR}/src/analysis/vector
${CMAKE_SOURCE_DIR}/src/analysis/vector/geometry_checker
${CMAKE_SOURCE_DIR}/src/analysis/mesh
${CMAKE_SOURCE_DIR}/src/analysis/raster
${CMAKE_SOURCE_DIR}/src/analysis/network
${CMAKE_SOURCE_DIR}/src/analysis/interpolation
${CMAKE_SOURCE_DIR}/src/analysis/openstreetmap

${CMAKE_BINARY_DIR}/src/analysis/processing
${CMAKE_BINARY_DIR}/src/analysis/vector
${CMAKE_BINARY_DIR}/src/analysis/mesh
${CMAKE_BINARY_DIR}/src/analysis/raster
${CMAKE_BINARY_DIR}/src/analysis/network
${CMAKE_BINARY_DIR}/src/analysis/interpolation
${CMAKE_BINARY_DIR}/src/analysis/openstreetmap
${CMAKE_BINARY_DIR}/src/analysis/geocoding
)

# analysis module
@@ -1,5 +1,8 @@
// Include auto-generated SIP files
%Include auto_generated/qgsanalysis.sip
%Include auto_generated/geocoding/qgsgeocoder.sip
%Include auto_generated/geocoding/qgsgeocodercontext.sip
%Include auto_generated/geocoding/qgsgeocoderresult.sip
%Include auto_generated/interpolation/qgsgridfilewriter.sip
%Include auto_generated/interpolation/qgsidwinterpolator.sip
%Include auto_generated/interpolation/qgsinterpolator.sip
@@ -0,0 +1,6 @@
# The following has been generated automatically from src/analysis/geocoding/qgsgeocoder.h
# monkey patching scoped based enum
QgsGeocoderInterface.Flag.GeocodesStrings.__doc__ = "Can geocode string input values"
QgsGeocoderInterface.Flag.GeocodesFeatures.__doc__ = "Can geocode QgsFeature input values"
QgsGeocoderInterface.Flag.__doc__ = 'Capability flags for the geocoder.\n\n' + '* ``GeocodesStrings``: ' + QgsGeocoderInterface.Flag.GeocodesStrings.__doc__ + '\n' + '* ``GeocodesFeatures``: ' + QgsGeocoderInterface.Flag.GeocodesFeatures.__doc__
# --
@@ -0,0 +1,87 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/geocoding/qgsgeocoder.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsGeocoderInterface
{
%Docstring
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.

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsgeocoder.h"
%End
public:

enum class Flag
{
GeocodesStrings,
GeocodesFeatures,
};
typedef QFlags<QgsGeocoderInterface::Flag> Flags;


virtual ~QgsGeocoderInterface();

virtual Flags flags() const = 0;
%Docstring
Returns the geocoder's capability flags.
%End

virtual QList< QgsGeocoderResult > geocodeFeature( const QgsFeature &feature, const QgsGeocoderContext &context, QgsFeedback *feedback = 0 ) const;
%Docstring
Geocodes a ``feature``.

If implemented by the geocoder (i.e. :py:func:`~QgsGeocoderInterface.flags` returns the QgsGeocoderInterface.Flag.GeocodesFeatures flag), a list of matching results will be returned.

The optional ``feedback`` argument can be used to provider cancelation support.
%End

virtual QgsFields appendedFields() const;
%Docstring
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.
%End

virtual QgsWkbTypes::Type wkbType() const;
%Docstring
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).
%End

virtual QList< QgsGeocoderResult > geocodeString( const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback = 0 ) const;
%Docstring
Geocodes a ``string``.

If implemented by the geocoder (i.e. :py:func:`~QgsGeocoderInterface.flags` returns the QgsGeocoderInterface.Flag.GeocodesStrings flag), a list of matching results will be returned.

The optional ``feedback`` argument can be used to provider cancelation support.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/geocoding/qgsgeocoder.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,108 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/geocoding/qgsgeocodercontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsGeocoderContext
{
%Docstring
Encapsulates the context of a geocoding operation.

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsgeocodercontext.h"
%End
public:

QgsGeocoderContext( const QgsCoordinateTransformContext &transformContext );
%Docstring
Constructor for QgsGeocoderContext, with the specified ``transformContext``.
%End

QgsCoordinateTransformContext transformContext() const;
%Docstring
Returns the coordinate transform context, which should be used whenever the
geocoder constructs a coordinate transform.

.. seealso:: :py:func:`setTransformContext`
%End

void setTransformContext( const QgsCoordinateTransformContext &context );
%Docstring
Sets the coordinate transform ``context``, which should be used whenever the
geocoder constructs a coordinate transform.

.. seealso:: :py:func:`transformContext`
%End

QgsGeometry areaOfInterest() const;
%Docstring
Returns the optional area of interest, which can be used to indicate the desired
geographic area where geocoding results are desired.

The area of interest can be a polygon geometry, in which case it represents the extent
to use for filtering candidate results, or a point geometry, in which case it represents
a "target point" for prioritising closer results.

The coordinate reference system for the area of interest can be retrieved via
:py:func:`~QgsGeocoderContext.areaOfInterestCrs`.

.. seealso:: :py:func:`setAreaOfInterest`

.. seealso:: :py:func:`areaOfInterestCrs`
%End

void setAreaOfInterest( const QgsGeometry &area );
%Docstring
Sets the optional ``area`` of interest, which can be used to indicate the desired
geographic area where geocoding results are desired.

The area of interest can be a polygon geometry, in which case it represents the extent
to use for filtering candidate results, or a point geometry, in which case it represents
a "target point" for prioritising closer results.

The coordinate reference system for the area of interest can be set via
:py:func:`~QgsGeocoderContext.setAreaOfInterestCrs`.

.. seealso:: :py:func:`areaOfInterest`

.. seealso:: :py:func:`setAreaOfInterestCrs`
%End

QgsCoordinateReferenceSystem areaOfInterestCrs() const;
%Docstring
Returns the coordinate reference system for the area of interest, which can be used to indicate the desired
geographic area where geocoding results are desired.

.. seealso:: :py:func:`areaOfInterest`

.. seealso:: :py:func:`setAreaOfInterestCrs`
%End

void setAreaOfInterestCrs( const QgsCoordinateReferenceSystem &crs );
%Docstring
Sets the ``crs`` for the area of interest, which can be used to indicate the desired
geographic area where geocoding results are desired.

.. seealso:: :py:func:`areaOfInterestCrs`

.. seealso:: :py:func:`setAreaOfInterest`
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/geocoding/qgsgeocodercontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,123 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/geocoding/qgsgeocoderresult.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsGeocoderResult
{
%Docstring
Represents a matching result from a geocoder search.

QgsGeocoderResult objects may represent valid matches, or an invalid
error result. This can be checked by testing :py:func:`~isValid`. An invalid
result represents that an error was encountered while geocoding, in which case the
error message can be retrieved by calling :py:func:`~error`.

Valid geocoding results will have a :py:func:`~geometry` and :py:func:`~crs`, along with a set
of optional :py:func:`~additionalAttributes` which may contain information such as the
accuracy of the geocoding result.

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsgeocoderresult.h"
%End
public:

static QgsGeocoderResult errorResult( const QString &errorMessage );
%Docstring
Creates an invalid error result, with the specified ``errorMessage`` string.
%End

QgsGeocoderResult( const QgsGeometry &geometry, const QgsCoordinateReferenceSystem &crs );
%Docstring
Constructor for a valid QgsGeocoderResult, with the specified ``geometry`` and ``crs``.
%End

bool isValid() const;
%Docstring
Returns ``True`` if the result is a valid result.

If the result is invalid, the error message can be retrieved by calling :py:func:`~QgsGeocoderResult.error`.
%End

QString error() const;
%Docstring
Returns the error string, if the result is invalid.
%End

QgsGeometry geometry() const;
%Docstring
Returns the resultant geometry resulting from the geocoding operation.

The coordinate reference system for the geometry can be retrieved
via :py:func:`~QgsGeocoderResult.crs`.

.. seealso:: :py:func:`setGeometry`

.. seealso:: :py:func:`crs`
%End

void setGeometry( const QgsGeometry &geometry );
%Docstring
Sets the resultant ``geometry`` resulting from the geocoding operation.

The coordinate reference system for the geometry should also be set
via :py:func:`~QgsGeocoderResult.setCrs`.

.. seealso:: :py:func:`geometry`

.. seealso:: :py:func:`setCrs`
%End

QgsCoordinateReferenceSystem crs() const;
%Docstring
Returns the coordinate reference system for the calculated :py:func:`~QgsGeocoderResult.geometry`.

.. seealso:: :py:func:`setCrs`

.. seealso:: :py:func:`geometry`
%End

void setCrs( const QgsCoordinateReferenceSystem &crs );
%Docstring
Sets the coordinate reference system for the calculated :py:func:`~QgsGeocoderResult.geometry`.

.. seealso:: :py:func:`crs`

.. seealso:: :py:func:`geometry`
%End

QVariantMap additionalAttributes() const;
%Docstring
Contains additional attributes generated during the geocode,
which may be added to features being geocoded.

.. seealso:: :py:func:`setAdditionalAttributes`
%End

void setAdditionalAttributes( const QVariantMap &attributes );
%Docstring
Setss additional attributes generated during the geocode,
which may be added to features being geocoded.

.. seealso:: :py:func:`additionalAttributes`
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/geocoding/qgsgeocoderresult.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -4,6 +4,10 @@
SET(QGIS_ANALYSIS_SRCS
qgsanalysis.cpp

geocoding/qgsgeocoder.cpp
geocoding/qgsgeocodercontext.cpp
geocoding/qgsgeocoderresult.cpp

interpolation/qgsgridfilewriter.cpp
interpolation/qgsidwinterpolator.cpp
interpolation/qgsinterpolator.cpp
@@ -280,6 +284,10 @@ SET(QGIS_ANALYSIS_SRCS
SET(QGIS_ANALYSIS_HDRS
qgsanalysis.h

geocoding/qgsgeocoder.h
geocoding/qgsgeocodercontext.h
geocoding/qgsgeocoderresult.h

interpolation/Bezier3D.h
interpolation/CloughTocherInterpolator.h
interpolation/qgsdualedgetriangulation.h
@@ -434,6 +442,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}/src/analysis
interpolation
network
geocoding
)
INCLUDE_DIRECTORIES(SYSTEM
${SPATIALINDEX_INCLUDE_DIR} # before GEOS for case-insensitive filesystems

0 comments on commit 94f3ea0

Please sign in to comment.
You can’t perform that action at this time.