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 import org.openstreetmap.josm.data.projection.Projection; 010 import org.openstreetmap.josm.data.projection.UTM_France_DOM; 011 012 public class UTM_France_DOM_ProjectionChoice extends ListProjectionChoice implements Alias { 013 014 private final static String FortMarigotName = tr("Guadeloupe Fort-Marigot 1949"); 015 private final static String SainteAnneName = tr("Guadeloupe Ste-Anne 1948"); 016 private final static String MartiniqueName = tr("Martinique Fort Desaix 1952"); 017 private final static String Reunion92Name = tr("Reunion RGR92"); 018 private final static String Guyane92Name = tr("Guyane RGFG95"); 019 private final static String[] utmGeodesicsNames = { FortMarigotName, SainteAnneName, MartiniqueName, Reunion92Name, Guyane92Name}; 020 021 public UTM_France_DOM_ProjectionChoice() { 022 super("core:utmfrancedom", tr("UTM France (DOM)"), utmGeodesicsNames, tr("UTM Geodesic system")); 023 } 024 025 @Override 026 protected String indexToZone(int index) { 027 return Integer.toString(index + 1); 028 } 029 030 @Override 031 protected int zoneToIndex(String zone) { 032 try { 033 return Integer.parseInt(zone) - 1; 034 } catch(NumberFormatException e) {} 035 return defaultIndex; 036 } 037 038 @Override 039 public Projection getProjection() { 040 return new UTM_France_DOM(index); 041 } 042 043 @Override 044 public String[] allCodes() { 045 String[] res = new String[UTM_France_DOM.utmEPSGs.length]; 046 for (int i=0; i<UTM_France_DOM.utmEPSGs.length; ++i) { 047 res[i] = "EPSG:"+UTM_France_DOM.utmEPSGs[i]; 048 } 049 return res; 050 } 051 052 @Override 053 public Collection<String> getPreferencesFromCode(String code) { 054 for (int i=0; i < UTM_France_DOM.utmEPSGs.length; i++ ) 055 if (("EPSG:"+UTM_France_DOM.utmEPSGs[i]).equals(code)) 056 return Collections.singleton(Integer.toString(i+1)); 057 return null; 058 } 059 060 @Override 061 public String getAlias() { 062 return UTM_France_DOM.class.getName(); 063 } 064 065 }