001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.preferences.projection;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import java.util.Collection;
007import java.util.Collections;
008
009import org.openstreetmap.josm.tools.Utils;
010
011public class PuwgProjectionChoice extends ListProjectionChoice {
012
013    private static final String[] CODES = {
014        "EPSG:2180",
015        "EPSG:2176",
016        "EPSG:2177",
017        "EPSG:2178",
018        "EPSG:2179"
019    };
020
021    private static final String[] NAMES = {
022        tr("PUWG 1992 (Poland)"),
023        tr("PUWG 2000 Zone {0} (Poland)", 5),
024        tr("PUWG 2000 Zone {0} (Poland)", 6),
025        tr("PUWG 2000 Zone {0} (Poland)", 7),
026        tr("PUWG 2000 Zone {0} (Poland)", 8)
027    };
028
029    /**
030     * Constructs a new {@code PuwgProjectionChoice}.
031     */
032    public PuwgProjectionChoice() {
033        super(tr("PUWG (Poland)"), "core:puwg", NAMES, tr("PUWG Zone"));
034    }
035
036    @Override
037    public String getCurrentCode() {
038        return CODES[index];
039    }
040
041    @Override
042    public String getProjectionName() {
043        return NAMES[index];
044    }
045
046
047    @Override
048    public String[] allCodes() {
049        return Utils.copyArray(CODES);
050    }
051
052    @Override
053    public Collection<String> getPreferencesFromCode(String code) {
054        for (String code2 : CODES) {
055            if (code.equals(code2))
056                return Collections.singleton(code2);
057        }
058        return null;
059    }
060
061    @Override
062    protected String indexToZone(int index) {
063        return CODES[index];
064    }
065
066    @Override
067    protected int zoneToIndex(String zone) {
068        for (int i=0; i<CODES.length; i++) {
069            if (zone.equals(CODES[i])) {
070                return i;
071            }
072        }
073        return defaultIndex;
074    }
075
076}