Skip to content
Permalink
Browse files

Rename various WKT/WKB/GeoJSON/GML methods for consistency

and consistent capitalisation
  • Loading branch information
nyalldawson committed Nov 15, 2017
1 parent 95765a1 commit 75885d70d5cfe8834d818055cc43554f6a5319cd
Showing with 761 additions and 770 deletions.
  1. +7 −1 doc/api_break.dox
  2. +1 −1 python/__init__.py
  3. +20 −20 python/core/geometry/qgsabstractgeometry.sip
  4. +3 −3 python/core/geometry/qgscircularstring.sip
  5. +3 −3 python/core/geometry/qgscompoundcurve.sip
  6. +3 −3 python/core/geometry/qgscurvepolygon.sip
  7. +4 −12 python/core/geometry/qgsgeometry.sip
  8. +3 −3 python/core/geometry/qgsgeometrycollection.sip
  9. +3 −3 python/core/geometry/qgslinestring.sip
  10. +3 −3 python/core/geometry/qgsmulticurve.sip
  11. +3 −3 python/core/geometry/qgsmultilinestring.sip
  12. +3 −3 python/core/geometry/qgsmultipoint.sip
  13. +3 −3 python/core/geometry/qgsmultipolygon.sip
  14. +3 −3 python/core/geometry/qgsmultisurface.sip
  15. +5 −5 python/core/geometry/qgspoint.sip
  16. +1 −1 python/core/geometry/qgstriangle.sip
  17. +2 −3 python/core/qgspointxy.sip
  18. +1 −1 python/plugins/db_manager/db_plugins/vlayers/data_model.py
  19. +1 −1 python/plugins/processing/algs/qgis/HypsometricCurves.py
  20. +2 −2 src/app/qgsclipboard.cpp
  21. +1 −1 src/app/qgsdecorationnortharrow.cpp
  22. +1 −1 src/app/qgsmaptoolselectutils.cpp
  23. +1 −1 src/app/qgsmaptoolshowhidelabels.cpp
  24. +1 −1 src/core/expression/qgsexpressionfunction.cpp
  25. +20 −20 src/core/geometry/qgsabstractgeometry.h
  26. +5 −5 src/core/geometry/qgscircularstring.cpp
  27. +3 −3 src/core/geometry/qgscircularstring.h
  28. +6 −6 src/core/geometry/qgscompoundcurve.cpp
  29. +3 −3 src/core/geometry/qgscompoundcurve.h
  30. +7 −7 src/core/geometry/qgscurvepolygon.cpp
  31. +3 −3 src/core/geometry/qgscurvepolygon.h
  32. +5 −5 src/core/geometry/qgsgeometry.cpp
  33. +4 −8 src/core/geometry/qgsgeometry.h
  34. +6 −6 src/core/geometry/qgsgeometrycollection.cpp
  35. +3 −3 src/core/geometry/qgsgeometrycollection.h
  36. +3 −3 src/core/geometry/qgslinestring.cpp
  37. +3 −3 src/core/geometry/qgslinestring.h
  38. +5 −5 src/core/geometry/qgsmulticurve.cpp
  39. +3 −3 src/core/geometry/qgsmulticurve.h
  40. +5 −5 src/core/geometry/qgsmultilinestring.cpp
  41. +3 −3 src/core/geometry/qgsmultilinestring.h
  42. +5 −5 src/core/geometry/qgsmultipoint.cpp
  43. +3 −3 src/core/geometry/qgsmultipoint.h
  44. +5 −5 src/core/geometry/qgsmultipolygon.cpp
  45. +3 −3 src/core/geometry/qgsmultipolygon.h
  46. +5 −5 src/core/geometry/qgsmultisurface.cpp
  47. +3 −3 src/core/geometry/qgsmultisurface.h
  48. +3 −3 src/core/geometry/qgspoint.cpp
  49. +5 −5 src/core/geometry/qgspoint.h
  50. +2 −2 src/core/geometry/qgstriangle.cpp
  51. +1 −2 src/core/geometry/qgstriangle.h
  52. +2 −2 src/core/qgsdistancearea.cpp
  53. +1 −1 src/core/qgsfeature.cpp
  54. +1 −1 src/core/qgsjsonutils.cpp
  55. +1 −1 src/core/qgsofflineediting.cpp
  56. +1 −1 src/core/qgsogcutils.cpp
  57. +1 −1 src/core/qgspallabeling.cpp
  58. +1 −1 src/core/qgspointlocator.cpp
  59. +1 −1 src/core/qgspointxy.cpp
  60. +2 −3 src/core/qgspointxy.h
  61. +2 −2 src/core/qgsvectorfilewriter.cpp
  62. +2 −2 src/providers/db2/qgsdb2provider.cpp
  63. +1 −1 src/providers/gpx/qgsgpxprovider.cpp
  64. +4 −4 src/providers/mssql/qgsmssqlprovider.cpp
  65. +2 −2 src/providers/ogr/qgsogrprovider.cpp
  66. +1 −1 src/providers/oracle/qgsoraclefeatureiterator.cpp
  67. +1 −1 src/providers/oracle/qgsoracleprovider.cpp
  68. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
  69. +2 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
  70. +1 −1 src/providers/virtual/qgsvirtuallayerblob.cpp
  71. +1 −1 src/providers/wfs/qgswfsfeatureiterator.cpp
  72. +2 −2 src/providers/wfs/qgswfsshareddata.cpp
  73. +1 −1 src/providers/wfs/qgswfsutils.cpp
  74. +2 −2 src/server/services/wfs/qgswfsgetfeature.cpp
  75. +2 −2 src/server/services/wms/qgswmsrenderer.cpp
  76. +56 −56 tests/src/analysis/testqgsgeometrysnapper.cpp
  77. +1 −1 tests/src/analysis/testqgsprocessing.cpp
  78. +1 −1 tests/src/app/testqgsmaptooladdfeature.cpp
  79. +1 −1 tests/src/app/testqgsnodetool.cpp
  80. +8 −8 tests/src/core/testqgsexpression.cpp
  81. +10 −10 tests/src/core/testqgsfeature.cpp
  82. +146 −146 tests/src/core/testqgsgeometry.cpp
  83. +1 −1 tests/src/core/testqgsgeometryimport.cpp
  84. +6 −6 tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp
  85. +3 −3 tests/src/providers/grass/testqgsgrassprovider.cpp
  86. +3 −3 tests/src/python/featuresourcetestbase.py
  87. +2 −2 tests/src/python/test_provider_memory.py
  88. +4 −4 tests/src/python/test_provider_ogr_gpkg.py
  89. +1 −1 tests/src/python/test_provider_postgres.py
  90. +6 −6 tests/src/python/test_provider_virtual.py
  91. +5 −5 tests/src/python/test_provider_wfs.py
  92. +2 −2 tests/src/python/test_qgsaggregatecalculator.py
  93. +1 −1 tests/src/python/test_qgsdelimitedtextprovider.py
  94. +33 −33 tests/src/python/test_qgsdistancearea.py
  95. +2 −2 tests/src/python/test_qgsfeaturesource.py
  96. +224 −224 tests/src/python/test_qgsgeometry.py
  97. +2 −2 tests/src/python/test_qgsserver_wfst.py
  98. +4 −4 tests/src/python/test_qgsvectorfilewriter.py
  99. +2 −2 tests/src/python/test_qgsvectorlayer.py
  100. +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}
