/** * Constructor with default parameters */ public LambertConformalConicEllipse() { this(23.0, -96.0, 29.5, 45.5, 0, 0, new Earth(6378137.0, 0.0, 298.257222101)); }
/** * {@code true} if the ellipsoid is degenerate and is actually a sphere. * The default implementation returns {@code true} if the {@linkplain Earth#getFlattening() * earth flattening} is zero. * * @return {@code true} if the ellipsoid is degenerate and is actually a sphere. */ @Override public boolean isSphere() { return earth.getFlattening() == 0; }
public void initialize() { this.e = ellipsoid.getEccentricity(); this.es = ellipsoid.getEccentricitySquared(); this.spherical = (e == 0.0); this.one_es = 1.0 - es; this.totalScale = ellipsoid.getMajor() * .001; // scale factor for cartesion coords in km. if (spherical) { esp = scaleFactor; ml0 = .5 * esp; } else { en = MapMath.enfn(es); ml0 = MapMath.mlfn(projectionLatitude, Math.sin(projectionLatitude), Math.cos(projectionLatitude), en); esp = es / (1. - es); } }
private void addParameters() { addParameter(CF.GRID_MAPPING_NAME, CF.LATITUDE_LONGITUDE); if (earth.isSpherical()) addParameter(CF.EARTH_RADIUS, earth.getEquatorRadius()); else { addParameter(CF.SEMI_MAJOR_AXIS, earth.getEquatorRadius()); addParameter(CF.SEMI_MINOR_AXIS, earth.getPoleRadius()); } }
public EquidistantAzimuthalProjection(double lat0, double lon0, double falseEasting, double falseNorthing, Earth earth) { super("EquidistantAzimuthalProjection", false); this.lat0 = lat0; this.lon0 = lon0; this.projectionLatitude = Math.toRadians(lat0); this.projectionLongitude = Math.toRadians(lon0); this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; this.earth = earth; this.e = earth.getEccentricity(); this.es = earth.getEccentricitySquared(); this.one_es = 1 - es; this.totalScale = earth.getMajor() * .001; // scale factor for cartesion coords in km. addParameter(CF.GRID_MAPPING_NAME, CF.AZIMUTHAL_EQUIDISTANT); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); if ((falseEasting != 0.0) || (falseNorthing != 0.0)) { addParameter(CF.FALSE_EASTING, falseEasting); addParameter(CF.FALSE_NORTHING, falseNorthing); addParameter(CDM.UNITS, "km"); } addParameter(CF.SEMI_MAJOR_AXIS, earth.getMajor()); addParameter(CF.INVERSE_FLATTENING, 1.0 / earth.getFlattening()); initialize(); }
public PolyconicProjection(double lat0, double lon0, double falseEasting, double falseNorthing, Earth ellipsoid) { super("Polyconic", false); //Initialization this.projectionLatitude = Math.toRadians(lat0); this.projectionLongitude = Math.toRadians(lon0); this.ellipsoid = ellipsoid; this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; this.es = this.ellipsoid.getEccentricitySquared(); this.totalScale = this.ellipsoid.getMajor() * .001; initialize(); //Adding parameters addParameter(CF.GRID_MAPPING_NAME, name); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); if ((falseEasting != 0.0) || (falseNorthing != 0.0)) { addParameter(CF.FALSE_EASTING, falseEasting); addParameter(CF.FALSE_NORTHING, falseNorthing); addParameter(CDM.UNITS, "km"); } addParameter(CF.SEMI_MAJOR_AXIS, ellipsoid.getMajor()); addParameter(CF.INVERSE_FLATTENING, 1.0 / ellipsoid.getFlattening()); }
this.e = earth.getEccentricity(); this.totalScale = earth.getMajor() * 0.001; // scale factor for cartesion coords in km. // issue if semimajor and semiminor axis defined in dataset? initialize(); addParameter(CDM.UNITS, "km"); addParameter(CF.SEMI_MAJOR_AXIS, earth.getMajor()); // seems correct for case where dataset has semimajor axis information, but where is semiminor? addParameter(CF.INVERSE_FLATTENING, 1.0 / earth.getFlattening()); // this gets us the semiminor axis from the semimajor (semimajor - flattening*semimajor)
/** * Set up a projection suitable for State Plane Coordinates. * Best used with earth ellipsoid and false-easting/northing in km */ public TransverseMercatorProjection(Earth ellipsoid, double lon_0_deg, double lat_0_deg, double k, double falseEast, double falseNorth) { this.ellipsoid = ellipsoid; projectionLongitude = Math.toRadians(lon_0_deg); projectionLatitude = Math.toRadians(lat_0_deg); scaleFactor = k; falseEasting = falseEast; falseNorthing = falseNorth; initialize(); // parameters addParameter(ATTR_NAME, "transverse_mercator"); addParameter("longitude_of_central_meridian", lon_0_deg); addParameter("latitude_of_projection_origin", lat_0_deg); addParameter("scale_factor_at_central_meridian", scaleFactor); if ((falseEasting != 0.0) || (falseNorthing != 0.0)) { addParameter("false_easting", falseEasting); addParameter("false_northing", falseNorthing); addParameter("units", "km"); } addParameter("semi_major_axis", ellipsoid.getMajor()); addParameter("inverse_flattening", 1.0/ellipsoid.getFlattening()); //System.err.println(paramsToString()); }
@Override public boolean equals(Object proj) { if (!(proj instanceof TransverseMercatorProjection)) { return false; } TransverseMercatorProjection oo = (TransverseMercatorProjection) proj; return ((this.projectionLatitude == oo.projectionLatitude) && (this.projectionLongitude == oo.projectionLongitude) && (this.scaleFactor == oo.scaleFactor) && (this.falseEasting == oo.falseEasting) && (this.falseNorthing == oo.falseNorthing) && this.ellipsoid.equals(oo.ellipsoid)); }
/** * Constructor with default parameters */ public LambertConformal() { this(40.0, -105.0, 20.0, 60.0, 0.0, 0.0, Earth.getRadius()*.001); }
public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl result) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = computeTheta(latLon.getLongitude()); double term = earth.isSpherical() ? n2 * Math.sin(fromLat) : n * MapMath.qsfn(Math.sin(fromLat), e, one_es); double rho = c - term; if (rho < 0.0) throw new RuntimeException("F"); rho = dd * Math.sqrt(rho); double toX = rho * Math.sin(theta); double toY = rho0 - rho * Math.cos(theta); result.setLocation(totalScale * toX + falseEasting, totalScale * toY + falseNorthing); return result; }
/** * Returns the length of the semi-major axis of the ellipsoid. * The default implementation delegates to {@link Earth#getMajor()}. * * @return length of semi-major axis. * * @see Earth#getMajor() */ @Override public double getSemiMajorAxis() { return earth.getMajor(); }
@Override public int hashCode() { int hash = 5; hash = 97 * hash + (int) (Double.doubleToLongBits(this.projectionLatitude) ^ (Double.doubleToLongBits(this.projectionLatitude) >>> 32)); hash = 97 * hash + (int) (Double.doubleToLongBits(this.projectionLongitude) ^ (Double.doubleToLongBits(this.projectionLongitude) >>> 32)); hash = 97 * hash + (int) (Double.doubleToLongBits(this.scaleFactor) ^ (Double.doubleToLongBits(this.scaleFactor) >>> 32)); hash = 97 * hash + (int) (Double.doubleToLongBits(this.falseEasting) ^ (Double.doubleToLongBits(this.falseEasting) >>> 32)); hash = 97 * hash + (int) (Double.doubleToLongBits(this.falseNorthing) ^ (Double.doubleToLongBits(this.falseNorthing) >>> 32)); hash = 97 * hash + (this.ellipsoid != null ? this.ellipsoid.hashCode() : 0); return hash; }
public GdsHorizCoordSys makeHorizCoordSys() { ProjectionImpl proj = null; Earth earth = getEarth(); if (earth.isSpherical()) { proj = new ucar.unidata.geoloc.projection.LambertConformal(latin1, lov, latin1, latin2, 0.0, 0.0, earth.getEquatorRadius() * .001); } else { proj = new ucar.unidata.geoloc.projection.proj4.LambertConformalConicEllipse(latin1, lov, latin1, latin2, 0.0, 0.0, earth); } LatLonPointImpl startLL = new LatLonPointImpl(la1, lo1); ProjectionPointImpl start = (ProjectionPointImpl) proj.latLonToProj(startLL); return new GdsHorizCoordSys(getNameShort(), template, 0, scanMode, proj, start.getX(), getDx(), start.getY(), getDy(), getNx(), getNy(), null); }
/** * Returns the length of the semi-minor axis of the ellipsoid. * The default implementation delegates to {@link Earth#getMinor()}. * * @return length of semi-minor axis. * * @see Earth#getMinor() */ @Override public double getSemiMinorAxis() { return earth.getMinor(); }
public EquidistantAzimuthalProjection(double lat0, double lon0, double falseEasting, double falseNorthing, Earth earth) { super("EquidistantAzimuthalProjection", false); this.lat0 = lat0; this.lon0 = lon0; this.projectionLatitude = Math.toRadians(lat0); this.projectionLongitude = Math.toRadians(lon0); this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; this.earth = earth; this.e = earth.getEccentricity(); this.es = earth.getEccentricitySquared(); this.one_es = 1 - es; this.totalScale = earth.getMajor() * .001; // scale factor for cartesion coords in km. addParameter(CF.GRID_MAPPING_NAME, CF.AZIMUTHAL_EQUIDISTANT); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); if ((falseEasting != 0.0) || (falseNorthing != 0.0)) { addParameter(CF.FALSE_EASTING, falseEasting); addParameter(CF.FALSE_NORTHING, falseNorthing); addParameter(CDM.UNITS, "km"); } addParameter(CF.SEMI_MAJOR_AXIS, earth.getMajor()); addParameter(CF.INVERSE_FLATTENING, 1.0/earth.getFlattening()); initialize(); }
public PolyconicProjection(double lat0, double lon0, double falseEasting, double falseNorthing, Earth ellipsoid) { super("Polyconic", false); //Initialization this.projectionLatitude = Math.toRadians(lat0); this.projectionLongitude = Math.toRadians(lon0); this.ellipsoid = ellipsoid; this.falseEasting = falseEasting; this.falseNorthing = falseNorthing; this.es = this.ellipsoid.getEccentricitySquared(); this.totalScale = this.ellipsoid.getMajor() * .001; initialize(); //Adding parameters addParameter(CF.GRID_MAPPING_NAME, name); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat0); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon0); if ((falseEasting != 0.0) || (falseNorthing != 0.0)) { addParameter(CF.FALSE_EASTING, falseEasting); addParameter(CF.FALSE_NORTHING, falseNorthing); addParameter(CDM.UNITS, "km"); } addParameter(CF.SEMI_MAJOR_AXIS, ellipsoid.getMajor()); addParameter(CF.INVERSE_FLATTENING, 1.0 / ellipsoid.getFlattening()); }
this.e = earth.getEccentricity(); this.totalScale = earth.getMajor() * 0.001; // scale factor for cartesion coords in km. // issue if semimajor and semiminor axis defined in dataset? initialize(); addParameter(CDM.UNITS, "km"); addParameter(CF.SEMI_MAJOR_AXIS, earth.getMajor()); // seems correct for case where dataset has semimajor axis information, but where is semiminor? addParameter(CF.INVERSE_FLATTENING, 1.0 / earth.getFlattening()); // this gets us the semiminor axis from the semimajor (semimajor - flattening*semimajor)
private void addAlbersEqualAreaEllipseTags(AlbersEqualAreaEllipse 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.GeogSemiMajorAxisGeoKey, proj.getEarth().getMajor())); geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeogSemiMinorAxisGeoKey, proj.getEarth().getMinor())); 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_AlbersEqualAreaEllipse)); 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)); }