source: josm/trunk/src/org/openstreetmap/josm/data/projection/UTM_France_DOM.java@ 4869

Last change on this file since 4869 was 4285, checked in by bastiK, 13 years ago

major projection rework

More modular structure, inspired by Proj.4.

There are almost no semantic changes to the projection algorithms. Mostly factors of 'a' and 180/PI have been moved from one place to the other. In UTM_France_DOM, the ellipsoid conversion for the first 3 projections has been changed from hayford <-> GRS80 to hayford <-> WGS84.

Some redundant algorithms have been removed. In particular:

  • UTM_France_DOM used to have its own Transverse Mercator implementation. It is different from the implementation in TransverseMercator.java as it has another series expansion. For EPSG::2975, there are numeric differences on centimeter scale. However, the new data fits better with Proj.4 output.
  • Also removed are alternate implementations of LambertConformalConic. (They are all quite similar, though.)
  • Property svn:eol-style set to native
File size: 6.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagLayout;
7import java.awt.event.ActionListener;
8import java.util.Collection;
9import java.util.Collections;
10
11import javax.swing.JComboBox;
12import javax.swing.JLabel;
13import javax.swing.JPanel;
14
15import org.openstreetmap.josm.data.Bounds;
16import org.openstreetmap.josm.data.coor.LatLon;
17import org.openstreetmap.josm.data.projection.datum.Datum;
18import org.openstreetmap.josm.data.projection.datum.GRS80Datum;
19import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum;
20import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum;
21import org.openstreetmap.josm.tools.GBC;
22
23/**
24 * This class implements all projections for French departements in the Caribbean Sea and
25 * Indian Ocean using the UTM transvers Mercator projection and specific geodesic settings (7 parameters transformation algorithm).
26 *
27 */
28public class UTM_France_DOM extends AbstractProjection implements ProjectionSubPrefs {
29
30 private final static String FortMarigotName = tr("Guadeloupe Fort-Marigot 1949");
31 private final static String SainteAnneName = tr("Guadeloupe Ste-Anne 1948");
32 private final static String MartiniqueName = tr("Martinique Fort Desaix 1952");
33 private final static String Reunion92Name = tr("Reunion RGR92");
34 private final static String Guyane92Name = tr("Guyane RGFG95");
35 private final static String[] utmGeodesicsNames = { FortMarigotName, SainteAnneName, MartiniqueName, Reunion92Name, Guyane92Name};
36
37 private final static Bounds FortMarigotBounds = new Bounds( new LatLon(17.6,-63.25), new LatLon(18.5,-62.5));
38 private final static Bounds SainteAnneBounds = new Bounds( new LatLon(15.8,-61.9), new LatLon(16.6,-60.9));
39 private final static Bounds MartiniqueBounds = new Bounds( new LatLon(14.25,-61.25), new LatLon(15.025,-60.725));
40 private final static Bounds ReunionBounds = new Bounds( new LatLon(-25.92,37.58), new LatLon(-10.6, 58.27));
41 private final static Bounds GuyaneBounds = new Bounds( new LatLon(2.16 , -54.0), new LatLon(9.06 , -49.62));
42 private final static Bounds[] utmBounds = { FortMarigotBounds, SainteAnneBounds, MartiniqueBounds, ReunionBounds, GuyaneBounds };
43
44 private final static Integer FortMarigotEPSG = 2969;
45 private final static Integer SainteAnneEPSG = 2970;
46 private final static Integer MartiniqueEPSG = 2973;
47 private final static Integer ReunionEPSG = 2975;
48 private final static Integer GuyaneEPSG = 2972;
49 private final static Integer[] utmEPSGs = { FortMarigotEPSG, SainteAnneEPSG, MartiniqueEPSG, ReunionEPSG, GuyaneEPSG };
50
51 private final static Datum FortMarigotDatum = new ThreeParameterDatum("FortMarigot Datum", null, Ellipsoid.hayford, 136.596, 248.148, -429.789);
52 private final static Datum SainteAnneDatum = new SevenParameterDatum("SainteAnne Datum", null, Ellipsoid.hayford, -472.29, -5.63, -304.12, 0.4362, -0.8374, 0.2563, 1.8984);
53 private final static Datum MartiniqueDatum = new SevenParameterDatum("Martinique Datum", null, Ellipsoid.hayford, 126.926, 547.939, 130.409, -2.78670, 5.16124, -0.85844, 13.82265);
54 private final static Datum ReunionDatum = GRS80Datum.INSTANCE;
55 private final static Datum GuyaneDatum = GRS80Datum.INSTANCE;
56 private final static Datum[] utmDatums = { FortMarigotDatum, SainteAnneDatum, MartiniqueDatum, ReunionDatum, GuyaneDatum };
57
58 private final static int[] utmZones = { 20, 20, 20, 40, 22 };
59
60 /**
61 * UTM zone (from 1 to 60)
62 */
63 private static int zone;
64 /**
65 * whether north or south hemisphere
66 */
67 private boolean isNorth;
68
69 public static final int DEFAULT_GEODESIC = 0;
70
71 public int currentGeodesic;
72
73
74 public UTM_France_DOM() {
75 updateParameters(DEFAULT_GEODESIC);
76 }
77
78 public void updateParameters(int currentGeodesic) {
79 this.currentGeodesic = currentGeodesic;
80 datum = utmDatums[currentGeodesic];
81 ellps = datum.getEllipsoid();
82 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(ellps);
83 isNorth = currentGeodesic != 3;
84 zone = utmZones[currentGeodesic];
85 x_0 = 500000;
86 y_0 = isNorth ? 0.0 : 10000000.0;
87 lon_0 = 6 * zone - 183;
88 k_0 = 0.9996;
89 }
90
91 public int getCurrentGeodesic() {
92 return currentGeodesic;
93 }
94
95 @Override
96 public String toString() {
97 return tr("UTM France (DOM)");
98 }
99
100 @Override
101 public String getCacheDirectoryName() {
102 return this.toString();
103 }
104
105 @Override
106 public Bounds getWorldBoundsLatLon() {
107 return utmBounds[currentGeodesic];
108 }
109
110 @Override
111 public Integer getEpsgCode() {
112 return utmEPSGs[currentGeodesic];
113 }
114
115 @Override
116 public int hashCode() {
117 return getClass().getName().hashCode()+currentGeodesic; // our only real variable
118 }
119
120 @Override
121 public void setupPreferencePanel(JPanel p, ActionListener listener) {
122 JComboBox prefcb = new JComboBox(utmGeodesicsNames);
123
124 prefcb.setSelectedIndex(currentGeodesic);
125 p.setLayout(new GridBagLayout());
126 p.add(new JLabel(tr("UTM Geodesic system")), GBC.std().insets(5,5,0,5));
127 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
128 p.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL));
129 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));
130 if (listener != null) {
131 prefcb.addActionListener(listener);
132 }
133 }
134
135 @Override
136 public Collection<String> getPreferences(JPanel p) {
137 Object prefcb = p.getComponent(2);
138 if(!(prefcb instanceof JComboBox))
139 return null;
140 currentGeodesic = ((JComboBox)prefcb).getSelectedIndex();
141 return Collections.singleton(Integer.toString(currentGeodesic+1));
142 }
143
144 @Override
145 public String[] allCodes() {
146 String[] res = new String[utmEPSGs.length];
147 for (int i=0; i<utmEPSGs.length; ++i) {
148 res[i] = "EPSG:"+utmEPSGs[i];
149 }
150 return res;
151 }
152
153 @Override
154 public Collection<String> getPreferencesFromCode(String code) {
155 for (int i=0; i < utmEPSGs.length; i++ )
156 if (("EPSG:"+utmEPSGs[i]).equals(code))
157 return Collections.singleton(Integer.toString(i+1));
158 return null;
159 }
160
161 @Override
162 public void setPreferences(Collection<String> args) {
163 int currentGeodesic = DEFAULT_GEODESIC;
164 if (args != null) {
165 try {
166 for(String s : args)
167 {
168 currentGeodesic = Integer.parseInt(s)-1;
169 if(currentGeodesic < 0 || currentGeodesic >= utmEPSGs.length) {
170 currentGeodesic = DEFAULT_GEODESIC;
171 }
172 break;
173 }
174 } catch(NumberFormatException e) {}
175 }
176 updateParameters(currentGeodesic);
177 }
178}
Note: See TracBrowser for help on using the repository browser.