/** copy constructor - avoid clone !! */ public ProjectionImpl constructCopy() { return new FlatEarth( getOriginLat(), getOriginLon(), getRotationAngle()); }
/** * Construct a FlatEarth Projection, two standard parellels. * For the one standard parellel case, set them both to the same value. * * @param lat0 lat origin of the coord. system on the projection plane * @param lon0 lon origin of the coord. system on the projection plane * @param rotAngle angle of rotation, in degrees * @param radius earth radius in km * @throws IllegalArgumentException if lat0, par1, par2 = +/-90 deg */ public FlatEarth(double lat0, double lon0, double rotAngle, double radius) { super("FlatEarth", false); this.lat0 = Math.toRadians(lat0); this.lon0 = Math.toRadians(lon0); this.rotAngle = Math.toRadians(rotAngle); this.radius = radius; precalculate(); addParameter(CF.GRID_MAPPING_NAME, "flat_earth"); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_PROJECTION_ORIGIN, lon0); addParameter(ROTATIONANGLE, rotAngle); addParameter(CF.EARTH_RADIUS, radius * 1000); }
/** * Test * * @param args not used */ public static void main(String[] args) { FlatEarth a = new FlatEarth(90, -100, 0.0); ProjectionPoint p = a.latLonToProj(89, -101); System.out.println("proj point = " + p); LatLonPoint ll = a.projToLatLon(p); System.out.println("ll = " + ll); }
/** * Check for equality with the Object in question * * @param proj object to check * @return true if they are equal */ public boolean equals(Object proj) { if ( !(proj instanceof FlatEarth)) { return false; } FlatEarth oo = (FlatEarth) proj; return ((this.getOriginLat() == oo.getOriginLat()) && (this.getOriginLon() == oo.getOriginLon()) && (this.rotAngle == oo.rotAngle)); }
@Test public void testFlatEarth() { testProjectionProjMax(new FlatEarth(), 5000, 5000); FlatEarth p = new FlatEarth(); FlatEarth p2 = (FlatEarth) p.constructCopy(); assert p.equals(p2); }
/** * Set the origin longitude. * @param lon the origin longitude. */ public void setOriginLon(double lon) { origin.setLongitude(lon); lon0 = Math.toRadians(lon); precalculate(); }
/** * Create a String of the parameters. * * @return a String of the parameters */ public String paramsToString() { return toString(); }
public CoordinateTransform makeCoordinateTransform(NetcdfDataset ds, Variable ctv) { double lon0 = readAttributeDouble( ctv, CF.LONGITUDE_OF_PROJECTION_ORIGIN, Double.NaN); double lat0 = readAttributeDouble( ctv, CF.LATITUDE_OF_PROJECTION_ORIGIN, Double.NaN); double rot = readAttributeDouble( ctv, ucar.unidata.geoloc.projection.FlatEarth.ROTATIONANGLE, 0.0); double earth_radius = getEarthRadiusInKm(ctv); ucar.unidata.geoloc.projection.FlatEarth proj = new ucar.unidata.geoloc.projection.FlatEarth(lat0, lon0, rot, earth_radius); return new ProjectionCT(ctv.getShortName(), "FGDC", proj); } }
/** * Clone this projection. * * @return Clone of this */ public Object clone() { FlatEarth cl = (FlatEarth) super.clone(); cl.origin = new LatLonPointImpl(getOriginLat(), getOriginLon()); return cl; }
/** * Set the origin latitude. * * @param lat the origin latitude. */ public void setOriginLat(double lat) { origin.setLatitude(lat); lat0 = Math.toRadians(lat); precalculate(); }
/** * Create a String of the parameters. * * @return a String of the parameters */ public String paramsToString() { return toString(); }
/** * origin */ //private LatLonPointImpl origin; // why are we keeping this? @Override public ProjectionImpl constructCopy() { ProjectionImpl result = new FlatEarth(getOriginLat(), getOriginLon(), getRotationAngle()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
/** * Test * * @param args not used */ public static void main(String[] args) { FlatEarth a = new FlatEarth(90, -100, 0.0); ProjectionPoint p = a.latLonToProj(89, -101); System.out.println("proj point = " + p); LatLonPoint ll = a.projToLatLon(p); System.out.println("ll = " + ll); }
public CoordinateTransform makeCoordinateTransform(NetcdfDataset ds, Variable ctv) { double lon0 = readAttributeDouble( ctv, CF.LONGITUDE_OF_PROJECTION_ORIGIN, Double.NaN); double lat0 = readAttributeDouble( ctv, CF.LATITUDE_OF_PROJECTION_ORIGIN, Double.NaN); double rot = readAttributeDouble( ctv, ucar.unidata.geoloc.projection.FlatEarth.ROTATIONANGLE, 0.0); double earth_radius = getEarthRadiusInKm(ctv); ucar.unidata.geoloc.projection.FlatEarth proj = new ucar.unidata.geoloc.projection.FlatEarth(lat0, lon0, rot, earth_radius); return new ProjectionCT(ctv.getShortName(), "FGDC", proj); } }
/** * Construct a FlatEarth Projection, two standard parellels. * For the one standard parellel case, set them both to the same value. * * @param lat0 lat origin of the coord. system on the projection plane * @param lon0 lon origin of the coord. system on the projection plane * @param rotAngle angle of rotation, in degrees * @param radius earth radius in km * @throws IllegalArgumentException if lat0, par1, par2 = +/-90 deg */ public FlatEarth(double lat0, double lon0, double rotAngle, double radius) { super("FlatEarth", false); this.lat0 = Math.toRadians(lat0); this.lon0 = Math.toRadians(lon0); this.rotAngle = Math.toRadians(rotAngle); this.radius = radius; precalculate(); addParameter(CF.GRID_MAPPING_NAME, "flat_earth"); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_PROJECTION_ORIGIN, lon0); addParameter(ROTATIONANGLE, rotAngle); addParameter(CF.EARTH_RADIUS, radius * 1000); }
/** * Create a String of the parameters. * * @return a String of the parameters */ public String paramsToString() { return toString(); }
/** * origin */ //private LatLonPointImpl origin; // why are we keeping this? @Override public ProjectionImpl constructCopy() { ProjectionImpl result = new FlatEarth(getOriginLat(), getOriginLon(), getRotationAngle()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
/** * Test * * @param args not used */ public static void main(String[] args) { FlatEarth a = new FlatEarth(90, -100, 0.0); ProjectionPointImpl p = a.latLonToProj(89, -101); System.out.println("proj point = " + p); LatLonPoint ll = a.projToLatLon(p); System.out.println("ll = " + ll); }
public ProjectionCT makeCoordinateTransform(AttributeContainer ctv, String geoCoordinateUnits) { double lon0 = readAttributeDouble( ctv, CF.LONGITUDE_OF_PROJECTION_ORIGIN, Double.NaN); double lat0 = readAttributeDouble( ctv, CF.LATITUDE_OF_PROJECTION_ORIGIN, Double.NaN); double rot = readAttributeDouble( ctv, ucar.unidata.geoloc.projection.FlatEarth.ROTATIONANGLE, 0.0); double earth_radius = getEarthRadiusInKm(ctv); ucar.unidata.geoloc.projection.FlatEarth proj = new ucar.unidata.geoloc.projection.FlatEarth(lat0, lon0, rot, earth_radius); return new ProjectionCT(ctv.getName(), "FGDC", proj); } }