/** * copy constructor - avoid clone !! */ public ProjectionImpl constructCopy() { return new AlbersEqualArea(getOriginLat(), getOriginLon(), getParallelOne(), getParallelTwo(), getFalseEasting(), getFalseNorthing(), getEarthRadius()); }
this.earth_radius = earth_radius; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.ALBERS_CONICAL_EQUAL_AREA); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); addParameter(CF.STANDARD_PARALLEL, par1); } else { double[] data = new double[2]; data[0] = par1; data[1] = par2; addParameter(new Parameter(CF.STANDARD_PARALLEL, data)); addParameter(CF.FALSE_EASTING, falseEasting); addParameter(CF.FALSE_NORTHING, falseNorthing); addParameter(CDM.UNITS, "km"); addParameter(CF.EARTH_RADIUS, earth_radius * 1000); // must be in meters
double rho = computeRho(fromLat); double theta = computeTheta(fromLon);
/** * 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 AlbersEqualArea)) { return false; } AlbersEqualArea oo = (AlbersEqualArea) proj; return ((this.getParallelOne() == oo.getParallelOne()) && (this.getParallelTwo() == oo.getParallelTwo()) && (this.getOriginLat() == oo.getOriginLat()) && (this.getOriginLon() == oo.getOriginLon()) && this.defaultMapArea.equals(oo.defaultMapArea)); }
/** * Test * * @param args not used */ public static void main(String[] args) { AlbersEqualArea a = new AlbersEqualArea(23, -96, 29.5, 45.5); System.out.printf("name=%s%n", a.getName()); System.out.println("ll = 35N 75W"); ProjectionPointImpl p = a.latLonToProj(35, -75); System.out.println("proj point = " + p); LatLonPoint ll = a.projToLatLon(p); System.out.println("ll = " + ll); }
@Override protected AlbersEqualArea createProjection(final ParameterValueGroup p) { if (p == null) return new AlbersEqualArea(); return new AlbersEqualArea(value(p, CF.LATITUDE_OF_PROJECTION_ORIGIN), value(p, CF.LONGITUDE_OF_CENTRAL_MERIDIAN), value(p, CF.STANDARD_PARALLEL + "[1]"), value(p, CF.STANDARD_PARALLEL + "[2]"), value(p, CF.FALSE_EASTING) / KILOMETRE, value(p, CF.FALSE_NORTHING) / KILOMETRE, earthRadius(p) / KILOMETRE); } }
@Test public void testAEA() { testProjection(new AlbersEqualArea()); AlbersEqualArea p = new AlbersEqualArea(); AlbersEqualArea p2 = (AlbersEqualArea) p.constructCopy(); assert p.equals(p2); }
/** * Clone this projection. * * @return Clone of this */ public Object clone() { AlbersEqualArea cl = (AlbersEqualArea) super.clone(); cl.origin = new LatLonPointImpl(getOriginLat(), getOriginLon()); return cl; }
/** * Precalculate some stuff */ private void precalculate() { double par1r = Math.toRadians(this.par1); double par2r = Math.toRadians(this.par2); if (Math.abs(par2 - par1) < TOLERANCE) { // single parallel n = Math.sin(par1r); } else { n = (Math.sin(par1r) + Math.sin(par2r)) / 2.0; } double c2 = Math.pow(Math.cos(par1r), 2); C = c2 + 2 * n * Math.sin(par1r); rho0 = computeRho(lat0); }
/** * Test * * @param args not used */ public static void main(String[] args) { AlbersEqualArea a = new AlbersEqualArea(23, -96, 29.5, 45.5); System.out.printf("name=%s%n", a.getName()); System.out.println("ll = 35N 75W"); ProjectionPointImpl p = a.latLonToProj(35, -75); System.out.println("proj point = " + p); LatLonPoint ll = a.projToLatLon(p); System.out.println("ll = " + ll); }
private void addAlbersEqualAreaTags(AlbersEqualArea proj) { geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GTModelTypeGeoKey, GeoKey.TagValue.ModelType_Projected)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GTRasterTypeGeoKey, GeoKey.TagValue.RasterType_Area)); // define the "geographic Coordinate System" geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeographicTypeGeoKey, GeoKey.TagValue.GeographicType_WGS_84)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeogLinearUnitsGeoKey, GeoKey.TagValue.ProjLinearUnits_METER)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeogAngularUnitsGeoKey, GeoKey.TagValue.GeogAngularUnits_DEGREE)); // define the "coordinate transformation" geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjectedCSTypeGeoKey, GeoKey.TagValue.ProjectedCSType_UserDefined)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.PCSCitationGeoKey, "Albers Conial Equal Area")); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjectionGeoKey, GeoKey.TagValue.ProjectedCSType_UserDefined)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjLinearUnitsGeoKey, GeoKey.TagValue.ProjLinearUnits_METER)); //geotiff.addGeoKey( new GeoKey( GeoKey.Tag.ProjLinearUnitsSizeGeoKey, 1.0)); // units of km // the specifics for mercator geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjCoordTransGeoKey, GeoKey.TagValue.ProjCoordTrans_AlbersConicalEqualArea)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLatGeoKey, proj.getOriginLat())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLongGeoKey, proj.getOriginLon())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel1GeoKey, proj.getParallelOne())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel2GeoKey, proj.getParallelTwo())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseEastingGeoKey, 0.0)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseNorthingGeoKey, 0.0)); }
private CoordinateTransform makeAlbersProjection(NetcdfDataset ds) { double lat0 = findAttributeDouble(ds, "YCENT"); double lon0 = findAttributeDouble(ds, "XCENT"); double par1 = findAttributeDouble(ds, "P_ALP"); double par2 = findAttributeDouble(ds, "P_BET"); AlbersEqualArea p = new AlbersEqualArea(lat0, lon0, par1, par2, 0.0, 0.0, earthRadius); return new ProjectionCT("Albers", "FGDC", p); }
/** * Precalculate some stuff */ private void precalculate() { double par1r = Math.toRadians(this.par1); double par2r = Math.toRadians(this.par2); if (Math.abs(par2 - par1) < TOLERANCE) { // single parallel n = Math.sin(par1r); } else { n = (Math.sin(par1r) + Math.sin(par2r)) / 2.0; } double c2 = Math.pow(Math.cos(par1r), 2); C = c2 + 2 * n * Math.sin(par1r); rho0 = computeRho(lat0); }
/** * copy constructor - avoid clone !! */ public ProjectionImpl constructCopy() { ProjectionImpl result = new AlbersEqualArea(getOriginLat(), getOriginLon(), getParallelOne(), getParallelTwo(), getFalseEasting(), getFalseNorthing(), getEarthRadius()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
/** * Test * * @param args not used */ public static void main(String[] args) { AlbersEqualArea a = new AlbersEqualArea(23, -96, 29.5, 45.5); System.out.printf("name=%s%n", a.getName()); System.out.println("ll = 35N 75W"); ProjectionPoint p = a.latLonToProj(35, -75); System.out.println("proj point = " + p); LatLonPoint ll = a.projToLatLon(p); System.out.println("ll = " + ll); }
private void addAlbersEqualAreaTags(AlbersEqualArea proj) { geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GTModelTypeGeoKey, GeoKey.TagValue.ModelType_Projected)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GTRasterTypeGeoKey, GeoKey.TagValue.RasterType_Area)); // define the "geographic Coordinate System" geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeographicTypeGeoKey, GeoKey.TagValue.GeographicType_WGS_84)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeogLinearUnitsGeoKey, GeoKey.TagValue.ProjLinearUnits_METER)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeogAngularUnitsGeoKey, GeoKey.TagValue.GeogAngularUnits_DEGREE)); // define the "coordinate transformation" geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjectedCSTypeGeoKey, GeoKey.TagValue.ProjectedCSType_UserDefined)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.PCSCitationGeoKey, "Albers Conial Equal Area")); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjectionGeoKey, GeoKey.TagValue.ProjectedCSType_UserDefined)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjLinearUnitsGeoKey, GeoKey.TagValue.ProjLinearUnits_METER)); //geotiff.addGeoKey( new GeoKey( GeoKey.Tag.ProjLinearUnitsSizeGeoKey, 1.0)); // units of km // the specifics for mercator geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjCoordTransGeoKey, GeoKey.TagValue.ProjCoordTrans_AlbersConicalEqualArea)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLatGeoKey, proj.getOriginLat())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLongGeoKey, proj.getOriginLon())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel1GeoKey, proj.getParallelOne())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel2GeoKey, proj.getParallelTwo())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseEastingGeoKey, 0.0)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseNorthingGeoKey, 0.0)); }
double rho = computeRho(fromLat); double theta = computeTheta(fromLon);
private CoordinateTransform makeAlbersProjection(NetcdfDataset ds) { double lat0 = findAttributeDouble(ds, "YCENT"); double lon0 = findAttributeDouble(ds, "XCENT"); double par1 = findAttributeDouble(ds, "P_ALP"); double par2 = findAttributeDouble(ds, "P_BET"); AlbersEqualArea p = new AlbersEqualArea(lat0, lon0, par1, par2, 0.0, 0.0, earthRadius); return new ProjectionCT("Albers", "FGDC", p); }
this.earth_radius = earth_radius; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.ALBERS_CONICAL_EQUAL_AREA); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); addParameter(CF.STANDARD_PARALLEL, par1); } else { double[] data = new double[2]; data[0] = par1; data[1] = par2; addParameter(new Parameter(CF.STANDARD_PARALLEL, data)); addParameter(CF.FALSE_EASTING, falseEasting); addParameter(CF.FALSE_NORTHING, falseNorthing); addParameter(CDM.UNITS, "km"); addParameter(CF.EARTH_RADIUS, earth_radius * 1000); // must be in meters
/** * Precalculate some stuff */ private void precalculate() { double par1r = Math.toRadians(this.par1); double par2r = Math.toRadians(this.par2); if (Math.abs(par2 - par1) < TOLERANCE) { // single parallel n = Math.sin(par1r); } else { n = (Math.sin(par1r) + Math.sin(par2r)) / 2.0; } double c2 = Math.pow(Math.cos(par1r), 2); C = c2 + 2 * n * Math.sin(par1r); rho0 = computeRho(lat0); }