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