Skip to content
Permalink
Browse files

Merge pull request #5535 from nyalldawson/datum

Datum transform handling rework, pt 1
  • Loading branch information
nyalldawson committed Dec 15, 2017
2 parents e9feeaa + 1217e59 commit 0c7cf21fe22279b4775e1669a1c3fb35c5219b69
Showing with 4,067 additions and 1,392 deletions.
  1. +15 −3 doc/api_break.dox
  2. +230 −0 python/core/conversions.sip
  3. +1 −2 python/core/core_auto.sip
  4. +203 −29 python/core/qgscoordinatetransform.sip
  5. +183 −0 python/core/qgscoordinatetransformcontext.sip
  6. +0 −56 python/core/qgscrscache.sip
  7. +0 −72 python/core/qgsdatumtransformstore.sip
  8. +18 −2 python/core/qgsmapsettings.sip
  9. +39 −0 python/core/qgsproject.sip
  10. +21 −0 python/core/qgsrendercontext.sip
  11. +9 −0 python/gui/qgisinterface.sip
  12. +0 −14 python/gui/qgsmapcanvas.sip
  13. +3 −3 python/plugins/MetaSearch/dialogs/maindialog.py
  14. +1 −1 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  15. +3 −1 python/plugins/processing/algs/qgis/FindProjection.py
  16. +1 −1 python/plugins/processing/algs/qgis/SpatialJoinSummary.py
  17. +11 −1 src/3d/qgs3dmapsettings.cpp
  18. +20 −0 src/3d/qgs3dmapsettings.h
  19. +2 −2 src/3d/qgs3dutils.cpp
  20. +2 −1 src/3d/qgs3dutils.h
  21. +3 −2 src/3d/terrain/qgsdemterraingenerator.cpp
  22. +4 −1 src/3d/terrain/qgsdemterraingenerator.h
  23. +1 −1 src/3d/terrain/qgsterrainentity_p.cpp
  24. +2 −2 src/3d/terrain/qgsterraingenerator.cpp
  25. +2 −1 src/analysis/processing/qgsalgorithmtransform.cpp
  26. +1 −0 src/analysis/processing/qgsalgorithmtransform.h
  27. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
  28. +2 −2 src/analysis/vector/geometry_checker/qgsgeometrycheck.h
  29. +3 −3 src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
  30. +3 −2 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp
  31. +1 −1 src/app/3d/qgs3dmapcanvasdockwidget.cpp
  32. +3 −3 src/app/3d/qgs3dmapconfigwidget.cpp
  33. +2 −0 src/app/CMakeLists.txt
  34. +3 −3 src/app/composer/qgscomposermapwidget.cpp
  35. +5 −5 src/app/gps/qgsgpsinformationwidget.cpp
  36. +2 −1 src/app/gps/qgsgpsmarker.cpp
  37. +3 −3 src/app/layout/qgslayoutmapwidget.cpp
  38. +2 −1 src/app/nodetool/qgsnodeeditor.cpp
  39. +101 −26 src/app/qgisapp.cpp
  40. +11 −0 src/app/qgisapp.h
  41. +6 −0 src/app/qgisappinterface.cpp
  42. +3 −0 src/app/qgisappinterface.h
  43. +1 −1 src/app/qgsbookmarks.cpp
  44. +3 −10 src/app/qgsclipboard.cpp
  45. +2 −3 src/app/qgscustomprojectiondialog.cpp
  46. +265 −0 src/app/qgsdatumtransformtablewidget.cpp
  47. +104 −0 src/app/qgsdatumtransformtablewidget.h
  48. +1 −1 src/app/qgsdecorationlayoutextent.cpp
  49. +0 −1 src/app/qgsdxfexportdialog.cpp
  50. +3 −3 src/app/qgsmapcanvasdockwidget.cpp
  51. +1 −0 src/app/qgsmapsavedialog.cpp
  52. +1 −1 src/app/qgsmaptoolannotation.cpp
  53. +2 −1 src/app/qgsmaptoolselectutils.cpp
  54. +1 −1 src/app/qgsmaptoolshowhidelabels.cpp
  55. +2 −1 src/app/qgsmeasuretool.cpp
  56. +8 −116 src/app/qgsoptions.cpp
  57. +0 −6 src/app/qgsoptions.h
  58. +12 −1 src/app/qgsprojectproperties.cpp
  59. +1 −0 src/app/qgsrasterlayerproperties.cpp
  60. +1 −0 src/app/qgsvectorlayerproperties.cpp
  61. +2 −4 src/core/CMakeLists.txt
  62. +1 −2 src/core/composer/qgsatlascomposition.cpp
  63. +1 −1 src/core/composer/qgscomposerattributetablev2.cpp
  64. +2 −4 src/core/composer/qgscomposermap.cpp
  65. +1 −1 src/core/composer/qgscomposermapgrid.cpp
  66. +1 −1 src/core/composer/qgscomposermapoverview.cpp
  67. +0 −1 src/core/dxf/qgsdxfexport.cpp
  68. +2 −0 src/core/expression/qgsexpressionfunction.cpp
  69. +1 −1 src/core/layout/qgslayoutitemattributetable.cpp
  70. +4 −2 src/core/layout/qgslayoutitemmap.cpp
  71. +1 −1 src/core/layout/qgslayoutitemmapgrid.cpp
  72. +1 −1 src/core/layout/qgslayoutitemmapoverview.cpp
  73. +8 −8 src/core/processing/qgsprocessingparameters.cpp
  74. +2 −0 src/core/processing/qgsprocessingutils.cpp
  75. +2 −0 src/core/providers/memory/qgsmemoryfeatureiterator.cpp
  76. +2 −0 src/core/qgsbearingutils.cpp
  77. +4 −0 src/core/qgscachedfeatureiterator.cpp
  78. +177 −74 src/core/qgscoordinatetransform.cpp
  79. +223 −26 src/core/qgscoordinatetransform.h
  80. +111 −14 src/core/qgscoordinatetransform_p.cpp
  81. +36 −3 src/core/qgscoordinatetransform_p.h
  82. +389 −0 src/core/qgscoordinatetransformcontext.cpp
  83. +274 −0 src/core/qgscoordinatetransformcontext.h
  84. +87 −0 src/core/qgscoordinatetransformcontext_p.h
  85. +2 −0 src/core/qgscoordinateutils.cpp
  86. +0 −75 src/core/qgscrscache.cpp
  87. +0 −66 src/core/qgscrscache.h
  88. +0 −123 src/core/qgsdatumtransformstore.cpp
  89. +0 −76 src/core/qgsdatumtransformstore.h
  90. +1 −2 src/core/qgsmaphittest.cpp
  91. +21 −8 src/core/qgsmapsettings.cpp
  92. +23 −6 src/core/qgsmapsettings.h
  93. +2 −0 src/core/qgspointlocator.cpp
  94. +24 −0 src/core/qgsproject.cpp
  95. +41 −0 src/core/qgsproject.h
  96. +18 −0 src/core/qgsrendercontext.cpp
  97. +26 −0 src/core/qgsrendercontext.h
  98. +2 −0 src/core/qgstracer.cpp
  99. +2 −0 src/core/qgsvectorfilewriter.cpp
  100. +4 −0 src/core/qgsvectorlayerdiagramprovider.cpp
  101. +4 −0 src/core/qgsvectorlayerexporter.cpp
  102. +2 −0 src/core/qgsvectorlayerfeatureiterator.cpp
  103. +4 −0 src/core/qgsvectorlayerlabelprovider.cpp
  104. +2 −0 src/core/raster/qgsrasterfilewriter.cpp
  105. +2 −2 src/core/raster/qgsrasterlayerrenderer.cpp
  106. +2 −3 src/core/raster/qgsrasterprojector.cpp
  107. +8 −0 src/gui/qgisinterface.h
  108. +83 −54 src/gui/qgsdatumtransformdialog.cpp
  109. +28 −15 src/gui/qgsdatumtransformdialog.h
  110. +2 −2 src/gui/qgsextentgroupbox.cpp
  111. +26 −82 src/gui/qgsmapcanvas.cpp
  112. +3 −7 src/gui/qgsmapcanvas.h
  113. +2 −2 src/gui/qgsmapcanvasannotationitem.cpp
  114. +2 −1 src/gui/qgsrasterlayersaveasdialog.cpp
  115. +2 −1 src/gui/qgsrubberband.cpp
  116. +1 −2 src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
  117. +4 −5 src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp
  118. +4 −4 src/plugins/grass/qgsgrassnewmapset.cpp
  119. +2 −0 src/providers/arcgisrest/qgsafsfeatureiterator.cpp
  120. +2 −0 src/providers/arcgisrest/qgsafsprovider.cpp
  121. +2 −0 src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
  122. +2 −0 src/providers/db2/qgsdb2featureiterator.cpp
  123. +2 −0 src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
  124. +2 −0 src/providers/gpx/qgsgpxfeatureiterator.cpp
  125. +2 −0 src/providers/mssql/qgsmssqlfeatureiterator.cpp
  126. +2 −0 src/providers/ogr/qgsogrfeatureiterator.cpp
  127. +2 −0 src/providers/postgres/qgspostgresfeatureiterator.cpp
  128. +2 −0 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  129. +2 −0 src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp
  130. +2 −1 src/providers/wcs/qgswcsprovider.cpp
  131. +3 −0 src/providers/wfs/qgswfscapabilities.cpp
  132. +2 −0 src/providers/wfs/qgswfsfeatureiterator.cpp
  133. +2 −0 src/providers/wfs/qgswfsprovider.cpp
  134. +2 −0 src/providers/wms/qgswmscapabilities.cpp
  135. +12 −0 src/providers/wms/qgswmsprovider.cpp
  136. +4 −0 src/server/qgsconfigparserutils.cpp
  137. +2 −0 src/server/services/wcs/qgswcsgetcoverage.cpp
  138. +2 −0 src/server/services/wcs/qgswcsutils.cpp
  139. +2 −0 src/server/services/wfs/qgswfsgetcapabilities.cpp
  140. +6 −0 src/server/services/wfs/qgswfsgetfeature.cpp
  141. +6 −0 src/server/services/wms/qgswmsgetcapabilities.cpp
  142. +2 −0 src/server/services/wms/qgswmsgetcontext.cpp
  143. +0 −1 src/server/services/wms/qgswmsrenderer.cpp
  144. +83 −97 src/ui/qgsdatumtransformdialogbase.ui
  145. +72 −0 src/ui/qgsdatumtransformtablewidgetbase.ui
  146. +92 −142 src/ui/qgsoptionsbase.ui
  147. +91 −43 src/ui/qgsprojectpropertiesbase.ui
  148. +1 −1 tests/src/3d/testqgs3dutils.cpp
  149. +1 −1 tests/src/app/testqgsmeasuretool.cpp
  150. +47 −12 tests/src/core/testqgscoordinatetransform.cpp
  151. +1 −1 tests/src/core/testqgsexpression.cpp
  152. +7 −6 tests/src/core/testqgsgeometry.cpp
  153. +2 −1 tests/src/core/testqgstracer.cpp
  154. +9 −9 tests/src/geometry_checker/testqgsgeometrychecks.cpp
  155. +1 −0 tests/src/python/CMakeLists.txt
  156. +164 −4 tests/src/python/test_qgscoordinatetransform.py
  157. +412 −0 tests/src/python/test_qgscoordinatetransformcontext.py
  158. +2 −1 tests/src/python/test_qgsvectorfilewriter.py
