From 3854668626445d20ff28b87fcacadf64f75460a8 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 24 Sep 2019 13:34:58 +0000 Subject: [PATCH 1/3] io.cpp: fix build on Solaris Rename CS template argument, to avoid conflict with macro in Solaris system headers. Similar to 2f8bd934860b135044c5122e3272f7cc41ba81e7 --- src/iso19111/io.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index ebccf78b47..0c414981f4 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -4444,12 +4444,12 @@ class JSONParser { } template + class CSClass = CoordinateSystem> util::nn> buildCRS(const json &j, DatumBuilderType f) { auto datum = (this->*f)(getObject(j, "datum")); auto cs = buildCS(getObject(j, "coordinate_system")); - auto csCast = util::nn_dynamic_pointer_cast(cs); + auto csCast = util::nn_dynamic_pointer_cast(cs); if (!csCast) { throw ParsingException("coordinate_system not of expected type"); } @@ -4457,7 +4457,7 @@ class JSONParser { NN_NO_CHECK(csCast)); } - template + template util::nn> buildDerivedCRS(const json &j) { auto baseCRSObj = create(getObject(j, "base_crs")); auto baseCRS = util::nn_dynamic_pointer_cast(baseCRSObj); @@ -4465,7 +4465,7 @@ class JSONParser { throw ParsingException("base_crs not of expected type"); } auto cs = buildCS(getObject(j, "coordinate_system")); - auto csCast = util::nn_dynamic_pointer_cast(cs); + auto csCast = util::nn_dynamic_pointer_cast(cs); if (!csCast) { throw ParsingException("coordinate_system not of expected type"); } From 7806af71e85f17c5bce0eb9d070fea1dbb40f38d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 25 Sep 2019 13:55:33 +0000 Subject: [PATCH 2/3] hatano/mbtfpp: do not use CS to fix Solaris build issue Patches proj-6.2.0-hanato.gpatch and proj-6.2.0-mbtfpp.gpatch from Eric Dechaux --- src/projections/hatano.cpp | 4 ++-- src/projections/mbtfpp.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/projections/hatano.cpp b/src/projections/hatano.cpp index 6c125d2e24..29a01f80b3 100644 --- a/src/projections/hatano.cpp +++ b/src/projections/hatano.cpp @@ -11,7 +11,7 @@ PROJ_HEAD(hatano, "Hatano Asymmetrical Equal Area") "\n\tPCyl, Sph"; #define EPS 1e-7 #define ONETOL 1.000001 #define CN 2.67595 -#define CS 2.43763 +#define CSz 2.43763 #define RCN 0.37369906014686373063 #define RCS 0.41023453108141924738 #define FYCN 1.75859 @@ -28,7 +28,7 @@ static PJ_XY hatano_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forwa int i; (void) P; - c = sin(lp.phi) * (lp.phi < 0. ? CS : CN); + c = sin(lp.phi) * (lp.phi < 0. ? CSz : CN); for (i = NITER; i; --i) { lp.phi -= th1 = (lp.phi + sin(lp.phi) - c) / (1. + cos(lp.phi)); if (fabs(th1) < EPS) break; diff --git a/src/projections/mbtfpp.cpp b/src/projections/mbtfpp.cpp index a4ab60b9f4..6cc7c46657 100644 --- a/src/projections/mbtfpp.cpp +++ b/src/projections/mbtfpp.cpp @@ -7,7 +7,7 @@ PROJ_HEAD(mbtfpp, "McBride-Thomas Flat-Polar Parabolic") "\n\tCyl, Sph"; -#define CS .95257934441568037152 +#define CSy .95257934441568037152 #define FXC .92582009977255146156 #define FYC 3.40168025708304504493 #define C23 .66666666666666666666 @@ -19,7 +19,7 @@ static PJ_XY mbtfpp_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forwa PJ_XY xy = {0.0,0.0}; (void) P; - lp.phi = asin(CS * sin(lp.phi)); + lp.phi = asin(CSy * sin(lp.phi)); xy.x = FXC * lp.lam * (2. * cos(C23 * lp.phi) - 1.); xy.y = FYC * sin(C13 * lp.phi); return xy; @@ -41,7 +41,7 @@ static PJ_LP mbtfpp_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver lp.phi = asin(lp.phi); lp.lam = xy.x / ( FXC * (2. * cos(C23 * (lp.phi *= 3.)) - 1.) ); - if (fabs(lp.phi = sin(lp.phi) / CS) >= 1.) { + if (fabs(lp.phi = sin(lp.phi) / CSy) >= 1.) { if (fabs(lp.phi) > ONEEPS) { proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); return lp; From be819a1340b5e8afd7b03237179d1793ec2d1d59 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 25 Sep 2019 13:56:17 +0000 Subject: [PATCH 3/3] isea: avoid shadowing warning on 'quad' on Solaris Patch proj-6.2.0-isea.gpatch by Eric Dechaux --- src/projections/isea.cpp | 102 +++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/projections/isea.cpp b/src/projections/isea.cpp index d1aeab4acb..6203617fa5 100644 --- a/src/projections/isea.cpp +++ b/src/projections/isea.cpp @@ -668,10 +668,10 @@ static int isea_tri_plane(int tri, struct isea_pt *pt, double radius) { /* convert projected triangle coords to quad xy coords, return quad number */ static int isea_ptdd(int tri, struct isea_pt *pt) { - int downtri, quad; + int downtri, quadz; downtri = (((tri - 1) / 5) % 2 == 1); - quad = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1; + quadz = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1; isea_rotate(pt, downtri ? 240.0 : 60.0); if (downtri) { @@ -679,10 +679,10 @@ static int isea_ptdd(int tri, struct isea_pt *pt) { /* pt->y += cos(30.0 * M_PI / 180.0); */ pt->y += .86602540378443864672; } - return quad; + return quadz; } -static int isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, +static int isea_dddi_ap3odd(struct isea_dgg *g, int quadz, struct isea_pt *pt, struct isea_pt *di) { struct isea_pt v; @@ -715,40 +715,40 @@ static int isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, * you want to test for max coords for the next quad in the same * "row" first to get the case where both are max */ - if (quad <= 5) { + if (quadz <= 5) { if (d == 0 && i == maxcoord) { /* north pole */ - quad = 0; + quadz = 0; d = 0; i = 0; } else if (i == maxcoord) { /* upper right in next quad */ - quad += 1; - if (quad == 6) - quad = 1; + quadz += 1; + if (quadz == 6) + quadz = 1; i = maxcoord - d; d = 0; } else if (d == maxcoord) { /* lower right in quad to lower right */ - quad += 5; + quadz += 5; d = 0; } - } else if (quad >= 6) { + } else if (quadz >= 6) { if (i == 0 && d == maxcoord) { /* south pole */ - quad = 11; + quadz = 11; d = 0; i = 0; } else if (d == maxcoord) { /* lower right in next quad */ - quad += 1; - if (quad == 11) - quad = 6; + quadz += 1; + if (quadz == 11) + quadz = 6; d = maxcoord - i; i = 0; } else if (i == maxcoord) { /* upper right in quad to upper right */ - quad = (quad - 4) % 5; + quadz = (quadz - 4) % 5; i = 0; } } @@ -756,11 +756,11 @@ static int isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, di->x = d; di->y = i; - g->quad = quad; - return quad; + g->quad = quadz; + return quadz; } -static int isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, +static int isea_dddi(struct isea_dgg *g, int quadz, struct isea_pt *pt, struct isea_pt *di) { struct isea_pt v; double hexwidth; @@ -768,7 +768,7 @@ static int isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, struct hex h; if (g->aperture == 3 && g->resolution % 2 != 0) { - return isea_dddi_ap3odd(g, quad, pt, di); + return isea_dddi_ap3odd(g, quadz, pt, di); } /* todo might want to do this as an iterated loop */ if (g->aperture >0) { @@ -793,41 +793,41 @@ static int isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, hex_iso(&h); /* we may actually be on another quad */ - if (quad <= 5) { + if (quadz <= 5) { if (h.x == 0 && h.z == -sidelength) { /* north pole */ - quad = 0; + quadz = 0; h.z = 0; h.y = 0; h.x = 0; } else if (h.z == -sidelength) { - quad = quad + 1; - if (quad == 6) - quad = 1; + quadz = quadz + 1; + if (quadz == 6) + quadz = 1; h.y = sidelength - h.x; h.z = h.x - sidelength; h.x = 0; } else if (h.x == sidelength) { - quad += 5; + quadz += 5; h.y = -h.z; h.x = 0; } - } else if (quad >= 6) { + } else if (quadz >= 6) { if (h.z == 0 && h.x == sidelength) { /* south pole */ - quad = 11; + quadz = 11; h.x = 0; h.y = 0; h.z = 0; } else if (h.x == sidelength) { - quad = quad + 1; - if (quad == 11) - quad = 6; + quadz = quadz + 1; + if (quadz == 11) + quadz = 6; h.x = h.y + sidelength; h.y = 0; h.z = -h.x; } else if (h.y == -sidelength) { - quad -= 4; + quadz -= 4; h.y = 0; h.z = -h.x; } @@ -835,35 +835,35 @@ static int isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, di->x = h.x; di->y = -h.z; - g->quad = quad; - return quad; + g->quad = quadz; + return quadz; } static int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt, struct isea_pt *di) { struct isea_pt v; - int quad; + int quadz; v = *pt; - quad = isea_ptdd(tri, &v); - quad = isea_dddi(g, quad, &v, di); - return quad; + quadz = isea_ptdd(tri, &v); + quadz = isea_dddi(g, quadz, &v, di); + return quadz; } /* q2di to seqnum */ -static long isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { +static long isea_disn(struct isea_dgg *g, int quadz, struct isea_pt *di) { long sidelength; long sn, height; long hexes; - if (quad == 0) { + if (quadz == 0) { g->serial = 1; return g->serial; } /* hexes in a quad */ hexes = lround(pow(static_cast(g->aperture), static_cast(g->resolution))); - if (quad == 11) { + if (quadz == 11) { g->serial = 1 + 10 * hexes + 1; return g->serial; } @@ -871,11 +871,11 @@ static long isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { height = lround(floor((pow(g->aperture, (g->resolution - 1) / 2.0)))); sn = ((long)di->x) * height; sn += ((long)di->y) / height; - sn += (quad - 1) * hexes; + sn += (quadz - 1) * hexes; sn += 2; } else { sidelength = lround((pow(g->aperture, g->resolution / 2.0))); - sn = lround(floor(((quad - 1) * hexes + sidelength * di->x + di->y + 2))); + sn = lround(floor(((quadz - 1) * hexes + sidelength * di->x + di->y + 2))); } g->serial = sn; @@ -894,15 +894,15 @@ static int isea_hex(struct isea_dgg *g, int tri, long sidelength; long d, i, x, y; #endif - int quad; + int quadz; - quad = isea_ptdi(g, tri, pt, &v); + quadz = isea_ptdi(g, tri, pt, &v); if( v.x < (INT_MIN >> 4) || v.x > (INT_MAX >> 4) ) { throw "Invalid shift"; } - hex->x = ((int)v.x * 16) + quad; + hex->x = ((int)v.x * 16) + quadz; hex->y = v.y; return 1; @@ -914,16 +914,16 @@ static int isea_hex(struct isea_dgg *g, int tri, if (g->aperture == 3 && g->resolution % 2 != 0) { long offset = lround((pow(3.0, g->resolution - 1) + 0.5)); - d += offset * ((g->quad-1) % 5); - i += offset * ((g->quad-1) % 5); + d += offset * ((g->quadz-1) % 5); + i += offset * ((g->quadz-1) % 5); - if (quad == 0) { + if (quadz == 0) { d = 0; i = offset; - } else if (quad == 11) { + } else if (quadz == 11) { d = 2 * offset; i = 0; - } else if (quad > 5) { + } else if (quadz > 5) { d += offset; }