public ProjectionImpl constructCopy() { return new LambertConformal(getOriginLat(), getOriginLon(), getParallelOne(), getParallelTwo(), getFalseEasting(), getFalseNorthing()); }
this.earth_radius = earth_radius; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.LAMBERT_CONFORMAL_CONIC); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); if (par2 == par1) { 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, false_easting); addParameter(CF.FALSE_NORTHING, false_northing); addParameter(CDM.UNITS, "km"); addParameter(CF.EARTH_RADIUS, earth_radius * 1000);
/** * Create a WKS string * * @return WKS string */ public String toWKS() { StringBuilder sbuff = new StringBuilder(); sbuff.append("PROJCS[\"").append(getName()).append("\","); if (true) { sbuff.append("GEOGCS[\"Normal Sphere (r=6371007)\","); sbuff.append("DATUM[\"unknown\","); sbuff.append("SPHEROID[\"sphere\",6371007,0]],"); } else { sbuff.append("GEOGCS[\"WGS 84\","); sbuff.append("DATUM[\"WGS_1984\","); sbuff.append("SPHEROID[\"WGS 84\",6378137,298.257223563],"); sbuff.append("TOWGS84[0,0,0,0,0,0,0]],"); } sbuff.append("PRIMEM[\"Greenwich\",0],"); sbuff.append("UNIT[\"degree\",0.0174532925199433]],"); sbuff.append("PROJECTION[\"Lambert_Conformal_Conic_1SP\"],"); sbuff.append("PARAMETER[\"latitude_of_origin\",").append(getOriginLat()).append("],"); // LOOK assumes getOriginLat = getParellel sbuff.append("PARAMETER[\"central_meridian\",").append(getOriginLon()).append("],"); sbuff.append("PARAMETER[\"scale_factor\",1],"); sbuff.append("PARAMETER[\"false_easting\",").append(falseEasting).append("],"); sbuff.append("PARAMETER[\"false_northing\",").append(falseNorthing).append("],"); return sbuff.toString(); }
/** * 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 LambertConformal)) { return false; } LambertConformal oo = (LambertConformal) proj; return ((this.getParallelOne() == oo.getParallelOne()) && (this.getParallelTwo() == oo.getParallelTwo()) && (this.getOriginLat() == oo.getOriginLat()) && (this.getOriginLon() == oo.getOriginLon()) && this.defaultMapArea.equals(oo.defaultMapArea)); }
/** * LambertConformal should accept latitude-at-origin that is at either pole. */ @Test public void acceptCenterLatAtAPole() { LambertConformal sp = new LambertConformal (-90., 0., 45., 45.); LambertConformal np = new LambertConformal ( 90., 0., 45., 45.); }
private ProjectionCT makeLCProjection(NetcdfDataset ds, String name) throws NoSuchElementException { double centralLat = findAttributeDouble(ds, "centralLat"); double centralLon = findAttributeDouble(ds, "centralLon"); double rotation = findAttributeDouble(ds, "rotation"); // we have to project in order to find the origin LambertConformal lc = new LambertConformal(rotation, centralLon, centralLat, centralLat); double lat0 = findAttributeDouble(ds, "lat00"); double lon0 = findAttributeDouble(ds, "lon00"); ProjectionPointImpl start = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(lat0, lon0)); if (debugProj) parseInfo.format("getLCProjection start at proj coord %s\n", start); startx = start.getX(); starty = start.getY(); return new ProjectionCT(name, "FGDC", lc); }
@Test public void testLCseam() { // test seam crossing LambertConformal lc = new LambertConformal(40.0, 180.0, 20.0, 60.0); ProjectionPointImpl p1 = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(0.0, -1.0), new ProjectionPointImpl()); ProjectionPointImpl p2 = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(0.0, 1.0), new ProjectionPointImpl()); if (show) { System.out.printf(" p1= x=%f y=%f%n", p1.getX(), p1.getY()); System.out.printf(" p2= x=%f y=%f%n", p2.getX(), p2.getY()); } assert lc.crossSeam(p1, p2); }
@Test public void testLC() { testProjection(new LambertConformal()); LambertConformal lc = new LambertConformal(); LambertConformal lc2 = (LambertConformal) lc.constructCopy(); assert lc.equals(lc2); }
/** * Clone this projection. * * @return Clone of this */ public Object clone() { LambertConformal cl = (LambertConformal) super.clone(); cl.origin = new LatLonPointImpl(getOriginLat(), getOriginLon()); return cl; }
/** * LambertConformal should reject standard parallel #2 set to +90. */ @Test(expected=IllegalArgumentException.class) public void rejectParallel2AtNorthPole() { LambertConformal lc = new LambertConformal (45., 0., 45., 90.); } }
private ProjectionCT makeLCProjection(NetcdfDataset ds, String name) throws NoSuchElementException { double centralLat = findAttributeDouble(ds, "centralLat"); double centralLon = findAttributeDouble(ds, "centralLon"); double rotation = findAttributeDouble(ds, "rotation"); // we have to project in order to find the origin LambertConformal lc = new LambertConformal(rotation, centralLon, centralLat, centralLat); double lat0 = findAttributeDouble(ds, "lat00"); double lon0 = findAttributeDouble(ds, "lon00"); ProjectionPointImpl start = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(lat0, lon0)); if (debugProj) parseInfo.format("getLCProjection start at proj coord %s%n", start); startx = start.getX(); starty = start.getY(); return new ProjectionCT(name, "FGDC", lc); }
private void addLambertConformalTags(LambertConformal proj, double FalseEasting, double FalseNorthing) { 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.GeogPrimeMeridianGeoKey, GeoKey.TagValue.GeogPrimeMeridian_GREENWICH)); //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, "Snyder")); 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 lambert conformal geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjCoordTransGeoKey, GeoKey.TagValue.ProjCoordTrans_LambertConfConic_2SP)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel1GeoKey, proj.getParallelOne())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel2GeoKey, proj.getParallelTwo())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjCenterLongGeoKey, proj.getOriginLon())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLatGeoKey, proj.getOriginLat())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLongGeoKey, proj.getOriginLon())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjScaleAtNatOriginGeoKey, 1.0)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseEastingGeoKey, 0.0)); // LOOK why not FalseNorthing ?? geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseNorthingGeoKey, 0.0)); }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new LambertConformal(getOriginLat(), getOriginLon(), getParallelOne(), getParallelTwo(), getFalseEasting(), getFalseNorthing(), earth_radius); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
/** * LambertConformal should reject standard parallel #1 set to +90. */ @Test(expected=IllegalArgumentException.class) public void rejectParallel1AtNorthPole() { LambertConformal lc = new LambertConformal (45., 0., 90., 45.); }
private ProjectionCT makeLCProjection(NetcdfDataset ds, String name) throws NoSuchElementException { double centralLat = findAttributeDouble(ds, "centralLat"); double centralLon = findAttributeDouble(ds, "centralLon"); double rotation = findAttributeDouble(ds, "rotation"); // we have to project in order to find the origin LambertConformal lc = new LambertConformal(rotation, centralLon, centralLat, centralLat); double lat0 = findAttributeDouble(ds, "lat00"); double lon0 = findAttributeDouble(ds, "lon00"); ProjectionPointImpl start = (ProjectionPointImpl) lc.latLonToProj(new LatLonPointImpl(lat0, lon0)); if (debugProj) parseInfo.format("getLCProjection start at proj coord %s%n", start); startx = start.getX(); starty = start.getY(); return new ProjectionCT(name, "FGDC", lc); }
private void addLambertConformalTags(LambertConformal proj, double FalseEasting, double FalseNorthing) { 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.GeogPrimeMeridianGeoKey, GeoKey.TagValue.GeogPrimeMeridian_GREENWICH)); //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, "Snyder")); 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 lambert conformal geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjCoordTransGeoKey, GeoKey.TagValue.ProjCoordTrans_LambertConfConic_2SP)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel1GeoKey, proj.getParallelOne())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjStdParallel2GeoKey, proj.getParallelTwo())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjCenterLongGeoKey, proj.getOriginLon())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLatGeoKey, proj.getOriginLat())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjNatOriginLongGeoKey, proj.getOriginLon())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjScaleAtNatOriginGeoKey, 1.0)); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseEastingGeoKey, 0.0)); // LOOK why not FalseNorthing ?? geotiff.addGeoKey(new GeoKey(GeoKey.Tag.ProjFalseNorthingGeoKey, 0.0)); }
/** * Create a WKS string * * @return WKS string */ public String toWKS() { StringBuilder sbuff = new StringBuilder(); sbuff.append("PROJCS[\"").append(getName()).append("\","); if (true) { sbuff.append("GEOGCS[\"Normal Sphere (r=6371007)\","); sbuff.append("DATUM[\"unknown\","); sbuff.append("SPHEROID[\"sphere\",6371007,0]],"); } else { sbuff.append("GEOGCS[\"WGS 84\","); sbuff.append("DATUM[\"WGS_1984\","); sbuff.append("SPHEROID[\"WGS 84\",6378137,298.257223563],"); sbuff.append("TOWGS84[0,0,0,0,0,0,0]],"); } sbuff.append("PRIMEM[\"Greenwich\",0],"); sbuff.append("UNIT[\"degree\",0.0174532925199433]],"); sbuff.append("PROJECTION[\"Lambert_Conformal_Conic_1SP\"],"); sbuff.append("PARAMETER[\"latitude_of_origin\",").append(getOriginLat()).append("],"); // LOOK assumes getOriginLat = getParellel sbuff.append("PARAMETER[\"central_meridian\",").append(getOriginLon()).append("],"); sbuff.append("PARAMETER[\"scale_factor\",1],"); sbuff.append("PARAMETER[\"false_easting\",").append(falseEasting).append("],"); sbuff.append("PARAMETER[\"false_northing\",").append(falseNorthing).append("],"); return sbuff.toString(); }
this.earth_radius = earth_radius; precalculate(); addParameter(CF.GRID_MAPPING_NAME, CF.LAMBERT_CONFORMAL_CONIC); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); if (par2 == par1) { 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, false_easting); addParameter(CF.FALSE_NORTHING, false_northing); addParameter(CDM.UNITS, "km"); addParameter(CF.EARTH_RADIUS, earth_radius * 1000);
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new LambertConformal(getOriginLat(), getOriginLon(), getParallelOne(), getParallelTwo(), getFalseEasting(), getFalseNorthing(), earth_radius); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
/** * LambertConformal should reject standard parallel #2 set to -90. */ @Test(expected=IllegalArgumentException.class) public void rejectParallel2AtSouthPole() { LambertConformal lc = new LambertConformal (45., 0., -45., -90.); }