Skip to content
Permalink
Browse files

Merge pull request #2586 from nyalldawson/coordinate_formatter

Initial implementation of QgsCoordinateFormatter
  • Loading branch information
nyalldawson committed Nov 15, 2017
2 parents ac574e2 + 3734a0d commit fbe5a17af745477709606cc73fa58858b9ffb5e8
Showing with 1,913 additions and 1,563 deletions.
  1. +8 −1 doc/api_break.dox
  2. +1 −1 python/__init__.py
  3. +1 −0 python/core/core_auto.sip
  4. +20 −20 python/core/geometry/qgsabstractgeometry.sip
  5. +3 −3 python/core/geometry/qgscircularstring.sip
  6. +3 −3 python/core/geometry/qgscompoundcurve.sip
  7. +3 −3 python/core/geometry/qgscurvepolygon.sip
  8. +4 −12 python/core/geometry/qgsgeometry.sip
  9. +3 −3 python/core/geometry/qgsgeometrycollection.sip
  10. +3 −3 python/core/geometry/qgslinestring.sip
  11. +3 −3 python/core/geometry/qgsmulticurve.sip
  12. +3 −3 python/core/geometry/qgsmultilinestring.sip
  13. +3 −3 python/core/geometry/qgsmultipoint.sip
  14. +3 −3 python/core/geometry/qgsmultipolygon.sip
  15. +3 −3 python/core/geometry/qgsmultisurface.sip
  16. +5 −5 python/core/geometry/qgspoint.sip
  17. +1 −1 python/core/geometry/qgstriangle.sip
  18. +107 −0 python/core/qgscoordinateformatter.sip
  19. +5 −38 python/core/qgspointxy.sip
  20. +1 −1 python/plugins/db_manager/db_plugins/vlayers/data_model.py
  21. +1 −1 python/plugins/processing/algs/qgis/HypsometricCurves.py
  22. +2 −2 src/app/qgsclipboard.cpp
  23. +1 −1 src/app/qgsdecorationnortharrow.cpp
  24. +1 −1 src/app/qgsmaptoolselectutils.cpp
  25. +1 −1 src/app/qgsmaptoolshowhidelabels.cpp
  26. +2 −0 src/core/CMakeLists.txt
  27. +46 −39 src/core/composer/qgscomposermapgrid.cpp
  28. +1 −1 src/core/expression/qgsexpressionfunction.cpp
  29. +20 −20 src/core/geometry/qgsabstractgeometry.h
  30. +5 −5 src/core/geometry/qgscircularstring.cpp
  31. +3 −3 src/core/geometry/qgscircularstring.h
  32. +6 −6 src/core/geometry/qgscompoundcurve.cpp
  33. +3 −3 src/core/geometry/qgscompoundcurve.h
  34. +7 −7 src/core/geometry/qgscurvepolygon.cpp
  35. +3 −3 src/core/geometry/qgscurvepolygon.h
  36. +5 −5 src/core/geometry/qgsgeometry.cpp
  37. +4 −8 src/core/geometry/qgsgeometry.h
  38. +6 −6 src/core/geometry/qgsgeometrycollection.cpp
  39. +3 −3 src/core/geometry/qgsgeometrycollection.h
  40. +3 −3 src/core/geometry/qgslinestring.cpp
  41. +3 −3 src/core/geometry/qgslinestring.h
  42. +5 −5 src/core/geometry/qgsmulticurve.cpp
  43. +3 −3 src/core/geometry/qgsmulticurve.h
  44. +5 −5 src/core/geometry/qgsmultilinestring.cpp
  45. +3 −3 src/core/geometry/qgsmultilinestring.h
  46. +5 −5 src/core/geometry/qgsmultipoint.cpp
  47. +3 −3 src/core/geometry/qgsmultipoint.h
  48. +5 −5 src/core/geometry/qgsmultipolygon.cpp
  49. +3 −3 src/core/geometry/qgsmultipolygon.h
  50. +5 −5 src/core/geometry/qgsmultisurface.cpp
  51. +3 −3 src/core/geometry/qgsmultisurface.h
  52. +3 −3 src/core/geometry/qgspoint.cpp
  53. +5 −5 src/core/geometry/qgspoint.h
  54. +2 −2 src/core/geometry/qgstriangle.cpp
  55. +1 −2 src/core/geometry/qgstriangle.h
  56. +46 −38 src/core/layout/qgslayoutitemmapgrid.cpp
  57. +448 −0 src/core/qgscoordinateformatter.cpp
  58. +124 −0 src/core/qgscoordinateformatter.h
  59. +5 −5 src/core/qgscoordinateutils.cpp
  60. +2 −2 src/core/qgsdistancearea.cpp
  61. +1 −1 src/core/qgsfeature.cpp
  62. +1 −1 src/core/qgsjsonutils.cpp
  63. +1 −1 src/core/qgsofflineediting.cpp
  64. +1 −1 src/core/qgsogcutils.cpp
  65. +1 −1 src/core/qgspallabeling.cpp
  66. +1 −1 src/core/qgspointlocator.cpp
  67. +10 −206 src/core/qgspointxy.cpp
  68. +5 −31 src/core/qgspointxy.h
  69. +2 −2 src/core/qgsvectorfilewriter.cpp
  70. +2 −2 src/providers/db2/qgsdb2provider.cpp
  71. +1 −1 src/providers/gpx/qgsgpxprovider.cpp
  72. +4 −4 src/providers/mssql/qgsmssqlprovider.cpp
  73. +2 −2 src/providers/ogr/qgsogrprovider.cpp
  74. +1 −1 src/providers/oracle/qgsoraclefeatureiterator.cpp
  75. +1 −1 src/providers/oracle/qgsoracleprovider.cpp
  76. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
  77. +2 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
  78. +1 −1 src/providers/virtual/qgsvirtuallayerblob.cpp
  79. +1 −1 src/providers/wfs/qgswfsfeatureiterator.cpp
  80. +2 −2 src/providers/wfs/qgswfsshareddata.cpp
  81. +1 −1 src/providers/wfs/qgswfsutils.cpp
  82. +2 −2 src/server/services/wfs/qgswfsgetfeature.cpp
  83. +2 −2 src/server/services/wms/qgswmsrenderer.cpp
  84. +56 −56 tests/src/analysis/testqgsgeometrysnapper.cpp
  85. +1 −1 tests/src/analysis/testqgsprocessing.cpp
  86. +1 −1 tests/src/app/testqgsmaptooladdfeature.cpp
  87. +1 −1 tests/src/app/testqgsnodetool.cpp
  88. +8 −8 tests/src/core/testqgsexpression.cpp
  89. +10 −10 tests/src/core/testqgsfeature.cpp
  90. +146 −146 tests/src/core/testqgsgeometry.cpp
  91. +1 −1 tests/src/core/testqgsgeometryimport.cpp
  92. +6 −6 tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp
  93. +0 −441 tests/src/core/testqgspoint.cpp
  94. +3 −3 tests/src/providers/grass/testqgsgrassprovider.cpp
  95. +1 −0 tests/src/python/CMakeLists.txt
  96. +3 −3 tests/src/python/featuresourcetestbase.py
  97. +2 −2 tests/src/python/test_provider_memory.py
  98. +4 −4 tests/src/python/test_provider_ogr_gpkg.py
  99. +1 −1 tests/src/python/test_provider_postgres.py
  100. +6 −6 tests/src/python/test_provider_virtual.py
  101. +5 −5 tests/src/python/test_provider_wfs.py
  102. +2 −2 tests/src/python/test_qgsaggregatecalculator.py
  103. +3 −2 tests/src/python/test_qgscomposition.py
  104. +353 −0 tests/src/python/test_qgscoordinateformatter.py
  105. +1 −1 tests/src/python/test_qgsdelimitedtextprovider.py
  106. +33 −33 tests/src/python/test_qgsdistancearea.py
  107. +2 −2 tests/src/python/test_qgsfeaturesource.py
  108. +224 −224 tests/src/python/test_qgsgeometry.py
  109. +2 −2 tests/src/python/test_qgsserver_wfst.py
  110. +4 −4 tests/src/python/test_qgsvectorfilewriter.py
  111. +2 −2 tests/src/python/test_qgsvectorlayer.py
  112. +1 −1 tests/src/python/test_qgsvectorlayerutils.py
@@ -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}
@@ -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
@@ -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}
@@ -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}
@@ -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)
@@ -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
@@ -166,7 +166,7 @@ class QgsAbstractGeometry
.. seealso:: asWkt
.. seealso:: asGML2
.. seealso:: asGML3
.. seealso:: asJSON
.. seealso:: asJson()
.. versionadded:: 3.0
:rtype: QByteArray
%End
@@ -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

@@ -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;
@@ -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;
@@ -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;
@@ -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::
@@ -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

@@ -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;
@@ -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;
@@ -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/ );

@@ -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/ );

@@ -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;

@@ -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/ );

@@ -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/ );

@@ -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
@@ -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;

@@ -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/;

0 comments on commit fbe5a17

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