vcpkg/ports/vtk/fix-proj4.patch
JackBoosY 75dd38cd8a [proj4] Upgrade version to 6.1.1 and remove patches. (#7917)
* [proj4]Upgrade version to 6.1.1 and remove useless patches.

* [libgeotiff]Fix build errors using proj4 6.1.1.

* [libspatialite]Fix build errors using proj4 6.1.1.

* [gdal]Fix build errors using proj4 6.1.1.

* [spatialite-tools]Fix build errors using proj4 6.1.1.

* [spatialite-tools]Fix build errors using proj4 6.1.1.

* [libgeotiff]Re-fix build errors using proj4 6.1.1.

* [vtk]Fix build errors using proj4 6.1.1.

* [proj4]Fix find sqlite binary failure.

* [proj4]Disable build tools when building proj4 in arm/uwp.

* [sqlite3/libgeotiff]Fix libdl library linkage. Re-fix use proj issue.

* add back dl libs

* [gdal]Fix dependent port proj library name.

* [proj4]Set Windows library name to "proj" and revert fix-proj-name changes.

* [liblas]Fix build errors using proj4 6.1.1.

* [liblas]Fix build errors using proj4 6.1.1.

* [liblas]Fix build errors using proj4 6.1.1.

* [proj4]Fix feature database on triplet arm/uwp.

* [gdal]Remove useless flag PROJ_STATIC.

* [proj4]Fix build error on x64-windows-static.

* [liblas]Use find_library to get proj4/sqlite3 libraries.

* [proj4]Fix sqlite dependency.

* [proj4]Fix arm/uwp dependency.

* [proj4]Fix linux build: configure error.

* [proj4]Disable export proj4 namespace.

* [liblas]Delete proj dependency.

* [libspatialite]Fix linux build.

* [libspatialite]Fix linux command.

* [libspatialite]Fix configure error.

* [proj4]fix static cmake tools path.

* [libgeotiff]Set configure options to 1/0 to avoid the "if" comparison failure in config.cmake.
[proj4]Revert changes about namespace.
[liblas]Remove FindPROJ4.cmake and FindGeoTIFF.cmake from the source.

* [vtk]Fix using latest proj4 issue.

* [proj4]Delete missing patch.
2019-10-17 17:15:52 -07:00

176 lines
5.8 KiB
Diff

diff --git a/Geovis/Core/vtkGeoProjection.cxx b/Geovis/Core/vtkGeoProjection.cxx
index f3a8852..8240603 100644
--- a/Geovis/Core/vtkGeoProjection.cxx
+++ b/Geovis/Core/vtkGeoProjection.cxx
@@ -72,6 +72,9 @@ public:
}
std::map< std::string, std::string > OptionalParameters;
+#if PROJ_VERSION_MAJOR >= 5
+ PJ_PROJ_INFO ProjInfo;
+#endif
};
//-----------------------------------------------------------------------------
@@ -80,7 +83,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 +94,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 +102,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 +147,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 +164,11 @@ const char* vtkGeoProjection::GetDescription()
{
return nullptr;
}
+#if PROJ_VERSION_MAJOR >= 5
+ return this->Internals->ProjInfo.description;
+#else
return this->Projection->descr;
+#endif
}
//-----------------------------------------------------------------------------
projPJ vtkGeoProjection::GetProjection()
@@ -232,6 +239,9 @@ int vtkGeoProjection::UpdateProjection()
this->ProjectionMTime = this->GetMTime();
if ( this->Projection )
{
+#if PROJ_VERSION_MAJOR >= 5
+ this->Internals->ProjInfo = proj_pj_info(this->Projection);
+#endif
return 0;
}
return 1;
diff --git a/Geovis/Core/vtkGeoTransform.cxx b/Geovis/Core/vtkGeoTransform.cxx
index aeeabc1..b80a8c0 100644
--- a/Geovis/Core/vtkGeoTransform.cxx
+++ b/Geovis/Core/vtkGeoTransform.cxx
@@ -167,9 +167,17 @@ void vtkGeoTransform::InternalTransformPoints( double* x, vtkIdType numPts, int
double* coord = x;
for ( vtkIdType i = 0; i < numPts; ++ i )
{
+#if PROJ_VERSION_MAJOR >= 5
+ xy.x = coord[0]; xy.y = coord[1];
+#else
xy.u = coord[0]; xy.v = coord[1];
+#endif
lp = pj_inv( xy, src );
+#if PROJ_VERSION_MAJOR >= 5
+ coord[0] = lp.lam; coord[1] = lp.phi;
+#else
coord[0] = lp.u; coord[1] = lp.v;
+#endif
coord += stride;
}
}
@@ -191,9 +199,17 @@ void vtkGeoTransform::InternalTransformPoints( double* x, vtkIdType numPts, int
double* coord = x;
for ( vtkIdType i = 0; i < numPts; ++ i )
{
+#if PROJ_VERSION_MAJOR >= 5
+ lp.lam = coord[0]; lp.phi = coord[1];
+#else
lp.u = coord[0]; lp.v = coord[1];
+#endif
xy = pj_fwd( lp, dst );
+#if PROJ_VERSION_MAJOR >= 5
+ coord[0] = xy.x; coord[1] = xy.y;
+#else
coord[0] = xy.u; coord[1] = xy.v;
+#endif
coord += stride;
}
}
diff --git a/ThirdParty/libproj/CMakeLists.txt b/ThirdParty/libproj/CMakeLists.txt
index a19609e..e23e44b 100644
--- a/ThirdParty/libproj/CMakeLists.txt
+++ b/ThirdParty/libproj/CMakeLists.txt
@@ -1,4 +1,9 @@
vtk_module_third_party(LibPROJ
LIBRARIES vtklibproj
+ USE_VARIABLES LibPROJ_MAJOR_VERSION
INCLUDE_DIRS ${vtklibproj_SOURCE_DIR}/vtklibproj
${vtklibproj_BINARY_DIR}/vtklibproj)
+
+if (NOT VTK_MODULE_USE_EXTERNAL_VTK_libproj)
+ set(LibPROJ_MAJOR_VERSION "4")
+endif ()
\ No newline at end of file
diff --git a/ThirdParty/libproj/vtk_libproj.h.in b/ThirdParty/libproj/vtk_libproj.h.in
index cd9edc3..d441a1a 100644
--- a/ThirdParty/libproj/vtk_libproj.h.in
+++ b/ThirdParty/libproj/vtk_libproj.h.in
@@ -17,8 +17,23 @@
/* Use the libproj library configured for VTK. */
#cmakedefine VTK_USE_SYSTEM_LIBPROJ
+
+#define VTK_LibPROJ_MAJOR_VERSION @LibPROJ_MAJOR_VERSION@
+
+#if VTK_LibPROJ_MAJOR_VERSION < 5
+# define PROJ_VERSION_MAJOR @LibPROJ_MAJOR_VERSION@
+# define proj_list_operations pj_get_list_ref
+#endif
#ifdef VTK_USE_SYSTEM_LIBPROJ
-# include <projects.h>
+# if VTK_LibPROJ_MAJOR_VERSION >= 5
+# include <proj.h>
+# endif
+# if VTK_LibPROJ_MAJOR_VERSION < 6
+# include <projects.h>
+# endif
+# if VTK_LibPROJ_MAJOR_VERSION >= 6
+# define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1
+# endif
# include <proj_api.h>
# include <geodesic.h>
#else
diff --git a/CMake/FindLibPROJ.cmake b/CMake/FindLibPROJ.cmake
index 2d8301d..d8d08cd 100644
--- a/CMake/FindLibPROJ.cmake
+++ b/CMake/FindLibPROJ.cmake
@@ -5,6 +5,14 @@
# LibPROJ_LIBRARIES to libproj4 and any dependent libraries
# If LibPROJ_REQUIRED is defined, then a fatal error message will be generated if libproj4 is not found
+find_package(PROJ4 6 CONFIG REQUIRED)
+if (PROJ4_FOUND)
+ set(LibPROJ_FOUND 1)
+ set(LibPROJ_INCLUDE_DIR ${PROJ4_INCLUDE_DIRS})
+ set(LibPROJ_LIBRARIES ${PROJ_LIBRARY})
+ set(LibPROJ_MAJOR_VERSION 6)
+endif()
+
if ( NOT LibPROJ_INCLUDE_DIR OR NOT LibPROJ_LIBRARIES OR NOT LibPROJ_FOUND )
if ( $ENV{LibPROJ_DIR} )