source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/projection/UTMFranceDOMProjectionChoice.java@ 12620

Last change on this file since 12620 was 12620, checked in by Don-vip, 7 years ago

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7import java.util.Collections;
8
9import org.openstreetmap.josm.tools.Logging;
10
11/**
12 * ProjectionChoice for various French overseas territories (EPSG:2969,2970,2972,2973,2975).
13 * <p>
14 * @see <a href="https://fr.wikipedia.org/wiki/Système_de_coordonnées_(cartographie)#Dans_les_d.C3.A9partements_d.27Outre-mer">DOM</a>
15 */
16public class UTMFranceDOMProjectionChoice extends ListProjectionChoice {
17
18 private static final String FORT_MARIGOT_NAME = tr("Guadeloupe Fort-Marigot 1949");
19 private static final String SAINTE_ANNE_NAME = tr("Guadeloupe Ste-Anne 1948");
20 private static final String MARTINIQUE_NAME = tr("Martinique Fort Desaix 1952");
21 private static final String REUNION_92_NAME = tr("Reunion RGR92");
22 private static final String GUYANE_92_NAME = tr("Guyane RGFG95");
23 private static final String[] UTM_GEODESIC_NAMES = {FORT_MARIGOT_NAME, SAINTE_ANNE_NAME, MARTINIQUE_NAME, REUNION_92_NAME, GUYANE_92_NAME};
24
25 private static final Integer FORT_MARIGOT_EPSG = 2969;
26 private static final Integer SAINTE_ANNE_EPSG = 2970;
27 private static final Integer MARTINIQUE_EPSG = 2973;
28 private static final Integer REUNION_EPSG = 2975;
29 private static final Integer GUYANE_EPSG = 2972;
30 private static final Integer[] UTM_EPSGS = {FORT_MARIGOT_EPSG, SAINTE_ANNE_EPSG, MARTINIQUE_EPSG, REUNION_EPSG, GUYANE_EPSG };
31
32 /**
33 * Constructs a new {@code UTMFranceDOMProjectionChoice}.
34 */
35 public UTMFranceDOMProjectionChoice() {
36 super(tr("UTM France (DOM)"), /* NO-ICON */ "core:utmfrancedom", UTM_GEODESIC_NAMES, tr("UTM Geodesic system"));
37 }
38
39 @Override
40 protected String indexToZone(int index) {
41 return Integer.toString(index + 1);
42 }
43
44 @Override
45 protected int zoneToIndex(String zone) {
46 try {
47 return Integer.parseInt(zone) - 1;
48 } catch (NumberFormatException e) {
49 Logging.warn(e);
50 }
51 return defaultIndex;
52 }
53
54 @Override
55 public String getProjectionName() {
56 return UTM_GEODESIC_NAMES[index];
57 }
58
59 @Override
60 public String getCurrentCode() {
61 return "EPSG:" + UTM_EPSGS[index];
62 }
63
64 @Override
65 public String[] allCodes() {
66 String[] res = new String[UTM_EPSGS.length];
67 for (int i = 0; i < UTM_EPSGS.length; ++i) {
68 res[i] = "EPSG:" + UTM_EPSGS[i];
69 }
70 return res;
71 }
72
73 @Override
74 public Collection<String> getPreferencesFromCode(String code) {
75 for (int i = 0; i < UTM_EPSGS.length; i++) {
76 if (("EPSG:" + UTM_EPSGS[i]).equals(code))
77 return Collections.singleton(Integer.toString(i+1));
78 }
79 return null;
80 }
81}
Note: See TracBrowser for help on using the repository browser.