|
| 1 | +Almost original commit patch. |
| 2 | +Slightly modified (to make it apply on top of 9.0.3 release tarball) by |
| 3 | +Vadim Misbakh-Soloviov < [email protected]> |
| 4 | + |
| 5 | +Modified part is last 3 lines in the second hunk of first file: |
| 6 | +``` |
| 7 | +} |
| 8 | +else |
| 9 | +{ |
| 10 | +``` |
| 11 | + |
| 12 | +Original commit patch had a bit different code there, while 9.0.3 has this. |
| 13 | + |
| 14 | +--- |
| 15 | +From 0325638832e35c8c8c6fc96e2c1d887aeea3dd43 Mon Sep 17 00:00:00 2001 |
| 16 | +From: Julien Schueller < [email protected]> |
| 17 | +Date: Mon, 8 Mar 2021 10:57:46 +0100 |
| 18 | +Subject: [PATCH] Geovis: Use proj>=5 api |
| 19 | + |
| 20 | +Closes #18130 |
| 21 | +--- |
| 22 | + Geovis/Core/vtkGeoProjection.cxx | 17 ++++++++++++++++- |
| 23 | + Geovis/Core/vtkGeoTransform.cxx | 28 ++++++++++++++-------------- |
| 24 | + ThirdParty/libproj/vtk_libproj.h.in | 7 +------ |
| 25 | + 3 files changed, 31 insertions(+), 21 deletions(-) |
| 26 | + |
| 27 | +diff --git a/Geovis/Core/vtkGeoProjection.cxx b/Geovis/Core/vtkGeoProjection.cxx |
| 28 | +index 7ff6526a5d3..0a0d06eba19 100644 |
| 29 | +--- a/Geovis/Core/vtkGeoProjection.cxx |
| 30 | ++++ b/Geovis/Core/vtkGeoProjection.cxx |
| 31 | +@@ -121,7 +121,11 @@ vtkGeoProjection::~vtkGeoProjection() |
| 32 | + this->SetPROJ4String(nullptr); |
| 33 | + if (this->Projection) |
| 34 | + { |
| 35 | ++#if PROJ_VERSION_MAJOR >= 5 |
| 36 | ++ proj_destroy(this->Projection); |
| 37 | ++#else |
| 38 | + pj_free(this->Projection); |
| 39 | ++#endif |
| 40 | + } |
| 41 | + delete this->Internals; |
| 42 | + this->Internals = nullptr; |
| 43 | +@@ -185,13 +189,21 @@ int vtkGeoProjection::UpdateProjection() |
| 44 | + |
| 45 | + if (this->Projection) |
| 46 | + { |
| 47 | ++#if PROJ_VERSION_MAJOR >= 5 |
| 48 | ++ proj_destroy(this->Projection); |
| 49 | ++#else |
| 50 | + pj_free(this->Projection); |
| 51 | ++#endif |
| 52 | + this->Projection = nullptr; |
| 53 | + } |
| 54 | + |
| 55 | + if (this->PROJ4String && strlen(this->PROJ4String)) |
| 56 | + { |
| 57 | ++#if PROJ_VERSION_MAJOR >= 5 |
| 58 | ++ this->Projection = proj_create(PJ_DEFAULT_CTX, this->PROJ4String); |
| 59 | ++#else |
| 60 | + this->Projection = pj_init_plus(this->PROJ4String); |
| 61 | ++#endif |
| 62 | + } |
| 63 | + else |
| 64 | + { |
| 65 | +@@ -234,8 +246,11 @@ int vtkGeoProjection::UpdateProjection() |
| 66 | + stringHolder[i] = param.str(); |
| 67 | + pjArgs[3 + i] = stringHolder[i].c_str(); |
| 68 | + } |
| 69 | +- |
| 70 | ++#if PROJ_VERSION_MAJOR >= 5 |
| 71 | ++ this->Projection = proj_create_argv(PJ_DEFAULT_CTX, argSize, const_cast<char**>(pjArgs)); |
| 72 | ++#else |
| 73 | + this->Projection = pj_init(argSize, const_cast<char**>(pjArgs)); |
| 74 | ++#endif |
| 75 | + delete[] pjArgs; |
| 76 | + } |
| 77 | + this->ProjectionMTime = this->GetMTime(); |
| 78 | +diff --git a/Geovis/Core/vtkGeoTransform.cxx b/Geovis/Core/vtkGeoTransform.cxx |
| 79 | +index 5c2c74279de..1c99b6b11be 100644 |
| 80 | +--- a/Geovis/Core/vtkGeoTransform.cxx |
| 81 | ++++ b/Geovis/Core/vtkGeoTransform.cxx |
| 82 | +@@ -163,8 +163,12 @@ void vtkGeoTransform::InternalTransformPoints(double* x, vtkIdType numPts, int s |
| 83 | + projPJ src = this->SourceProjection ? this->SourceProjection->GetProjection() : nullptr; |
| 84 | + projPJ dst = this->DestinationProjection ? this->DestinationProjection->GetProjection() : nullptr; |
| 85 | + int delta = stride - 2; |
| 86 | ++#if PROJ_VERSION_MAJOR >= 5 |
| 87 | ++ PJ_COORD c, c_out; |
| 88 | ++#else |
| 89 | + projLP lp; |
| 90 | + projXY xy; |
| 91 | ++#endif |
| 92 | + if (src) |
| 93 | + { |
| 94 | + // Convert from src system to lat/long using inverse of src transform |
| 95 | +@@ -172,17 +176,15 @@ void vtkGeoTransform::InternalTransformPoints(double* x, vtkIdType numPts, int s |
| 96 | + for (vtkIdType i = 0; i < numPts; ++i) |
| 97 | + { |
| 98 | + #if PROJ_VERSION_MAJOR >= 5 |
| 99 | +- xy.x = coord[0]; |
| 100 | +- xy.y = coord[1]; |
| 101 | ++ c.xy.x = coord[0]; |
| 102 | ++ c.xy.y = coord[1]; |
| 103 | ++ c_out = proj_trans(src, PJ_INV, c); |
| 104 | ++ coord[0] = c_out.lp.lam; |
| 105 | ++ coord[1] = c_out.lp.phi; |
| 106 | + #else |
| 107 | + xy.u = coord[0]; |
| 108 | + xy.v = coord[1]; |
| 109 | +-#endif |
| 110 | + lp = pj_inv(xy, src); |
| 111 | +-#if PROJ_VERSION_MAJOR >= 5 |
| 112 | +- coord[0] = lp.lam; |
| 113 | +- coord[1] = lp.phi; |
| 114 | +-#else |
| 115 | + coord[0] = lp.u; |
| 116 | + coord[1] = lp.v; |
| 117 | + #endif |
| 118 | +@@ -208,17 +210,15 @@ void vtkGeoTransform::InternalTransformPoints(double* x, vtkIdType numPts, int s |
| 119 | + for (vtkIdType i = 0; i < numPts; ++i) |
| 120 | + { |
| 121 | + #if PROJ_VERSION_MAJOR >= 5 |
| 122 | +- lp.lam = coord[0]; |
| 123 | +- lp.phi = coord[1]; |
| 124 | ++ c.lp.lam = coord[0]; |
| 125 | ++ c.lp.phi = coord[1]; |
| 126 | ++ c_out = proj_trans(src, PJ_FWD, c); |
| 127 | ++ coord[0] = c_out.xy.x; |
| 128 | ++ coord[1] = c_out.xy.y; |
| 129 | + #else |
| 130 | + lp.u = coord[0]; |
| 131 | + lp.v = coord[1]; |
| 132 | +-#endif |
| 133 | + xy = pj_fwd(lp, dst); |
| 134 | +-#if PROJ_VERSION_MAJOR >= 5 |
| 135 | +- coord[0] = xy.x; |
| 136 | +- coord[1] = xy.y; |
| 137 | +-#else |
| 138 | + coord[0] = xy.u; |
| 139 | + coord[1] = xy.v; |
| 140 | + #endif |
| 141 | +diff --git a/ThirdParty/libproj/vtk_libproj.h.in b/ThirdParty/libproj/vtk_libproj.h.in |
| 142 | +index 4d8ffc3c5d5..c4182c4db2b 100644 |
| 143 | +--- a/ThirdParty/libproj/vtk_libproj.h.in |
| 144 | ++++ b/ThirdParty/libproj/vtk_libproj.h.in |
| 145 | +@@ -28,14 +28,9 @@ |
| 146 | + #if VTK_MODULE_USE_EXTERNAL_vtklibproj |
| 147 | + # if VTK_LibPROJ_MAJOR_VERSION >= 5 |
| 148 | + # include <proj.h> |
| 149 | +-# endif |
| 150 | +-# if VTK_LibPROJ_MAJOR_VERSION < 6 |
| 151 | ++# else |
| 152 | + # include <projects.h> |
| 153 | + # endif |
| 154 | +-# if VTK_LibPROJ_MAJOR_VERSION >= 6 |
| 155 | +-# define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1 |
| 156 | +-# endif |
| 157 | +-# include <proj_api.h> |
| 158 | + # include <geodesic.h> |
| 159 | + #else |
| 160 | + # include <vtklibproj/src/projects.h> |
| 161 | +-- |
| 162 | +GitLab |
| 163 | + |
0 commit comments