static public void main(String[] args) { // test-code Earth e = new Earth(6378.137, 0, 298.257224); StereographicAzimuthalProjection proj = new StereographicAzimuthalProjection(90., 0., 0.93306907, 90., 0., 0.,e); double[] lat = {60., 90., 60.}; double[] lon = {0., 0., 10.}; test(proj, lat, lon); proj = new StereographicAzimuthalProjection(90., -45., 0.96985819, 90., 0., 0.,e); test(proj, lat, lon); } }
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(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); 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"); 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)
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = computeTheta(latLon.getLongitude()); //System.err.println(Math.toDegrees(theta) + " " + Math.toDegrees(fromLat)); Point2D.Double res = project(theta, fromLat, new Point2D.Double()); destPoint.setLocation(totalScale * res.x + falseEasting, totalScale * res.y + falseNorthing); return destPoint; }
@Override public ProjectionImpl constructCopy() { return new StereographicAzimuthalProjection(Math.toDegrees(projectionLatitude), Math.toDegrees(projectionLongitude), scaleFactor, Math.toDegrees(trueScaleLatitude), falseEasting, falseNorthing, earth); }
case OBLIQUE: t = Math.sin(projectionLatitude); X = 2. * Math.atan(ssfn(projectionLatitude, t, e)) - MapMath.HALFPI; t *= e; akm1 = 2. * scaleFactor * Math.cos(projectionLatitude) / Math.sqrt(1. - t * t);
@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) dst.x = MapMath.normalizeLongitude(dst.x + projectionLongitude); result.setLongitude(Math.toDegrees(dst.x)); result.setLatitude(Math.toDegrees(dst.y)); return result; }
@Override public boolean equals(Object proj) { if (!(proj instanceof StereographicAzimuthalProjection)) { return false; } StereographicAzimuthalProjection oo = (StereographicAzimuthalProjection) 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.projectionLatitude == oo.projectionLatitude) && (this.projectionLongitude == oo.projectionLongitude) && (this.scaleFactor == oo.scaleFactor) && (this.trueScaleLatitude == oo.trueScaleLatitude) && (this.falseEasting == oo.falseEasting) && (this.falseNorthing == oo.falseNorthing) && this.earth.equals(oo.earth)); }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new StereographicAzimuthalProjection(Math.toDegrees(projectionLatitude), Math.toDegrees(projectionLongitude), scaleFactor, Math.toDegrees(trueScaleLatitude), falseEasting, falseNorthing, earth); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
case OBLIQUE: t = Math.sin(projectionLatitude); X = 2. * Math.atan(ssfn(projectionLatitude, t, e)) - MapMath.HALFPI; t *= e; akm1 = 2. * scaleFactor * Math.cos(projectionLatitude) / Math.sqrt(1. - t * t);
@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) dst.x = MapMath.normalizeLongitude(dst.x+projectionLongitude); result.setLongitude(Math.toDegrees(dst.x)); result.setLatitude(Math.toDegrees(dst.y)); return result; }
@Override public boolean equals(Object proj) { if (!(proj instanceof StereographicAzimuthalProjection)) { return false; } StereographicAzimuthalProjection oo = (StereographicAzimuthalProjection) 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.projectionLatitude == oo.projectionLatitude) && (this.projectionLongitude == oo.projectionLongitude) && (this.scaleFactor == oo.scaleFactor) && (this.trueScaleLatitude == oo.trueScaleLatitude) && (this.falseEasting == oo.falseEasting) && (this.falseNorthing == oo.falseNorthing) && this.earth.equals(oo.earth)); }
static public void main(String[] args) { // test-code Earth e = new Earth(6378137., 0, 298.257224); StereographicAzimuthalProjection proj = new StereographicAzimuthalProjection(90., 0., 0.93306907, 90., 0., 0., e); double[] lat = {60., 90., 60.}; double[] lon = {0., 0., 10.}; test(proj, lat, lon); proj = new StereographicAzimuthalProjection(90., -45., 0.96985819, 90., 0., 0., e); test(proj, lat, lon); // southpole proj = new StereographicAzimuthalProjection(-90., 0., -1, -70., 0., 0., e); double[] latS = {-60., -90., -60.}; double[] lonS = {0., 0., 10.}; test(proj, latS, lonS); } }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new StereographicAzimuthalProjection(Math.toDegrees(projectionLatitude), Math.toDegrees(projectionLongitude), scaleFactor, Math.toDegrees(trueScaleLatitude), falseEasting, falseNorthing, earth); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = computeTheta(latLon.getLongitude()); Point2D.Double res = project(theta, fromLat, new Point2D.Double()); destPoint.setLocation(totalScale * res.x + falseEasting, totalScale * res.y + falseNorthing); return destPoint; }
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(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); 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"); 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)
case OBLIQUE: t = Math.sin(projectionLatitude); X = 2. * Math.atan(ssfn(projectionLatitude, t, e)) - MapMath.HALFPI; t *= e; akm1 = 2. * scaleFactor * Math.cos(projectionLatitude) / Math.sqrt(1. - t * t);
@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 dst = new ProjectionPointImpl(); projectInverse(fromX, fromY, dst); if (dst.getX() < -Math.PI) dst.setX(-Math.PI); else if (dst.getX() > Math.PI) dst.setX(Math.PI); if (projectionLongitude != 0) dst.setX(MapMath.normalizeLongitude(dst.getX() + projectionLongitude)); result.setLongitude(Math.toDegrees(dst.getX())); result.setLatitude(Math.toDegrees(dst.getY())); return result; }
@Override public boolean equals(Object proj) { if (!(proj instanceof StereographicAzimuthalProjection)) { return false; } StereographicAzimuthalProjection oo = (StereographicAzimuthalProjection) 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.projectionLatitude == oo.projectionLatitude) && (this.projectionLongitude == oo.projectionLongitude) && (this.scaleFactor == oo.scaleFactor) && (this.trueScaleLatitude == oo.trueScaleLatitude) && (this.falseEasting == oo.falseEasting) && (this.falseNorthing == oo.falseNorthing) && this.earth.equals(oo.earth)); }
static public void main(String[] args) { // test-code Earth e = new Earth(6378137., 0, 298.257224); StereographicAzimuthalProjection proj = new StereographicAzimuthalProjection(90., 0., 0.93306907, 90., 0., 0., e); double[] lat = {60., 90., 60.}; double[] lon = {0., 0., 10.}; test(proj, lat, lon); proj = new StereographicAzimuthalProjection(90., -45., 0.96985819, 90., 0., 0., e); test(proj, lat, lon); // southpole proj = new StereographicAzimuthalProjection(-90., 0., -1, -70., 0., 0., e); double[] latS = {-60., -90., -60.}; double[] lonS = {0., 0., 10.}; test(proj, latS, lonS); } }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new StereographicAzimuthalProjection(Math.toDegrees(projectionLatitude), Math.toDegrees(projectionLongitude), scaleFactor, Math.toDegrees(trueScaleLatitude), falseEasting, falseNorthing, earth); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }