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