source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/projection/PuwgProjectionChoice.java@ 16438

Last change on this file since 16438 was 16438, checked in by simon04, 4 years ago

see #19251 - Java 8: use Stream

  • Property svn:eol-style set to native
File size: 2.1 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.Arrays;
7import java.util.Collection;
8import java.util.Collections;
9import java.util.stream.IntStream;
10
11import org.openstreetmap.josm.tools.Utils;
12
13/**
14 * ProjectionChoice for PUWG 1992 (EPSG:2180) and PUWG 2000 for Poland (Zone 5-8, EPSG:2176-2179).
15 * <p>
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>
18 */
19public class PuwgProjectionChoice extends ListProjectionChoice {
20
21 private static final String[] CODES = {
22 "EPSG:2180",
23 "EPSG:2176",
24 "EPSG:2177",
25 "EPSG:2178",
26 "EPSG:2179"
27 };
28
29 private static final String[] NAMES = {
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
37 /**
38 * Constructs a new {@code PuwgProjectionChoice}.
39 */
40 public PuwgProjectionChoice() {
41 super(tr("PUWG (Poland)"), /* NO-ICON */ "core:puwg", NAMES, tr("PUWG Zone"));
42 }
43
44 @Override
45 public String getCurrentCode() {
46 return CODES[index];
47 }
48
49 @Override
50 public String getProjectionName() {
51 return NAMES[index];
52 }
53
54 @Override
55 public String[] allCodes() {
56 return Utils.copyArray(CODES);
57 }
58
59 @Override
60 public Collection<String> getPreferencesFromCode(String code) {
61 return Arrays.stream(CODES).filter(code::equals).findFirst().map(Collections::singleton).orElse(null);
62 }
63
64 @Override
65 protected String indexToZone(int index) {
66 return CODES[index];
67 }
68
69 @Override
70 protected int zoneToIndex(String zone) {
71 return IntStream.range(0, CODES.length)
72 .filter(i -> zone.equals(CODES[i]))
73 .findFirst().orElse(defaultIndex);
74 }
75}
Note: See TracBrowser for help on using the repository browser.