static ProjectionImpl processUTM(WKTParser srp) { // NAD_1983_UTM_Zone_12N String name = srp.getProjName(); int pos = name.indexOf("UTM_Zone_"); String zoneS = name.substring(pos + 9); char lastC; int zone = Integer.parseInt(zoneS.substring(0, zoneS.length()-1)); lastC = zoneS.charAt(zoneS.length()-1); boolean isNorth = (lastC =='N'); return new UtmProjection(zone, isNorth); }
static ProjectionImpl processUTM(WKTParser srp) { // NAD_1983_UTM_Zone_12N String name = srp.getProjName(); int pos = name.indexOf("UTM_Zone_"); String zoneS = name.substring(pos + 9); char lastC; int zone = Integer.parseInt(zoneS.substring(0, zoneS.length()-1)); lastC = zoneS.charAt(zoneS.length()-1); boolean isNorth = (lastC =='N'); return new UtmProjection(zone, isNorth); }
static ProjectionImpl processUTM(WKTParser srp) { // NAD_1983_UTM_Zone_12N String name = srp.getProjName(); int pos = name.indexOf("UTM_Zone_"); String zoneS = name.substring(pos + 9); char lastC; int zone = Integer.parseInt(zoneS.substring(0, zoneS.length()-1)); lastC = zoneS.charAt(zoneS.length()-1); boolean isNorth = (lastC =='N'); return new UtmProjection(zone, isNorth); }
/** * copy constructor - avoid clone !! */ public ProjectionImpl constructCopy() { return (save == null) ? new UtmProjection(getZone(), isNorth()) : new UtmProjection(save.a, save.f, getZone(), isNorth()); }
public CoordinateTransform makeCoordinateTransform(NetcdfDataset ds, Variable ctv) { double zoned = readAttributeDouble( ctv, UtmProjection.UTM_ZONE1, Double.NaN); if (Double.isNaN(zoned)) zoned = readAttributeDouble( ctv, UtmProjection.UTM_ZONE2, Double.NaN); if (Double.isNaN(zoned)) throw new IllegalArgumentException("No zone was specified") ; int zone = (int) zoned; boolean isNorth = zone > 0; zone = Math.abs(zone); Attribute a; double axis = 0.0, f = 0.0; if (null != (a = ctv.findAttribute( "semimajor_axis"))) axis = a.getNumericValue().doubleValue(); if (null != (a = ctv.findAttribute( "inverse_flattening"))) f = a.getNumericValue().doubleValue(); // double a, double f, int zone, boolean isNorth UtmProjection proj = (axis != 0.0) ? new UtmProjection(axis, f, zone, isNorth) : new UtmProjection(zone, isNorth); return new ProjectionCT(ctv.getShortName(), "FGDC", proj); } }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = (saveParams == null) ? new UtmProjection(getZone(), isNorth()) : new UtmProjection(saveParams.a, saveParams.f, getZone(), isNorth()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = (saveParams == null) ? new UtmProjection(getZone(), isNorth()) : new UtmProjection(saveParams.a, saveParams.f, getZone(), isNorth()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
public CoordinateTransform makeCoordinateTransform(NetcdfDataset ds, Variable ctv) { double zoned = readAttributeDouble( ctv, UtmProjection.UTM_ZONE1, Double.NaN); if (Double.isNaN(zoned)) zoned = readAttributeDouble( ctv, UtmProjection.UTM_ZONE2, Double.NaN); if (Double.isNaN(zoned)) throw new IllegalArgumentException("No zone was specified") ; int zone = (int) zoned; boolean isNorth = zone > 0; zone = Math.abs(zone); Attribute a; double axis = 0.0, f = 0.0; if (null != (a = ctv.findAttribute( "semimajor_axis"))) axis = a.getNumericValue().doubleValue(); if (null != (a = ctv.findAttribute( "inverse_flattening"))) f = a.getNumericValue().doubleValue(); // double a, double f, int zone, boolean isNorth UtmProjection proj = (axis != 0.0) ? new UtmProjection(axis, f, zone, isNorth) : new UtmProjection(zone, isNorth); return new ProjectionCT(ctv.getShortName(), "FGDC", proj); } }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = (save == null) ? new UtmProjection(getZone(), isNorth()) : new UtmProjection(save.a, save.f, getZone(), isNorth()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
@Override protected UtmProjection createProjection(final ParameterValueGroup p) { if (p == null) return new UtmProjection(); return new UtmProjection(value(p, CF.SEMI_MAJOR_AXIS), value(p, CF.INVERSE_FLATTENING), p.parameter(UtmProjection.UTM_ZONE1).intValue(), p.parameter("north_hemisphere").booleanValue()); } }
public ProjectionCT makeCoordinateTransform(AttributeContainer ctv, String geoCoordinateUnits) { double zoned = readAttributeDouble( ctv, UtmProjection.UTM_ZONE1, Double.NaN); if (Double.isNaN(zoned)) zoned = readAttributeDouble( ctv, UtmProjection.UTM_ZONE2, Double.NaN); if (Double.isNaN(zoned)) throw new IllegalArgumentException("No zone was specified") ; int zone = (int) zoned; boolean isNorth = zone > 0; zone = Math.abs(zone); Attribute a; double axis = 0.0, f = 0.0; if (null != (a = ctv.findAttribute( "semimajor_axis"))) axis = a.getNumericValue().doubleValue(); if (null != (a = ctv.findAttribute( "inverse_flattening"))) f = a.getNumericValue().doubleValue(); // double a, double f, int zone, boolean isNorth UtmProjection proj = (axis != 0.0) ? new UtmProjection(axis, f, zone, isNorth) : new UtmProjection(zone, isNorth); return new ProjectionCT(ctv.getName(), "FGDC", proj); } }
/** * Intend to use EPSG system parameters * * @param ds dataset * @return CoordinateTransform */ private CoordinateTransform makeUTMProjection(NetcdfDataset ds) { int zone = (int) findAttributeDouble(ds, "P_ALP"); double ycent = findAttributeDouble(ds, "YCENT"); //double lon0 = findAttributeDouble( "X_CENT"); //double lat0 = findAttributeDouble( "Y_CENT"); /** * Construct a UTM Projection. * @param zone - UTM zone * @param if ycent < 0, then isNorth = False */ boolean isNorth = true; if (ycent < 0) isNorth = false; UtmProjection utm = new UtmProjection(zone, isNorth); return new ProjectionCT("UTM", "EPSG", utm); }
/** * Intend to use EPSG system parameters * * @param ds dataset * @return CoordinateTransform */ private CoordinateTransform makeUTMProjection(NetcdfDataset ds) { int zone = (int) findAttributeDouble(ds, "P_ALP"); double ycent = findAttributeDouble(ds, "YCENT"); //double lon0 = findAttributeDouble( "X_CENT"); //double lat0 = findAttributeDouble( "Y_CENT"); /** * Construct a UTM Projection. * @param zone - UTM zone * @param if ycent < 0, then isNorth = False */ boolean isNorth = true; if (ycent < 0) isNorth = false; UtmProjection utm = new UtmProjection(zone, isNorth); return new ProjectionCT("UTM", "EPSG", utm); }
public static void main(String arg[]) { UtmProjection utm = new UtmProjection(17, true); LatLonPointImpl ll = utm.projToLatLon(577.8000000000001, 2951.8); System.out.printf("%15.12f %15.12f%n",ll.getLatitude(), ll.getLongitude()); assert closeEnough(ll.getLongitude(), -80.21802662821469, 1.0e-8); assert closeEnough(ll.getLatitude(), 26.685132668190793, 1.0e-8); }
public static void main(String arg[]) { UtmProjection utm = new UtmProjection(17, true); LatLonPointImpl ll = utm.projToLatLon(577.8000000000001, 2951.8); System.out.printf("%15.12f %15.12f%n", ll.getLatitude(), ll.getLongitude()); assert Misc.closeEnough(ll.getLongitude(), -80.21802662821469, 1.0e-8); assert Misc.closeEnough(ll.getLatitude(), 26.685132668190793, 1.0e-8); }
public static void main(String arg[]) { UtmProjection utm = new UtmProjection(17, true); LatLonPoint ll = utm.projToLatLon(577.8000000000001, 2951.8); System.out.printf("%15.12f %15.12f%n", ll.getLatitude(), ll.getLongitude()); assert Misc.closeEnough(ll.getLongitude(), -80.21802662821469, 1.0e-8); assert Misc.closeEnough(ll.getLatitude(), 26.685132668190793, 1.0e-8); }
public static void main(String arg[]) { UtmProjection utm = new UtmProjection(17, true); LatLonPoint ll = utm.projToLatLon(577.8000000000001, 2951.8); System.out.printf("%15.12f %15.12f%n", ll.getLatitude(), ll.getLongitude()); assert Misc.nearlyEquals(ll.getLongitude(), -80.21802662821469, 1.0e-8); assert Misc.nearlyEquals(ll.getLatitude(), 26.685132668190793, 1.0e-8); }
void doOne (double x, double y, int zone, boolean isNorth) { ProjectionImpl proj = new UtmProjection( zone, isNorth); System.out.println("*** x="+x+" y="+y); LatLonPoint latlon = proj.projToLatLon( x, y); System.out.println(" lat="+latlon.getLatitude()+" lon="+latlon.getLongitude()); ProjectionPoint endP = proj.latLonToProj( latlon); System.out.println(" x="+endP.getX()+" y="+endP.getY()); }
@Test public void testUTM() { // The central meridian = (zone * 6 - 183) degrees, where zone in [1,60]. // zone = (lon + 183)/6 // 33.75N 15.25E end = 90.0N 143.4W // doOne(new UtmProjection(10, true), 33.75, -122); testProjectionUTM(-12.89, .07996); testProjectionUTM(NTRIALS); UtmProjection p = new UtmProjection(); UtmProjection p2 = (UtmProjection) p.constructCopy(); assert p.equals(p2); // */ }
private void testProjectionUTM(double lat, double lon) { LatLonPointImpl startL = new LatLonPointImpl(); startL.setLatitude(lat); startL.setLongitude(lon); int zone = (int) ((lon + 183) / 6); UtmProjection proj = new UtmProjection(zone, lat >= 0.0); ProjectionPoint p = proj.latLonToProj(startL); LatLonPoint endL = proj.projToLatLon(p); if (show) { System.out.println("startL = " + startL); System.out.println("inter = " + p); System.out.println("endL = " + endL); } Assert.assertEquals(startL.toString(8), startL.getLatitude(), endL.getLatitude(), 1.3e-4); Assert.assertEquals(startL.toString(8), startL.getLongitude(), endL.getLongitude(), 1.3e-4); }