@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new PolyconicProjection(getOriginLatitude(), getOriginLongitude(), getFalseEasting(), getFalseNorthing(), getEarth()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; } }
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()); }
/** * Check for equality with the Object in question * * @param proj object to check * @return true if they are equal */ @Override public boolean equals(Object proj) { if (!(proj instanceof LambertConformalConicEllipse)) { return false; } PolyconicProjection oo = (PolyconicProjection) proj; if ((this.getDefaultMapArea() == null) != (oo.defaultMapArea == null)) return false; // common case is that these are null if (this.getDefaultMapArea() != null && !this.defaultMapArea.equals(oo.defaultMapArea)) return false; return ((this.getOriginLatitude() == oo.getOriginLatitude()) && (this.getOriginLongitude() == oo.getOriginLongitude()) && this.ellipsoid.equals(oo.getEarth())); }
public ProjectionCT makeCoordinateTransform(AttributeContainer ctv, String geoCoordinateUnits) { double lon0 = readAttributeDouble(ctv, "longitude_of_central_meridian", Double.NaN); double lat0 = readAttributeDouble(ctv, "latitude_of_projection_origin", Double.NaN); double semi_major_axis = readAttributeDouble(ctv, "semi_major_axis", Double.NaN); double semi_minor_axis = readAttributeDouble(ctv, "semi_minor_axis", Double.NaN); double inverse_flattening = readAttributeDouble(ctv, "inverse_flattening", 0.0); ucar.unidata.geoloc.ProjectionImpl proj; // check for ellipsoidal earth if (!Double.isNaN(semi_major_axis) && (!Double.isNaN(semi_minor_axis) || inverse_flattening != 0.0)) { Earth earth = new Earth(semi_major_axis, semi_minor_axis, inverse_flattening); proj = new ucar.unidata.geoloc.projection.proj4.PolyconicProjection(lat0, lon0, earth); } else { proj = new ucar.unidata.geoloc.projection.proj4.PolyconicProjection(lat0, lon0); } return new ProjectionCT(ctv.getName(), "FGDC", proj); }
/** * Convert a LatLonPoint to projection coordinates * * @param latlon convert from these lat, lon coordinates * @param result the object to write to * @return the given result */ @Override public ProjectionPoint latLonToProj(LatLonPoint latlon, ProjectionPointImpl result) { double fromLat = Math.toRadians(latlon.getLatitude()); double theta = Math.toRadians(latlon.getLongitude()); if (projectionLongitude != 0 && !Double.isNaN(theta)) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } Point2D.Double out = new Point2D.Double(); out = project(theta, fromLat, out); result.setLocation(totalScale * out.x + falseEasting, totalScale * out.y + falseNorthing); return result; }
/** * Convert projection coordinates to a LatLonPoint * Note: a new object is not created on each call for the return value. * * @param world convert from these projection coordinates * @param result the object to write to * @return LatLonPoint convert to these lat/lon coordinates */ @Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; Point2D.Double dst = projectInverse(fromX, fromY, new Point2D.Double()); if (dst.x < -Math.PI) { dst.x = -Math.PI; } else if (dst.x > Math.PI) { dst.x = Math.PI; } if (projectionLongitude != 0 && !Double.isNaN(dst.x)) { dst.x = MapMath.normalizeLongitude(dst.x + projectionLongitude); } result.setLatitude(Math.toDegrees(dst.y)); result.setLongitude(Math.toDegrees(dst.x)); return result; }
public CoordinateTransform makeCoordinateTransform(NetcdfDataset ds, Variable ctv) { double lon0 = readAttributeDouble(ctv, "longitude_of_central_meridian", Double.NaN); double lat0 = readAttributeDouble(ctv, "latitude_of_projection_origin", Double.NaN); double semi_major_axis = readAttributeDouble(ctv, "semi_major_axis", Double.NaN); double semi_minor_axis = readAttributeDouble(ctv, "semi_minor_axis", Double.NaN); double inverse_flattening = readAttributeDouble(ctv, "inverse_flattening", 0.0); ucar.unidata.geoloc.ProjectionImpl proj; // check for ellipsoidal earth if (!Double.isNaN(semi_major_axis) && (!Double.isNaN(semi_minor_axis) || inverse_flattening != 0.0)) { Earth earth = new Earth(semi_major_axis, semi_minor_axis, inverse_flattening); proj = new ucar.unidata.geoloc.projection.proj4.PolyconicProjection(lat0, lon0, earth); } else { proj = new ucar.unidata.geoloc.projection.proj4.PolyconicProjection(lat0, lon0); } return new ProjectionCT(ctv.getShortName(), "FGDC", proj); }
/** * Convert a LatLonPoint to projection coordinates * * @param latlon convert from these lat, lon coordinates * @param result the object to write to * @return the given result */ @Override public ProjectionPoint latLonToProj(LatLonPoint latlon, ProjectionPointImpl result) { double fromLat = Math.toRadians(latlon.getLatitude()); double theta = Math.toRadians(latlon.getLongitude()); if (projectionLongitude != 0 && !Double.isNaN(theta)) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } ProjectionPointImpl out = new ProjectionPointImpl(); project(theta, fromLat, out); result.setLocation(totalScale * out.getX() + falseEasting, totalScale * out.getY() + falseNorthing); return result; }
/** * Convert projection coordinates to a LatLonPoint * Note: a new object is not created on each call for the return value. * * @param world convert from these projection coordinates * @param result the object to write to * @return LatLonPoint convert to these lat/lon coordinates */ @Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl pp = new ProjectionPointImpl(); projectInverse(fromX, fromY, pp); if (pp.getX() < -Math.PI) { pp.setX(-Math.PI); } else if (pp.getX() > Math.PI) { pp.setX(Math.PI); } if (projectionLongitude != 0 && !Double.isNaN(pp.getX())) { pp.setX(MapMath.normalizeLongitude(pp.getX() + projectionLongitude)); } result.setLatitude( Math.toDegrees(pp.getY())); result.setLongitude( Math.toDegrees(pp.getX())); return result; }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new PolyconicProjection(getOriginLatitude(), getOriginLongitude(), getFalseEasting(), getFalseNorthing(), getEarth()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; } }
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()); }
public CoordinateTransform makeCoordinateTransform(NetcdfDataset ds, Variable ctv) { double lon0 = readAttributeDouble(ctv, "longitude_of_central_meridian", Double.NaN); double lat0 = readAttributeDouble(ctv, "latitude_of_projection_origin", Double.NaN); double semi_major_axis = readAttributeDouble(ctv, "semi_major_axis", Double.NaN); double semi_minor_axis = readAttributeDouble(ctv, "semi_minor_axis", Double.NaN); double inverse_flattening = readAttributeDouble(ctv, "inverse_flattening", 0.0); ucar.unidata.geoloc.ProjectionImpl proj; // check for ellipsoidal earth if (!Double.isNaN(semi_major_axis) && (!Double.isNaN(semi_minor_axis) || inverse_flattening != 0.0)) { Earth earth = new Earth(semi_major_axis, semi_minor_axis, inverse_flattening); proj = new ucar.unidata.geoloc.projection.proj4.PolyconicProjection(lat0, lon0, earth); } else { proj = new ucar.unidata.geoloc.projection.proj4.PolyconicProjection(lat0, lon0); } return new ProjectionCT(ctv.getShortName(), "FGDC", proj); }
/** * Convert a LatLonPoint to projection coordinates * * @param latlon convert from these lat, lon coordinates * @param result the object to write to * @return the given result */ @Override public ProjectionPoint latLonToProj(LatLonPoint latlon, ProjectionPointImpl result) { double fromLat = Math.toRadians(latlon.getLatitude()); double theta = Math.toRadians(latlon.getLongitude()); if (projectionLongitude != 0 && !Double.isNaN(theta)) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } ProjectionPointImpl out = new ProjectionPointImpl(); project(theta, fromLat, out); result.setLocation(totalScale * out.getX() + falseEasting, totalScale * out.getY() + falseNorthing); return result; }
/** * Convert projection coordinates to a LatLonPoint * Note: a new object is not created on each call for the return value. * * @param world convert from these projection coordinates * @param result the object to write to * @return LatLonPoint convert to these lat/lon coordinates */ @Override public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result) { double fromX = (world.getX() - falseEasting) / totalScale; // assumes cartesian coords in km double fromY = (world.getY() - falseNorthing) / totalScale; ProjectionPointImpl pp = new ProjectionPointImpl(); projectInverse(fromX, fromY, pp); if (pp.getX() < -Math.PI) { pp.setX(-Math.PI); } else if (pp.getX() > Math.PI) { pp.setX(Math.PI); } if (projectionLongitude != 0 && !Double.isNaN(pp.getX())) { pp.setX(MapMath.normalizeLongitude(pp.getX() + projectionLongitude)); } result.setLatitude( Math.toDegrees(pp.getY())); result.setLongitude( Math.toDegrees(pp.getX())); return result; }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new PolyconicProjection(getOriginLatitude(), getOriginLongitude(), getFalseEasting(), getFalseNorthing(), getEarth()); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; } }
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()); }