/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * Convert a projection coordinate to a LatLonPoint * Note: a new object is now created on each call for the return value, as of 4.0.46 * * @param x x value to convert * @param y y value to convert * @return LatLonPointImpl convert to these lat/lon coordinates */ public LatLonPoint projToLatLon(double x, double y) { return projToLatLon(new ProjectionPointImpl(x, y)); }
/** * 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()); }
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()); }
/** * Get the minimum corner of the bounding box. * * @return minimum corner of the bounding box */ public ProjectionPoint getMinPoint() { return new ProjectionPointImpl(getX(), 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()); }
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()); }
/** * Get the Lower Right Point * * @return the Lower Right Point */ public ProjectionPoint getLowerRightPoint() { return new ProjectionPointImpl(getMaxPoint().getX(), getMinPoint().getY()); }
/** * Constructor. * @param northPoleLat * @param northPoleLon */ public RotatedPole(double northPoleLat, double northPoleLon) { northPole = new ProjectionPointImpl(northPoleLon, northPoleLat); buildRotationMatrices(); addParameter(ATTR_NAME, "rotated_latitude_longitude"); addParameter("grid_north_pole_latitude", northPoleLat); addParameter("grid_north_pole_longitude", northPoleLon); }
/** * Get the maximum corner of the bounding box. * * @return maximum corner of the bounding box */ public ProjectionPoint getMaxPoint() { return new ProjectionPointImpl(getX() + getWidth(), getY() + getHeight()); }
/** * Get the Upper Left Point * * @return the Upper Left Point */ public ProjectionPoint getUpperLeftPoint() { return new ProjectionPointImpl(getMinPoint().getX(), getMaxPoint().getY()); }
/** * Get the maximum corner of the bounding box. * * @return maximum corner of the bounding box */ public ProjectionPoint getMaxPoint() { return new ProjectionPointImpl(getX() + getWidth(), getY() + getHeight()); }
/** * Get the Upper Left Point * * @return the Upper Left Point */ public ProjectionPoint getUpperLeftPoint() { return new ProjectionPointImpl(getMinPoint().getX(), getMaxPoint().getY()); }
@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; }
@Test public void projToLatLonBB_completelyOffTheMap() { // None of the corners are on the map and none of the sides intersect its edge. ProjectionPoint upperLeft = new ProjectionPointImpl(10000, -7000); ProjectionPoint lowerRight = new ProjectionPointImpl(13000, -10000); Sinusoidal proj = new Sinusoidal(); ProjectionRect projBB = new ProjectionRect(upperLeft, lowerRight); LatLonRect latLonBB = proj.projToLatLonBB(projBB); Assert.assertEquals(LatLonRect.INVALID, latLonBB); }
@Ignore("not visible on spock") @Test public void testWriteFileOnNarr3() throws Exception { Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly")); ProjectionRect rect = new ProjectionRect( new ProjectionPointImpl(-5645, -4626), 11329, 8992); testFileSize("B:/ncdc/0409/narr/Narr_A_fc.ncx4", "Accum_snow_surface,Convective_cloud_cover_entire_atmosphere_3_Hour_Average", "2014-10-01T21:00:00Z", "2014-10-02T21:00:00Z", rect, true); Grib.setDebugFlags(new DebugFlagsImpl("")); }
@Ignore("not visible on spock") @Test public void testWriteFileOnNarr4() throws Exception { Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly")); ProjectionRect rect = new ProjectionRect( new ProjectionPointImpl(-5645, -4626), 11329, 8992); testFileSize("B:/ncdc/0409/narr/Narr_A_fc.ncx4", "Convective_cloud_cover_entire_atmosphere_3_Hour_Average,Accum_snow_surface", "2014-10-01T21:00:00Z", "2014-10-02T21:00:00Z", rect, true); Grib.setDebugFlags(new DebugFlagsImpl("")); }
@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); }