Changeset 5554 in josm


Ignore:
Timestamp:
2012-11-03T09:58:37+01:00 (11 years ago)
Author:
bastiK
Message:

join ProjectionInfo and Projections

the first is not referenced in core code (therefore removed by server build) but needed in plugins (see #8172)

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r5548 r5554  
    66import java.io.InputStream;
    77import java.io.InputStreamReader;
     8import java.util.Collection;
    89import java.util.HashMap;
    910import java.util.Map;
     
    2425import org.openstreetmap.josm.data.projection.proj.SwissObliqueMercator;
    2526import org.openstreetmap.josm.data.projection.proj.TransverseMercator;
     27import org.openstreetmap.josm.gui.preferences.projection.ProjectionChoice;
     28import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    2629import org.openstreetmap.josm.io.MirroredInputStream;
    2730import org.openstreetmap.josm.tools.Pair;
     
    140143        }
    141144    }
     145
     146    private final static Map<String, ProjectionChoice> allCodesPC = new HashMap<String, ProjectionChoice>();
     147    private final static Map<String, Projection> allCodes = new HashMap<String, Projection>();
     148
     149    static {
     150        // FIXME: use {@link #inits}, because it may contain more codes in future
     151        // than exposed by the ProjectionChoices
     152        for (ProjectionChoice pc : ProjectionPreference.getProjectionChoices()) {
     153            for (String code : pc.allCodes()) {
     154                allCodesPC.put(code, pc);
     155            }
     156        }
     157    }
     158
     159    public static Projection getProjectionByCode(String code) {
     160        Projection p = allCodes.get(code);
     161        if (p != null) return p;
     162        ProjectionChoice pc = allCodesPC.get(code);
     163        if (pc == null) return null;
     164        Collection<String> pref = pc.getPreferencesFromCode(code);
     165        pc.setPreferences(pref);
     166        p = pc.getProjection();
     167        allCodes.put(code, p);
     168        return p;
     169    }
     170
    142171}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r5236 r5554  
    6565            double east = Double.parseDouble(f[3]);
    6666            double north = Double.parseDouble(f[4]);
    67             Projection p = ProjectionInfo.getProjectionByCode(code);
     67            Projection p = Projections.getProjectionByCode(code);
    6868            {
    6969                EastNorth en = p.latlon2eastNorth(new LatLon(lat, lon));
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r5236 r5554  
    171171
    172172        for (TestData data : allData) {
    173             Projection proj = ProjectionInfo.getProjectionByCode(data.code);
     173            Projection proj = Projections.getProjectionByCode(data.code);
    174174            if (proj == null) {
    175175                fail.append("Projection "+data.code+" from test data was not found!\n");
Note: See TracChangeset for help on using the changeset viewer.