1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences.projection;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Collection;
|
---|
7 | import java.util.Collections;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.projection.GaussKrueger;
|
---|
10 | import org.openstreetmap.josm.data.projection.Projection;
|
---|
11 |
|
---|
12 | public class GaussKruegerProjectionChoice extends ListProjectionChoice implements Alias {
|
---|
13 |
|
---|
14 | private static String[] zones = { "2", "3", "4", "5" };
|
---|
15 |
|
---|
16 | public GaussKruegerProjectionChoice() {
|
---|
17 | super("core:gauss-krueger", tr("Gau\u00DF-Kr\u00FCger"), zones, tr("GK Zone"));
|
---|
18 | }
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public Projection getProjection() {
|
---|
22 | return new GaussKrueger(indexToZone(index));
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Override
|
---|
26 | protected int indexToZone(int index) {
|
---|
27 | return index + 2;
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | protected int zoneToIndex(int zone) {
|
---|
32 | return zone - 2;
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public String[] allCodes() {
|
---|
37 | String[] codes = new String[4];
|
---|
38 | for (int zone = 2; zone <= 5; zone++) {
|
---|
39 | codes[zone-2] = "EPSG:" + (31464 + zone);
|
---|
40 | }
|
---|
41 | return codes;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public Collection<String> getPreferencesFromCode(String code)
|
---|
46 | {
|
---|
47 | //zone 2 = EPSG:31466 up to zone 5 = EPSG:31469
|
---|
48 | for (int zone = 2; zone <= 5; zone++) {
|
---|
49 | String epsg = "EPSG:" + (31464 + zone);
|
---|
50 | if (epsg.equals(code))
|
---|
51 | return Collections.singleton(String.valueOf(zone));
|
---|
52 | }
|
---|
53 | return null;
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Override
|
---|
57 | public String getAlias() {
|
---|
58 | return GaussKrueger.class.getName();
|
---|
59 | }
|
---|
60 |
|
---|
61 | }
|
---|