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.tools.Utils;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * ProjectionChoice for PUWG 1992 (EPSG:2180) and PUWG 2000 for Poland (Zone 5-8, EPSG:2176-2179).
|
---|
13 | * <p>
|
---|
14 | * @see <a href="https://pl.wikipedia.org/wiki/Uk%C5%82ad_wsp%C3%B3%C5%82rz%C4%99dnych_1992">PUWG 1992</a>
|
---|
15 | * @see <a href="https://pl.wikipedia.org/wiki/Uk%C5%82ad_wsp%C3%B3%C5%82rz%C4%99dnych_2000">PUWG 2000</a>
|
---|
16 | */
|
---|
17 | public class PuwgProjectionChoice extends ListProjectionChoice {
|
---|
18 |
|
---|
19 | private static final String[] CODES = {
|
---|
20 | "EPSG:2180",
|
---|
21 | "EPSG:2176",
|
---|
22 | "EPSG:2177",
|
---|
23 | "EPSG:2178",
|
---|
24 | "EPSG:2179"
|
---|
25 | };
|
---|
26 |
|
---|
27 | private static final String[] NAMES = {
|
---|
28 | tr("PUWG 1992 (Poland)"),
|
---|
29 | tr("PUWG 2000 Zone {0} (Poland)", 5),
|
---|
30 | tr("PUWG 2000 Zone {0} (Poland)", 6),
|
---|
31 | tr("PUWG 2000 Zone {0} (Poland)", 7),
|
---|
32 | tr("PUWG 2000 Zone {0} (Poland)", 8)
|
---|
33 | };
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Constructs a new {@code PuwgProjectionChoice}.
|
---|
37 | */
|
---|
38 | public PuwgProjectionChoice() {
|
---|
39 | super(tr("PUWG (Poland)"), /* NO-ICON */ "core:puwg", NAMES, tr("PUWG Zone"));
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | public String getCurrentCode() {
|
---|
44 | return CODES[index];
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | public String getProjectionName() {
|
---|
49 | return NAMES[index];
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public String[] allCodes() {
|
---|
54 | return Utils.copyArray(CODES);
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Override
|
---|
58 | public Collection<String> getPreferencesFromCode(String code) {
|
---|
59 | for (String code2 : CODES) {
|
---|
60 | if (code.equals(code2))
|
---|
61 | return Collections.singleton(code2);
|
---|
62 | }
|
---|
63 | return null;
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | protected String indexToZone(int index) {
|
---|
68 | return CODES[index];
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | protected int zoneToIndex(String zone) {
|
---|
73 | for (int i = 0; i < CODES.length; i++) {
|
---|
74 | if (zone.equals(CODES[i])) {
|
---|
75 | return i;
|
---|
76 | }
|
---|
77 | }
|
---|
78 | return defaultIndex;
|
---|
79 | }
|
---|
80 | }
|
---|