001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.gui.preferences.projection; 003 004 import static org.openstreetmap.josm.tools.I18n.tr; 005 006 import java.util.Collection; 007 import java.util.Collections; 008 009 public class UTM_France_DOM_ProjectionChoice 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 public UTM_France_DOM_ProjectionChoice() { 026 super(tr("UTM France (DOM)"), "core:utmfrancedom", utmGeodesicsNames, tr("UTM Geodesic system")); 027 } 028 029 @Override 030 protected String indexToZone(int index) { 031 return Integer.toString(index + 1); 032 } 033 034 @Override 035 protected int zoneToIndex(String zone) { 036 try { 037 return Integer.parseInt(zone) - 1; 038 } catch(NumberFormatException e) {} 039 return defaultIndex; 040 } 041 042 @Override 043 public String getProjectionName() { 044 return utmGeodesicsNames[index]; 045 } 046 047 @Override 048 public String getCurrentCode() { 049 return "EPSG:" + utmEPSGs[index]; 050 } 051 052 @Override 053 public String[] allCodes() { 054 String[] res = new String[utmEPSGs.length]; 055 for (int i=0; i<utmEPSGs.length; ++i) { 056 res[i] = "EPSG:" + utmEPSGs[i]; 057 } 058 return res; 059 } 060 061 @Override 062 public Collection<String> getPreferencesFromCode(String code) { 063 for (int i=0; i < utmEPSGs.length; i++ ) 064 if (("EPSG:" + utmEPSGs[i]).equals(code)) 065 return Collections.singleton(Integer.toString(i+1)); 066 return null; 067 } 068 069 }