cosphi = Math.cos(phi);
coslam = Math.cos(lam);
switch (mode) {
case EQUATOR:
xy.y = 1. + cosphi * coslam;
if (xy.y <= EPS10) throw new ProjectionException();
xy.x = (xy.y = Math.sqrt(2. / xy.y)) * cosphi * Math.sin(lam);
xy.y *= mode == EQUATOR ? sinphi :
cosphi0 * sinphi - sinphi0 * cosphi * coslam;
break;
case OBLIQUE:
xy.y = 1. + sinphi0 * sinphi + cosphi0 * cosphi * coslam;
if (xy.y <= EPS10) throw new ProjectionException();
xy.x = (xy.y = Math.sqrt(2. / xy.y)) * cosphi * Math.sin(lam);
xy.y *= mode == EQUATOR ? sinphi :
cosphi0 * sinphi - sinphi0 * cosphi * coslam;
break;
case NORTH_POLE:
coslam = -coslam;
case SOUTH_POLE:
if (Math.abs(phi + projectionLatitude) < EPS10) throw new ProjectionException();
xy.y = ProjectionMath.QUARTERPI - phi * .5;
xy.y = 2. * (mode == SOUTH_POLE ? Math.cos(xy.y) : Math.sin(xy.y));
xy.x = xy.y * Math.sin(lam);
xy.y *= coslam;
break;
}
} else {
double coslam, sinlam, sinphi, q, sinb = 0, cosb = 0, b = 0;
coslam = Math.cos(lam);
sinlam = Math.sin(lam);
sinphi = Math.sin(phi);
q = ProjectionMath.qsfn(sinphi, e, one_es);
if (mode == OBLIQUE || mode == EQUATOR) {
sinb = q / qp;
cosb = Math.sqrt(1. - sinb * sinb);
}
switch (mode) {
case OBLIQUE:
b = 1. + sinb1 * sinb + cosb1 * cosb * coslam;
break;
case EQUATOR:
b = 1. + cosb * coslam;
break;
case NORTH_POLE:
b = ProjectionMath.HALFPI + phi;
q = qp - q;
break;
case SOUTH_POLE:
b = phi - ProjectionMath.HALFPI;
q = qp + q;
break;
}
if (Math.abs(b) < EPS10) throw new ProjectionException();
switch (mode) {
case OBLIQUE:
xy.y = ymf * ( b = Math.sqrt(2. / b) )
* (cosb1 * sinb - sinb1 * cosb * coslam);
xy.x = xmf * b * cosb * sinlam;