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