Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.cpp: fix build on Solaris #1637

Merged
merged 3 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4444,28 +4444,28 @@ class JSONParser {
}

template <class TargetCRS, class DatumBuilderType,
class CS = CoordinateSystem>
class CSClass = CoordinateSystem>
util::nn<std::shared_ptr<TargetCRS>> 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>(cs);
auto csCast = util::nn_dynamic_pointer_cast<CSClass>(cs);
if (!csCast) {
throw ParsingException("coordinate_system not of expected type");
}
return TargetCRS::create(buildProperties(j), datum,
NN_NO_CHECK(csCast));
}

template <class TargetCRS, class BaseCRS, class CS = CoordinateSystem>
template <class TargetCRS, class BaseCRS, class CSClass = CoordinateSystem>
util::nn<std::shared_ptr<TargetCRS>> buildDerivedCRS(const json &j) {
auto baseCRSObj = create(getObject(j, "base_crs"));
auto baseCRS = util::nn_dynamic_pointer_cast<BaseCRS>(baseCRSObj);
if (!baseCRS) {
throw ParsingException("base_crs not of expected type");
}
auto cs = buildCS(getObject(j, "coordinate_system"));
auto csCast = util::nn_dynamic_pointer_cast<CS>(cs);
auto csCast = util::nn_dynamic_pointer_cast<CSClass>(cs);
if (!csCast) {
throw ParsingException("coordinate_system not of expected type");
}
Expand Down
4 changes: 2 additions & 2 deletions src/projections/hatano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
102 changes: 51 additions & 51 deletions src/projections/isea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,21 +668,21 @@ 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) {
pt->x += 0.5;
/* 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;
Expand Down Expand Up @@ -715,60 +715,60 @@ 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;
}
}

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;
long sidelength; /* in hexes */
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) {
Expand All @@ -793,89 +793,89 @@ 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;
}
}
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<double>(g->aperture), static_cast<double>(g->resolution)));
if (quad == 11) {
if (quadz == 11) {
g->serial = 1 + 10 * hexes + 1;
return g->serial;
}
if (g->aperture == 3 && g->resolution % 2 == 1) {
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;
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/projections/mbtfpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand Down