Changeset 5066 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-03-10T16:18:23+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/projection
- Files:
-
- 2 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/BelgianLambert1972.java
r5022 r5066 7 7 import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum; 8 8 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; 9 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 9 10 10 11 /** 11 12 * Belgian Lambert 72 projection as specified by the Belgian IGN 12 13 * in this document: http://www.ngi.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf 13 * @author Don-vip 14 * @author Don-vip 14 15 * 15 16 */ … … 19 20 ellps = Ellipsoid.hayford; 20 21 // 7 parameters transformation: http://www.eye4software.com/resources/datum/4313/ 21 datum = new SevenParameterDatum("Belgium Datum 72", null, Ellipsoid.hayford, -99.06, 53.32, -112.49, 0.419, -0.830, 1.885, -1);22 datum = new SevenParameterDatum("Belgium Datum 72", null, ellps, -99.06, 53.32, -112.49, 0.419, -0.830, 1.885, -1); 22 23 x_0 = 150000.013; 23 24 y_0 = 5400088.438; 24 25 lon_0 = convertDegreeMinuteSecond(4, 22, 2.952); 25 double lat_0 = 90.0;26 double lat_1 = 49 + convertMinuteSecond(50, 0.00204);27 double lat_2 = 51 + convertMinuteSecond(10, 0.00204);28 26 proj = new LambertConformalConic(); 29 ((LambertConformalConic)proj).updateParameters2SP(ellps, lat_0, lat_1, lat_2); 27 try { 28 proj.initialize(new ProjParameters() {{ 29 ellps = BelgianLambert1972.this.ellps; 30 lat_0 = 90.0; 31 lat_1 = 49 + convertMinuteSecond(50, 0.00204); 32 lat_2 = 51 + convertMinuteSecond(10, 0.00204); 33 }}); 34 } catch (ProjectionConfigurationException e) { 35 throw new RuntimeException(e); 36 } 30 37 } 31 38 32 39 @Override 33 40 public String getCacheDirectoryName() { … … 46 53 return 31370; 47 54 } 48 55 49 56 @Override 50 57 public String toString() { -
trunk/src/org/openstreetmap/josm/data/projection/BelgianLambert2008.java
r5022 r5066 7 7 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 8 8 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; 9 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 9 10 10 11 /** 11 12 * Belgian Lambert 2008 projection as specified by the Belgian IGN 12 13 * in this document: http://www.ngi.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf 13 * @author Don-vip 14 * @author Don-vip 14 15 * 15 16 */ … … 22 23 y_0 = 665262.0; 23 24 lon_0 = convertDegreeMinuteSecond(4, 21, 33.177); 24 double lat_0 = convertDegreeMinuteSecond(50, 47, 52.134);25 double lat_1 = convertDegreeMinuteSecond(49, 50, 0);26 double lat_2 = convertDegreeMinuteSecond(51, 10, 0);27 25 proj = new LambertConformalConic(); 28 ((LambertConformalConic)proj).updateParameters2SP(ellps, lat_0, lat_1, lat_2); 26 try { 27 proj.initialize(new ProjParameters() {{ 28 ellps = BelgianLambert2008.this.ellps; 29 lat_0 = convertDegreeMinuteSecond(50, 47, 52.134); 30 lat_1 = convertDegreeMinuteSecond(49, 50, 0); 31 lat_2 = convertDegreeMinuteSecond(51, 10, 0); 32 }}); 33 } catch (ProjectionConfigurationException e) { 34 throw new RuntimeException(e); 35 } 29 36 } 30 37 31 38 @Override 32 39 public String getCacheDirectoryName() { … … 45 52 return 3812; 46 53 } 47 54 48 55 @Override 49 56 public String toString() { -
trunk/src/org/openstreetmap/josm/data/projection/Epsg3008.java
r4285 r5066 7 7 import org.openstreetmap.josm.data.coor.LatLon; 8 8 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 9 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 9 10 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 10 11 … … 19 20 public Epsg3008() { 20 21 ellps = Ellipsoid.GRS80; 21 proj = new TransverseMercator(ellps); 22 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); 23 try { 24 proj.initialize(new ProjParameters() {{ ellps = Epsg3008.this.ellps; }}); 25 } catch (ProjectionConfigurationException e) { 26 throw new RuntimeException(e); 27 } 22 28 datum = GRS80Datum.INSTANCE; 23 29 lon_0 = 13.5; 24 30 x_0 = 150000; 25 31 } 26 32 27 33 @Override 28 34 public String toString() { -
trunk/src/org/openstreetmap/josm/data/projection/GaussKrueger.java
r4869 r5066 17 17 import org.openstreetmap.josm.data.Bounds; 18 18 import org.openstreetmap.josm.data.coor.LatLon; 19 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 19 20 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 20 21 import org.openstreetmap.josm.tools.GBC; … … 64 65 // tr("Deutsches Hauptdreiecksnetz"), null, ellps, 65 66 // 598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.70); 66 proj = new TransverseMercator(ellps); 67 proj = new TransverseMercator(); 68 try { 69 proj.initialize(new ProjParameters() {{ ellps = GaussKrueger.this.ellps; }}); 70 } catch (ProjectionConfigurationException e) { 71 throw new RuntimeException(e); 72 } 67 73 x_0 = 1000000 * zone + 500000; 68 74 lon_0 = 3 * zone; -
trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
r4288 r5066 18 18 import org.openstreetmap.josm.data.coor.LatLon; 19 19 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; 20 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 20 21 import org.openstreetmap.josm.tools.GBC; 21 22 import org.openstreetmap.josm.tools.ImageProvider; … … 96 97 updateParameters(DEFAULT_ZONE); 97 98 } 98 99 private void updateParameters( int layoutZone) {99 100 private void updateParameters(final int layoutZone) { 100 101 this.layoutZone = layoutZone; 101 102 ellps = Ellipsoid.clarke; … … 107 108 proj = new LambertConformalConic(); 108 109 } 109 ((LambertConformalConic)proj).updateParametersDirect( 110 Ellipsoid.clarke, n[layoutZone], c[layoutZone] / ellps.a, y_fs[layoutZone] / ellps.a); 111 } 112 113 @Override 110 proj = new LambertConformalConic(); 111 try { 112 proj.initialize(new ProjParameters() {{ 113 ellps = Lambert.this.ellps; 114 lcc_n = n[layoutZone]; 115 lcc_F = c[layoutZone] / ellps.a; 116 lcc_r0 = y_fs[layoutZone] / ellps.a; 117 }}); 118 } catch (ProjectionConfigurationException e) { 119 throw new RuntimeException(e); 120 } 121 } 122 123 @Override 114 124 public String toString() { 115 125 return tr("Lambert 4 Zones (France)"); -
trunk/src/org/openstreetmap/josm/data/projection/Lambert93.java
r4781 r5066 7 7 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 8 8 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; 9 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 9 10 10 11 /** 11 12 * Lambert 93 projection as specified by the IGN 12 13 * in this document http://professionnels.ign.fr/DISPLAY/000/526/702/5267026/NTG_87.pdf 13 * @author Don-vip 14 * @author Don-vip 14 15 * 15 16 */ … … 22 23 y_0 = 6600000; 23 24 lon_0 = 3; 24 double lat_0 = 46.50;25 double lat_1 = 44.00;26 double lat_2 = 49.00;27 25 proj = new LambertConformalConic(); 28 ((LambertConformalConic)proj).updateParameters2SP(ellps, lat_0, lat_1, lat_2); 26 try { 27 proj.initialize(new ProjParameters() {{ 28 ellps = Lambert93.this.ellps; 29 lat_0 = 46.50; 30 lat_1 = 44.00; 31 lat_2 = 49.00; 32 }}); 33 } catch (ProjectionConfigurationException e) { 34 throw new RuntimeException(e); 35 } 29 36 } 30 37 31 38 @Override 32 39 public String getCacheDirectoryName() { … … 45 52 return 2154; 46 53 } 47 54 48 55 @Override 49 56 public String toString() { -
trunk/src/org/openstreetmap/josm/data/projection/LambertCC9Zones.java
r4382 r5066 17 17 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 18 18 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; 19 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 19 20 import org.openstreetmap.josm.tools.GBC; 20 21 import org.openstreetmap.josm.tools.ImageProvider; … … 49 50 } 50 51 51 public void updateParameters( int layoutZone) {52 public void updateParameters(final int layoutZone) { 52 53 ellps = Ellipsoid.GRS80; 53 54 datum = GRS80Datum.INSTANCE; … … 56 57 y_0 = (layoutZone+1) * 1000000 + 200000; 57 58 lon_0 = 3; 58 double lat_0 = 42 + layoutZone;59 double lat_1 = 41.25 + layoutZone;60 double lat_2 = 42.75 + layoutZone;61 59 if (proj == null) { 62 60 proj = new LambertConformalConic(); 63 61 } 64 ((LambertConformalConic)proj).updateParameters2SP(ellps, lat_0, lat_1, lat_2); 62 try { 63 proj.initialize(new ProjParameters() {{ 64 ellps = LambertCC9Zones.this.ellps; 65 lat_0 = 42.0 + layoutZone; 66 lat_1 = 41.25 + layoutZone; 67 lat_2 = 42.75 + layoutZone; 68 }}); 69 } catch (ProjectionConfigurationException e) { 70 throw new RuntimeException(e); 71 } 65 72 } 66 73 -
trunk/src/org/openstreetmap/josm/data/projection/LambertEST.java
r4285 r5066 8 8 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 9 9 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; 10 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 10 11 11 12 /** 12 13 * Estonian Coordinate System of 1997. 13 * 14 * 14 15 * Thanks to Johan Montagnat and its geoconv java converter application 15 16 * (http://www.i3s.unice.fr/~johan/gps/ , published under GPL license) … … 22 23 datum = GRS80Datum.INSTANCE; 23 24 lon_0 = 24; 24 double lat_0 = 57.517553930555555555555555555556;25 double lat_1 = 59 + 1.0/3.0;26 double lat_2 = 58;27 25 x_0 = 500000; 28 26 y_0 = 6375000; 29 27 proj = new LambertConformalConic(); 30 ((LambertConformalConic) proj).updateParameters2SP(ellps, lat_0, lat_1, lat_2); 28 try { 29 proj.initialize(new ProjParameters() {{ 30 ellps = LambertEST.this.ellps; 31 lat_0 = 57.517553930555555555555555555556; 32 lat_1 = 59.0 + 1.0/3.0; 33 lat_2 = 58.0; 34 }}); 35 } catch (ProjectionConfigurationException e) { 36 throw new RuntimeException(e); 37 } 31 38 } 32 39 -
trunk/src/org/openstreetmap/josm/data/projection/Mercator.java
r4285 r5066 7 7 import org.openstreetmap.josm.data.coor.LatLon; 8 8 import org.openstreetmap.josm.data.projection.datum.WGS84Datum; 9 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 9 10 10 11 /** … … 25 26 datum = WGS84Datum.INSTANCE; 26 27 proj = new org.openstreetmap.josm.data.projection.proj.Mercator(); 28 try { 29 proj.initialize(new ProjParameters()); 30 } catch (ProjectionConfigurationException e) { 31 throw new RuntimeException(e); 32 } 27 33 } 28 34 29 @Override 35 @Override 30 36 public String toString() { 31 37 return tr("Mercator"); … … 34 40 @Override 35 41 public Integer getEpsgCode() { 36 /* initially they used 3785 but that has been superseded, 42 /* initially they used 3785 but that has been superseded, 37 43 * see http://www.epsg-registry.org/ */ 38 44 return 3857; -
trunk/src/org/openstreetmap/josm/data/projection/Puwg.java
r4285 r5066 17 17 import org.openstreetmap.josm.data.coor.LatLon; 18 18 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 19 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 19 20 import org.openstreetmap.josm.tools.GBC; 20 21 … … 26 27 */ 27 28 public class Puwg extends AbstractProjection implements ProjectionSubPrefs { 28 29 29 30 public static final int DEFAULT_ZONE = 0; 30 31 31 32 private int zone; 32 33 … … 45 46 public Puwg(int zone) { 46 47 ellps = Ellipsoid.GRS80; 47 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(ellps); 48 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); 49 try { 50 proj.initialize(new ProjParameters() {{ ellps = Puwg.this.ellps; }}); 51 } catch (ProjectionConfigurationException e) { 52 throw new RuntimeException(e); 53 } 48 54 datum = GRS80Datum.INSTANCE; 49 55 updateParameters(zone); 50 56 } 51 57 52 58 public void updateParameters(int zone) { 53 59 this.zone = zone; … … 59 65 } 60 66 61 @Override 67 @Override 62 68 public String toString() { 63 69 return tr("PUWG (Poland)"); … … 176 182 return 2180; 177 183 } 178 184 179 185 @Override 180 186 public String toCode() { -
trunk/src/org/openstreetmap/josm/data/projection/SwissGrid.java
r4341 r5066 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum; 16 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 16 17 import org.openstreetmap.josm.data.projection.proj.SwissObliqueMercator; 17 18 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 20 21 /** 21 22 * SwissGrid CH1903 / L03, see http://de.wikipedia.org/wiki/Swiss_Grid. 22 * 23 * 23 24 * Actually, what we have here, is CH1903+ (EPSG:2056), but without 24 25 * the additional false easting of 2000km and false northing 1000 km. … … 26 27 * To get to CH1903, a shift file is required. So currently, there are errors 27 28 * up to 1.6m (depending on the location). 28 * 29 * 29 30 * This projection does not have any parameters, it only implements 30 31 * ProjectionSubPrefs to show a warning that the grid file correction is not done. … … 38 39 y_0 = 200000; 39 40 lon_0 = 7.0 + 26.0/60 + 22.50/3600; 40 double lat_0 = 46.0 + 57.0/60 + 8.66/3600; 41 proj = new SwissObliqueMercator(ellps, lat_0); 41 proj = new SwissObliqueMercator(); 42 try { 43 proj.initialize(new ProjParameters() {{ 44 ellps = SwissGrid.this.ellps; 45 lat_0 = 46.0 + 57.0/60 + 8.66/3600; 46 }}); 47 } catch (ProjectionConfigurationException e) { 48 throw new RuntimeException(e); 49 } 42 50 } 43 51 -
trunk/src/org/openstreetmap/josm/data/projection/TransverseMercatorLV.java
r4285 r5066 7 7 import org.openstreetmap.josm.data.coor.LatLon; 8 8 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 9 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 9 10 10 11 /** … … 18 19 public TransverseMercatorLV() { 19 20 ellps = Ellipsoid.GRS80; 20 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(ellps); 21 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); 22 try { 23 proj.initialize(new ProjParameters() {{ ellps = TransverseMercatorLV.this.ellps; }}); 24 } catch (ProjectionConfigurationException e) { 25 throw new RuntimeException(e); 26 } 21 27 datum = GRS80Datum.INSTANCE; 22 28 lon_0 = 24; … … 25 31 k_0 = 0.9996; 26 32 } 27 28 @Override 33 34 @Override 29 35 public String toString() { 30 36 return tr("LKS-92 (Latvia TM)"); -
trunk/src/org/openstreetmap/josm/data/projection/UTM.java
r4285 r5066 20 20 import org.openstreetmap.josm.data.coor.LatLon; 21 21 import org.openstreetmap.josm.data.projection.datum.GRS80Datum; 22 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 22 23 import org.openstreetmap.josm.tools.GBC; 23 24 … … 48 49 public UTM(int zone, Hemisphere hemisphere, boolean offset) { 49 50 ellps = Ellipsoid.GRS80; 50 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(ellps); 51 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); 52 try { 53 proj.initialize(new ProjParameters() {{ ellps = UTM.this.ellps; }}); 54 } catch (ProjectionConfigurationException e) { 55 throw new RuntimeException(e); 56 } 51 57 datum = GRS80Datum.INSTANCE; 52 58 updateParameters(zone, hemisphere, offset); -
trunk/src/org/openstreetmap/josm/data/projection/UTM_France_DOM.java
r4285 r5066 19 19 import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum; 20 20 import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum; 21 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 21 22 import org.openstreetmap.josm.tools.GBC; 22 23 … … 24 25 * This class implements all projections for French departements in the Caribbean Sea and 25 26 * Indian Ocean using the UTM transvers Mercator projection and specific geodesic settings (7 parameters transformation algorithm). 26 * 27 * 27 28 */ 28 29 public class UTM_France_DOM extends AbstractProjection implements ProjectionSubPrefs { … … 75 76 updateParameters(DEFAULT_GEODESIC); 76 77 } 77 78 78 79 public void updateParameters(int currentGeodesic) { 79 80 this.currentGeodesic = currentGeodesic; 80 81 datum = utmDatums[currentGeodesic]; 81 82 ellps = datum.getEllipsoid(); 82 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(ellps); 83 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); 84 try { 85 proj.initialize(new ProjParameters() {{ ellps = UTM_France_DOM.this.ellps; }}); 86 } catch (ProjectionConfigurationException e) { 87 throw new RuntimeException(e); 88 } 83 89 isNorth = currentGeodesic != 3; 84 90 zone = utmZones[currentGeodesic]; … … 88 94 k_0 = 0.9996; 89 95 } 90 96 91 97 public int getCurrentGeodesic() { 92 98 return currentGeodesic; 93 99 } 94 100 95 @Override 101 @Override 96 102 public String toString() { 97 103 return tr("UTM France (DOM)"); -
trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java
r5040 r5066 7 7 8 8 import org.openstreetmap.josm.data.projection.Ellipsoid; 9 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 9 10 10 11 /** … … 14 15 */ 15 16 public class LambertConformalConic implements Proj { 16 17 17 18 protected Ellipsoid ellps; 18 19 protected double e; 19 20 20 21 public static abstract class Parameters { 21 22 public final double latitudeOrigin; … … 24 25 } 25 26 }; 26 27 27 28 public static class Parameters1SP extends Parameters { 28 29 public Parameters1SP(double latitudeOrigin) { … … 42 43 43 44 private Parameters params; 44 45 45 46 /** 46 47 * projection exponent … … 52 53 protected double F; 53 54 /** 54 * radius of the parallel of latitude of the false origin (2SP) or at 55 * radius of the parallel of latitude of the false origin (2SP) or at 55 56 * natural origin (1SP) 56 57 */ 57 protected double r0; 58 58 protected double r0; 59 59 60 /** 60 61 * precision in iterative schema … … 62 63 protected static final double epsilon = 1e-12; 63 64 64 /** 65 * Constructor. 66 * Call one of the updateParameters... methods for initialization. 67 */ 68 public LambertConformalConic() { 65 @Override 66 public void initialize(ProjParameters params) throws ProjectionConfigurationException { 67 ellps = params.ellps; 68 e = ellps.e; 69 if (params.lcc_n != null && params.lcc_F != null && params.lcc_r0 != null) { 70 initializeDirect(params.lcc_n, params.lcc_F, params.lcc_r0); 71 } else { 72 if (params.lat_0 == null) 73 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0")); 74 if (params.lat_1 != null && params.lat_2 != null) { 75 initialize2SP(params.lat_0, params.lat_1, params.lat_2); 76 } else { 77 initialize1SP(params.lat_0); 78 } 79 } 69 80 } 70 81 71 82 /** 72 83 * Initialize for LCC with 2 standard parallels. 73 * 74 * @param ellps the ellipsoid 84 * 75 85 * @param lat_0 latitude of false origin (in degrees) 76 86 * @param lat_1 latitude of first standard parallel (in degrees) 77 87 * @param lat_2 latitude of second standard parallel (in degrees) 78 88 */ 79 p ublic void updateParameters2SP(Ellipsoid ellps,double lat_0, double lat_1, double lat_2) {89 private void initialize2SP(double lat_0, double lat_1, double lat_2) { 80 90 this.params = new Parameters2SP(lat_0, lat_1, lat_2); 81 this.ellps = ellps; 82 this.e = ellps.e; 83 91 84 92 final double m1 = m(toRadians(lat_1)); 85 93 final double m2 = m(toRadians(lat_2)); 86 94 87 95 final double t1 = t(toRadians(lat_1)); 88 96 final double t2 = t(toRadians(lat_2)); 89 97 final double tf = t(toRadians(lat_0)); 90 98 91 99 n = (log(m1) - log(m2)) / (log(t1) - log(t2)); 92 100 F = m1 / (n * pow(t1, n)); 93 101 r0 = F * pow(tf, n); 94 102 } 95 103 96 104 /** 97 105 * Initialize for LCC with 1 standard parallel. 98 * 99 * @param ellps the ellipsoid 106 * 100 107 * @param lat_0 latitude of natural origin (in degrees) 101 108 */ 102 p ublic void updateParameters1SP(Ellipsoid ellps,double lat_0) {109 private void initialize1SP(double lat_0) { 103 110 this.params = new Parameters1SP(lat_0); 104 this.ellps = ellps;105 this.e = ellps.e;106 111 final double lat_0_rad = toRadians(lat_0); 107 112 108 113 final double m0 = m(lat_0_rad); 109 114 final double t0 = t(lat_0_rad); 110 115 111 116 n = sin(lat_0_rad); 112 117 F = m0 / (n * pow(t0, n)); … … 116 121 /** 117 122 * Initialize LCC by providing the projection parameters directly. 118 * 119 * @param ellps the ellipsoid 123 * 120 124 * @param n see field n 121 125 * @param F see field F 122 126 * @param r0 see field r0 123 127 */ 124 p ublic void updateParametersDirect(Ellipsoid ellps,double n, double F, double r0) {128 private void initializeDirect(double n, double F, double r0) { 125 129 this.params = null; 126 this.ellps = ellps;127 this.e = ellps.e;128 130 this.n = n; 129 131 this.F = F; … … 145 147 return cos(lat_rad) / (sqrt(1 - e * e * pow(sin(lat_rad), 2))); 146 148 } 147 149 148 150 @Override 149 151 public String getName() { … … 166 168 return new double[] { X, Y }; 167 169 } 168 170 169 171 @Override 170 172 public double[] invproject(double east, double north) { … … 176 178 return new double[] { phi, lambda }; 177 179 } 178 180 179 181 public final Parameters getParameters() { 180 182 return params; -
trunk/src/org/openstreetmap/josm/data/projection/proj/Mercator.java
r4285 r5066 6 6 import static org.openstreetmap.josm.tools.I18n.tr; 7 7 8 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 9 8 10 /** 9 11 * Mercator Projection. 10 12 */ 11 13 public class Mercator implements Proj { 12 14 13 15 @Override 14 16 public String getName() { … … 19 21 public String getProj4Id() { 20 22 return "merc"; 23 } 24 25 @Override 26 public void initialize(ProjParameters params) throws ProjectionConfigurationException { 21 27 } 22 28 -
trunk/src/org/openstreetmap/josm/data/projection/proj/Proj.java
r4285 r5066 2 2 package org.openstreetmap.josm.data.projection.proj; 3 3 4 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 5 4 6 /** 5 7 * A projection (in the narrow sense). 6 * 8 * 7 9 * Converts lat/lon the east/north and the other way around. 8 * 9 * Datum conversion, false easting / northing, origin of longitude 10 * 11 * Datum conversion, false easting / northing, origin of longitude 10 12 * and general scale factor is already applied when the projection is invoked. 11 * 13 * 12 14 * Lat/lon is not in degrees, but in radians (unlike other parts of JOSM). 13 * Additional parameters in the constructor arguments are usually still in 14 * degrees. So to avoid confusion, you can follow the convention, that 15 * Additional parameters in the constructor arguments are usually still in 16 * degrees. So to avoid confusion, you can follow the convention, that 15 17 * coordinates in radians are called lat_rad/lon_rad or phi/lambda. 16 * 17 * East/north values are not in meters, but in meters divided by the semi major 18 * axis of the ellipsoid (earth radius). (Usually this is what you get anyway, 18 * 19 * East/north values are not in meters, but in meters divided by the semi major 20 * axis of the ellipsoid (earth radius). (Usually this is what you get anyway, 19 21 * unless you multiply by 'a' somehow implicitly or explicitly.) 20 22 * … … 28 30 /** 29 31 * The Proj.4 identifier. 30 * 32 * 31 33 * (as reported by cs2cs -lp) 32 34 * If no id exists, return null. 33 35 */ 34 36 String getProj4Id(); 35 37 38 /** 39 * Initialize the projection using the provided parameters. 40 * 41 * @throws ProjectionConfigurationException in case parameters are not suitable 42 */ 43 void initialize(ProjParameters params) throws ProjectionConfigurationException; 44 36 45 /** 37 46 * Convert lat/lon to east/north. 38 * 47 * 39 48 * @param lat_rad the latitude in radians 40 49 * @param lon_rad the longitude in radians … … 43 52 */ 44 53 double[] project(double lat_rad, double lon_rad); 45 54 46 55 /** 47 56 * Convert east/north to lat/lon. 48 * 57 * 49 58 * @param east east value in meters, divided by the semi major axis of the ellipsoid 50 59 * @param north north value in meters, divided by the semi major axis of the ellipsoid … … 52 61 */ 53 62 double[] invproject(double east, double north); 63 54 64 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/SwissObliqueMercator.java
r4285 r5066 7 7 8 8 import org.openstreetmap.josm.data.projection.Ellipsoid; 9 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 9 10 10 11 /** … … 19 20 public class SwissObliqueMercator implements Proj { 20 21 21 private finalEllipsoid ellps;22 private Ellipsoid ellps; 22 23 private double kR; 23 24 private double alpha; 24 25 private double b0; 25 26 private double K; 26 27 27 28 private static final double EPSILON = 1e-11; 28 29 public SwissObliqueMercator(Ellipsoid ellps, double lat_0) { 30 this.ellps = ellps; 31 updateParameters(lat_0); 29 30 @Override 31 public void initialize(ProjParameters params) throws ProjectionConfigurationException { 32 if (params.lat_0 == null) 33 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0")); 34 ellps = params.ellps; 35 initialize(params.lat_0); 32 36 } 33 37 34 p ublic void updateParameters(double lat_0) {38 private void initialize(double lat_0) { 35 39 double phi0 = toRadians(lat_0); 36 40 kR = sqrt(1 - ellps.e2) / (1 - (ellps.e2 * pow(sin(phi0), 2))); … … 41 45 * log((1 + ellps.e * sin(phi0)) / (1 - ellps.e * sin(phi0))); 42 46 } 43 47 44 48 @Override 45 49 public String getName() { … … 94 98 return new double[] { phi, lambda }; 95 99 } 96 100 97 101 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java
r4285 r5066 7 7 8 8 import org.openstreetmap.josm.data.projection.Ellipsoid; 9 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 9 10 10 11 /** … … 13 14 * @author Dirk Stöcker 14 15 * code based on JavaScript from Chuck Taylor 15 * 16 * 16 17 */ 17 18 public class TransverseMercator implements Proj { … … 19 20 protected double a, b; 20 21 21 public TransverseMercator(Ellipsoid ellps) {22 this.a = ellps.a;23 this.b = ellps.b;24 }25 26 22 @Override 27 23 public String getName() { … … 32 28 public String getProj4Id() { 33 29 return "tmerc"; 30 } 31 32 @Override 33 public void initialize(ProjParameters params) throws ProjectionConfigurationException { 34 this.a = params.ellps.a; 35 this.b = params.ellps.b; 34 36 } 35 37 … … 41 43 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 42 44 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 43 * 45 * 44 46 * @param phi Latitude of the point, in radians 45 47 * @param lambda Longitude of the point, in radians … … 49 51 @Override 50 52 public double[] project(double phi, double lambda) { 51 53 52 54 /* Precalculate ep2 */ 53 55 double ep2 = (pow(a, 2.0) - pow(b, 2.0)) / pow(b, 2.0); … … 105 107 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 106 108 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 107 * 109 * 108 110 * Remarks: 109 111 * The local variables Nf, nuf2, tf, and tf2 serve the same purpose as … … 113 115 * x1frac, x2frac, x2poly, x3poly, etc. are to enhance readability and 114 116 * to optimize computations. 115 * 117 * 116 118 * @param x The easting of the point, in meters, divided by the semi major axis of the ellipsoid 117 119 * @param y The northing of the point, in meters, divided by the semi major axis of the ellipsoid … … 190 192 + x7frac * x7poly * pow(x, 7.0) }; 191 193 } 192 194 193 195 /** 194 196 * ArcLengthOfMeridian … … 199 201 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 200 202 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 201 * 203 * 202 204 * @param phi Latitude of the point, in radians 203 205 * @return The ellipsoidal distance of the point from the equator … … 234 236 + (epsilon * sin(8.0 * phi))); 235 237 } 236 238 237 239 /** 238 240 * FootpointLatitude … … 243 245 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 244 246 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 245 * 247 * 246 248 * @param y northing coordinate, in meters, divided by the semi major axis of the ellipsoid 247 249 * @return The footpoint latitude, in radians … … 280 282 + (epsilon_ * sin(8.0 * y_)); 281 283 } 282 284 283 285 }
Note:
See TracChangeset
for help on using the changeset viewer.