Skip to content

Commit

Permalink
Merge pull request #2586 from nyalldawson/coordinate_formatter
Browse files Browse the repository at this point in the history
Initial implementation of QgsCoordinateFormatter
  • Loading branch information
nyalldawson committed Nov 15, 2017
2 parents ac574e2 + 3734a0d commit fbe5a17
Show file tree
Hide file tree
Showing 112 changed files with 1,913 additions and 1,563 deletions.
9 changes: 8 additions & 1 deletion doc/api_break.dox
Expand Up @@ -453,6 +453,9 @@ QgsAbstractGeometry {#qgis_api_break_3_0_QgsAbstractGeometry}
- asWkb() returns QByteArray instead of new raw pointer
- wkbSize() has been removed, use asWkb() to get length of returned QByteArray
- fromWkb() gets the WKB pointer passed by reference instead of value, so that caller may to find out where the parsing ended
- asGML2() was renamed to asGml2()
- asGML3() was renamed to asGml3()
- asJSON() was renamed to asJson()


QgsActionManager {#qgis_api_break_3_0_QgsActionManager}
Expand Down Expand Up @@ -1313,7 +1316,7 @@ can force a detach and full clone of the geometry, so it is preferable to use th
method if the geometry is not being modified.
- isEmpty() was renamed to isNull() to differentiate a missing geometry from a geometry which is empty (eg an
empty geometry collection)
- wkbSize() and asWkb() has been replaced by exportToWkb(). WKB representation is no longer cached within QgsGeometry
- wkbSize() was removed. WKB representation is no longer cached within QgsGeometry
- asGeos() has been replaced by exportToGeos(). GEOS representation is no longer cached within QgsGeometry
- int addPart( const QList<QgsPoint> &points, QgsWkbTypes::GeometryType geomType ) has been renamed to addPointsXY
- int addPart( const QList<QgsPointV2> &points, QgsWkbTypes::GeometryType geomType ) has been renamed to addPoints
Expand All @@ -1333,6 +1336,8 @@ maintains Z or M dimensions from the input points and is more efficient.
- fromMultiPolyline() was renamed to fromMultiPolylineXY()
- fromPolygon() was renamed to fromPolygonXY()
- fromMultiPolygon() was renamed to fromMultiPolygonXY()
- exportToWkt() was renamed to asWkt()
- exportToGeoJSON() was renamed to asJson()


QgsGeometryAnalyzer {#qgis_api_break_3_0_QgsGeometryAnalyzer}
Expand Down Expand Up @@ -1963,6 +1968,8 @@ QgsPoint {#qgis_api_break_3_0_QgsPoint}
--------

- onSegment() has been removed. Use sqrDistToSegment() instead for a more precise test.
- toDegreesMinutesSeconds() and toDegreesMinutes() have been removed. Use QgsCoordinateFormatter instead.
- wellKnownText() was renamed to asWkt()


QgsPointDisplacementRenderer {#qgis_api_break_3_0_QgsPointDisplacementRenderer}
Expand Down
2 changes: 1 addition & 1 deletion python/__init__.py
Expand Up @@ -83,7 +83,7 @@ def mapping_feature(feature):


def mapping_geometry(geometry):
geo = geometry.exportToGeoJSON()
geo = geometry.asJson()
# We have to use eval because exportToGeoJSON() gives us
# back a string that looks like a dictionary.
return eval(geo)
Expand Down
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -21,6 +21,7 @@
%Include qgscolorscheme.sip
%Include qgscolorschemeregistry.sip
%Include qgsconditionalstyle.sip
%Include qgscoordinateformatter.sip
%Include qgscoordinatetransform.sip
%Include qgscrscache.sip
%Include qgsdartmeasurement.sip
Expand Down
40 changes: 20 additions & 20 deletions python/core/geometry/qgsabstractgeometry.sip
Expand Up @@ -166,7 +166,7 @@ class QgsAbstractGeometry
.. seealso:: asWkt
.. seealso:: asGML2
.. seealso:: asGML3
.. seealso:: asJSON
.. seealso:: asJson()
.. versionadded:: 3.0
:rtype: QByteArray
%End
Expand All @@ -175,47 +175,47 @@ class QgsAbstractGeometry
%Docstring
Returns a WKT representation of the geometry.
\param precision number of decimal places for coordinates
.. seealso:: asWkb
.. seealso:: asGML2
.. seealso:: asGML3
.. seealso:: asJSON
.. seealso:: asWkb()
.. seealso:: asGml2()
.. seealso:: asGml3()
.. seealso:: asJson()
:rtype: str
%End

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const = 0;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const = 0;
%Docstring
Returns a GML2 representation of the geometry.
\param doc DOM document
\param precision number of decimal places for coordinates
\param ns XML namespace
.. seealso:: asWkb
.. seealso:: asWkt
.. seealso:: asGML3
.. seealso:: asJSON
.. seealso:: asWkb()
.. seealso:: asWkt()
.. seealso:: asGml3()
.. seealso:: asJson()
:rtype: QDomElement
%End

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const = 0;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const = 0;
%Docstring
Returns a GML3 representation of the geometry.
\param doc DOM document
\param precision number of decimal places for coordinates
\param ns XML namespace
.. seealso:: asWkb
.. seealso:: asWkt
.. seealso:: asGML2
.. seealso:: asJSON
.. seealso:: asWkb()
.. seealso:: asWkt()
.. seealso:: asGml2()
.. seealso:: asJson()
:rtype: QDomElement
%End

virtual QString asJSON( int precision = 17 ) const = 0;
virtual QString asJson( int precision = 17 ) const = 0;
%Docstring
Returns a GeoJSON representation of the geometry.
\param precision number of decimal places for coordinates
.. seealso:: asWkb
.. seealso:: asWkt
.. seealso:: asGML2
.. seealso:: asGML3
.. seealso:: asWkb()
.. seealso:: asWkt()
.. seealso:: asGml2()
.. seealso:: asGml3()
:rtype: str
%End

Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgscircularstring.sip
Expand Up @@ -47,11 +47,11 @@ class QgsCircularString: QgsCurve

virtual QString asWkt( int precision = 17 ) const;

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;


virtual bool isEmpty() const;
Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgscompoundcurve.sip
Expand Up @@ -47,11 +47,11 @@ class QgsCompoundCurve: QgsCurve

virtual QString asWkt( int precision = 17 ) const;

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;


virtual double length() const;
Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgscurvepolygon.sip
Expand Up @@ -50,11 +50,11 @@ class QgsCurvePolygon: QgsSurface

virtual QString asWkt( int precision = 17 ) const;

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;


virtual double area() const;
Expand Down
16 changes: 4 additions & 12 deletions python/core/geometry/qgsgeometry.sip
Expand Up @@ -1088,14 +1088,14 @@ Returns an extruded version of this geometry.
:rtype: QgsGeometry
%End

QByteArray exportToWkb() const;
QByteArray asWkb() const;
%Docstring
Export the geometry to WKB
.. versionadded:: 3.0
:rtype: QByteArray
%End

QString exportToWkt( int precision = 17 ) const;
QString asWkt( int precision = 17 ) const;
%Docstring
Exports the geometry to WKT
.. note::
Expand All @@ -1105,17 +1105,9 @@ Returns an extruded version of this geometry.
:rtype: str
%End

QString exportToGeoJSON( int precision = 17 ) const;
QString asJson( int precision = 17 ) const;
%Docstring
Exports the geometry to GeoJSON
:return: a QString representing the geometry as GeoJSON
.. versionadded:: 1.8
.. note::

Available in Python bindings since QGIS 1.9
.. note::

precision parameter added in QGIS 2.4
Exports the geometry to a GeoJSON string.
:rtype: str
%End

Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsgeometrycollection.sip
Expand Up @@ -97,11 +97,11 @@ Adds a geometry and takes ownership. Returns true in case of success.

virtual QString asWkt( int precision = 17 ) const;

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;


virtual QgsRectangle boundingBox() const;
Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgslinestring.sip
Expand Up @@ -189,11 +189,11 @@ Closes the line string by appending the first point to the end of the line, if i

virtual QString asWkt( int precision = 17 ) const;

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;


virtual double length() const;
Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsmulticurve.sip
Expand Up @@ -30,11 +30,11 @@ class QgsMultiCurve: QgsGeometryCollection

virtual bool fromWkt( const QString &wkt );

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsmultilinestring.sip
Expand Up @@ -29,11 +29,11 @@ class QgsMultiLineString: QgsMultiCurve

virtual bool fromWkt( const QString &wkt );

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsmultipoint.sip
Expand Up @@ -31,11 +31,11 @@ class QgsMultiPoint: QgsGeometryCollection

virtual void clear();

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;

virtual int nCoordinates() const;

Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsmultipolygon.sip
Expand Up @@ -28,11 +28,11 @@ class QgsMultiPolygon: QgsMultiSurface

virtual bool fromWkt( const QString &wkt );

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

Expand Down
6 changes: 3 additions & 3 deletions python/core/geometry/qgsmultisurface.sip
Expand Up @@ -30,11 +30,11 @@ class QgsMultiSurface: QgsGeometryCollection

virtual bool fromWkt( const QString &wkt );

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

Expand Down
10 changes: 5 additions & 5 deletions python/core/geometry/qgspoint.sip
Expand Up @@ -34,10 +34,10 @@ class QgsPoint: QgsAbstractGeometry

\code{.py}
pt = QgsPoint(43.4, 5.3)
pt.exportToWkt() # Point(43.4 5.3)
pt.asWkt() # Point(43.4 5.3)

pt_z = QgsPoint(120, 343, 77)
pt.exportToWkt() # PointZ(120 343 77)
pt.asWkt() # PointZ(120 343 77)

pt_m = QgsPoint(33, 88, m=5)
pt_m.m() # 5
Expand Down Expand Up @@ -349,11 +349,11 @@ class QgsPoint: QgsAbstractGeometry

virtual QString asWkt( int precision = 17 ) const;

virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;

virtual QString asJSON( int precision = 17 ) const;
virtual QString asJson( int precision = 17 ) const;

virtual void draw( QPainter &p ) const;

Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgstriangle.sip
Expand Up @@ -65,7 +65,7 @@ class QgsTriangle : QgsPolygon
virtual bool fromWkt( const QString &wkt );


virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;


virtual QgsPolygon *surfaceToPolygon() const /Factory/;
Expand Down

0 comments on commit fbe5a17

Please sign in to comment.