From afdfe02b0b6a0117e047d0461c1daa29143cb30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 14 Mar 2019 23:25:52 +0100 Subject: [PATCH] Make code calling proj4 compatible with proj4 5.0 and later - projects.h is no longer available in 6.0 - use of proj_api.h has to be opted in since 6.0, to be removed in 7.0 - pj_get_list_ref has been renamed proj_list_operations in 5.0 - PJProps is opaque now, its contents can be accessed with proj_pj_info. As the contents are no longer global, the const char* from GetProjectionName has to be copied into the vtkGeoProjection object. --- Geovis/Core/vtkGeoProjection.cxx | 12 +++++++----- Geovis/Core/vtkGeoTransform.cxx | 8 ++++---- ThirdParty/libproj/vtk_libproj.h.in | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Geovis/Core/vtkGeoProjection.cxx b/Geovis/Core/vtkGeoProjection.cxx index f3a8852d..0bd7678f 100644 --- a/Geovis/Core/vtkGeoProjection.cxx +++ b/Geovis/Core/vtkGeoProjection.cxx @@ -72,6 +72,7 @@ public: } std::map< std::string, std::string > OptionalParameters; + PJ_PROJ_INFO ProjInfo; }; //----------------------------------------------------------------------------- @@ -80,7 +81,7 @@ int vtkGeoProjection::GetNumberOfProjections() if ( vtkGeoProjectionNumProj < 0 ) { vtkGeoProjectionNumProj = 0; - for ( const PJ_LIST* pj = pj_get_list_ref(); pj && pj->id; ++ pj ) + for ( const PJ_LIST* pj = proj_list_operations(); pj && pj->id; ++ pj ) ++ vtkGeoProjectionNumProj; } return vtkGeoProjectionNumProj; @@ -91,7 +92,7 @@ const char* vtkGeoProjection::GetProjectionName( int projection ) if ( projection < 0 || projection >= vtkGeoProjection::GetNumberOfProjections() ) return nullptr; - return pj_get_list_ref()[projection].id; + return proj_list_operations()[projection].id; } //----------------------------------------------------------------------------- const char* vtkGeoProjection::GetProjectionDescription( int projection ) @@ -99,7 +100,7 @@ const char* vtkGeoProjection::GetProjectionDescription( int projection ) if ( projection < 0 || projection >= vtkGeoProjection::GetNumberOfProjections() ) return nullptr; - return pj_get_list_ref()[projection].descr[0]; + return proj_list_operations()[projection].descr[0]; } //----------------------------------------------------------------------------- vtkGeoProjection::vtkGeoProjection() @@ -144,7 +145,7 @@ void vtkGeoProjection::PrintSelf( ostream& os, vtkIndent indent ) int vtkGeoProjection::GetIndex() { int i = 0; - for ( const PJ_LIST* proj = pj_get_list_ref(); proj && proj->id; ++ proj, ++ i ) + for ( const PJ_LIST* proj = proj_list_operations(); proj && proj->id; ++ proj, ++ i ) { if ( ! strcmp( proj->id, this->Name ) ) { @@ -161,7 +162,7 @@ const char* vtkGeoProjection::GetDescription() { return nullptr; } - return this->Projection->descr; + return this->Internals->ProjInfo.description; } //----------------------------------------------------------------------------- projPJ vtkGeoProjection::GetProjection() @@ -232,6 +233,7 @@ int vtkGeoProjection::UpdateProjection() this->ProjectionMTime = this->GetMTime(); if ( this->Projection ) { + this->Internals->ProjInfo = proj_pj_info(this->Projection); return 0; } return 1; diff --git a/Geovis/Core/vtkGeoTransform.cxx b/Geovis/Core/vtkGeoTransform.cxx index aeeabc10..1ca20f9d 100644 --- a/Geovis/Core/vtkGeoTransform.cxx +++ b/Geovis/Core/vtkGeoTransform.cxx @@ -167,9 +167,9 @@ void vtkGeoTransform::InternalTransformPoints( double* x, vtkIdType numPts, int double* coord = x; for ( vtkIdType i = 0; i < numPts; ++ i ) { - xy.u = coord[0]; xy.v = coord[1]; + xy.x = coord[0]; xy.y = coord[1]; lp = pj_inv( xy, src ); - coord[0] = lp.u; coord[1] = lp.v; + coord[0] = lp.lam; coord[1] = lp.phi; coord += stride; } } @@ -191,9 +191,9 @@ void vtkGeoTransform::InternalTransformPoints( double* x, vtkIdType numPts, int double* coord = x; for ( vtkIdType i = 0; i < numPts; ++ i ) { - lp.u = coord[0]; lp.v = coord[1]; + lp.lam = coord[0]; lp.phi = coord[1]; xy = pj_fwd( lp, dst ); - coord[0] = xy.u; coord[1] = xy.v; + coord[0] = xy.x; coord[1] = xy.y; coord += stride; } } diff --git a/ThirdParty/libproj/vtk_libproj.h.in b/ThirdParty/libproj/vtk_libproj.h.in index cd9edc3a..9725eb37 100644 --- a/ThirdParty/libproj/vtk_libproj.h.in +++ b/ThirdParty/libproj/vtk_libproj.h.in @@ -18,7 +18,8 @@ /* Use the libproj library configured for VTK. */ #cmakedefine VTK_USE_SYSTEM_LIBPROJ #ifdef VTK_USE_SYSTEM_LIBPROJ -# include +# include +# define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1 # include # include #else -- 2.21.0