/** * Convert a LatLonPoint to projection coordinates * Note: a new object is now created on each call for the return value, as of 4.0.46 * * @param latLon convert from these lat, lon coordinates * @return ProjectionPoint convert to these projection coordinates */ public ProjectionPoint latLonToProj(LatLonPoint latLon) { return latLonToProj(latLon, new ProjectionPointImpl()); }
public static void negate(ProjectionPointImpl a) { a.setLocation( -a.getX(), -a.getY()); }
static private void doTwo(ProjectionImpl proj, double x, double y) { ProjectionPointImpl startL = new ProjectionPointImpl(x, y); LatLonPoint p = proj.projToLatLon(startL); ProjectionPointImpl endL = (ProjectionPointImpl) proj.latLonToProj(p); System.out.println("start = " + startL.toString()); System.out.println("lat,lon = " + p.toString()); System.out.println("end = " + endL.toString()); }
@Test public void testLCseam() { // test seam crossing LambertConformal lc = new LambertConformal(40.0, 180.0, 20.0, 60.0); ProjectionPointImpl p1 = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(0.0, -1.0), new ProjectionPointImpl()); ProjectionPointImpl p2 = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(0.0, 1.0), new ProjectionPointImpl()); if (show) { System.out.printf(" p1= x=%f y=%f%n", p1.getX(), p1.getY()); System.out.printf(" p2= x=%f y=%f%n", p2.getX(), p2.getY()); } assert lc.crossSeam(p1, p2); }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = Math.toRadians(latLon.getLongitude()); if (projectionLongitude != 0) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } ProjectionPoint res = project(theta, fromLat, new ProjectionPointImpl()); destPoint.setLocation(totalScale * res.getX() + falseEasting, totalScale * res.getY() + falseNorthing); return destPoint; }
/** * set x,y location from pt * * @param pt point to use for values */ public void setLocation(Point2D pt) { setLocation(pt.getX(), pt.getY()); }
/** * This returns true when the line between pt1 and pt2 crosses the seam. * When the cone is flattened, the "seam" is lon0 +- 180. * * @param pt1 point 1 * @param pt2 point 2 * @return true when the line between pt1 and pt2 crosses the seam. */ public boolean crossSeam(ProjectionPoint pt1, ProjectionPoint pt2) { if (ProjectionPointImpl.isInfinite(pt1) || ProjectionPointImpl.isInfinite(pt2)) { return true; } return false; /* opposite signed X values, larger then 5000 km LOOK ???? return (pt1.getX() * pt2.getX() < 0) && (Math.abs(pt1.getX() - pt2.getX()) > 5000.0); */ }
/** * Test that the unrotated centre lat/lon is the origin of the rotated * projection. */ @Test public void testLatLonToProj() { LatLonPointImpl latlon = new LatLonPointImpl(54, 254); ProjectionPointImpl result = new ProjectionPointImpl(); proj.latLonToProj(latlon, result); Assert.assertEquals("Unexpected rotated longitude", 0, result.getX(), TOLERANCE); Assert.assertEquals("Unexpected rotated latitude", 0, result.getY(), TOLERANCE); }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = Math.toRadians(latLon.getLongitude()); if (projectionLongitude != 0) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } ProjectionPoint res = project(theta, fromLat, new ProjectionPointImpl()); destPoint.setLocation(totalScale * res.getX() + falseEasting, totalScale * res.getY() + falseNorthing); return destPoint; }
static private void doTwo(ProjectionImpl proj, double x, double y) { ProjectionPointImpl startL = new ProjectionPointImpl(x, y); LatLonPoint p = proj.projToLatLon(startL); ProjectionPointImpl endL = (ProjectionPointImpl) proj.latLonToProj(p); System.out.println("start = " + startL.toString()); System.out.println("lat,lon = " + p.toString()); System.out.println("end = " + endL.toString()); }
/** * set x,y location from pt * * @param pt point to use for values */ public void setLocation(Point2D pt) { setLocation(pt.getX(), pt.getY()); }
/** * This returns true when the line between pt1 and pt2 crosses the seam. * When the cone is flattened, the "seam" is lon0 +- 180. * * @param pt1 point 1 * @param pt2 point 2 * @return true when the line between pt1 and pt2 crosses the seam. */ public boolean crossSeam(ProjectionPoint pt1, ProjectionPoint pt2) { if (ProjectionPointImpl.isInfinite(pt1) || ProjectionPointImpl.isInfinite(pt2)) { return true; } return false; /* opposite signed X values, larger then 5000 km LOOK ???? return (pt1.getX() * pt2.getX() < 0) && (Math.abs(pt1.getX() - pt2.getX()) > 5000.0); */ }
public static void normalize(ProjectionPointImpl a) { double d = distance(a.getX(), a.getY()); a.setLocation( a.getX() / d, a.getY() / d); }
/** * Convert a LatLonPoint to projection coordinates * Note: a new object is now created on each call for the return value, as of 4.0.46 * * @param latLon convert from these lat, lon coordinates * @return ProjectionPoint convert to these projection coordinates */ public ProjectionPoint latLonToProj(LatLonPoint latLon) { return latLonToProj(latLon, new ProjectionPointImpl()); }
/** * Test that the unrotated centre lat/lon is the origin of the rotated * projection. */ @Test public void testLatLonToProj() { LatLonPointImpl latlon = new LatLonPointImpl(54, 254); ProjectionPointImpl result = new ProjectionPointImpl(); proj.latLonToProj(latlon, result); Assert.assertEquals("Unexpected rotated longitude", 0, result.getX(), TOLERANCE); Assert.assertEquals("Unexpected rotated latitude", 0, result.getY(), TOLERANCE); }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = computeTheta(latLon.getLongitude()); //System.err.println(Math.toDegrees(theta) + " " + Math.toDegrees(fromLat)); ProjectionPoint res = project(theta, fromLat, new ProjectionPointImpl()); destPoint.setLocation(totalScale * res.getX() + falseEasting, totalScale * res.getY() + falseNorthing); return destPoint; }
static private void doTwo(ProjectionImpl proj, double x, double y) { ProjectionPointImpl startL = new ProjectionPointImpl(x, y); LatLonPoint p = proj.projToLatLon(startL); ProjectionPointImpl endL = (ProjectionPointImpl) proj.latLonToProj(p); System.out.println("start = " + startL.toString()); System.out.println("lat,lon = " + p.toString()); System.out.println("end = " + endL.toString()); }
/** * set x,y location from pt * * @param pt point to use for values */ public void setLocation(ProjectionPoint pt) { setLocation(pt.getX(), pt.getY()); }