source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/projection/GaussKruegerProjectionChoice.java@ 13182

Last change on this file since 13182 was 12620, checked in by Don-vip, 7 years ago

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

  • Property svn:eol-style set to native
File size: 2.0 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.Collection;
7import java.util.Collections;
8
9import org.openstreetmap.josm.tools.Logging;
10
11/**
12 * ProjectionChoice for Gauß-Krüger coordinate system (zones 2-5, EPSG:31466-31469).
13 * <p>
14 * @see <a href="https://de.wikipedia.org/wiki/Gauß-Krüger-Koordinatensystem">Gauß-Krüger</a>
15 */
16public class GaussKruegerProjectionChoice extends ListProjectionChoice {
17
18 private static String[] zones = {"2", "3", "4", "5"};
19
20 /**
21 * Constructs a new {@code GaussKruegerProjectionChoice}.
22 */
23 public GaussKruegerProjectionChoice() {
24 super(tr("Gau\u00DF-Kr\u00FCger"), /* NO-ICON */ "core:gauss-krueger", zones, tr("GK Zone"));
25 }
26
27 @Override
28 public String getCurrentCode() {
29 return "EPSG:"+Integer.toString(31466 + index);
30 }
31
32 @Override
33 protected String indexToZone(int index) {
34 return Integer.toString(index + 2);
35 }
36
37 @Override
38 protected int zoneToIndex(String zone) {
39 try {
40 return Integer.parseInt(zone) - 2;
41 } catch (NumberFormatException e) {
42 Logging.warn(e);
43 }
44 return defaultIndex;
45 }
46
47 @Override
48 public String[] allCodes() {
49 String[] codes = new String[4];
50 for (int zone = 2; zone <= 5; zone++) {
51 codes[zone-2] = "EPSG:" + (31464 + zone);
52 }
53 return codes;
54 }
55
56 @Override
57 public Collection<String> getPreferencesFromCode(String code) {
58 //zone 2 = EPSG:31466 up to zone 5 = EPSG:31469
59 for (int zone = 2; zone <= 5; zone++) {
60 String epsg = "EPSG:" + (31464 + zone);
61 if (epsg.equals(code))
62 return Collections.singleton(String.valueOf(zone));
63 }
64 return null;
65 }
66
67 @Override
68 public String getProjectionName() {
69 return tr("Gau\u00DF-Kr\u00FCger Zone {0}", index + 2);
70 }
71
72}
Note: See TracBrowser for help on using the repository browser.