diff --git a/src/ch/ethz/karto/gui/ProjectionSelectionPanel.java b/src/ch/ethz/karto/gui/ProjectionSelectionPanel.java index 1e2610a..792d67e 100644 --- a/src/ch/ethz/karto/gui/ProjectionSelectionPanel.java +++ b/src/ch/ethz/karto/gui/ProjectionSelectionPanel.java @@ -139,7 +139,7 @@ private void initComponents() { selectionPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 10)); projectionComboBox.setMaximumRowCount(40); - projectionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Plate Carre (Geographic)", "Cylindrical Equal-Area", "Cylindrical Conformal (Mercator)", "Conical Equidistant", "Conical Equal-Area (Albers)", "Conical Conformal (Lambert)", "Azimuthal Equidistant", "Azimuthal Equal-Area (Lambert)", "Azimuthal Conformal (Stereographic)", "Azimuthal Orthographic", "Sinusoidal", "Pseudoconical Equal-Area (Bonne)" })); + projectionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Plate Carrée (Geographic)", "Cylindrical Equal-Area", "Cylindrical Conformal (Mercator)", "Conical Equidistant", "Conical Equal-Area (Albers)", "Conical Conformal (Lambert)", "Azimuthal Equidistant", "Azimuthal Equal-Area (Lambert)", "Azimuthal Conformal (Stereographic)", "Azimuthal Orthographic", "Sinusoidal", "Pseudoconical Equal-Area (Bonne)" })); projectionComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { projectionComboBoxItemStateChanged(evt); @@ -166,7 +166,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { selectionPanel.add(nextProjectionButton); inverseCheckBox.setText("Test Inverse"); - inverseCheckBox.setToolTipText("Applies forward and inverse projection, which should result in a Plate Carre projection."); + inverseCheckBox.setToolTipText("Applies forward and inverse projection, which should result in a Plate Carrée projection."); inverseCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { inverseCheckBoxActionPerformed(evt); diff --git a/src/com/jhlabs/map/GeodeticPosition.java b/src/com/jhlabs/map/GeodeticPosition.java index e65b135..2f4fe2e 100755 --- a/src/com/jhlabs/map/GeodeticPosition.java +++ b/src/com/jhlabs/map/GeodeticPosition.java @@ -1,26 +1,26 @@ -package com.jhlabs.map; - -public class GeodeticPosition { - - public double lat; - public double lon; - public double h; - - public GeodeticPosition() { - lat = 0; - lon = 0; - h = 0; - } - - public GeodeticPosition(double lat, double lon) { - this.lat = lat; - this.lon = lon; - this.h = 0; - } - - public GeodeticPosition(double lat, double lon, double h) { - this.lat = lat; - this.lon = lon; - this.h = h; - } -} +package com.jhlabs.map; + +public class GeodeticPosition { + + public double lat; + public double lon; + public double h; + + public GeodeticPosition() { + lat = 0; + lon = 0; + h = 0; + } + + public GeodeticPosition(double lat, double lon) { + this.lat = lat; + this.lon = lon; + this.h = 0; + } + + public GeodeticPosition(double lat, double lon, double h) { + this.lat = lat; + this.lon = lon; + this.h = h; + } +} diff --git a/src/com/jhlabs/map/proj/Apian1Projection.java b/src/com/jhlabs/map/proj/Apian1Projection.java index 828ac22..3c2a9d3 100644 --- a/src/com/jhlabs/map/proj/Apian1Projection.java +++ b/src/com/jhlabs/map/proj/Apian1Projection.java @@ -73,7 +73,7 @@ public Year getYear() { @Override public String getAuthor() { - return "Peter Apian (Peter Bienewitz) (14951552)"; + return "Peter Apian (Peter Bienewitz) (1495-1552)"; } @Override diff --git a/src/com/jhlabs/map/proj/Apian2Projection.java b/src/com/jhlabs/map/proj/Apian2Projection.java index f8fb39b..1ccc553 100644 --- a/src/com/jhlabs/map/proj/Apian2Projection.java +++ b/src/com/jhlabs/map/proj/Apian2Projection.java @@ -63,7 +63,7 @@ public Year getYear() { @Override public String getAuthor() { - return "Peter Apian (Peter Bienewitz) (14951552)"; + return "Peter Apian (Peter Bienewitz) (1495-1552)"; } @Override diff --git a/src/com/jhlabs/map/proj/BaconProjection.java b/src/com/jhlabs/map/proj/BaconProjection.java index bf910a1..8a8fae4 100644 --- a/src/com/jhlabs/map/proj/BaconProjection.java +++ b/src/com/jhlabs/map/proj/BaconProjection.java @@ -76,7 +76,7 @@ public Year getYear() { @Override public String getAuthor() { - return "Roger Bacon (12141294)"; + return "Roger Bacon (1214-1294)"; } @Override diff --git a/src/com/jhlabs/map/proj/BonneProjection.java b/src/com/jhlabs/map/proj/BonneProjection.java index 06ddb9b..85eb3b1 100644 --- a/src/com/jhlabs/map/proj/BonneProjection.java +++ b/src/com/jhlabs/map/proj/BonneProjection.java @@ -161,6 +161,6 @@ public String getHistoryDescription() { + " 1511 and Honter in 1561. Accurate use by De l'Isle before " + "1700, Coronelli in 1696. Named after Rigobert Bonne (1727-1795). " + "The Werner projection was invented by Johannes Stabius " - + "around 1500 and promoted by Johannes Werner (14661528)."; + + "around 1500 and promoted by Johannes Werner (1466-1528)."; } } diff --git a/src/com/jhlabs/map/proj/CassiniProjection.java b/src/com/jhlabs/map/proj/CassiniProjection.java index d262c54..e1422f4 100644 --- a/src/com/jhlabs/map/proj/CassiniProjection.java +++ b/src/com/jhlabs/map/proj/CassiniProjection.java @@ -134,12 +134,12 @@ public Year getYear() { @Override public String getAuthor() { - return "Csar Franois Cassini de Thury (1714-1784)"; + return "César François Cassini de Thury (1714-1784)"; } @Override public String getDescription() { - return super.getDescription() + "\nTransverse aspect of Plate Carre."; + return super.getDescription() + "\nTransverse aspect of Plate Carrée."; } } diff --git a/src/com/jhlabs/map/proj/CylindricalEqualAreaProjection.java b/src/com/jhlabs/map/proj/CylindricalEqualAreaProjection.java index b0e9074..ab4d927 100644 --- a/src/com/jhlabs/map/proj/CylindricalEqualAreaProjection.java +++ b/src/com/jhlabs/map/proj/CylindricalEqualAreaProjection.java @@ -119,6 +119,6 @@ public Year getYear() { @Override public String getAuthor() { - return "Johann Heinrich Lambert (17281777)"; + return "Johann Heinrich Lambert (1728-1777)"; } } diff --git a/src/com/jhlabs/map/proj/HufnagelProjection.java b/src/com/jhlabs/map/proj/HufnagelProjection.java index aee492a..8c49e40 100644 --- a/src/com/jhlabs/map/proj/HufnagelProjection.java +++ b/src/com/jhlabs/map/proj/HufnagelProjection.java @@ -19,8 +19,8 @@ /** * The Hufnagel projection family was introduced by Herbert Hufnagel in - * "Hufnagel, H. 1989. Ein System unecht-zylindrischer Kartennetze fr - * Erdkarten. Kartographische Nachrichten, 39(3), 8996." All projections are + * "Hufnagel, H. 1989. Ein System unecht-zylindrischer Kartennetze für + * Erdkarten. Kartographische Nachrichten, 39(3), 89-96." All projections are * equal-area. Implementation by Bernhard Jenny, Oregon State University, Bojan * Savric, Oregon State University, with substantial contributions by Daniel * "daan" Strebe, Mapthematics. November 2014 to October 2015. @@ -115,7 +115,7 @@ private double approximatePsiFromTable(double v, double[] table) { } else if (vAbs > table[imid]) { imin = imid; } else { - // abs(phi) < latitudeTable[mid], or abs(phi) == latitudeTable[mid] and mid 0 + // abs(phi) < latitudeTable[mid], or abs(phi) == latitudeTable[mid] and mid ­ 0 imax = imid; } } diff --git a/src/com/jhlabs/map/proj/LagrangeProjection.java b/src/com/jhlabs/map/proj/LagrangeProjection.java index 442cc49..101fce7 100644 --- a/src/com/jhlabs/map/proj/LagrangeProjection.java +++ b/src/com/jhlabs/map/proj/LagrangeProjection.java @@ -97,6 +97,6 @@ public Year getYear() { @Override public String getAuthor() { - return "Johann Heinrich Lambert (17281777) and Joseph Louis Lagrange (17361813)"; + return "Johann Heinrich Lambert (1728-1777) and Joseph Louis Lagrange (1736-1813)"; } } diff --git a/src/com/jhlabs/map/proj/LambertAzimuthalEqualAreaProjection.java b/src/com/jhlabs/map/proj/LambertAzimuthalEqualAreaProjection.java index 28839e9..c1b3e16 100644 --- a/src/com/jhlabs/map/proj/LambertAzimuthalEqualAreaProjection.java +++ b/src/com/jhlabs/map/proj/LambertAzimuthalEqualAreaProjection.java @@ -84,6 +84,6 @@ public Year getYear() { @Override public String getAuthor() { - return "Johann Heinrich Lambert (17281777)"; + return "Johann Heinrich Lambert (1728-1777)"; } } diff --git a/src/com/jhlabs/map/proj/LambertConformalConicProjection.java b/src/com/jhlabs/map/proj/LambertConformalConicProjection.java index 88fff24..5ac7086 100644 --- a/src/com/jhlabs/map/proj/LambertConformalConicProjection.java +++ b/src/com/jhlabs/map/proj/LambertConformalConicProjection.java @@ -150,7 +150,7 @@ public Year getYear() { @Override public String getAuthor() { - return "Johann Heinrich Lambert (17281777)"; + return "Johann Heinrich Lambert (1728-1777)"; } } diff --git a/src/com/jhlabs/map/proj/LambertEqualAreaConicProjection.java b/src/com/jhlabs/map/proj/LambertEqualAreaConicProjection.java index 8f5262a..727965e 100644 --- a/src/com/jhlabs/map/proj/LambertEqualAreaConicProjection.java +++ b/src/com/jhlabs/map/proj/LambertEqualAreaConicProjection.java @@ -47,6 +47,6 @@ public Year getYear() { @Override public String getAuthor() { - return "Johann Heinrich Lambert (17281777)"; + return "Johann Heinrich Lambert (1728-1777)"; } } diff --git a/src/com/jhlabs/map/proj/NZMGProjection.java b/src/com/jhlabs/map/proj/NZMGProjection.java index 5185580..f4a37d1 100755 --- a/src/com/jhlabs/map/proj/NZMGProjection.java +++ b/src/com/jhlabs/map/proj/NZMGProjection.java @@ -1,99 +1,99 @@ -/** -Contributed by Andrey Novikov, September 2011. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ - -package com.jhlabs.map.proj; - -import com.jhlabs.map.MapMath; -import java.awt.geom.Point2D; - -public class NZMGProjection extends Projection { - - private static final double SEC5_TO_RAD = 0.4848136811095359935899141023; - private static final double RAD_TO_SEC5 = 2.062648062470963551564733573; - private static final double bf[][] = { - {.7557853228, 0.0}, - {.249204646, .003371507}, - {-.001541739, .041058560}, - {-.10162907, .01727609}, - {-.26623489, -.36249218}, - {-.6870983, -1.1651967}}; - private static final double tphi[] = {1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594, - .007317, .01220, .00394, -.0013}; - private static final double tpsi[] = {.6399175073, -.1358797613, .063294409, -.02526853, .0117879, - -.0055161, .0026906, -.001333, .00067, -.00034}; - - public void initialize() { - // force to International major axis - a = 6378388.0; - super.initialize(); - //ra = 1. / a; - projectionLongitude = DTR * 173.; - projectionLatitude = DTR * -41.; - falseEasting = 2510000.; - falseNorthing = 6023150.; - } - - public Point2D.Double project(double lam, double phi, Point2D.Double xy) { - double[] p = new double[2]; - - phi = (phi - projectionLatitude) * RAD_TO_SEC5; - p[0] = tpsi[tpsi.length - 1]; - for (int i = tpsi.length - 2; i >= 0; i--) { - p[0] = tpsi[i] + phi * p[0]; - } - p[0] *= phi; - p[1] = lam; - p = MapMath.zpoly1(p, bf, bf.length); - xy.x = p[1]; - xy.y = p[0]; - return xy; - } - - public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { - int nn, i; - double[] p = new double[2], f, fp = new double[2], dp = new double[2]; - double den; - - p[0] = y; - p[1] = x; - for (nn = 20; nn > 0; --nn) { - f = MapMath.zpolyd1(p, bf, bf.length, fp); - f[0] -= y; - f[1] -= x; - den = fp[0] * fp[0] + fp[1] * fp[1]; - p[0] += dp[0] = -(f[0] * fp[0] + f[1] * fp[1]) / den; - p[1] += dp[1] = -(f[1] * fp[0] - f[0] * fp[1]) / den; - if ((Math.abs(dp[0]) + Math.abs(dp[1])) <= EPS10) { - break; - } - } - lp.x = p[1]; - lp.y = tphi[tphi.length - 1]; - for (i = tphi.length - 2; i >= 0; --i) { - lp.y = tphi[i] + p[0] * lp.y; - } - lp.y = projectionLatitude + p[0] * lp.y * SEC5_TO_RAD; - return lp; - } - - public boolean hasInverse() { - return true; - } - - public String toString() { - return "New Zealand Map Grid"; - } -} +/** +Contributed by Andrey Novikov, September 2011. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ + +package com.jhlabs.map.proj; + +import com.jhlabs.map.MapMath; +import java.awt.geom.Point2D; + +public class NZMGProjection extends Projection { + + private static final double SEC5_TO_RAD = 0.4848136811095359935899141023; + private static final double RAD_TO_SEC5 = 2.062648062470963551564733573; + private static final double bf[][] = { + {.7557853228, 0.0}, + {.249204646, .003371507}, + {-.001541739, .041058560}, + {-.10162907, .01727609}, + {-.26623489, -.36249218}, + {-.6870983, -1.1651967}}; + private static final double tphi[] = {1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594, + .007317, .01220, .00394, -.0013}; + private static final double tpsi[] = {.6399175073, -.1358797613, .063294409, -.02526853, .0117879, + -.0055161, .0026906, -.001333, .00067, -.00034}; + + public void initialize() { + // force to International major axis + a = 6378388.0; + super.initialize(); + //ra = 1. / a; + projectionLongitude = DTR * 173.; + projectionLatitude = DTR * -41.; + falseEasting = 2510000.; + falseNorthing = 6023150.; + } + + public Point2D.Double project(double lam, double phi, Point2D.Double xy) { + double[] p = new double[2]; + + phi = (phi - projectionLatitude) * RAD_TO_SEC5; + p[0] = tpsi[tpsi.length - 1]; + for (int i = tpsi.length - 2; i >= 0; i--) { + p[0] = tpsi[i] + phi * p[0]; + } + p[0] *= phi; + p[1] = lam; + p = MapMath.zpoly1(p, bf, bf.length); + xy.x = p[1]; + xy.y = p[0]; + return xy; + } + + public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { + int nn, i; + double[] p = new double[2], f, fp = new double[2], dp = new double[2]; + double den; + + p[0] = y; + p[1] = x; + for (nn = 20; nn > 0; --nn) { + f = MapMath.zpolyd1(p, bf, bf.length, fp); + f[0] -= y; + f[1] -= x; + den = fp[0] * fp[0] + fp[1] * fp[1]; + p[0] += dp[0] = -(f[0] * fp[0] + f[1] * fp[1]) / den; + p[1] += dp[1] = -(f[1] * fp[0] - f[0] * fp[1]) / den; + if ((Math.abs(dp[0]) + Math.abs(dp[1])) <= EPS10) { + break; + } + } + lp.x = p[1]; + lp.y = tphi[tphi.length - 1]; + for (i = tphi.length - 2; i >= 0; --i) { + lp.y = tphi[i] + p[0] * lp.y; + } + lp.y = projectionLatitude + p[0] * lp.y * SEC5_TO_RAD; + return lp; + } + + public boolean hasInverse() { + return true; + } + + public String toString() { + return "New Zealand Map Grid"; + } +} diff --git a/src/com/jhlabs/map/proj/SwissObliqueMercatorProjection.java b/src/com/jhlabs/map/proj/SwissObliqueMercatorProjection.java index e993c88..84ca955 100755 --- a/src/com/jhlabs/map/proj/SwissObliqueMercatorProjection.java +++ b/src/com/jhlabs/map/proj/SwissObliqueMercatorProjection.java @@ -1,99 +1,99 @@ -/** -Contributed by Andrey Novikov, September 2011. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ - -package com.jhlabs.map.proj; - -import com.jhlabs.map.MapMath; -import java.awt.geom.Point2D; - -public class SwissObliqueMercatorProjection extends CylindricalProjection { - - private double K, c, hlf_e, kR, cosp0, sinp0; - private static final int NITER = 6; - - public void initialize() { - super.initialize(); - - double cp, phip0, sp; - - hlf_e = 0.5 * e; - cp = Math.cos(projectionLatitude); - cp *= cp; - c = Math.sqrt(1 + es * cp * cp * rone_es); - sp = Math.sin(projectionLatitude); - phip0 = Math.asin(sinp0 = sp / c); - cosp0 = Math.cos(phip0); - sp *= e; - K = Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip0)) - c * (Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * projectionLatitude)) - hlf_e - * Math.log((1. + sp) / (1. - sp))); - kR = scaleFactor * Math.sqrt(one_es) / (1. - sp * sp); - } - - public Point2D.Double project(double lam, double phi, Point2D.Double xy) { - double phip, lamp, phipp, lampp, sp, cp; - - sp = e * Math.sin(phi); - phip = 2. * Math.atan(Math.exp(c * (Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phi)) - hlf_e * Math.log((1. + sp) / (1. - sp))) - + K)) - MapMath.HALFPI; - lamp = c * lam; - cp = Math.cos(phip); - phipp = Math.asin(cosp0 * Math.sin(phip) - sinp0 * cp * Math.cos(lamp)); - lampp = Math.asin(cp * Math.sin(lamp) / Math.cos(phipp)); - xy.x = kR * lampp; - xy.y = kR * Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phipp)); - return xy; - } - - public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { - double phip, lamp, phipp, lampp, cp, esp, con, delp; - int i; - - phipp = 2. * (Math.atan(Math.exp(y / kR)) - MapMath.QUARTERPI); - lampp = x / kR; - cp = Math.cos(phipp); - phip = Math.asin(cosp0 * Math.sin(phipp) + sinp0 * cp * Math.cos(lampp)); - lamp = Math.asin(cp * Math.sin(lampp) / Math.cos(phip)); - con = (K - Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip))) / c; - for (i = NITER; i >= 0; i--) { - esp = e * Math.sin(phip); - delp = (con + Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip)) - hlf_e - * Math.log((1. + esp) / (1. - esp))) - * (1. - esp * esp) * Math.cos(phip) * rone_es; - phip -= delp; - if (Math.abs(delp) < EPS10) { - break; - } - } - - // FIXME TODO error was set in C on this condition - if (i == 0) { - } - - lp.x = phip; - lp.y = lamp / c; - - return lp; - } - - public boolean hasInverse() { - return true; - } - - public String toString() { - // For CH1903 - return "Swiss Oblique Mercator"; - } -} +/** +Contributed by Andrey Novikov, September 2011. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ + +package com.jhlabs.map.proj; + +import com.jhlabs.map.MapMath; +import java.awt.geom.Point2D; + +public class SwissObliqueMercatorProjection extends CylindricalProjection { + + private double K, c, hlf_e, kR, cosp0, sinp0; + private static final int NITER = 6; + + public void initialize() { + super.initialize(); + + double cp, phip0, sp; + + hlf_e = 0.5 * e; + cp = Math.cos(projectionLatitude); + cp *= cp; + c = Math.sqrt(1 + es * cp * cp * rone_es); + sp = Math.sin(projectionLatitude); + phip0 = Math.asin(sinp0 = sp / c); + cosp0 = Math.cos(phip0); + sp *= e; + K = Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip0)) - c * (Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * projectionLatitude)) - hlf_e + * Math.log((1. + sp) / (1. - sp))); + kR = scaleFactor * Math.sqrt(one_es) / (1. - sp * sp); + } + + public Point2D.Double project(double lam, double phi, Point2D.Double xy) { + double phip, lamp, phipp, lampp, sp, cp; + + sp = e * Math.sin(phi); + phip = 2. * Math.atan(Math.exp(c * (Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phi)) - hlf_e * Math.log((1. + sp) / (1. - sp))) + + K)) - MapMath.HALFPI; + lamp = c * lam; + cp = Math.cos(phip); + phipp = Math.asin(cosp0 * Math.sin(phip) - sinp0 * cp * Math.cos(lamp)); + lampp = Math.asin(cp * Math.sin(lamp) / Math.cos(phipp)); + xy.x = kR * lampp; + xy.y = kR * Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phipp)); + return xy; + } + + public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { + double phip, lamp, phipp, lampp, cp, esp, con, delp; + int i; + + phipp = 2. * (Math.atan(Math.exp(y / kR)) - MapMath.QUARTERPI); + lampp = x / kR; + cp = Math.cos(phipp); + phip = Math.asin(cosp0 * Math.sin(phipp) + sinp0 * cp * Math.cos(lampp)); + lamp = Math.asin(cp * Math.sin(lampp) / Math.cos(phip)); + con = (K - Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip))) / c; + for (i = NITER; i >= 0; i--) { + esp = e * Math.sin(phip); + delp = (con + Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip)) - hlf_e + * Math.log((1. + esp) / (1. - esp))) + * (1. - esp * esp) * Math.cos(phip) * rone_es; + phip -= delp; + if (Math.abs(delp) < EPS10) { + break; + } + } + + // FIXME TODO error was set in C on this condition + if (i == 0) { + } + + lp.x = phip; + lp.y = lamp / c; + + return lp; + } + + public boolean hasInverse() { + return true; + } + + public String toString() { + // For CH1903 + return "Swiss Oblique Mercator"; + } +} diff --git a/src/com/jhlabs/map/proj/TransverseMercatorProjection.java b/src/com/jhlabs/map/proj/TransverseMercatorProjection.java index 93f108c..69415ec 100644 --- a/src/com/jhlabs/map/proj/TransverseMercatorProjection.java +++ b/src/com/jhlabs/map/proj/TransverseMercatorProjection.java @@ -202,6 +202,6 @@ public Year getYear() { @Override public String getAuthor() { - return "Johann Heinrich Lambert (17281777)"; + return "Johann Heinrich Lambert (1728-1777)"; } } diff --git a/src/com/jhlabs/map/proj/UniversalTransverseMercatorProjection.java b/src/com/jhlabs/map/proj/UniversalTransverseMercatorProjection.java index b6bb877..f9cb02f 100755 --- a/src/com/jhlabs/map/proj/UniversalTransverseMercatorProjection.java +++ b/src/com/jhlabs/map/proj/UniversalTransverseMercatorProjection.java @@ -1,95 +1,95 @@ -/** -Contributed by Andrey Novikov, September 2011. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ -package com.jhlabs.map.proj; - -import com.jhlabs.map.MapMath; - -public class UniversalTransverseMercatorProjection extends TransverseMercatorProjection { - - protected int utmzone = -1; - - public void initialize() { - // TODO -// if (!P->es) E_ERROR(-34); FIXME - if (utmzone < 0) { - int zone = (int) getZoneFromNearestMeridian(projectionLongitude * RTD); - setUTMZone(zone); - } - super.initialize(); - } - - public int getRowFromNearestParallel(double latitude) { - int degrees = (int)MapMath.radToDeg(MapMath.normalizeLatitude(latitude)); - if (degrees < -80 || degrees > 84) { - return 0; - } - if (degrees > 80) { - return 24; - } - return (degrees + 80) / 8 + 3; - } - - public int getZoneFromNearestMeridian(double longitude) { - - // int zone = (int) (Math.floor(((180.0 + longitude) / 6)) + 1); FIXME - int zone = (int) Math.floor((MapMath.normalizeLongitude(longitude) + Math.PI) * 30.0 / Math.PI) + 1; - if (zone < 1) { - zone = 1; - } else if (zone > 60) { - zone = 60; - } - - /* - if( Lat >= 56.0 && Lat < 64.0 && LongTemp >= 3.0 && LongTemp < 12.0 ) - ZoneNumber = 32; - - // Special zones for Svalbard - if( Lat >= 72.0 && Lat < 84.0 ) - { - if( LongTemp >= 0.0 && LongTemp < 9.0 ) ZoneNumber = 31; - else if( LongTemp >= 9.0 && LongTemp < 21.0 ) ZoneNumber = 33; - else if( LongTemp >= 21.0 && LongTemp < 33.0 ) ZoneNumber = 35; - else if( LongTemp >= 33.0 && LongTemp < 42.0 ) ZoneNumber = 37; - } - */ - - - return zone; - } - - public void setIsSouth(boolean south) { - falseNorthing = south ? 10000000. : 0.; - } - - public void clearUTMZone() { - utmzone = -1; - } - - public void setUTMZone(int zone) { - utmzone = zone - 1; - - projectionLongitude = (utmzone * 6 - 180 + 3) * DTR; //+3 puts origin in middle of zone - projectionLatitude = 0.0; - scaleFactor = 0.9996; - falseNorthing = 0.; - falseEasting = 500000; - //initialize(); FIXME - } - - public String toString() { - return "Universal Transverse Mercator"; - } -} +/** +Contributed by Andrey Novikov, September 2011. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ +package com.jhlabs.map.proj; + +import com.jhlabs.map.MapMath; + +public class UniversalTransverseMercatorProjection extends TransverseMercatorProjection { + + protected int utmzone = -1; + + public void initialize() { + // TODO +// if (!P->es) E_ERROR(-34); FIXME + if (utmzone < 0) { + int zone = (int) getZoneFromNearestMeridian(projectionLongitude * RTD); + setUTMZone(zone); + } + super.initialize(); + } + + public int getRowFromNearestParallel(double latitude) { + int degrees = (int)MapMath.radToDeg(MapMath.normalizeLatitude(latitude)); + if (degrees < -80 || degrees > 84) { + return 0; + } + if (degrees > 80) { + return 24; + } + return (degrees + 80) / 8 + 3; + } + + public int getZoneFromNearestMeridian(double longitude) { + + // int zone = (int) (Math.floor(((180.0 + longitude) / 6)) + 1); FIXME + int zone = (int) Math.floor((MapMath.normalizeLongitude(longitude) + Math.PI) * 30.0 / Math.PI) + 1; + if (zone < 1) { + zone = 1; + } else if (zone > 60) { + zone = 60; + } + + /* + if( Lat >= 56.0 && Lat < 64.0 && LongTemp >= 3.0 && LongTemp < 12.0 ) + ZoneNumber = 32; + + // Special zones for Svalbard + if( Lat >= 72.0 && Lat < 84.0 ) + { + if( LongTemp >= 0.0 && LongTemp < 9.0 ) ZoneNumber = 31; + else if( LongTemp >= 9.0 && LongTemp < 21.0 ) ZoneNumber = 33; + else if( LongTemp >= 21.0 && LongTemp < 33.0 ) ZoneNumber = 35; + else if( LongTemp >= 33.0 && LongTemp < 42.0 ) ZoneNumber = 37; + } + */ + + + return zone; + } + + public void setIsSouth(boolean south) { + falseNorthing = south ? 10000000. : 0.; + } + + public void clearUTMZone() { + utmzone = -1; + } + + public void setUTMZone(int zone) { + utmzone = zone - 1; + + projectionLongitude = (utmzone * 6 - 180 + 3) * DTR; //+3 puts origin in middle of zone + projectionLatitude = 0.0; + scaleFactor = 0.9996; + falseNorthing = 0.; + falseEasting = 500000; + //initialize(); FIXME + } + + public String toString() { + return "Universal Transverse Mercator"; + } +}