Ignore:
Timestamp:
2012-11-03T09:58:37+01:00 (7 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/src/org/openstreetmap/josm/data/projection
Files:
1 deleted
1 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}
Note: See TracChangeset for help on using the changeset viewer.