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

Last change on this file was 16438, checked in by simon04, 6 years ago

see #19251 - Java 8: use Stream

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