@@ -276,9 +276,11 @@ Use QgsComposerAttributeTableV2 instead.
- QgsCRSCache was removed. QgsCoordinateReferenceSystem now internally uses a cache for CRS creation,
so there is no longer a need for the separate cache class. Code which previously called QgsCRSCache::updateCRSCache()
should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinateTransformCache::instance()->invalidateCrs( authid ).
- QgsCoordinateTransformCache was removed. QgsCoordinateTransform now transparently caches transforms.
- QgsDataDefined was removed. Use the QgsProperty framework instead.
- QgsDataDefinedButton was removed. Use QgsPropertyOverrideButton instead.
- QgsDataDefinedSymbolDialog was removed. Code using this dialog should be reworked to use QgsPropertyOverrideButton
- QgsDatumTransformStore. Use QgsCoordinateTransformContext instead.
- QgsDefaultPluginLayerLegend was removed. Use QgsMapLayer::setLegend() to provide legend nodes for plugin layers.
- DualEdgeTriangulation
- QgsFileNameWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
@@ -914,11 +916,12 @@ called if changes are made to the CRS database.
QgsCoordinateTransform {#qgis_api_break_3_0_QgsCoordinateTransform}
----------------------

- QgsCoordinateTransform is no longer a QObject. readXml, writeXml and initialize are all normal public members now,
- QgsCoordinateTransform is no longer a QObject. Initialize is a normal public members now,
not slots. The invalidTransformInput() signal has been removed.
- The extra QgsCoordinateTransform constructors (those not taking QgsCoordinateReferenceSystem arguments) have been
removed. Now, QgsCoordinateTransform must be created using an already existing source and destination
QgsCoordinateReferenceSystem object.
QgsCoordinateReferenceSystem object, and either a QgsCoordinateTransformContext object or a reference to the
current project instance.
- QgsCoordinateTransform::clone() has been removed. Just use direct copies instead.
- sourceCrs() and destCrs() now return a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
plugins calling these methods will need to be updated.
@@ -930,7 +933,15 @@ plugins calling these methods will need to be updated.
- 'p' argument in transform() has been renamed to 'point', 'theRect' to 'rectangle', 'poly' to 'polygon'
- setDestCRSID has been removed, use setDestinationCrs() instead
- 'theNode', 'theDoc' parameters in readXML and writeXML have been renamed to 'node' and 'document' respectively
- readXML() and writeXML() have been renamed to readXml() and writeXml() for consistency
- readXML() and writeXML() have been removed.
- initialize() was removed.
- datumTransformations() now returns a list of QgsCoordinateTransform.TransformPair instead of a list of lists.
- datumTransformString() was renamed to datumTransformToProj()
- datumTransformCrsInfo() was renamed to datumTransformInfo(), and now returns a QgsCoordinateTransform.TransformInfo object.
- sourceDatumTransform() was renamed to sourceDatumTransformId()
- setSourceDatumTransform() was renamed to setSourceDatumTransformId()
- destinationDatumTransform() was renamed to destinationDatumTransformId()
- setDestinationDatumTransform() was renamed to setDestinationDatumTransformId()


QgsCoordinateTransformCache {#qgis_api_break_3_0_QgsCoordinateTransformCache}
@@ -1636,6 +1647,7 @@ QgsMapCanvas {#qgis_api_break_3_0_QgsMapCanvas}
- setCrsTransformEnabled(), hasCrsTransformEnabled(), hasCrsTransformEnabledChanged() were removed. CRS transformation is now always enabled.
- setMapUnits() was removed. The map units are dictated by the units for the destination CRS.
- The mapUnitsChanged() signal was removed. Listen for the destinationCrsChanged() signal instead, as the destination CRS dictates the map units.
- layerCrsChange() slot was removed. Datum transforms are now handled in QgisApp.

QgsMapCanvasItem {#qgis_api_break_3_0_QgsMapCanvasItem}
----------------
@@ -1742,6 +1742,236 @@ template<int, TYPE2*>
%End
};

%MappedType QMap< QPair< QString, QString>, QPair< int, int > >
{
%TypeHeaderCode
#include <QPair>
#include <QMap>
%End

%ConvertFromTypeCode
//convert map to a python dictionary
PyObject *d;

if ( ( d = PyDict_New() ) == NULL )
return NULL;

for ( auto it = sipCpp->constBegin(); it != sipCpp->constEnd(); ++ it )
{
PyObject *keyobj;
if ( ( keyobj = PyTuple_New( 2 ) ) == NULL )
{
Py_DECREF( d );
return NULL;
}
PyObject *valueobj;
if ( ( valueobj = PyTuple_New( 2 ) ) == NULL )
{
Py_DECREF( d );
return NULL;
}

// build key
PyObject *k1obj = sipConvertFromNewType( new QString( it.key().first ), sipType_QString, sipTransferObj );
PyTuple_SetItem( keyobj, 0, k1obj );
PyObject *k2obj = sipConvertFromNewType( new QString( it.key().second ), sipType_QString, sipTransferObj );
PyTuple_SetItem( keyobj, 1, k2obj );

// build value
PyObject *v1obj = PyLong_FromLong( (long)( it.value().first ) );
PyTuple_SetItem( valueobj, 0, v1obj );
PyObject *v2obj = PyLong_FromLong( (long)( it.value().second ) );
PyTuple_SetItem( valueobj, 1, v2obj );

if(keyobj == NULL || valueobj == NULL || PyDict_SetItem(d, keyobj, valueobj) < 0)
{
Py_DECREF(d);

if (valueobj)
{
Py_DECREF(valueobj);
}

if (keyobj)
{
Py_DECREF(keyobj);
}
return NULL;
}

}

return d;
%End

%ConvertToTypeCode
Py_ssize_t i = 0;

PyObject *t1obj, *t2obj;
QMap< QPair< QString, QString>, QPair< int, int > > *qm = new QMap< QPair< QString, QString>, QPair< int, int > >;

int state;
while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
{
PyObject *sipKeyFirst = PyTuple_GetItem( t1obj, 0 );
PyObject *sipKeySecond = PyTuple_GetItem( t1obj, 1 );

PyObject *sipValueFirst = PyTuple_GetItem( t2obj, 0 );
qint64 v1 = PyLong_AsLongLong(sipValueFirst);
PyObject *sipValueSecond = PyTuple_GetItem( t2obj, 1 );
qint64 v2 = PyLong_AsLongLong(sipValueSecond);

QString *k1 = reinterpret_cast<QString *>(sipConvertToType(sipKeyFirst, sipType_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
if (*sipIsErr)
{
sipReleaseType(k1, sipType_QString, state);
delete qm;
return 0;
}
QString *k2 = reinterpret_cast<QString *>(sipConvertToType(sipKeySecond, sipType_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
if (*sipIsErr)
{
sipReleaseType(k1, sipType_QString, state);
sipReleaseType(k2, sipType_QString, state);
delete qm;
return 0;
}

qm->insert( qMakePair( *k1,*k2 ), qMakePair( v1, v2 ) );
sipReleaseType(k1, sipType_QString, state);
sipReleaseType(k2, sipType_QString, state);
}

*sipCppPtr = qm;

return sipGetState( sipTransferObj );
%End
};

template <TYPE>
%MappedType QMap< QPair< QString, QString>, TYPE >
{
%TypeHeaderCode
#include <QPair>
#include <QMap>
%End

%ConvertFromTypeCode
//convert map to a python dictionary
PyObject *d;

if ( ( d = PyDict_New() ) == NULL )
return NULL;

for ( auto it = sipCpp->constBegin(); it != sipCpp->constEnd(); ++ it )
{
PyObject *keyobj;
if ( ( keyobj = PyTuple_New( 2 ) ) == NULL )
{
Py_DECREF( d );
return NULL;
}

TYPE *t = new TYPE(it.value());
PyObject *tobj = sipConvertFromNewType(t, sipType_TYPE, sipTransferObj);
if ( tobj == NULL )
{
Py_DECREF(d);
delete t;
return NULL;
}

// build key
PyObject *k1obj = sipConvertFromNewType( new QString( it.key().first ), sipType_QString, sipTransferObj );
PyTuple_SetItem( keyobj, 0, k1obj );
PyObject *k2obj = sipConvertFromNewType( new QString( it.key().second ), sipType_QString, sipTransferObj );
PyTuple_SetItem( keyobj, 1, k2obj );

if(keyobj == NULL || tobj == NULL || PyDict_SetItem(d, keyobj, tobj) < 0)
{
Py_DECREF(d);

if (keyobj)
{
Py_DECREF(keyobj);
}

if (tobj)
{
Py_DECREF(tobj);
}
return NULL;
}

Py_DECREF(keyobj);
Py_DECREF(tobj);
}

return d;
%End

%ConvertToTypeCode
Py_ssize_t i = 0;
PyObject *kobj, *tobj;

// Check the type if that is all that is required.
if (sipIsErr == NULL)
{
if (!PyDict_Check(sipPy))
return 0;

while (PyDict_Next(sipPy, &i, &kobj, &tobj))
if (!sipCanConvertToType(tobj, sipType_TYPE, SIP_NOT_NONE))
return 0;

return 1;
}

PyObject *t1obj, *t2obj;
QMap< QPair< QString, QString>, TYPE > *qm = new QMap< QPair< QString, QString>, TYPE >;

int state;
while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
{
PyObject *sipKeyFirst = PyTuple_GetItem( t1obj, 0 );
PyObject *sipKeySecond = PyTuple_GetItem( t1obj, 1 );
QString *k1 = reinterpret_cast<QString *>(sipConvertToType(sipKeyFirst, sipType_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
if (*sipIsErr)
{
sipReleaseType(k1, sipType_QString, state);
delete qm;
return 0;
}

QString *k2 = reinterpret_cast<QString *>(sipConvertToType(sipKeySecond, sipType_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
if (*sipIsErr)
{
sipReleaseType(k1, sipType_QString, state);
sipReleaseType(k2, sipType_QString, state);
delete qm;
return 0;
}

TYPE *t = reinterpret_cast<TYPE *>(sipConvertToType(t2obj, sipType_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
if (*sipIsErr)
{
sipReleaseType(t, sipType_TYPE, state);

delete qm;
return 0;
}

qm->insert( qMakePair( *k1,*k2 ), *t );
sipReleaseType(k1, sipType_QString, state);
sipReleaseType(k2, sipType_QString, state);
sipReleaseType(t, sipType_TYPE, state);
}

*sipCppPtr = qm;

return sipGetState( sipTransferObj );
%End
};

template <TYPE>
%MappedType QVector< TYPE* >
@@ -23,14 +23,13 @@
%Include qgsconditionalstyle.sip
%Include qgscoordinateformatter.sip
%Include qgscoordinatetransform.sip
%Include qgscrscache.sip
%Include qgscoordinatetransformcontext.sip
%Include qgsdartmeasurement.sip
%Include qgsdatadefinedsizelegend.sip
%Include qgsdataitemprovider.sip
%Include qgsdataitemproviderregistry.sip
%Include qgsdatasourceuri.sip
%Include qgsdatetimestatisticalsummary.sip
%Include qgsdatumtransformstore.sip
%Include qgsdbfilterproxymodel.sip
%Include qgsdefaultvalue.sip
%Include qgsdiagramrenderer.sip

0 comments on commit 0c7cf21

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