From 5d22d137b1be282bdc14c1d12ab8f669f58d41a6 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Mon, 26 Oct 2020 12:44:18 -0400 Subject: Update Mercator projection Introduction ------------ The existing formulation for the Mercator projection is "satisfactory"; it is reasonably accurate. However for a core projection like Mercator, I think we should strive for full double precision accuracy. This commit uses cleaner, more accurate, and faster methods for computing the forward and inverse projections. These use the formulation in terms of hyperbolic functions that are manifestly odd in latitude psi = asinh(tan(phi)) - e * atanh(e * sin(phi)) (phi = latitude; psi = isometric latitude = Mercator y coordinate). Contrast this with the existing formulation psi = log(tan(pi/4 - phi/2)) - e/2 * log((1 + e * sin(phi)) / (1 - e * sin(phi))) where psi(-phi) isn't exactly equal to -psi(phi) and psi(0) isn't guaranteed to be 0. Implementation -------------- There's no particular issue implementing the forward projection, just apply the formulas above. The inverse projection is tricky because there's no closed form solution for the inverse. The existing code for the inverse uses an iterative method from Snyder. This is the usual hokey function iteration, and, as usual, the convergence rate is linear (error reduced by a constant factor on each iteration). This is OK (just) for low accuracy work. But nowadays, something with quadratic convergence (e.g., Newton's method, number of correct digits doubles on each iteration) is preferred (and used here). More on this later. The solution for phi(psi) I use is described in my TM paper and I lifted the specific formulation from GeographicLib's Math::tauf, which uses the same underlying machinery for all conformal projections. It solves for tan(phi) in terms of sinh(psi) which as a near identity mapping is ideal for Newton's method. For comparison I also look at the approach adopted by Poder + Engsager in their TM paper and implemented in etmerc. This uses trigonometric series (accurate to n^6) to convert phi <-> chi. psi is then given by psi = asinh(tan(chi)) Accuracy -------- I tested just the routines for transforming phi <-> psi from merc.cpp and measured the errors (converted to true nm = nanometers) for the forward and inverse mapping. I also included in my analysis the method used by etmerc. This uses a trigonometric series to convert phi <-> chi = atan(sinh(psi)), the conformal latitude. forward inverse max rms max rms old merc 3.60 0.85 2189.47 264.81 etmerc 1.82 0.38 1.42 0.37 new merc 1.83 0.30 2.12 0.31 1 nm is pretty much the absolute limit for accuracy in double precision (1 nm = 10e6 m / 2^53, approximately), and 5 nm is probably the limit on what you should routinely expect. So the old merc inverse is considerably less accurate that it could be. The old merc forward is OK on accuracy -- except that if does not preserve the parity of the projection. The accuracy of etmerc is fine (the truncation error of the 6th order series is small compared with the round-off error). However, situation reverses as the flattening is increased. E.g., at f = 1/150, the max error for the inverse projection is 8 nm. etmerc is OK for terrestrial applications, but couldn't be used for Mars. Timing ------ Here's what I get with g++ -O3 on various Linux machines with recent versions of g++. As always, you should take these with a grain of salt. You might expect the relative timings to vary by 20% or so when switching between compilers/machines. Times per call in ns = nanoseconds. forward inverse old merc 121 360 etmerc 4e-6 1.4 new merc 20 346 The new merc method is 6 times faster at the forward projection and modestly faster at the inverse projection (despite being more accurate). The latter result is because it only take 2 iterations of Newton's method to get full accuracy compared with an average of 5 iterations for the old method to get only um accuracy. A shocking aspect of these timings is how fast etmerc is. Another is that forward etmerc is streaks faster that inverse etmerc (it made be doubt my timing code). Evidently, asinh(tan(chi)) is a lot faster to compute than atan(sinh(psi)). The hesitation about adopting etmerc then comes down to: * the likelihood that Mercator may be used for non-terrestrial bodies; * the question of whether the timing benefits for the etmerc method would be noticeable in a realistic application; * need to duplicate the machinery for evaluating the coefficients for the series and for Clenshaw summation in the current code layout. Ripple effects ============== The Mercator routines used the the Snyder method, pj_tsfn and pj_phi2, are used in other projections. These relate phi to t = exp(-psi) (a rather bizarre choice in my book). I've retrofitted these to use the more accurate methods. These do the "right thing" for phi in [-pi/2, pi/2] , t in [0, inf], and e in [0, 1). NANs are properly handled. Of course, phi = pi/2 in double precision is actually less than pi/2, so cos(pi/2) > 0. So no special handling is needed for pi/2. Even if angles were handled in such a way that 90deg were exactly represented, these routines would still "work", with, e.g., tan(pi/2) -> inf. (A caution: with long doubles = a 64-bit fraction, we have cos(pi/2) < 0; and now we would need to be careful.) As a consequence, there no need for error handling in pj_tsfn; the HUGE_VAL return has gone and, of course, HUGE_VAL is a perfectly legal input to tsfn's inverse, phi2, which would return -pi/2. This "error handling" was only needed for e = 1, a case which is filtered out upstream. I will note that bad argument handling is much more natural using NAN instead of HUGE_VAL. See issue #2376 I've renamed the error condition for non-convergence of the inverse projection from "non-convergent inverse phi2" to "non-convergent sinh(psi) to tan(phi)". Now that pj_tsfn and pj_phi2 now return "better" results, there were some malfunctions in the projections that called them, specifically gstmerc, lcc, and tobmerc. * gstmerc invoked pj_tsfn(phi, sinphi, e) with a value of sinphi that wasn't equal to sin(phi). Disaster followed. I fixed this. I also replaced numerous occurrences of "-1.0 * x" by "-x". (Defining a function with arguments phi and sinphi is asking for trouble.) * lcc incorrectly thinks that the projection isn't defined for standard latitude = +/- 90d. This happens to be false (it reduces to polar stereographic in this limit). The check was whether tsfn(phi) = 0 (which only tested for the north pole not the south pole). However since tsfn(pi/2) now (correctly) returns a nonzero result, this test fails. I now just test for |phi| = pi/2. This is clearer and catches both poles (I'm assuming that the current implementation will probably fail in these cases). * tobmerc similarly thinks that phi close to +/- pi/2 can't be transformed even though psi(pi/2) is only 38. I'm disincline to fight this. However I did tighten up the failure condition (strict equality of |phi| == pi/2). OTHER STUFF =========== Testing ------- builtins.gei: I tightened up the tests for merc (and while I was about it etmerc and tmerc) to reflect full double precision accuracy. My test values are generated with MPFR enabled code and so should be accurate to all digits given. For the record, for GRS80 I use f = 1/298.2572221008827112431628366 in these calculations. pj_phi2_test: many of the tests were bogus testing irrelevant input parameters, like negative values of exp(-psi), and freezing in the arbitrary behavior of phi2. I've reworked most for the tests to be semi-useful. @schwehr can you review. Documentation ------------- I've updated merc.rst to outline the calculation of the inverse projection. phi2.cpp includes detailed notes about applying Newton's method to find tan(phi) in terms of sinh(psi). Future work ----------- lcc needs some tender loving care. It can easily (and should) be modified to allow stdlat = +/- 90 (reduces to polar stereographic), stdlat = 0 and stdlat_1 + stdlat_2 = 0 (reduces to Mercator). A little more elbow grease will allow the treatment of stdlat_1 close to stdlat_2 using divided differences. (See my implementation of the LambertConformalConic class in GeographicLib.) All the places where pj_tsfn and pj_phi2 are called need to be reworked to cut out the use of Snyder's t = exp(-psi() variable and instead use sinh(psi). Maybe include the machinery for series conversions between all auxiliary latitudes as "support functions". Then etmerc could use this (as could mlfn for computing meridional distance). merc could offer the etmerc style projection via chi as an option when the flattening is sufficiently small. --- src/projections/gstmerc.cpp | 18 +++++++++--------- src/projections/lcc.cpp | 10 +++++----- src/projections/merc.cpp | 26 +++----------------------- src/projections/tobmerc.cpp | 19 ++++++++----------- 4 files changed, 25 insertions(+), 48 deletions(-) (limited to 'src/projections') diff --git a/src/projections/gstmerc.cpp b/src/projections/gstmerc.cpp index 808d9ef7..50814bb5 100644 --- a/src/projections/gstmerc.cpp +++ b/src/projections/gstmerc.cpp @@ -28,9 +28,9 @@ static PJ_XY gstmerc_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forw double L, Ls, sinLs1, Ls1; L = Q->n1*lp.lam; - Ls = Q->c + Q->n1 * log(pj_tsfn(-1.0 * lp.phi, -1.0 * sin(lp.phi), P->e)); + Ls = Q->c + Q->n1 * log(pj_tsfn(-lp.phi, -sin(lp.phi), P->e)); sinLs1 = sin(L) / cosh(Ls); - Ls1 = log(pj_tsfn(-1.0 * asin(sinLs1), 0.0, 0.0)); + Ls1 = log(pj_tsfn(-asin(sinLs1), -sinLs1, 0.0)); xy.x = (Q->XS + Q->n2*Ls1) * P->ra; xy.y = (Q->YS + Q->n2*atan(sinh(Ls) / cos(L))) * P->ra; @@ -45,9 +45,9 @@ static PJ_LP gstmerc_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inve L = atan(sinh((xy.x * P->a - Q->XS) / Q->n2) / cos((xy.y * P->a - Q->YS) / Q->n2)); sinC = sin((xy.y * P->a - Q->YS) / Q->n2) / cosh((xy.x * P->a - Q->XS) / Q->n2); - LC = log(pj_tsfn(-1.0 * asin(sinC), 0.0, 0.0)); + LC = log(pj_tsfn(-asin(sinC), -sinC, 0.0)); lp.lam = L / Q->n1; - lp.phi = -1.0 * pj_phi2(P->ctx, exp((LC - Q->c) / Q->n1), P->e); + lp.phi = -pj_phi2(P->ctx, exp((LC - Q->c) / Q->n1), P->e); return lp; } @@ -60,13 +60,13 @@ PJ *PROJECTION(gstmerc) { P->opaque = Q; Q->lamc = P->lam0; - Q->n1 = sqrt(1.0 + P->es * pow(cos(P->phi0), 4.0) / (1.0 - P->es)); + Q->n1 = sqrt(1 + P->es * pow(cos(P->phi0), 4.0) / (1 - P->es)); Q->phic = asin(sin(P->phi0) / Q->n1); - Q->c = log(pj_tsfn(-1.0 * Q->phic, 0.0, 0.0)) - - Q->n1 * log(pj_tsfn(-1.0 * P->phi0, -1.0 * sin(P->phi0), P->e)); - Q->n2 = P->k0 * P->a * sqrt(1.0 - P->es) / (1.0 - P->es * sin(P->phi0) * sin(P->phi0)); + Q->c = log(pj_tsfn(-Q->phic, -sin(P->phi0) / Q->n1, 0.0)) + - Q->n1 * log(pj_tsfn(-P->phi0, -sin(P->phi0), P->e)); + Q->n2 = P->k0 * P->a * sqrt(1 - P->es) / (1 - P->es * sin(P->phi0) * sin(P->phi0)); Q->XS = 0; - Q->YS = -1.0 * Q->n2 * Q->phic; + Q->YS = -Q->n2 * Q->phic; P->inv = gstmerc_s_inverse; P->fwd = gstmerc_s_forward; diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp index 91ffc511..b83b8072 100644 --- a/src/projections/lcc.cpp +++ b/src/projections/lcc.cpp @@ -106,10 +106,10 @@ PJ *PROJECTION(lcc) { double ml1, m1; m1 = pj_msfn(sinphi, cosphi, P->es); - ml1 = pj_tsfn(Q->phi1, sinphi, P->e); - if( ml1 == 0 ) { + if( abs(Q->phi1) == M_HALFPI ) { return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); } + ml1 = pj_tsfn(Q->phi1, sinphi, P->e); if (secant) { /* secant cone */ sinphi = sin(Q->phi2); Q->n = log(m1 / pj_msfn(sinphi, cos(Q->phi2), P->es)); @@ -117,10 +117,10 @@ PJ *PROJECTION(lcc) { // Not quite, but es is very close to 1... return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY); } - const double ml2 = pj_tsfn(Q->phi2, sinphi, P->e); - if( ml2 == 0 ) { - return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); + if( abs(Q->phi2) == M_HALFPI ) { + return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); } + const double ml2 = pj_tsfn(Q->phi2, sinphi, P->e); const double denom = log(ml1 / ml2); if( denom == 0 ) { // Not quite, but es is very close to 1... diff --git a/src/projections/merc.cpp b/src/projections/merc.cpp index a77d7517..472cb43f 100644 --- a/src/projections/merc.cpp +++ b/src/projections/merc.cpp @@ -10,45 +10,25 @@ PROJ_HEAD(merc, "Mercator") "\n\tCyl, Sph&Ell\n\tlat_ts="; PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Ell\n\t"; -#define EPS10 1.e-10 -static double logtanpfpim1(double x) { /* log(tan(x/2 + M_FORTPI)) */ - if (fabs(x) <= DBL_EPSILON) { - /* tan(M_FORTPI + .5 * x) can be approximated by 1.0 + x */ - return log1p(x); - } - return log(tan(M_FORTPI + .5 * x)); -} - static PJ_XY merc_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ PJ_XY xy = {0.0,0.0}; - if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) { - proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); - return xy; - } xy.x = P->k0 * lp.lam; - xy.y = - P->k0 * log(pj_tsfn(lp.phi, sin(lp.phi), P->e)); + xy.y = P->k0 * (asinh(tan(lp.phi)) - P->e * atanh(P->e * sin(lp.phi))); return xy; } static PJ_XY merc_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */ PJ_XY xy = {0.0,0.0}; - if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) { - proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); - return xy; -} xy.x = P->k0 * lp.lam; - xy.y = P->k0 * logtanpfpim1(lp.phi); + xy.y = P->k0 * asinh(tan(lp.phi)); return xy; } static PJ_LP merc_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ_LP lp = {0.0,0.0}; - if ((lp.phi = pj_phi2(P->ctx, exp(- xy.y / P->k0), P->e)) == HUGE_VAL) { - proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); - return lp; -} + lp.phi = atan(pj_sinhpsi2tanphi(P->ctx, sinh(xy.y / P->k0), P->e)); lp.lam = xy.x / P->k0; return lp; } diff --git a/src/projections/tobmerc.cpp b/src/projections/tobmerc.cpp index a1616036..f05a9b6b 100644 --- a/src/projections/tobmerc.cpp +++ b/src/projections/tobmerc.cpp @@ -9,27 +9,24 @@ PROJ_HEAD(tobmerc, "Tobler-Mercator") "\n\tCyl, Sph"; -#define EPS10 1.e-10 -static double logtanpfpim1(double x) { /* log(tan(x/2 + M_FORTPI)) */ - if (fabs(x) <= DBL_EPSILON) { - /* tan(M_FORTPI + .5 * x) can be approximated by 1.0 + x */ - return log1p(x); - } - return log(tan(M_FORTPI + .5 * x)); -} - static PJ_XY tobmerc_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */ PJ_XY xy = {0.0, 0.0}; double cosphi; - if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) { + if (fabs(lp.phi) >= M_HALFPI) { + // builtins.gie tests "Test expected failure at the poles:". However + // given that M_HALFPI is strictly less than pi/2 in double precision, + // it's not clear why shouldn't just return a large result for xy.y (and + // it's not even that large, merely 38.025...). Even if the logic was + // such that phi was strictly equal to pi/2, allowing xy.y = inf would be + // a reasonable result. proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); return xy; } cosphi = cos(lp.phi); xy.x = P->k0 * lp.lam * cosphi * cosphi; - xy.y = P->k0 * logtanpfpim1(lp.phi); + xy.y = P->k0 * asinh(tan(lp.phi)); return xy; } -- cgit v1.2.3 From 1081e496a0fc7e45c6eb4703b0fc402bf2a9e945 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Mon, 26 Oct 2020 16:06:19 -0400 Subject: lcc.cpp: fix abs -> fabs Also some corrected information... Timing UPDATED -------------- Sorry the previous timing data was wrong. Here are corrected values.. Here's what I get with g++ -O3 on two Linux machines with recent versions of g++. As always, you should take these with a grain of salt. Times per call in ns = nanoseconds. Fedora 31 Ubuntu 18 g++-9.3.1 g++-7.5.0 fwd inv fwd inv old merc 207 461 217 522 new merc 228 457 168 410 etmerc 212 196 174 147 The new forward method is the 10% slower (resp 20% faster) on Fedora 31 (resp Ubuntu 18). The new inverse method is the same speed (resp 20% faster) on Fedora 31 (resp Ubuntu 18). Roughly speaking the speed comparison is a wash. Maybe we should pay attention more to the Fedora 31 results since these are with a newer version of the compiler. I would still make the argument that a 20% time penalty (which in a full PROJ pipeline would probably be no more than a 5% penalty) would be a worthwhile price to pay for a more robust implementation of the projection. --- src/projections/lcc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/projections') diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp index b83b8072..46378ce4 100644 --- a/src/projections/lcc.cpp +++ b/src/projections/lcc.cpp @@ -106,7 +106,7 @@ PJ *PROJECTION(lcc) { double ml1, m1; m1 = pj_msfn(sinphi, cosphi, P->es); - if( abs(Q->phi1) == M_HALFPI ) { + if( fabs(Q->phi1) == M_HALFPI ) { return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); } ml1 = pj_tsfn(Q->phi1, sinphi, P->e); @@ -117,7 +117,7 @@ PJ *PROJECTION(lcc) { // Not quite, but es is very close to 1... return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY); } - if( abs(Q->phi2) == M_HALFPI ) { + if( fabs(Q->phi2) == M_HALFPI ) { return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); } const double ml2 = pj_tsfn(Q->phi2, sinphi, P->e); -- cgit v1.2.3 From 75a8436b2491dbc1eebb196ea42b961fd011a52e Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Mon, 26 Oct 2020 18:29:19 -0400 Subject: Use sincos optimization in merc_e_forward. Revised timing data... Times per call in ns = nanoseconds. Fedora 31 Ubuntu 18 g++-9.3.1 g++-7.5.0 fwd inv fwd inv old merc 207 461 217 522 new merc 159 457 137 410 etmerc 212 196 174 147 The new forward method is now 25% faster (resp 35% faster) on Fedora 31 (resp Ubuntu 18). The new inverse method is the same speed (resp 20% faster) on Fedora 31 (resp Ubuntu 18). The accuracy is hardly affected: rms error increases from 0.30 nm to 0.33 nm, max error increases from 1.83 nm to 1.84 nm (a barely noticeable degradation). --- src/projections/merc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/projections') diff --git a/src/projections/merc.cpp b/src/projections/merc.cpp index 472cb43f..e5da3967 100644 --- a/src/projections/merc.cpp +++ b/src/projections/merc.cpp @@ -13,7 +13,8 @@ PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Ell\n\t"; static PJ_XY merc_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ PJ_XY xy = {0.0,0.0}; xy.x = P->k0 * lp.lam; - xy.y = P->k0 * (asinh(tan(lp.phi)) - P->e * atanh(P->e * sin(lp.phi))); + double sphi = sin(lp.phi), cphi = cos(lp.phi); + xy.y = P->k0 * (asinh(sphi/cphi) - P->e * atanh(P->e * sphi)); return xy; } -- cgit v1.2.3 From 6bd7c777f8e789f8ea34a6aa68104ab44a31beee Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Mon, 26 Oct 2020 19:03:26 -0400 Subject: Fix/add some comments. --- src/projections/merc.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/projections') diff --git a/src/projections/merc.cpp b/src/projections/merc.cpp index e5da3967..39685478 100644 --- a/src/projections/merc.cpp +++ b/src/projections/merc.cpp @@ -13,6 +13,8 @@ PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Ell\n\t"; static PJ_XY merc_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ PJ_XY xy = {0.0,0.0}; xy.x = P->k0 * lp.lam; + // Instead of calling tan and sin, call sin and cos which the compiler + // optimizes to a single call to sincos. double sphi = sin(lp.phi), cphi = cos(lp.phi); xy.y = P->k0 * (asinh(sphi/cphi) - P->e * atanh(P->e * sphi)); return xy; -- cgit v1.2.3 From 692fc26b6d494aeaa85658314bc020a5cd6da7a1 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Tue, 27 Oct 2020 16:44:43 -0400 Subject: merc.cpp + phi2.cpp: Avoid declaring multiple variables in 1 statement. --- src/projections/merc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/projections') diff --git a/src/projections/merc.cpp b/src/projections/merc.cpp index 39685478..3a0ed7b4 100644 --- a/src/projections/merc.cpp +++ b/src/projections/merc.cpp @@ -15,7 +15,8 @@ static PJ_XY merc_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward xy.x = P->k0 * lp.lam; // Instead of calling tan and sin, call sin and cos which the compiler // optimizes to a single call to sincos. - double sphi = sin(lp.phi), cphi = cos(lp.phi); + double sphi = sin(lp.phi); + double cphi = cos(lp.phi); xy.y = P->k0 * (asinh(sphi/cphi) - P->e * atanh(P->e * sphi)); return xy; } -- cgit v1.2.3 From b38d0143a65fff72635b95a61ed6c4c41802889e Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Nov 2020 23:56:58 +0100 Subject: Polar stereographic at pole: make it return (0,0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the improved accuracy of pj_tsfn(), it no longer returns 0 when phi=90° due to the conversion in radians. Some GDAL tests are very sensitive to the pole transforming to (0,0) exactly, so add a special case for that. master only --- src/projections/stere.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/projections') diff --git a/src/projections/stere.cpp b/src/projections/stere.cpp index abc4aa13..3fff722d 100644 --- a/src/projections/stere.cpp +++ b/src/projections/stere.cpp @@ -86,7 +86,10 @@ static PJ_XY stere_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forwar sinphi = -sinphi; /*-fallthrough*/ case N_POLE: - xy.x = Q->akm1 * pj_tsfn (lp.phi, sinphi, P->e); + if( fabs(lp.phi - M_HALFPI) < 1e-15 ) + xy.x = 0; + else + xy.x = Q->akm1 * pj_tsfn (lp.phi, sinphi, P->e); xy.y = - xy.x * coslam; break; } -- cgit v1.2.3 From 9419b42ade1f1d35a61c05f0f7ce9aab2eeff3c7 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Sun, 1 Nov 2020 13:34:32 +0100 Subject: Remove proj_api.h Removes proj_api.h from the public API. The contents of the header file has been moved to proj_internal.h verbatim and any references to proj_api.h has been changed to proj_internal.h. The documentation of proj_api.h has been removed. The only exception to this is the API migration guides which still mention the old API. Fixes #837 --- src/projections/calcofi.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/projections') diff --git a/src/projections/calcofi.cpp b/src/projections/calcofi.cpp index 57c12dde..d1e96de8 100644 --- a/src/projections/calcofi.cpp +++ b/src/projections/calcofi.cpp @@ -4,7 +4,6 @@ #include "proj.h" #include "proj_internal.h" -#include "proj_api.h" PROJ_HEAD(calcofi, "Cal Coop Ocean Fish Invest Lines/Stations") "\n\tCyl, Sph&Ell"; -- cgit v1.2.3 From aa46197d66ce70ece382bf955326c46b13f35864 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Sat, 14 Nov 2020 22:55:31 +0100 Subject: Weed out proj_api.h datatypes and replace them with their proj.h counterparts --- src/projections/chamb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/projections') diff --git a/src/projections/chamb.cpp b/src/projections/chamb.cpp index 36609e79..1b926b8a 100644 --- a/src/projections/chamb.cpp +++ b/src/projections/chamb.cpp @@ -29,7 +29,7 @@ PROJ_HEAD(chamb, "Chamberlin Trimetric") "\n\tMisc Sph, no inv" #define TOL 1e-9 /* distance and azimuth from point 1 to point 2 */ -static VECT vect(projCtx ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) { +static VECT vect(PJ_CONTEXT *ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) { VECT v; double cdl, dp, dl; @@ -49,7 +49,7 @@ static VECT vect(projCtx ctx, double dphi, double c1, double s1, double c2, doub } /* law of cosines */ -static double lc(projCtx ctx, double b,double c,double a) { +static double lc(PJ_CONTEXT *ctx, double b,double c,double a) { return aacos(ctx, .5 * (b * b + c * c - a * a) / (b * c)); } -- cgit v1.2.3 From a74b985b5006c2d279353a245cfcb850cf7fcc94 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Tue, 17 Nov 2020 12:54:24 +0100 Subject: Remove pj_ctx_* functions and use their proj_context counterparts --- src/projections/aitoff.cpp | 2 +- src/projections/comill.cpp | 2 +- src/projections/eqearth.cpp | 2 +- src/projections/healpix.cpp | 8 ++++---- src/projections/krovak.cpp | 2 +- src/projections/natearth.cpp | 2 +- src/projections/natearth2.cpp | 2 +- src/projections/ortho.cpp | 2 +- src/projections/patterson.cpp | 2 +- src/projections/robin.cpp | 2 +- src/projections/tmerc.cpp | 6 +++--- 11 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/projections') diff --git a/src/projections/aitoff.cpp b/src/projections/aitoff.cpp index 7920309c..d02e7761 100644 --- a/src/projections/aitoff.cpp +++ b/src/projections/aitoff.cpp @@ -170,7 +170,7 @@ static PJ_LP aitoff_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver if (iter == MAXITER && round == MAXROUND) { - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); /* fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl); */ } diff --git a/src/projections/comill.cpp b/src/projections/comill.cpp index 189e583e..44524990 100644 --- a/src/projections/comill.cpp +++ b/src/projections/comill.cpp @@ -66,7 +66,7 @@ static PJ_LP comill_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/eqearth.cpp b/src/projections/eqearth.cpp index 832c9444..60effde0 100644 --- a/src/projections/eqearth.cpp +++ b/src/projections/eqearth.cpp @@ -110,7 +110,7 @@ static PJ_LP eqearth_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal/sphe } if( i == 0 ) { - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); return lp; } diff --git a/src/projections/healpix.cpp b/src/projections/healpix.cpp index aab5c41e..5a06125d 100644 --- a/src/projections/healpix.cpp +++ b/src/projections/healpix.cpp @@ -524,7 +524,7 @@ static PJ_LP s_healpix_inverse(PJ_XY xy, PJ *P) { /* sphere */ PJ_LP lp; lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } return healpix_spherhealpix_e_inverse(xy); @@ -540,7 +540,7 @@ static PJ_LP e_healpix_inverse(PJ_XY xy, PJ *P) { /* ellipsoid */ if (in_image(xy.x, xy.y, 0, 0, 0) == 0) { lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } lp = healpix_spherhealpix_e_inverse(xy); @@ -574,7 +574,7 @@ static PJ_LP s_rhealpix_inverse(PJ_XY xy, PJ *P) { /* sphere */ PJ_LP lp; lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1); @@ -590,7 +590,7 @@ static PJ_LP e_rhealpix_inverse(PJ_XY xy, PJ *P) { /* ellipsoid */ if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) { lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1); diff --git a/src/projections/krovak.cpp b/src/projections/krovak.cpp index aef44d42..3e6a5c30 100644 --- a/src/projections/krovak.cpp +++ b/src/projections/krovak.cpp @@ -181,7 +181,7 @@ static PJ_LP krovak_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, fi1 = lp.phi; } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.lam -= P->lam0; diff --git a/src/projections/natearth.cpp b/src/projections/natearth.cpp index 5c096605..e1f71089 100644 --- a/src/projections/natearth.cpp +++ b/src/projections/natearth.cpp @@ -82,7 +82,7 @@ static PJ_LP natearth_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inv } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/natearth2.cpp b/src/projections/natearth2.cpp index d149ca85..e4516a0a 100644 --- a/src/projections/natearth2.cpp +++ b/src/projections/natearth2.cpp @@ -76,7 +76,7 @@ static PJ_LP natearth2_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, in } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/ortho.cpp b/src/projections/ortho.cpp index 8dcfb53c..d9c84dba 100644 --- a/src/projections/ortho.cpp +++ b/src/projections/ortho.cpp @@ -273,7 +273,7 @@ static PJ_LP ortho_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inver return lp; } } - pj_ctx_set_errno(P->ctx, PJD_ERR_NON_CONVERGENT); + proj_context_errno_set(P->ctx, PJD_ERR_NON_CONVERGENT); return lp; } diff --git a/src/projections/patterson.cpp b/src/projections/patterson.cpp index 71099cdb..32544580 100644 --- a/src/projections/patterson.cpp +++ b/src/projections/patterson.cpp @@ -100,7 +100,7 @@ static PJ_LP patterson_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, in } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/robin.cpp b/src/projections/robin.cpp index 8b646502..6a1405b6 100644 --- a/src/projections/robin.cpp +++ b/src/projections/robin.cpp @@ -138,7 +138,7 @@ static PJ_LP robin_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers break; } if( iters == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = (5 * i + t) * DEG_TO_RAD; if (xy.y < 0.) lp.phi = -lp.phi; lp.lam /= V(X[i], t); diff --git a/src/projections/tmerc.cpp b/src/projections/tmerc.cpp index 69f4d352..ff1bc2a5 100644 --- a/src/projections/tmerc.cpp +++ b/src/projections/tmerc.cpp @@ -89,7 +89,7 @@ static PJ_XY approx_e_fwd (PJ_LP lp, PJ *P) if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { xy.x = HUGE_VAL; xy.y = HUGE_VAL; - pj_ctx_set_errno( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); + proj_context_errno_set( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); return xy; } @@ -130,7 +130,7 @@ static PJ_XY approx_s_fwd (PJ_LP lp, PJ *P) { if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { xy.x = HUGE_VAL; xy.y = HUGE_VAL; - pj_ctx_set_errno( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); + proj_context_errno_set( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); return xy; } @@ -679,7 +679,7 @@ static bool getAlgoFromParams(PJ* P, TMercAlgo& algo) else { pj_load_ini(P->ctx); // if not already done - pj_ctx_set_errno(P->ctx, 0); // reset error in case proj.ini couldn't be found + proj_context_errno_set(P->ctx, 0); // reset error in case proj.ini couldn't be found algo = P->ctx->defaultTmercAlgo; } -- cgit v1.2.3 From 43efca4ab87fb37a0931edcb6be11c0bd3784098 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 18 Nov 2020 09:57:42 +0100 Subject: Remove pj_free() and move it's functional parts to proj_destroy() --- src/projections/goode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/projections') diff --git a/src/projections/goode.cpp b/src/projections/goode.cpp index fdace387..9a6fb86c 100644 --- a/src/projections/goode.cpp +++ b/src/projections/goode.cpp @@ -54,8 +54,8 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ return nullptr; if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_free (static_cast(P->opaque)->sinu); - pj_free (static_cast(P->opaque)->moll); + proj_destroy (static_cast(P->opaque)->sinu); + proj_destroy (static_cast(P->opaque)->moll); return pj_default_destructor (P, errlev); } -- cgit v1.2.3 From 046270a85faf20f38d01e02942d197db74bb8542 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Fri, 20 Nov 2020 16:37:12 +0100 Subject: Remove old pj_ memory (de)allocation functions Gone are pj_malloc, pj_calloc, pj_dalloc and pj_dealloc. Their primary function as API memory functions in proj_api.h is no longer there and the other use as a workaround for old errno problems is no longer valid either. Replaced with malloc and free across the codebase. --- src/projections/adams.cpp | 2 +- src/projections/aea.cpp | 6 +++--- src/projections/aeqd.cpp | 4 ++-- src/projections/airy.cpp | 2 +- src/projections/aitoff.cpp | 4 ++-- src/projections/bacon.cpp | 6 +++--- src/projections/bertin1953.cpp | 2 +- src/projections/bipc.cpp | 2 +- src/projections/bonne.cpp | 4 ++-- src/projections/cass.cpp | 4 ++-- src/projections/ccon.cpp | 4 ++-- src/projections/cea.cpp | 4 ++-- src/projections/chamb.cpp | 2 +- src/projections/col_urban.cpp | 2 +- src/projections/eck3.cpp | 8 ++++---- src/projections/eqc.cpp | 2 +- src/projections/eqdc.cpp | 4 ++-- src/projections/eqearth.cpp | 4 ++-- src/projections/fouc_s.cpp | 2 +- src/projections/geos.cpp | 2 +- src/projections/gn_sinu.cpp | 10 +++++----- src/projections/gnom.cpp | 2 +- src/projections/goode.cpp | 2 +- src/projections/gstmerc.cpp | 2 +- src/projections/hammer.cpp | 2 +- src/projections/healpix.cpp | 6 +++--- src/projections/igh.cpp | 2 +- src/projections/igh_o.cpp | 2 +- src/projections/imw_p.cpp | 4 ++-- src/projections/isea.cpp | 2 +- src/projections/krovak.cpp | 2 +- src/projections/labrd.cpp | 2 +- src/projections/laea.cpp | 4 ++-- src/projections/lagrng.cpp | 2 +- src/projections/lcc.cpp | 2 +- src/projections/lcca.cpp | 4 ++-- src/projections/loxim.cpp | 2 +- src/projections/lsat.cpp | 2 +- src/projections/misrsom.cpp | 2 +- src/projections/mod_ster.cpp | 10 +++++----- src/projections/moll.cpp | 6 +++--- src/projections/nsper.cpp | 4 ++-- src/projections/ob_tran.cpp | 8 ++++---- src/projections/ocea.cpp | 2 +- src/projections/oea.cpp | 2 +- src/projections/omerc.cpp | 2 +- src/projections/ortho.cpp | 2 +- src/projections/poly.cpp | 4 ++-- src/projections/putp3.cpp | 4 ++-- src/projections/putp4p.cpp | 4 ++-- src/projections/putp5.cpp | 4 ++-- src/projections/putp6.cpp | 4 ++-- src/projections/qsc.cpp | 2 +- src/projections/rouss.cpp | 4 ++-- src/projections/rpoly.cpp | 2 +- src/projections/sch.cpp | 2 +- src/projections/sconics.cpp | 2 +- src/projections/somerc.cpp | 2 +- src/projections/stere.cpp | 4 ++-- src/projections/sterea.cpp | 4 ++-- src/projections/sts.cpp | 8 ++++---- src/projections/tmerc.cpp | 4 ++-- src/projections/tpeqd.cpp | 2 +- src/projections/urm5.cpp | 2 +- src/projections/urmfps.cpp | 4 ++-- src/projections/vandg2.cpp | 4 ++-- src/projections/wag3.cpp | 2 +- src/projections/wink1.cpp | 2 +- src/projections/wink2.cpp | 2 +- 69 files changed, 117 insertions(+), 117 deletions(-) (limited to 'src/projections') diff --git a/src/projections/adams.cpp b/src/projections/adams.cpp index 4f7d1a03..d1217ff1 100644 --- a/src/projections/adams.cpp +++ b/src/projections/adams.cpp @@ -205,7 +205,7 @@ static PJ_LP adams_inverse(PJ_XY xy, PJ *P) static PJ *setup(PJ *P, projection_type mode) { struct pj_opaque *Q = static_cast( - pj_calloc (1, sizeof (struct pj_opaque))); + calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); diff --git a/src/projections/aea.cpp b/src/projections/aea.cpp index 6ffb4fd6..af0f292d 100644 --- a/src/projections/aea.cpp +++ b/src/projections/aea.cpp @@ -94,7 +94,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } @@ -219,7 +219,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(aea) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -232,7 +232,7 @@ PJ *PROJECTION(aea) { PJ *PROJECTION(leac) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/aeqd.cpp b/src/projections/aeqd.cpp index ad8c289e..d5d90b62 100644 --- a/src/projections/aeqd.cpp +++ b/src/projections/aeqd.cpp @@ -69,7 +69,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } @@ -274,7 +274,7 @@ static PJ_LP aeqd_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(aeqd) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/airy.cpp b/src/projections/airy.cpp index f7602e53..15ff60d8 100644 --- a/src/projections/airy.cpp +++ b/src/projections/airy.cpp @@ -120,7 +120,7 @@ static PJ_XY airy_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward PJ *PROJECTION(airy) { double beta; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); diff --git a/src/projections/aitoff.cpp b/src/projections/aitoff.cpp index d02e7761..857ebb80 100644 --- a/src/projections/aitoff.cpp +++ b/src/projections/aitoff.cpp @@ -187,7 +187,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(aitoff) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -198,7 +198,7 @@ PJ *PROJECTION(aitoff) { PJ *PROJECTION(wintri) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/bacon.cpp b/src/projections/bacon.cpp index 3efd4dbe..7ff2a7ac 100644 --- a/src/projections/bacon.cpp +++ b/src/projections/bacon.cpp @@ -43,7 +43,7 @@ static PJ_XY bacon_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forwar PJ *PROJECTION(bacon) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -57,7 +57,7 @@ PJ *PROJECTION(bacon) { PJ *PROJECTION(apian) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -70,7 +70,7 @@ PJ *PROJECTION(apian) { PJ *PROJECTION(ortel) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/bertin1953.cpp b/src/projections/bertin1953.cpp index b864f83a..58509e16 100644 --- a/src/projections/bertin1953.cpp +++ b/src/projections/bertin1953.cpp @@ -75,7 +75,7 @@ static PJ_XY bertin1953_s_forward (PJ_LP lp, PJ *P) { PJ *PROJECTION(bertin1953) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/bipc.cpp b/src/projections/bipc.cpp index bf4ba834..743acd1c 100644 --- a/src/projections/bipc.cpp +++ b/src/projections/bipc.cpp @@ -168,7 +168,7 @@ static PJ_LP bipc_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(bipc) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/bonne.cpp b/src/projections/bonne.cpp index c94764cf..7817e968 100644 --- a/src/projections/bonne.cpp +++ b/src/projections/bonne.cpp @@ -106,14 +106,14 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } PJ *PROJECTION(bonne) { double c; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/cass.cpp b/src/projections/cass.cpp index e253cafc..f5531f6a 100644 --- a/src/projections/cass.cpp +++ b/src/projections/cass.cpp @@ -95,7 +95,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } @@ -111,7 +111,7 @@ PJ *PROJECTION(cass) { } /* otherwise it's ellipsoidal */ - P->opaque = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + P->opaque = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==P->opaque) return pj_default_destructor (P, ENOMEM); P->destructor = destructor; diff --git a/src/projections/ccon.cpp b/src/projections/ccon.cpp index df995f21..7b3b7105 100644 --- a/src/projections/ccon.cpp +++ b/src/projections/ccon.cpp @@ -75,14 +75,14 @@ static PJ *destructor (PJ *P, int errlev) { if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } PJ *PROJECTION(ccon) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/cea.cpp b/src/projections/cea.cpp index 7e6d3212..b7874b90 100644 --- a/src/projections/cea.cpp +++ b/src/projections/cea.cpp @@ -66,14 +66,14 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->apa); + free (static_cast(P->opaque)->apa); return pj_default_destructor (P, errlev); } PJ *PROJECTION(cea) { double t = 0.0; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/chamb.cpp b/src/projections/chamb.cpp index 1b926b8a..b315832a 100644 --- a/src/projections/chamb.cpp +++ b/src/projections/chamb.cpp @@ -103,7 +103,7 @@ static PJ_XY chamb_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forwar PJ *PROJECTION(chamb) { int i, j; char line[10]; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/col_urban.cpp b/src/projections/col_urban.cpp index 5bc8407f..de0c178f 100644 --- a/src/projections/col_urban.cpp +++ b/src/projections/col_urban.cpp @@ -54,7 +54,7 @@ static PJ_LP col_urban_inverse (PJ_XY xy, PJ *P) { } PJ *PROJECTION(col_urban) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/eck3.cpp b/src/projections/eck3.cpp index 0deeb4f3..2563053f 100644 --- a/src/projections/eck3.cpp +++ b/src/projections/eck3.cpp @@ -52,7 +52,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(eck3) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -67,7 +67,7 @@ PJ *PROJECTION(eck3) { PJ *PROJECTION(kav7) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -85,7 +85,7 @@ PJ *PROJECTION(kav7) { PJ *PROJECTION(wag6) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -100,7 +100,7 @@ PJ *PROJECTION(wag6) { PJ *PROJECTION(putp1) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/eqc.cpp b/src/projections/eqc.cpp index 194625ef..9ebc9286 100644 --- a/src/projections/eqc.cpp +++ b/src/projections/eqc.cpp @@ -39,7 +39,7 @@ static PJ_LP eqc_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(eqc) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/eqdc.cpp b/src/projections/eqdc.cpp index 659488b1..28767d74 100644 --- a/src/projections/eqdc.cpp +++ b/src/projections/eqdc.cpp @@ -68,7 +68,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } @@ -77,7 +77,7 @@ PJ *PROJECTION(eqdc) { double cosphi, sinphi; int secant; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/eqearth.cpp b/src/projections/eqearth.cpp index 60effde0..2ef2775b 100644 --- a/src/projections/eqearth.cpp +++ b/src/projections/eqearth.cpp @@ -137,13 +137,13 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->apa); + free (static_cast(P->opaque)->apa); return pj_default_destructor (P, errlev); } PJ *PROJECTION(eqearth) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/fouc_s.cpp b/src/projections/fouc_s.cpp index c5989514..f7607635 100644 --- a/src/projections/fouc_s.cpp +++ b/src/projections/fouc_s.cpp @@ -55,7 +55,7 @@ static PJ_LP fouc_s_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver PJ *PROJECTION(fouc_s) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/geos.cpp b/src/projections/geos.cpp index 338f07c2..5de4c7ca 100644 --- a/src/projections/geos.cpp +++ b/src/projections/geos.cpp @@ -199,7 +199,7 @@ static PJ_LP geos_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse PJ *PROJECTION(geos) { char *sweep_axis; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/gn_sinu.cpp b/src/projections/gn_sinu.cpp index 815de8be..ef312613 100644 --- a/src/projections/gn_sinu.cpp +++ b/src/projections/gn_sinu.cpp @@ -102,7 +102,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } @@ -121,7 +121,7 @@ static void setup(PJ *P) { PJ *PROJECTION(sinu) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -143,7 +143,7 @@ PJ *PROJECTION(sinu) { PJ *PROJECTION(eck6) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -158,7 +158,7 @@ PJ *PROJECTION(eck6) { PJ *PROJECTION(mbtfps) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -173,7 +173,7 @@ PJ *PROJECTION(mbtfps) { PJ *PROJECTION(gn_sinu) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/gnom.cpp b/src/projections/gnom.cpp index 23dee030..9abbb7ce 100644 --- a/src/projections/gnom.cpp +++ b/src/projections/gnom.cpp @@ -124,7 +124,7 @@ static PJ_LP gnom_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(gnom) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/goode.cpp b/src/projections/goode.cpp index 9a6fb86c..c0afd2d8 100644 --- a/src/projections/goode.cpp +++ b/src/projections/goode.cpp @@ -62,7 +62,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ PJ *PROJECTION(goode) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/gstmerc.cpp b/src/projections/gstmerc.cpp index 50814bb5..b21f6ffd 100644 --- a/src/projections/gstmerc.cpp +++ b/src/projections/gstmerc.cpp @@ -54,7 +54,7 @@ static PJ_LP gstmerc_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inve PJ *PROJECTION(gstmerc) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/hammer.cpp b/src/projections/hammer.cpp index 8d6d9408..d9bcafc7 100644 --- a/src/projections/hammer.cpp +++ b/src/projections/hammer.cpp @@ -57,7 +57,7 @@ static PJ_LP hammer_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver PJ *PROJECTION(hammer) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/healpix.cpp b/src/projections/healpix.cpp index 5a06125d..c778f28f 100644 --- a/src/projections/healpix.cpp +++ b/src/projections/healpix.cpp @@ -607,13 +607,13 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->apa); + free (static_cast(P->opaque)->apa); return pj_default_destructor (P, errlev); } PJ *PROJECTION(healpix) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -641,7 +641,7 @@ PJ *PROJECTION(healpix) { PJ *PROJECTION(rhealpix) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/igh.cpp b/src/projections/igh.cpp index 2be94889..8aaaaba1 100644 --- a/src/projections/igh.cpp +++ b/src/projections/igh.cpp @@ -208,7 +208,7 @@ static bool setup_zone(PJ *P, struct pj_opaque *Q, int n, PJ *PROJECTION(igh) { PJ_XY xy1, xy3; PJ_LP lp = { 0, phi_boundary }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/igh_o.cpp b/src/projections/igh_o.cpp index b14d79a5..80874845 100644 --- a/src/projections/igh_o.cpp +++ b/src/projections/igh_o.cpp @@ -222,7 +222,7 @@ static bool setup_zone(PJ *P, struct pj_opaque *Q, int n, PJ *PROJECTION(igh_o) { PJ_XY xy1, xy4; PJ_LP lp = { 0, phi_boundary }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/imw_p.cpp b/src/projections/imw_p.cpp index ee206091..6e82d287 100644 --- a/src/projections/imw_p.cpp +++ b/src/projections/imw_p.cpp @@ -160,7 +160,7 @@ static PJ *destructor (PJ *P, int errlev) { return pj_default_destructor (P, errlev); if( static_cast(P->opaque)->en ) - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor(P, errlev); } @@ -169,7 +169,7 @@ static PJ *destructor (PJ *P, int errlev) { PJ *PROJECTION(imw_p) { double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2; int err; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/isea.cpp b/src/projections/isea.cpp index dd1d48ff..77a5689b 100644 --- a/src/projections/isea.cpp +++ b/src/projections/isea.cpp @@ -1039,7 +1039,7 @@ static PJ_XY isea_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward PJ *PROJECTION(isea) { char *opt; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/krovak.cpp b/src/projections/krovak.cpp index 3e6a5c30..adc039fe 100644 --- a/src/projections/krovak.cpp +++ b/src/projections/krovak.cpp @@ -191,7 +191,7 @@ static PJ_LP krovak_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, PJ *PROJECTION(krovak) { double u0, n0, g; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/labrd.cpp b/src/projections/labrd.cpp index c9dfdfc6..4fbcf460 100644 --- a/src/projections/labrd.cpp +++ b/src/projections/labrd.cpp @@ -105,7 +105,7 @@ static PJ_LP labrd_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, invers PJ *PROJECTION(labrd) { double Az, sinp, R, N, t; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/laea.cpp b/src/projections/laea.cpp index 3d135864..2d19cab1 100644 --- a/src/projections/laea.cpp +++ b/src/projections/laea.cpp @@ -234,7 +234,7 @@ static PJ *destructor (PJ *P, int errlev) { if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->apa); + free (static_cast(P->opaque)->apa); return pj_default_destructor(P, errlev); } @@ -242,7 +242,7 @@ static PJ *destructor (PJ *P, int errlev) { PJ *PROJECTION(laea) { double t; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/lagrng.cpp b/src/projections/lagrng.cpp index d37a00e6..1029bf8d 100644 --- a/src/projections/lagrng.cpp +++ b/src/projections/lagrng.cpp @@ -71,7 +71,7 @@ static PJ_LP lagrng_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver PJ *PROJECTION(lagrng) { double sin_phi1; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp index 46378ce4..525281f4 100644 --- a/src/projections/lcc.cpp +++ b/src/projections/lcc.cpp @@ -80,7 +80,7 @@ static PJ_LP lcc_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse PJ *PROJECTION(lcc) { double cosphi, sinphi; int secant; - struct pj_opaque *Q = static_cast(pj_calloc(1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc(1, sizeof (struct pj_opaque))); if (nullptr == Q) return pj_default_destructor(P, ENOMEM); diff --git a/src/projections/lcca.cpp b/src/projections/lcca.cpp index 51dd28aa..53646fc6 100644 --- a/src/projections/lcca.cpp +++ b/src/projections/lcca.cpp @@ -128,14 +128,14 @@ static PJ *destructor (PJ *P, int errlev) { if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } PJ *PROJECTION(lcca) { double s2p0, N0, R0, tan0; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/loxim.cpp b/src/projections/loxim.cpp index 2ee88037..64124bdd 100644 --- a/src/projections/loxim.cpp +++ b/src/projections/loxim.cpp @@ -56,7 +56,7 @@ static PJ_LP loxim_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers PJ *PROJECTION(loxim) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/lsat.cpp b/src/projections/lsat.cpp index f6114485..a811a3a6 100644 --- a/src/projections/lsat.cpp +++ b/src/projections/lsat.cpp @@ -158,7 +158,7 @@ static PJ_LP lsat_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse PJ *PROJECTION(lsat) { int land, path; double lam, alf, esc, ess; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/misrsom.cpp b/src/projections/misrsom.cpp index 71116e1e..d7e199f2 100644 --- a/src/projections/misrsom.cpp +++ b/src/projections/misrsom.cpp @@ -178,7 +178,7 @@ PJ *PROJECTION(misrsom) { int path; double lam, alf, esc, ess; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/mod_ster.cpp b/src/projections/mod_ster.cpp index c7a8e899..0c30b7b6 100644 --- a/src/projections/mod_ster.cpp +++ b/src/projections/mod_ster.cpp @@ -134,7 +134,7 @@ PJ *PROJECTION(mil_os) { {0.019430, 0.} }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -157,7 +157,7 @@ PJ *PROJECTION(lee_os) { {-0.0088162, -0.00617325} }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -182,7 +182,7 @@ PJ *PROJECTION(gs48) { {0.075528, 0.} }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -217,7 +217,7 @@ PJ *PROJECTION(alsk) { { .3660976, -.2937382} }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -265,7 +265,7 @@ PJ *PROJECTION(gs50) { {-.0225161, .0853673} }; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/moll.cpp b/src/projections/moll.cpp index 5d4f7825..4864c8e1 100644 --- a/src/projections/moll.cpp +++ b/src/projections/moll.cpp @@ -77,7 +77,7 @@ static PJ * setup(PJ *P, double p) { PJ *PROJECTION(moll) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -87,7 +87,7 @@ PJ *PROJECTION(moll) { PJ *PROJECTION(wag4) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -96,7 +96,7 @@ PJ *PROJECTION(wag4) { } PJ *PROJECTION(wag5) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/nsper.cpp b/src/projections/nsper.cpp index 903946b9..951111ac 100644 --- a/src/projections/nsper.cpp +++ b/src/projections/nsper.cpp @@ -180,7 +180,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(nsper) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -194,7 +194,7 @@ PJ *PROJECTION(nsper) { PJ *PROJECTION(tpers) { double omega, gamma; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/ob_tran.cpp b/src/projections/ob_tran.cpp index 7cf1cf98..4990ab2a 100644 --- a/src/projections/ob_tran.cpp +++ b/src/projections/ob_tran.cpp @@ -142,7 +142,7 @@ static ARGS ob_tran_target_params (paralist *params) { return args; /* all args except the proj_ob_tran */ - args.argv = static_cast(pj_calloc (argc - 1, sizeof (char *))); + args.argv = static_cast(calloc (argc - 1, sizeof (char *))); if (nullptr==args.argv) return args; @@ -160,7 +160,7 @@ static ARGS ob_tran_target_params (paralist *params) { continue; args.argv[i] += 2; if (strcmp(args.argv[i], "proj=ob_tran") == 0 ) { - pj_dealloc (args.argv); + free (args.argv); args.argc = 0; args.argv = nullptr; } @@ -177,7 +177,7 @@ PJ *PROJECTION(ob_tran) { ARGS args; PJ *R; /* projection to rotate */ - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return destructor(P, ENOMEM); @@ -195,7 +195,7 @@ PJ *PROJECTION(ob_tran) { return destructor(P, PJD_ERR_FAILED_TO_FIND_PROJ); } R = pj_init_ctx (pj_get_ctx(P), args.argc, args.argv); - pj_dealloc (args.argv); + free (args.argv); if (nullptr==R) return destructor (P, PJD_ERR_UNKNOWN_PROJECTION_ID); diff --git a/src/projections/ocea.cpp b/src/projections/ocea.cpp index de9838cb..c78e1ebc 100644 --- a/src/projections/ocea.cpp +++ b/src/projections/ocea.cpp @@ -52,7 +52,7 @@ static PJ_LP ocea_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(ocea) { double phi_1, phi_2, lam_1, lam_2, lonz, alpha; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/oea.cpp b/src/projections/oea.cpp index 61fb0647..46c00d16 100644 --- a/src/projections/oea.cpp +++ b/src/projections/oea.cpp @@ -58,7 +58,7 @@ static PJ_LP oea_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(oea) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp index e9f3b833..90067cc3 100644 --- a/src/projections/omerc.cpp +++ b/src/projections/omerc.cpp @@ -126,7 +126,7 @@ PJ *PROJECTION(omerc) { gamma0, lamc=0, lam1=0, lam2=0, phi1=0, phi2=0, alpha_c=0; int alp, gam, no_off = 0; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/ortho.cpp b/src/projections/ortho.cpp index d9c84dba..4417dac7 100644 --- a/src/projections/ortho.cpp +++ b/src/projections/ortho.cpp @@ -279,7 +279,7 @@ static PJ_LP ortho_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inver PJ *PROJECTION(ortho) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/poly.cpp b/src/projections/poly.cpp index 10d93ed2..4ea95cc7 100644 --- a/src/projections/poly.cpp +++ b/src/projections/poly.cpp @@ -147,14 +147,14 @@ static PJ *destructor(PJ *P, int errlev) { return pj_default_destructor (P, errlev); if (static_cast(P->opaque)->en) - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor(P, errlev); } PJ *PROJECTION(poly) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); diff --git a/src/projections/putp3.cpp b/src/projections/putp3.cpp index c2df20e8..09763851 100644 --- a/src/projections/putp3.cpp +++ b/src/projections/putp3.cpp @@ -38,7 +38,7 @@ static PJ_LP putp3_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers PJ *PROJECTION(putp3) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -53,7 +53,7 @@ PJ *PROJECTION(putp3) { } PJ *PROJECTION(putp3p) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/putp4p.cpp b/src/projections/putp4p.cpp index 365f7c1b..8df18972 100644 --- a/src/projections/putp4p.cpp +++ b/src/projections/putp4p.cpp @@ -45,7 +45,7 @@ static PJ_LP putp4p_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver PJ *PROJECTION(putp4p) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -62,7 +62,7 @@ PJ *PROJECTION(putp4p) { PJ *PROJECTION(weren) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/putp5.cpp b/src/projections/putp5.cpp index 1847e7a9..5e70382d 100644 --- a/src/projections/putp5.cpp +++ b/src/projections/putp5.cpp @@ -43,7 +43,7 @@ static PJ_LP putp5_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers PJ *PROJECTION(putp5) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -60,7 +60,7 @@ PJ *PROJECTION(putp5) { PJ *PROJECTION(putp5p) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/putp6.cpp b/src/projections/putp6.cpp index db334ff9..da8c0a7c 100644 --- a/src/projections/putp6.cpp +++ b/src/projections/putp6.cpp @@ -59,7 +59,7 @@ static PJ_LP putp6_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers PJ *PROJECTION(putp6) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -79,7 +79,7 @@ PJ *PROJECTION(putp6) { PJ *PROJECTION(putp6p) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/qsc.cpp b/src/projections/qsc.cpp index 98e3755e..dd9ce965 100644 --- a/src/projections/qsc.cpp +++ b/src/projections/qsc.cpp @@ -377,7 +377,7 @@ static PJ_LP qsc_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse PJ *PROJECTION(qsc) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/rouss.cpp b/src/projections/rouss.cpp index f5a8f12f..2eb13b3d 100644 --- a/src/projections/rouss.cpp +++ b/src/projections/rouss.cpp @@ -93,7 +93,7 @@ static PJ *destructor (PJ *P, int errlev) { return pj_default_destructor (P, errlev); if (static_cast(P->opaque)->en) - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, ENOMEM); } @@ -102,7 +102,7 @@ static PJ *destructor (PJ *P, int errlev) { PJ *PROJECTION(rouss) { double N0, es2, t, t2, R_R0_2, R_R0_4; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/rpoly.cpp b/src/projections/rpoly.cpp index b065861f..e3f09c59 100644 --- a/src/projections/rpoly.cpp +++ b/src/projections/rpoly.cpp @@ -44,7 +44,7 @@ static PJ_XY rpoly_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forwar PJ *PROJECTION(rpoly) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/sch.cpp b/src/projections/sch.cpp index 7548039d..359e8efc 100644 --- a/src/projections/sch.cpp +++ b/src/projections/sch.cpp @@ -184,7 +184,7 @@ static PJ *setup(PJ *P) { /* general initialization */ PJ *PROJECTION(sch) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/sconics.cpp b/src/projections/sconics.cpp index f305e291..c12b05a2 100644 --- a/src/projections/sconics.cpp +++ b/src/projections/sconics.cpp @@ -117,7 +117,7 @@ static PJ_LP sconics_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, (and ellipsoi static PJ *setup(PJ *P, enum Type type) { double del, cs; int err; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/somerc.cpp b/src/projections/somerc.cpp index fe6477fa..a184500c 100644 --- a/src/projections/somerc.cpp +++ b/src/projections/somerc.cpp @@ -71,7 +71,7 @@ static PJ_LP somerc_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inver PJ *PROJECTION(somerc) { double cp, phip0, sp; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/stere.cpp b/src/projections/stere.cpp index 3fff722d..ad1caae2 100644 --- a/src/projections/stere.cpp +++ b/src/projections/stere.cpp @@ -302,7 +302,7 @@ static PJ *setup(PJ *P) { /* general initialization */ PJ *PROJECTION(stere) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -315,7 +315,7 @@ PJ *PROJECTION(stere) { PJ *PROJECTION(ups) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/sterea.cpp b/src/projections/sterea.cpp index 55404c86..4dd22d2f 100644 --- a/src/projections/sterea.cpp +++ b/src/projections/sterea.cpp @@ -93,14 +93,14 @@ static PJ *destructor (PJ *P, int errlev) { if (nullptr==P->opaque) return pj_default_destructor (P, errlev); - pj_dealloc (static_cast(P->opaque)->en); + free (static_cast(P->opaque)->en); return pj_default_destructor (P, errlev); } PJ *PROJECTION(sterea) { double R; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); diff --git a/src/projections/sts.cpp b/src/projections/sts.cpp index cbc36b7d..75190e85 100644 --- a/src/projections/sts.cpp +++ b/src/projections/sts.cpp @@ -70,7 +70,7 @@ static PJ *setup(PJ *P, double p, double q, int mode) { PJ *PROJECTION(fouc) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -80,7 +80,7 @@ PJ *PROJECTION(fouc) { PJ *PROJECTION(kav5) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -91,7 +91,7 @@ PJ *PROJECTION(kav5) { PJ *PROJECTION(qua_aut) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -101,7 +101,7 @@ PJ *PROJECTION(qua_aut) { PJ *PROJECTION(mbt_s) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/tmerc.cpp b/src/projections/tmerc.cpp index ff1bc2a5..8cae9968 100644 --- a/src/projections/tmerc.cpp +++ b/src/projections/tmerc.cpp @@ -221,7 +221,7 @@ static PJ *destructor(PJ *P, int errlev) { if (nullptr==P->opaque) return pj_default_destructor(P, errlev); - pj_dealloc (static_cast(P->opaque)->approx.en); + free (static_cast(P->opaque)->approx.en); return pj_default_destructor(P, errlev); } @@ -592,7 +592,7 @@ static PJ_LP auto_e_inv (PJ_XY xy, PJ *P) { static PJ *setup(PJ *P, TMercAlgo eAlg) { - struct tmerc_data *Q = static_cast(pj_calloc (1, sizeof (struct tmerc_data))); + struct tmerc_data *Q = static_cast(calloc (1, sizeof (struct tmerc_data))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/tpeqd.cpp b/src/projections/tpeqd.cpp index 58aeb8e1..90efb395 100644 --- a/src/projections/tpeqd.cpp +++ b/src/projections/tpeqd.cpp @@ -64,7 +64,7 @@ static PJ_LP tpeqd_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers PJ *PROJECTION(tpeqd) { double lam_1, lam_2, phi_1, phi_2, A12; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/urm5.cpp b/src/projections/urm5.cpp index 499644d2..c3021841 100644 --- a/src/projections/urm5.cpp +++ b/src/projections/urm5.cpp @@ -30,7 +30,7 @@ static PJ_XY urm5_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward PJ *PROJECTION(urm5) { double alpha, t; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/urmfps.cpp b/src/projections/urmfps.cpp index 3f9fdf23..5d689f9f 100644 --- a/src/projections/urmfps.cpp +++ b/src/projections/urmfps.cpp @@ -47,7 +47,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(urmfps) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); @@ -66,7 +66,7 @@ PJ *PROJECTION(urmfps) { PJ *PROJECTION(wag1) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/vandg2.cpp b/src/projections/vandg2.cpp index 223620d6..cd7e7b6c 100644 --- a/src/projections/vandg2.cpp +++ b/src/projections/vandg2.cpp @@ -53,7 +53,7 @@ static PJ_XY vandg2_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forwa PJ *PROJECTION(vandg2) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -65,7 +65,7 @@ PJ *PROJECTION(vandg2) { } PJ *PROJECTION(vandg3) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/projections/wag3.cpp b/src/projections/wag3.cpp index 33313cdb..ed3250ef 100644 --- a/src/projections/wag3.cpp +++ b/src/projections/wag3.cpp @@ -35,7 +35,7 @@ static PJ_LP wag3_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse PJ *PROJECTION(wag3) { double ts; - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); diff --git a/src/projections/wink1.cpp b/src/projections/wink1.cpp index d097978f..f4ffafe3 100644 --- a/src/projections/wink1.cpp +++ b/src/projections/wink1.cpp @@ -33,7 +33,7 @@ static PJ_LP wink1_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers PJ *PROJECTION(wink1) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/projections/wink2.cpp b/src/projections/wink2.cpp index d457f842..b5b1e812 100644 --- a/src/projections/wink2.cpp +++ b/src/projections/wink2.cpp @@ -53,7 +53,7 @@ static PJ_LP wink2_s_inverse(PJ_XY xy, PJ *P) PJ *PROJECTION(wink2) { - struct pj_opaque *Q = static_cast(pj_calloc (1, sizeof (struct pj_opaque))); + struct pj_opaque *Q = static_cast(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; -- cgit v1.2.3 From bc0c9f3e96dc4a9829f1f3d1e1307b4dd5dd10de Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 29 Nov 2020 14:10:15 +0100 Subject: Inverse tmerc spherical: fix wrong sign of latitude when lat_0 is used (fixes #2468) Corrected formula given by @evanmiller --- src/projections/tmerc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/projections') diff --git a/src/projections/tmerc.cpp b/src/projections/tmerc.cpp index 8cae9968..2d13b064 100644 --- a/src/projections/tmerc.cpp +++ b/src/projections/tmerc.cpp @@ -203,11 +203,13 @@ static PJ_LP approx_s_inv (PJ_XY xy, PJ *P) { return proj_coord_error().lp; } g = .5 * (h - 1. / h); - h = cos (P->phi0 + xy.y / Q->esp); + /* D, as in equation 8-8 of USGS "Map Projections - A Working Manual" */ + const double D = P->phi0 + xy.y / Q->esp; + h = cos (D); lp.phi = asin(sqrt((1. - h * h) / (1. + g * g))); /* Make sure that phi is on the correct hemisphere when false northing is used */ - if (xy.y < 0. && -lp.phi+P->phi0 < 0.0) lp.phi = -lp.phi; + lp.phi = copysign(lp.phi, D); lp.lam = (g != 0.0 || h != 0.0) ? atan2 (g, h) : 0.; return lp; -- cgit v1.2.3 From 284feecd27f3fd43569d3d37d62ae7b0153c20ce Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 29 Nov 2020 20:53:21 +0100 Subject: Spherical tmerc forward: do not restrict to [-90,90] longitude range The restriction was a copy&paste from the Evenden/Snyder approximate ellipsoidal implementation, but the spherical one is exact, so this restriction isn't needed. Also tune a bit the handling of lat=0, |lon| > 90 --- src/projections/tmerc.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src/projections') diff --git a/src/projections/tmerc.cpp b/src/projections/tmerc.cpp index 2d13b064..8f897061 100644 --- a/src/projections/tmerc.cpp +++ b/src/projections/tmerc.cpp @@ -115,25 +115,11 @@ static PJ_XY approx_e_fwd (PJ_LP lp, PJ *P) return (xy); } -static PJ_XY approx_s_fwd (PJ_LP lp, PJ *P) { +static PJ_XY tmerc_spherical_fwd (PJ_LP lp, PJ *P) { PJ_XY xy = {0.0,0.0}; double b, cosphi; const auto *Q = &(static_cast(P->opaque)->approx); - /* - * Fail if our longitude is more than 90 degrees from the - * central meridian since the results are essentially garbage. - * Is error -20 really an appropriate return value? - * - * http://trac.osgeo.org/proj/ticket/5 - */ - if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { - xy.x = HUGE_VAL; - xy.y = HUGE_VAL; - proj_context_errno_set( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); - return xy; - } - cosphi = cos(lp.phi); b = cosphi * sin (lp.lam); if (fabs (fabs (b) - 1.) <= EPS10) { @@ -145,7 +131,12 @@ static PJ_XY approx_s_fwd (PJ_LP lp, PJ *P) { xy.y = cosphi * cos (lp.lam) / sqrt (1. - b * b); b = fabs ( xy.y ); - if (b >= 1.) { + if (cosphi == 1 && (lp.lam < -M_HALFPI || lp.lam > M_HALFPI) ) { + /* Helps to be able to roundtrip |longitudes| > 90 at lat=0 */ + /* We could also map to -M_PI ... */ + xy.y = M_PI; + } + else if (b >= 1.) { if ((b - 1.) > EPS10) { proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); return xy; @@ -192,7 +183,7 @@ static PJ_LP approx_e_inv (PJ_XY xy, PJ *P) { return lp; } -static PJ_LP approx_s_inv (PJ_XY xy, PJ *P) { +static PJ_LP tmerc_spherical_inv (PJ_XY xy, PJ *P) { PJ_LP lp = {0.0, 0.0}; double h, g; const auto *Q = &(static_cast(P->opaque)->approx); @@ -611,8 +602,8 @@ static PJ *setup(PJ *P, TMercAlgo eAlg) { return nullptr; if( P->es == 0 ) { - P->inv = approx_s_inv; - P->fwd = approx_s_fwd; + P->inv = tmerc_spherical_inv; + P->fwd = tmerc_spherical_fwd; } else { -- cgit v1.2.3 From f4dc79075c19706dda6e3253c2f224e9df468291 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 30 Nov 2020 01:35:59 +0100 Subject: API cleanup: unexport number of internal symbols, and remove/replace a few unused ones --- src/projections/ob_tran.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/projections') diff --git a/src/projections/ob_tran.cpp b/src/projections/ob_tran.cpp index 4990ab2a..86798e0a 100644 --- a/src/projections/ob_tran.cpp +++ b/src/projections/ob_tran.cpp @@ -141,14 +141,15 @@ static ARGS ob_tran_target_params (paralist *params) { if (argc < 2) return args; - /* all args except the proj_ob_tran */ + /* all args except the proj=ob_tran */ args.argv = static_cast(calloc (argc - 1, sizeof (char *))); if (nullptr==args.argv) return args; - /* Copy all args *except* the proj=ob_tran arg to the argv array */ + /* Copy all args *except* the proj=ob_tran or inv arg to the argv array */ for (i = 0; params != nullptr; params = params->next) { - if (0==strcmp (params->param, "proj=ob_tran")) + if (0==strcmp (params->param, "proj=ob_tran") || + 0==strcmp (params->param, "inv") ) continue; args.argv[i++] = params->param; } @@ -194,7 +195,7 @@ PJ *PROJECTION(ob_tran) { if (args.argv == nullptr ) { return destructor(P, PJD_ERR_FAILED_TO_FIND_PROJ); } - R = pj_init_ctx (pj_get_ctx(P), args.argc, args.argv); + R = proj_create_argv (P->ctx, args.argc, args.argv); free (args.argv); if (nullptr==R) -- cgit v1.2.3