1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences.projection;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Collection;
|
---|
7 | import java.util.Collections;
|
---|
8 |
|
---|
9 | public class UTMFranceDOMProjectionChoice extends ListProjectionChoice {
|
---|
10 |
|
---|
11 | private final static String FortMarigotName = tr("Guadeloupe Fort-Marigot 1949");
|
---|
12 | private final static String SainteAnneName = tr("Guadeloupe Ste-Anne 1948");
|
---|
13 | private final static String MartiniqueName = tr("Martinique Fort Desaix 1952");
|
---|
14 | private final static String Reunion92Name = tr("Reunion RGR92");
|
---|
15 | private final static String Guyane92Name = tr("Guyane RGFG95");
|
---|
16 | private final static String[] utmGeodesicsNames = { FortMarigotName, SainteAnneName, MartiniqueName, Reunion92Name, Guyane92Name};
|
---|
17 |
|
---|
18 | private final static Integer FortMarigotEPSG = 2969;
|
---|
19 | private final static Integer SainteAnneEPSG = 2970;
|
---|
20 | private final static Integer MartiniqueEPSG = 2973;
|
---|
21 | private final static Integer ReunionEPSG = 2975;
|
---|
22 | private final static Integer GuyaneEPSG = 2972;
|
---|
23 | private final static Integer[] utmEPSGs = { FortMarigotEPSG, SainteAnneEPSG, MartiniqueEPSG, ReunionEPSG, GuyaneEPSG };
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Constructs a new {@code UTMFranceDOMProjectionChoice}.
|
---|
27 | */
|
---|
28 | public UTMFranceDOMProjectionChoice() {
|
---|
29 | super(tr("UTM France (DOM)"), "core:utmfrancedom", utmGeodesicsNames, tr("UTM Geodesic system"));
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | protected String indexToZone(int index) {
|
---|
34 | return Integer.toString(index + 1);
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | protected int zoneToIndex(String zone) {
|
---|
39 | try {
|
---|
40 | return Integer.parseInt(zone) - 1;
|
---|
41 | } catch(NumberFormatException e) {}
|
---|
42 | return defaultIndex;
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Override
|
---|
46 | public String getProjectionName() {
|
---|
47 | return utmGeodesicsNames[index];
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public String getCurrentCode() {
|
---|
52 | return "EPSG:" + utmEPSGs[index];
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | public String[] allCodes() {
|
---|
57 | String[] res = new String[utmEPSGs.length];
|
---|
58 | for (int i=0; i<utmEPSGs.length; ++i) {
|
---|
59 | res[i] = "EPSG:" + utmEPSGs[i];
|
---|
60 | }
|
---|
61 | return res;
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Override
|
---|
65 | public Collection<String> getPreferencesFromCode(String code) {
|
---|
66 | for (int i=0; i < utmEPSGs.length; i++ )
|
---|
67 | if (("EPSG:" + utmEPSGs[i]).equals(code))
|
---|
68 | return Collections.singleton(Integer.toString(i+1));
|
---|
69 | return null;
|
---|
70 | }
|
---|
71 |
|
---|
72 | }
|
---|