@@ -1964,6 +1969,7 @@ 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)
@@ -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/;
@@ -111,11 +111,10 @@ Sets the x and y value of the point
:rtype: str
%End

QString wellKnownText() const;
QString asWkt() const;
%Docstring
Return the well known text representation for the point.
Return the well known text representation for the point (e.g. "POINT(x y)").
The wkt is created without an SRID.
:return: Well known text in the form POINT(x y)
:rtype: str
%End

@@ -100,7 +100,7 @@ def __init__(self, db, sql, parent=None):
a = f.attributes()
if has_geometry:
if f.hasGeometry():
a += [f.geometry().exportToWkt()]
a += [f.geometry().asWkt()]
else:
a += [None]
data += [a]
@@ -135,7 +135,7 @@ def processAlgorithm(self, parameters, context, feedback):
fName = os.path.join(
outputPath, 'hystogram_%s_%s.csv' % (source.sourceName(), f.id()))

ogrGeom = ogr.CreateGeometryFromWkt(intersectedGeom.exportToWkt())
ogrGeom = ogr.CreateGeometryFromWkt(intersectedGeom.asWkt())
bbox = intersectedGeom.boundingBox()
xMin = bbox.xMinimum()
xMax = bbox.xMaximum()
@@ -115,7 +115,7 @@ QString QgsClipboard::generateClipboardText() const
if ( format == AttributesWithWKT )
{
if ( it->hasGeometry() )
textFields += it->geometry().exportToWkt();
textFields += it->geometry().asWkt();
else
{
textFields += QgsApplication::nullRepresentation();
@@ -249,7 +249,7 @@ void QgsClipboard::insert( const QgsFeature &feature )
{
mFeatureClipboard.push_back( feature );

QgsDebugMsgLevel( "inserted " + feature.geometry().exportToWkt(), 4 );
QgsDebugMsgLevel( "inserted " + feature.geometry().asWkt(), 4 );
mUseSystemClipboard = false;
emit changed();
}

1 comment on commit 75885d7

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn commented on 75885d7 Nov 15, 2017

Nice cleanup

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