static public void main(String[] args) { // test-code Earth e = new Earth(6378.137, 6356.7523142, 0); ProjectionImpl proj = new TransverseMercatorProjection(e, 9., 0., 0.9996, 500.000, 0.); double[] lat = {60., 90., 60.}; double[] lon = {0., 0., 10.}; test(proj, lat, lon); proj = new TransverseMercatorProjection(e, 9., 0., 0.9996, 500., 0.); test(proj, lat, lon); }
/** * 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 ProjectionImpl constructCopy() { return (ProjectionImpl) clone(); }
public void setUTMZone(int zone) { zone--; projectionLongitude = (zone + .5) * Math.PI / 30. - Math.PI; projectionLatitude = 0.0; scaleFactor = 0.9996; falseEasting = 500000; initialize(); }
@Override public Object clone() { return new TransverseMercatorProjection(ellipsoid, Math.toDegrees(projectionLongitude), Math.toDegrees(projectionLatitude), scaleFactor, falseEasting, falseNorthing); }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = Math.toRadians(latLon.getLongitude()); if (projectionLongitude != 0) { theta = MapMath.normalizeLongitude(theta-projectionLongitude); } Point2D.Double res = project(theta, fromLat, new Point2D.Double()); destPoint.setLocation(totalScale * res.x + falseEasting, totalScale * res.y + falseNorthing); return destPoint; }
@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; }
public void setUTMZone(int zone) { zone--; projectionLongitude = (zone + .5) * Math.PI / 30. - Math.PI; projectionLatitude = 0.0; scaleFactor = 0.9996; falseEasting = 500000; initialize(); }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new TransverseMercatorProjection(ellipsoid, Math.toDegrees(projectionLongitude), Math.toDegrees(projectionLatitude), scaleFactor, falseEasting, falseNorthing); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = Math.toRadians(latLon.getLongitude()); if (projectionLongitude != 0) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } Point2D.Double res = project(theta, fromLat, new Point2D.Double()); destPoint.setLocation(totalScale * res.x + falseEasting, totalScale * res.y + falseNorthing); return destPoint; }
@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; }
static public void main(String[] args) { // test-code Earth e = new Earth(6378.137, 6356.7523142, 0); ProjectionImpl proj = new TransverseMercatorProjection(e, 9., 0., 0.9996, 500.000, 0.); double[] lat = {60., 90., 60.}; double[] lon = {0., 0., 10.}; test(proj, lat, lon); proj = new TransverseMercatorProjection(e, 9., 0., 0.9996, 500., 0.); test(proj, lat, lon); }
/** * 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) { super("TransverseMercatorProjection", false); this.ellipsoid = ellipsoid; projectionLongitude = Math.toRadians(lon_0_deg); projectionLatitude = Math.toRadians(lat_0_deg); scaleFactor = k; falseEasting = falseEast; falseNorthing = falseNorth; initialize(); // parameters addParameter(CF.GRID_MAPPING_NAME, CF.TRANSVERSE_MERCATOR); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon_0_deg); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat_0_deg); addParameter(CF.SCALE_FACTOR_AT_CENTRAL_MERIDIAN, scaleFactor); 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()); //System.err.println(paramsToString()); }
public void setUTMZone(int zone) { zone--; projectionLongitude = (zone + .5) * Math.PI / 30. - Math.PI; projectionLatitude = 0.0; scaleFactor = 0.9996; falseEasting = 500000; initialize(); }
@Override public ProjectionImpl constructCopy() { ProjectionImpl result = new TransverseMercatorProjection(ellipsoid, Math.toDegrees(projectionLongitude), Math.toDegrees(projectionLatitude), scaleFactor, falseEasting, falseNorthing); result.setDefaultMapArea(defaultMapArea); result.setName(name); return result; }
@Override public ProjectionPoint latLonToProj(LatLonPoint latLon, ProjectionPointImpl destPoint) { double fromLat = Math.toRadians(latLon.getLatitude()); double theta = Math.toRadians(latLon.getLongitude()); if (projectionLongitude != 0) { theta = MapMath.normalizeLongitude(theta - projectionLongitude); } ProjectionPoint res = project(theta, fromLat, new ProjectionPointImpl()); destPoint.setLocation(totalScale * res.getX() + falseEasting, totalScale * res.getY() + falseNorthing); return destPoint; }
@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; }
static public void main(String[] args) { // test-code Earth e = new Earth(6378.137, 6356.7523142, 0); ProjectionImpl proj = new TransverseMercatorProjection(e, 9., 0., 0.9996, 500.000, 0.); double[] lat = {60., 90., 60.}; double[] lon = {0., 0., 10.}; test(proj, lat, lon); proj = new TransverseMercatorProjection(e, 9., 0., 0.9996, 500., 0.); test(proj, lat, lon); }
/** * 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) { super("TransverseMercatorProjection", false); this.ellipsoid = ellipsoid; projectionLongitude = Math.toRadians(lon_0_deg); projectionLatitude = Math.toRadians(lat_0_deg); scaleFactor = k; falseEasting = falseEast; falseNorthing = falseNorth; initialize(); // parameters addParameter(CF.GRID_MAPPING_NAME, CF.TRANSVERSE_MERCATOR); addParameter(CF.LONGITUDE_OF_CENTRAL_MERIDIAN, lon_0_deg); addParameter(CF.LATITUDE_OF_PROJECTION_ORIGIN, lat_0_deg); addParameter(CF.SCALE_FACTOR_AT_CENTRAL_MERIDIAN, scaleFactor); 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()); //System.err.println(paramsToString()); }
public void setUTMZone(int zone) { zone--; projectionLongitude = (zone + .5) * Math.PI / 30. -Math.PI; projectionLatitude = 0.0; scaleFactor = 0.9996; falseEasting = 500000; initialize(); }