/** * copy constructor - avoid clone !! */ public ProjectionImpl constructCopy() { return new Stereographic(getTangentLat(), getTangentLon(), getScale(), getFalseEasting(), getFalseNorthing()); }
/** * Construct a polar Stereographic Projection, from the "natural origin" and the tangent point, * calculating the scale factor. * * @param lat_ts_deg Latitude at natural origin (degrees_north) * @param latt_deg tangent point of projection (degrees_north) * @param lont_deg tangent point of projection, also origin of projection coord system ((degrees_east) * @param north true if north pole, false is south pole */ public Stereographic(double lat_ts_deg, double latt_deg, double lont_deg, boolean north) { super("PolarStereographic", false); this.latts = Math.toRadians(lat_ts_deg); this.latt = Math.toRadians(latt_deg); this.lont = Math.toRadians(lont_deg); this.isPolar = true; this.isNorth = north; this.earthRadius = EARTH_RADIUS; this.falseEasting = 0; this.falseNorthing = 0; precalculate(); double scaleFactor = (lat_ts_deg == 90 || lat_ts_deg == -90) ? 1.0 : getScaleFactor(latts, north); this.scale = scaleFactor * earthRadius; addParameter(CF.GRID_MAPPING_NAME, "polar_stereographic"); addParameter("longitude_of_projection_origin", lont_deg); addParameter("latitude_of_projection_origin", latt_deg); addParameter("scale_factor_at_projection_origin", scaleFactor); }
/** * 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 Stereographic)) { return false; } Stereographic oo = (Stereographic) proj; return ((this.getScale() == oo.getScale()) && (this.getTangentLat() == oo.getTangentLat()) && (this.getTangentLon() == oo.getTangentLon()) && this.defaultMapArea.equals(oo.defaultMapArea)); }
/** * Construct a Stereographic Projection. * * @param latt tangent point of projection, also origin of projection coord system * @param lont tangent point of projection, also origin of projection coord system * @param scale scale factor at tangent point, "normally 1.0 but may be reduced" * @param false_easting false easting in units of x coords * @param false_northing false northing in units of y coords * @param radius earth radius in km */ public Stereographic(double latt, double lont, double scale, double false_easting, double false_northing, double radius) { super("Stereographic", false); this.latt = Math.toRadians(latt); this.lont = Math.toRadians(lont); this.earthRadius = radius; this.scale = scale * earthRadius; this.falseEasting = false_easting; this.falseNorthing = false_northing; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.STEREOGRAPHIC); addParameter(CF.LONGITUDE_OF_PROJECTION_ORIGIN, lont); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, latt); addParameter(CF.SCALE_FACTOR_AT_PROJECTION_ORIGIN, scale); addParameter(CF.EARTH_RADIUS, earthRadius * 1000); if ((false_easting != 0.0) || (false_northing != 0.0)) { addParameter(CF.FALSE_EASTING, false_easting); addParameter(CF.FALSE_NORTHING, false_northing); addParameter(CDM.UNITS, "km"); } }
/** * Construct a Stereographic Projection using latitude of true scale and calculating scale factor. * <p> Since the scale factor at lat = k = 2*k0/(1+sin(lat)) [Snyder,Working Manual p157] * then to make scale = 1 at lat, set k0 = (1+sin(lat))/2 * * @param latt tangent point of projection, also origin of projection coord system * @param lont tangent point of projection, also origin of projection coord system * @param latTrue latitude of true scale in degrees north; latitude where scale factor = 1.0 * @return Stereographic projection */ static public Stereographic factory(double latt, double lont, double latTrue) { double scale = (1.0 + Math.sin(Math.toRadians(latTrue))) / 2.0; return new Stereographic(latt, lont, scale); }
private ProjectionCT makeStereoProjection(NetcdfDataset ds, String name) throws NoSuchElementException { double centralLat = findAttributeDouble(ds, "centralLat"); double centralLon = findAttributeDouble(ds, "centralLon"); // scale factor at lat = k = 2*k0/(1+sin(lat)) [Snyder,Working Manual p157] // then to make scale = 1 at lat, k0 = (1+sin(lat))/2 double latDxDy = findAttributeDouble(ds, "latDxDy"); double latR = Math.toRadians(latDxDy); double scale = (1.0 + Math.abs(Math.sin(latR))) / 2; // thanks to R Schmunk // Stereographic(double latt, double lont, double scale) Stereographic proj = new Stereographic(centralLat, centralLon, scale); // we have to project in order to find the origin double lat0 = findAttributeDouble(ds, "lat00"); double lon0 = findAttributeDouble(ds, "lon00"); ProjectionPointImpl start = (ProjectionPointImpl) proj.latLonToProj(new LatLonPointImpl(lat0, lon0)); startx = start.getX(); starty = start.getY(); // projection info parseInfo.format("---makeStereoProjection start at proj coord %s%n", start); double latN = findAttributeDouble(ds, "latNxNy"); double lonN = findAttributeDouble(ds, "lonNxNy"); ProjectionPointImpl pt = (ProjectionPointImpl) proj.latLonToProj(new LatLonPointImpl(latN, lonN)); parseInfo.format(" end at proj coord %s%n", pt); parseInfo.format(" scale= %f%n", scale); return new ProjectionCT(name, "FGDC", proj); }
@Test public void testStereo() { testProjection(new Stereographic()); Stereographic p = new Stereographic(); Stereographic p2 = (Stereographic) p.constructCopy(); assert p.equals(p2); }
/** * @deprecated */ public void setTangentLat(double latt) { this.latt = Math.toRadians(latt); precalculate(); }
/** * Clone this projection * * @return a clone of this. */ public Object clone() { Stereographic cl = (Stereographic) super.clone(); cl.origin = new LatLonPointImpl(getTangentLat(), getTangentLon()); return cl; }
/** * Get the parameters as a String * * @return the parameters as a String */ public String paramsToString() { return " tangent " + origin.toString() + " scale: " + Format.d(getScale(), 6); }
/** * Construct a Stereographic Projection using latitude of true scale and calculating scale factor. * <p> Since the scale factor at lat = k = 2*k0/(1+sin(lat)) [Snyder,Working Manual p157] * then to make scale = 1 at lat, set k0 = (1+sin(lat))/2 * * @param latt tangent point of projection, also origin of projection coord system * @param lont tangent point of projection, also origin of projection coord system * @param latTrue latitude of true scale in degrees north; latitude where scale factor = 1.0 * @return Stereographic projection */ static public Stereographic factory(double latt, double lont, double latTrue) { double scale = (1.0 + Math.sin(Math.toRadians(latTrue))) / 2.0; return new Stereographic(latt, lont, scale); }
private ProjectionCT makeStereoProjection(NetcdfDataset ds, String name) throws NoSuchElementException { double centralLat = findAttributeDouble(ds, "centralLat"); double centralLon = findAttributeDouble(ds, "centralLon"); double rotation = findAttributeDouble(ds, "rotation"); // scale factor at lat = k = 2*k0/(1+sin(lat)) [Snyder,Working Manual p157] // then to make scale = 1 at lat, k0 = (1+sin(lat))/2 double latDxDy = findAttributeDouble(ds, "latDxDy"); double latR = Math.toRadians(latDxDy); double scale = (1.0 + Math.abs(Math.sin(latR))) / 2; // thanks to R Schmunk // Stereographic(double latt, double lont, double scale) Stereographic proj = new Stereographic(centralLat, centralLon, scale); // we have to project in order to find the origin double lat0 = findAttributeDouble(ds, "lat00"); double lon0 = findAttributeDouble(ds, "lon00"); ProjectionPointImpl start = (ProjectionPointImpl) proj.latLonToProj(new LatLonPointImpl(lat0, lon0)); startx = start.getX(); starty = start.getY(); // projection info parseInfo.format("---makeStereoProjection start at proj coord %s\n", start); double latN = findAttributeDouble(ds, "latNxNy"); double lonN = findAttributeDouble(ds, "lonNxNy"); ProjectionPointImpl pt = (ProjectionPointImpl) proj.latLonToProj(new LatLonPointImpl(latN, lonN)); parseInfo.format(" end at proj coord %s\n", pt); parseInfo.format(" scale= %f\n", scale); return new ProjectionCT(name, "FGDC", proj); }
/** * Construct a Stereographic Projection. * * @param latt tangent point of projection, also origin of projection coord system * @param lont tangent point of projection, also origin of projection coord system * @param scale scale factor at tangent point, "normally 1.0 but may be reduced" * @param false_easting false easting in units of x coords * @param false_northing false northing in units of y coords * @param radius earth radius in km */ public Stereographic(double latt, double lont, double scale, double false_easting, double false_northing, double radius) { super("Stereographic", false); this.latt = Math.toRadians(latt); this.lont = Math.toRadians(lont); this.earthRadius = radius; this.scale = scale * earthRadius; this.falseEasting = false_easting; this.falseNorthing = false_northing; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.STEREOGRAPHIC); addParameter(CF.LONGITUDE_OF_PROJECTION_ORIGIN, lont); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, latt); addParameter(CF.SCALE_FACTOR_AT_PROJECTION_ORIGIN, scale); addParameter(CF.EARTH_RADIUS, earthRadius * 1000); if ((false_easting != 0.0) || (false_northing != 0.0)) { addParameter(CF.FALSE_EASTING, false_easting); addParameter(CF.FALSE_NORTHING, false_northing); addParameter(CDM.UNITS, "km"); } }
/** * @deprecated */ public void setTangentLat(double latt) { this.latt = Math.toRadians(latt); precalculate(); }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new Stereographic(getTangentLat(), getTangentLon(), getScale(), getFalseEasting(), getFalseNorthing(), getEarthRadius()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
/** * Construct a Stereographic Projection using latitude of true scale and calculating scale factor. * <p> Since the scale factor at lat = k = 2*k0/(1+sin(lat)) [Snyder,Working Manual p157] * then to make scale = 1 at lat, set k0 = (1+sin(lat))/2 * * @param latt tangent point of projection, also origin of projection coord system * @param lont tangent point of projection, also origin of projection coord system * @param latTrue latitude of true scale in degrees north; latitude where scale factor = 1.0 * @return Stereographic projection */ static public Stereographic factory(double latt, double lont, double latTrue) { double scale = (1.0 + Math.sin(Math.toRadians(latTrue))) / 2.0; return new Stereographic(latt, lont, scale); }
private ProjectionCT makeStereoProjection(NetcdfDataset ds, String name) throws NoSuchElementException { double centralLat = findAttributeDouble(ds, "centralLat"); double centralLon = findAttributeDouble(ds, "centralLon"); double rotation = findAttributeDouble(ds, "rotation"); // scale factor at lat = k = 2*k0/(1+sin(lat)) [Snyder,Working Manual p157] // then to make scale = 1 at lat, k0 = (1+sin(lat))/2 double latDxDy = findAttributeDouble(ds, "latDxDy"); double latR = Math.toRadians(latDxDy); double scale = (1.0 + Math.abs(Math.sin(latR))) / 2; // thanks to R Schmunk // Stereographic(double latt, double lont, double scale) Stereographic proj = new Stereographic(centralLat, centralLon, scale); // we have to project in order to find the origin double lat0 = findAttributeDouble(ds, "lat00"); double lon0 = findAttributeDouble(ds, "lon00"); ProjectionPointImpl start = (ProjectionPointImpl) proj.latLonToProj(new LatLonPointImpl(lat0, lon0)); startx = start.getX(); starty = start.getY(); // projection info parseInfo.format("---makeStereoProjection start at proj coord %s%n", start); double latN = findAttributeDouble(ds, "latNxNy"); double lonN = findAttributeDouble(ds, "lonNxNy"); ProjectionPointImpl pt = (ProjectionPointImpl) proj.latLonToProj(new LatLonPointImpl(latN, lonN)); parseInfo.format(" end at proj coord %s%n", pt); parseInfo.format(" scale= %f%n", scale); return new ProjectionCT(name, "FGDC", proj); }
/** * Construct a polar Stereographic Projection, from the "natural origin" and the tangent point, * calculating the scale factor. * * @param lat_ts_deg Latitude at natural origin (degrees_north) * @param latt_deg tangent point of projection (degrees_north) * @param lont_deg tangent point of projection, also origin of projection coord system ((degrees_east) * @param north true if north pole, false is south pole */ public Stereographic(double lat_ts_deg, double latt_deg, double lont_deg, boolean north) { super("PolarStereographic", false); this.latts = Math.toRadians(lat_ts_deg); this.latt = Math.toRadians(latt_deg); this.lont = Math.toRadians(lont_deg); this.isPolar = true; this.isNorth = north; this.earthRadius = EARTH_RADIUS; this.falseEasting = 0; this.falseNorthing = 0; precalculate(); double scaleFactor = (lat_ts_deg == 90 || lat_ts_deg == -90) ? 1.0 : getScaleFactor(latts, north); this.scale = scaleFactor * earthRadius; addParameter(CF.GRID_MAPPING_NAME, "polar_stereographic"); addParameter("longitude_of_projection_origin", lont_deg); addParameter("latitude_of_projection_origin", latt_deg); addParameter("scale_factor_at_projection_origin", scaleFactor); }
/** * Construct a Stereographic Projection. * * @param latt tangent point of projection, also origin of projection coord system * @param lont tangent point of projection, also origin of projection coord system * @param scale scale factor at tangent point, "normally 1.0 but may be reduced" * @param false_easting false easting in units of x coords * @param false_northing false northing in units of y coords * @param radius earth radius in km */ public Stereographic(double latt, double lont, double scale, double false_easting, double false_northing, double radius) { super("Stereographic", false); this.latt = Math.toRadians(latt); this.lont = Math.toRadians(lont); this.earthRadius = radius; this.scale = scale * earthRadius; this.falseEasting = false_easting; this.falseNorthing = false_northing; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.STEREOGRAPHIC); addParameter(CF.LONGITUDE_OF_PROJECTION_ORIGIN, lont); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, latt); addParameter(CF.SCALE_FACTOR_AT_PROJECTION_ORIGIN, scale); addParameter(CF.EARTH_RADIUS, earthRadius * 1000); if ((false_easting != 0.0) || (false_northing != 0.0)) { addParameter(CF.FALSE_EASTING, false_easting); addParameter(CF.FALSE_NORTHING, false_northing); addParameter(CDM.UNITS, "km"); } }
/** * @deprecated */ public void setTangentLon(double lont) { this.lont = Math.toRadians(lont); precalculate(); }