@Test public void testProjToLatLon() { ProjectionPoint p = ProjectionPoint.create(0, 0); LatLonPoint latlonResult = proj.projToLatLon(p); Assert.assertEquals("Unexpected longitude", LatLonPoints.lonNormal(254), latlonResult.getLongitude(), TOLERANCE); Assert.assertEquals("Unexpected latitude", 54, latlonResult.getLatitude(), TOLERANCE); }
@Override public LatLonPoint projToLatLon(ProjectionPoint ppt) { double lonR = LatLonPoints.range180(ppt.getX()); double latR = ppt.getY(); if (Math.abs(latR) > 90.) { throw new IllegalArgumentException("ProjectionPoint y must be in range [-90,90]."); } double lonRRad = Math.toRadians(lonR); double latRRad = Math.toRadians(latR); double[] p0 = {Math.cos(latRRad) * Math.cos(lonRRad), Math.cos(latRRad) * Math.sin(lonRRad), Math.sin(latRRad)}; double[] p1 = {rotY[0][0] * p0[0] + rotY[2][0] * p0[2], p0[1], rotY[0][2] * p0[0] + rotY[2][2] * p0[2]}; double[] p2 = {rotZ[0][0] * p1[0] + rotZ[1][0] * p1[1], rotZ[0][1] * p1[0] + rotZ[1][1] * p1[1], p1[2]}; double lon = Math.atan2(p2[1], p2[0]) * DEG_PER_RAD; double lat = Math.asin(p2[2]) * DEG_PER_RAD; return LatLonPoint.create(lat, lon); }
RotatedPole extends AbstractProjection { @Override public LatLonPoint projToLatLon(ProjectionPoint ppt) { double lonR = LatLonPoints.range180(ppt.getX()); double latR = ppt.getY(); if (Math.abs(latR) > 90.) { throw new IllegalArgumentException("ProjectionPoint y must be in range [-90,90]."); } double lonRRad = Math.toRadians(lonR); double latRRad = Math.toRadians(latR); double[] p0 = {Math.cos(latRRad) * Math.cos(lonRRad), Math.cos(latRRad) * Math.sin(lonRRad), Math.sin(latRRad)}; double[] p1 = {rotY[0][0] * p0[0] + rotY[2][0] * p0[2], p0[1], rotY[0][2] * p0[0] + rotY[2][2] * p0[2]}; double[] p2 = {rotZ[0][0] * p1[0] + rotZ[1][0] * p1[1], rotZ[0][1] * p1[0] + rotZ[1][1] * p1[1], p1[2]}; double lon = Math.atan2(p2[1], p2[0]) * DEG_PER_RAD; double lat = Math.asin(p2[2]) * DEG_PER_RAD; return LatLonPoint.create(lat, lon); } }
RotatedPole extends AbstractProjection { @Override public LatLonPoint projToLatLon(ProjectionPoint ppt) { double lonR = LatLonPoints.range180(ppt.getX()); double latR = ppt.getY(); if (Math.abs(latR) > 90.) { throw new IllegalArgumentException("ProjectionPoint y must be in range [-90,90]."); } double lonRRad = Math.toRadians(lonR); double latRRad = Math.toRadians(latR); double[] p0 = {Math.cos(latRRad) * Math.cos(lonRRad), Math.cos(latRRad) * Math.sin(lonRRad), Math.sin(latRRad)}; double[] p1 = {rotY[0][0] * p0[0] + rotY[2][0] * p0[2], p0[1], rotY[0][2] * p0[0] + rotY[2][2] * p0[2]}; double[] p2 = {rotZ[0][0] * p1[0] + rotZ[1][0] * p1[1], rotZ[0][1] * p1[0] + rotZ[1][1] * p1[1], p1[2]}; double lon = Math.atan2(p2[1], p2[0]) * DEG_PER_RAD; double lat = Math.asin(p2[2]) * DEG_PER_RAD; return LatLonPoint.create(lat, lon); } RotatedPole();  RotatedPole(double northPoleLat, double northPoleLon); }
RotatedPole extends AbstractProjection { @Override public LatLonPoint projToLatLon(ProjectionPoint ppt) { double lonR = LatLonPoints.range180(ppt.getX()); double latR = ppt.getY(); if (Math.abs(latR) > 90.) { throw new IllegalArgumentException("ProjectionPoint y must be in range [-90,90]."); } double lonRRad = Math.toRadians(lonR); double latRRad = Math.toRadians(latR); double[] p0 = {Math.cos(latRRad) * Math.cos(lonRRad), Math.cos(latRRad) * Math.sin(lonRRad), Math.sin(latRRad)}; double[] p1 = {rotY[0][0] * p0[0] + rotY[2][0] * p0[2], p0[1], rotY[0][2] * p0[0] + rotY[2][2] * p0[2]}; double[] p2 = {rotZ[0][0] * p1[0] + rotZ[1][0] * p1[1], rotZ[0][1] * p1[0] + rotZ[1][1] * p1[1], p1[2]}; double lon = Math.atan2(p2[1], p2[0]) * DEG_PER_RAD; double lat = Math.asin(p2[2]) * DEG_PER_RAD; return LatLonPoint.create(lat, lon); } RotatedPole();  RotatedPole(double northPoleLat, double northPoleLon); ProjectionPoint getNorthPole(); @Override Projection constructCopy(); @Override String paramsToString(); @Override ProjectionPoint latLonToProj(LatLonPoint latlon); @Override LatLonPoint projToLatLon(ProjectionPoint ppt); boolean crossSeam(ProjectionPoint pt1, ProjectionPoint pt2); @Override boolean equals(Object o); @Override int hashCode(); }
RotatedPole extends AbstractProjection { @Override public LatLonPoint projToLatLon(ProjectionPoint ppt) { double lonR = LatLonPoints.range180(ppt.getX()); double latR = ppt.getY(); if (Math.abs(latR) > 90.) { throw new IllegalArgumentException("ProjectionPoint y must be in range [-90,90]."); } double lonRRad = Math.toRadians(lonR); double latRRad = Math.toRadians(latR); double[] p0 = {Math.cos(latRRad) * Math.cos(lonRRad), Math.cos(latRRad) * Math.sin(lonRRad), Math.sin(latRRad)}; double[] p1 = {rotY[0][0] * p0[0] + rotY[2][0] * p0[2], p0[1], rotY[0][2] * p0[0] + rotY[2][2] * p0[2]}; double[] p2 = {rotZ[0][0] * p1[0] + rotZ[1][0] * p1[1], rotZ[0][1] * p1[0] + rotZ[1][1] * p1[1], p1[2]}; double lon = Math.atan2(p2[1], p2[0]) * DEG_PER_RAD; double lat = Math.asin(p2[2]) * DEG_PER_RAD; return LatLonPoint.create(lat, lon); } RotatedPole();  RotatedPole(double northPoleLat, double northPoleLon); ProjectionPoint getNorthPole(); @Override Projection constructCopy(); @Override String paramsToString(); @Override ProjectionPoint latLonToProj(LatLonPoint latlon); @Override LatLonPoint projToLatLon(ProjectionPoint ppt); boolean crossSeam(ProjectionPoint pt1, ProjectionPoint pt2); @Override boolean equals(Object o); @Override int hashCode();  }