/** * copy constructor - avoid clone !! */ public ProjectionImpl constructCopy() { return (save == null) ? new UtmProjection(getZone(), isNorth()) : new UtmProjection(save.a, save.f, getZone(), isNorth()); }
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); }
/** * Construct a Universal Transverse Mercator Projection. * * @param a the semi-major axis (meters) for the ellipsoid * @param f the inverse flattening for the ellipsoid * @param zone the UTM zone number (1-60) * @param isNorth true if the UTM coordinate is in the northern hemisphere */ public UtmProjection(double a, double f, int zone, boolean isNorth) { super("UtmProjection", false); saveParams = new SaveParams(a, f, zone, isNorth); convert2latlon = new Utm_To_Gdc_Converter(a, f, zone, isNorth); convert2xy = new Gdc_To_Utm_Converter(a, f, zone, isNorth); addParameter(CF.GRID_MAPPING_NAME, GRID_MAPPING_NAME); addParameter(CF.SEMI_MAJOR_AXIS, a); addParameter(CF.INVERSE_FLATTENING, f); addParameter(UTM_ZONE1, zone); }
/** * Returns true if this represents the same Projection as proj. * * @param proj projection in question * @return true if this represents the same Projection as proj. */ public boolean equals(Object proj) { if (!(proj instanceof UtmProjection)) { return false; } UtmProjection op = (UtmProjection) proj; if ((this.getDefaultMapArea() == null) != (op.defaultMapArea == null)) return false; // common case is that these are null if (this.getDefaultMapArea() != null && !this.defaultMapArea.equals(op.defaultMapArea)) return false; return op.getZone() == getZone(); }
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); }
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); }
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); }
@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); // */ }
/** * Returns true if this represents the same Projection as proj. * * @param proj projection in question * @return true if this represents the same Projection as proj. */ public boolean equals(Object proj) { if (!(proj instanceof UtmProjection)) { return false; } UtmProjection op = (UtmProjection) proj; return op.getZone() == getZone(); // LOOK }
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); }
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); }
double lon = startL.getLongitude(); int zone = (int) ((lon + 183) / 6); UtmProjection proj = new UtmProjection(zone, lat >= 0.0); ProjectionPoint p = proj.latLonToProj(startL); LatLonPoint endL = proj.projToLatLon(p);
@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; }
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); }
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); }
/** * Constructor with default WGS 84 ellipsoid. * * @param zone the UTM zone number (1-60) * @param isNorth true if the UTM coordinate is in the northern hemisphere */ public UtmProjection(int zone, boolean isNorth) { convert2latlon = new Utm_To_Gdc_Converter(zone, isNorth); convert2xy = new Gdc_To_Utm_Converter(zone, isNorth); addParameter(ATTR_NAME, "UTM"); addParameter("semi-major_axis", convert2latlon.getA()); addParameter("inverse_flattening", convert2latlon.getF()); addParameter("UTM_zone", zone); addParameter("north_hemisphere", isNorth ? "true" : "false"); }
@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; }