001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.preferences.projection; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.util.Collection; 007import java.util.Collections; 008 009public class UTMFranceDOMProjectionChoice extends ListProjectionChoice { 010 011 private final static String FortMarigotName = tr("Guadeloupe Fort-Marigot 1949"); 012 private final static String SainteAnneName = tr("Guadeloupe Ste-Anne 1948"); 013 private final static String MartiniqueName = tr("Martinique Fort Desaix 1952"); 014 private final static String Reunion92Name = tr("Reunion RGR92"); 015 private final static String Guyane92Name = tr("Guyane RGFG95"); 016 private final static String[] utmGeodesicsNames = { FortMarigotName, SainteAnneName, MartiniqueName, Reunion92Name, Guyane92Name}; 017 018 private final static Integer FortMarigotEPSG = 2969; 019 private final static Integer SainteAnneEPSG = 2970; 020 private final static Integer MartiniqueEPSG = 2973; 021 private final static Integer ReunionEPSG = 2975; 022 private final static Integer GuyaneEPSG = 2972; 023 private final static Integer[] utmEPSGs = { FortMarigotEPSG, SainteAnneEPSG, MartiniqueEPSG, ReunionEPSG, GuyaneEPSG }; 024 025 /** 026 * Constructs a new {@code UTMFranceDOMProjectionChoice}. 027 */ 028 public UTMFranceDOMProjectionChoice() { 029 super(tr("UTM France (DOM)"), "core:utmfrancedom", utmGeodesicsNames, tr("UTM Geodesic system")); 030 } 031 032 @Override 033 protected String indexToZone(int index) { 034 return Integer.toString(index + 1); 035 } 036 037 @Override 038 protected int zoneToIndex(String zone) { 039 try { 040 return Integer.parseInt(zone) - 1; 041 } catch(NumberFormatException e) {} 042 return defaultIndex; 043 } 044 045 @Override 046 public String getProjectionName() { 047 return utmGeodesicsNames[index]; 048 } 049 050 @Override 051 public String getCurrentCode() { 052 return "EPSG:" + utmEPSGs[index]; 053 } 054 055 @Override 056 public String[] allCodes() { 057 String[] res = new String[utmEPSGs.length]; 058 for (int i=0; i<utmEPSGs.length; ++i) { 059 res[i] = "EPSG:" + utmEPSGs[i]; 060 } 061 return res; 062 } 063 064 @Override 065 public Collection<String> getPreferencesFromCode(String code) { 066 for (int i=0; i < utmEPSGs.length; i++ ) 067 if (("EPSG:" + utmEPSGs[i]).equals(code)) 068 return Collections.singleton(Integer.toString(i+1)); 069 return null; 070 } 071 072}