QGIS/python/core/auto_generated/qgsjsonutils.sip.in

318 lines
9.2 KiB
Plaintext
Raw Normal View History

2017-05-02 17:36:51 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsjsonutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsJsonExporter
{
2017-05-02 17:36:51 +02:00
%Docstring
Handles exporting QgsFeature features to GeoJSON features.
2017-12-15 10:36:55 -04:00
Note that geometries will be automatically reprojected to WGS84 to match GeoJSON spec
if either the source vector layer or source CRS is set.
2017-05-02 17:36:51 +02:00
.. versionadded:: 2.16
%End
%TypeHeaderCode
2017-05-02 17:36:51 +02:00
#include "qgsjsonutils.h"
%End
public:
QgsJsonExporter( QgsVectorLayer *vectorLayer = 0, int precision = 6 );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsJsonExporter.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param vectorLayer: associated vector layer (required for related attribute export)
:param precision: maximum number of decimal places to use for geometry coordinates,
the RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
2017-05-02 17:36:51 +02:00
%End
void setPrecision( int precision );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the maximum number of decimal places to use in geometry coordinates.
The RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param precision: number of decimal places
.. seealso:: :py:func:`precision`
2017-05-02 17:36:51 +02:00
%End
int precision() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the maximum number of decimal places to use in geometry coordinates.
.. seealso:: :py:func:`setPrecision`
2017-05-02 17:36:51 +02:00
%End
void setIncludeGeometry( bool includeGeometry );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets whether to include geometry in the JSON exports.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param includeGeometry: set to false to prevent geometry inclusion
.. seealso:: :py:func:`includeGeometry`
2017-05-02 17:36:51 +02:00
%End
bool includeGeometry() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns whether geometry will be included in the JSON exports.
.. seealso:: :py:func:`setIncludeGeometry`
2017-05-02 17:36:51 +02:00
%End
void setIncludeAttributes( bool includeAttributes );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets whether to include attributes in the JSON exports.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param includeAttributes: set to false to prevent attribute inclusion
.. seealso:: :py:func:`includeAttributes`
2017-05-02 17:36:51 +02:00
%End
bool includeAttributes() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns whether attributes will be included in the JSON exports.
.. seealso:: :py:func:`setIncludeAttributes`
2017-05-02 17:36:51 +02:00
%End
void setIncludeRelated( bool includeRelated );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets whether to include attributes of features linked via references in the JSON exports.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param includeRelated: set to true to include attributes for any related child features
within the exported properties element.
2017-05-02 17:36:51 +02:00
.. note::
associated vector layer must be set with setVectorLayer()
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`includeRelated`
2017-05-02 17:36:51 +02:00
%End
bool includeRelated() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns whether attributes of related (child) features will be included in the JSON exports.
.. seealso:: :py:func:`setIncludeRelated`
2017-05-02 17:36:51 +02:00
%End
void setVectorLayer( QgsVectorLayer *vectorLayer );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the associated vector layer (required for related attribute export). This will automatically
update the sourceCrs() to match.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param vectorLayer: vector layer
.. seealso:: :py:func:`vectorLayer`
2017-05-02 17:36:51 +02:00
%End
QgsVectorLayer *vectorLayer() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the associated vector layer, if set.
.. seealso:: :py:func:`setVectorLayer`
2017-05-02 17:36:51 +02:00
%End
void setSourceCrs( const QgsCoordinateReferenceSystem &crs );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the source CRS for feature geometries. The source CRS must be set if geometries are to be
correctly automatically reprojected to WGS 84, to match GeoJSON specifications.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param crs: source CRS for input feature geometries
2017-05-02 17:36:51 +02:00
.. note::
the source CRS will be overwritten when a vector layer is specified via setVectorLayer()
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`sourceCrs`
2017-05-02 17:36:51 +02:00
%End
QgsCoordinateReferenceSystem sourceCrs() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the source CRS for feature geometries. The source CRS must be set if geometries are to be
correctly automatically reprojected to WGS 84, to match GeoJSON specifications.
.. seealso:: :py:func:`setSourceCrs`
2017-05-02 17:36:51 +02:00
%End
void setAttributes( const QgsAttributeList &attributes );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the list of attributes to include in the JSON exports.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param attributes: list of attribute indexes, or an empty list to include all
attributes
.. seealso:: :py:func:`attributes`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`setExcludedAttributes`
2017-12-15 10:36:55 -04:00
2017-05-02 17:36:51 +02:00
.. note::
Attributes excluded via setExcludedAttributes() take precedence over
2018-01-12 20:51:17 -04:00
attributes specified by this method.
2017-05-02 17:36:51 +02:00
%End
QgsAttributeList attributes() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the list of attributes which will be included in the JSON exports, or
an empty list if all attributes will be included.
.. seealso:: :py:func:`setAttributes`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`excludedAttributes`
2017-12-15 10:36:55 -04:00
2017-05-02 17:36:51 +02:00
.. note::
Attributes excluded via excludedAttributes() take precedence over
2018-01-12 20:51:17 -04:00
attributes returned by this method.
2017-05-02 17:36:51 +02:00
%End
void setExcludedAttributes( const QgsAttributeList &attributes );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets a list of attributes to specifically exclude from the JSON exports. Excluded attributes
take precedence over attributes included via setAttributes().
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param attributes: list of attribute indexes to exclude
.. seealso:: :py:func:`excludedAttributes`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`setAttributes`
2017-05-02 17:36:51 +02:00
%End
QgsAttributeList excludedAttributes() const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a list of attributes which will be specifically excluded from the JSON exports. Excluded attributes
take precedence over attributes included via attributes().
.. seealso:: :py:func:`setExcludedAttributes`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`attributes`
2017-05-02 17:36:51 +02:00
%End
2017-05-02 17:36:51 +02:00
QString exportFeature( const QgsFeature &feature,
const QVariantMap &extraProperties = QVariantMap(),
const QVariant &id = QVariant() ) const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a GeoJSON string representation of a feature.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param feature: feature to convert
:param extraProperties: map of extra attributes to include in feature's properties
:param id: optional ID to use as GeoJSON feature's ID instead of input feature's ID. If omitted, feature's
ID is used.
:return: GeoJSON string
.. seealso:: :py:func:`exportFeatures`
2017-05-02 17:36:51 +02:00
%End
QString exportFeatures( const QgsFeatureList &features ) const;
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a GeoJSON string representation of a list of features (feature collection).
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param features: features to convert
:return: GeoJSON string
.. seealso:: :py:func:`exportFeature`
2017-05-02 17:36:51 +02:00
%End
};
class QgsJsonUtils
{
2017-05-02 17:36:51 +02:00
%Docstring
Helper utilities for working with JSON and GeoJSON conversions.
2017-12-15 10:36:55 -04:00
2017-05-02 17:36:51 +02:00
.. versionadded:: 2.16
%End
2017-05-02 17:36:51 +02:00
%TypeHeaderCode
#include "qgsjsonutils.h"
%End
public:
static QgsFeatureList stringToFeatureList( const QString &string, const QgsFields &fields, QTextCodec *encoding );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Attempts to parse a GeoJSON string to a collection of features.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param string: GeoJSON string to parse
:param fields: fields collection to use for parsed features
:param encoding: text encoding
:return: list of parsed features, or an empty list if no features could be parsed
.. seealso:: :py:func:`stringToFields`
2017-12-15 10:36:55 -04:00
2017-05-02 17:36:51 +02:00
.. note::
2017-12-19 11:43:52 -04:00
this function is a wrapper around :py:func:`QgsOgrUtils.stringToFeatureList()`
2017-05-02 17:36:51 +02:00
%End
static QgsFields stringToFields( const QString &string, QTextCodec *encoding );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Attempts to retrieve the fields from a GeoJSON string representing a collection of features.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param string: GeoJSON string to parse
:param encoding: text encoding
:return: retrieved fields collection, or an empty list if no fields could be determined from the string
.. seealso:: :py:func:`stringToFeatureList`
2017-12-15 10:36:55 -04:00
2017-05-02 17:36:51 +02:00
.. note::
2017-12-19 11:43:52 -04:00
this function is a wrapper around :py:func:`QgsOgrUtils.stringToFields()`
2017-05-02 17:36:51 +02:00
%End
static QString encodeValue( const QVariant &value );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Encodes a value to a JSON string representation, adding appropriate quotations and escaping
where required.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param value: value to encode
:return: encoded value
2017-05-02 17:36:51 +02:00
%End
static QString exportAttributes( const QgsFeature &feature, QgsVectorLayer *layer = 0,
2017-09-11 21:19:22 +10:00
const QVector<QVariant> &attributeWidgetCaches = QVector<QVariant>() );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Exports all attributes from a QgsFeature as a JSON map type.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param feature: feature to export
:param layer: optional associated vector layer. If specified, this allows
richer export utilising settings like the layer's fields widget configuration.
:param attributeWidgetCaches: optional widget configuration cache. Can be used
to speed up exporting the attributes for multiple features from the same layer.
2017-05-02 17:36:51 +02:00
%End
static QVariantList parseArray( const QString &json, QVariant::Type type );
2017-05-02 17:36:51 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Parse a simple array (depth=1).
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param json: the JSON to parse
:param type: the type of the elements
2017-05-02 17:36:51 +02:00
.. versionadded:: 3.0
%End
};
2017-05-02 17:36:51 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsjsonutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/