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 GaussKruegerProjectionChoice extends ListProjectionChoice { 010 011 private static String[] zones = { "2", "3", "4", "5" }; 012 013 public GaussKruegerProjectionChoice() { 014 super(tr("Gau\u00DF-Kr\u00FCger"), "core:gauss-krueger", zones, tr("GK Zone")); 015 } 016 017 @Override 018 public String getCurrentCode() { 019 return "EPSG:"+Integer.toString(31466 + index); 020 } 021 022 @Override 023 protected String indexToZone(int index) { 024 return Integer.toString(index + 2); 025 } 026 027 @Override 028 protected int zoneToIndex(String zone) { 029 try { 030 return Integer.parseInt(zone) - 2; 031 } catch(NumberFormatException e) {} 032 return defaultIndex; 033 } 034 035 @Override 036 public String[] allCodes() { 037 String[] codes = new String[4]; 038 for (int zone = 2; zone <= 5; zone++) { 039 codes[zone-2] = "EPSG:" + (31464 + zone); 040 } 041 return codes; 042 } 043 044 @Override 045 public Collection<String> getPreferencesFromCode(String code) 046 { 047 //zone 2 = EPSG:31466 up to zone 5 = EPSG:31469 048 for (int zone = 2; zone <= 5; zone++) { 049 String epsg = "EPSG:" + (31464 + zone); 050 if (epsg.equals(code)) 051 return Collections.singleton(String.valueOf(zone)); 052 } 053 return null; 054 } 055 056 @Override 057 public String getProjectionName() { 058 return tr("Gau\u00DF-Kr\u00FCger Zone {0}", index + 2); 059 } 060 061 }