Ignore:
Timestamp:
2012-11-01T16:52:19+01:00 (11 years ago)
Author:
bastiK
Message:

remove Projection classes (replaced by data/epsg file)

concludes the projection rework from ealier this year

Location:
trunk/src/org/openstreetmap/josm/data/projection
Files:
15 deleted
3 edited

Legend:

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

    r5279 r5548  
    2121import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum;
    2222import org.openstreetmap.josm.data.projection.datum.WGS84Datum;
     23import org.openstreetmap.josm.data.projection.proj.Mercator;
    2324import org.openstreetmap.josm.data.projection.proj.Proj;
    2425import org.openstreetmap.josm.data.projection.proj.ProjParameters;
     
    3839     */
    3940    protected String pref;
     41    protected String name;
     42    protected String code;
     43    protected String cacheDir;
    4044    protected Bounds bounds;
    4145
     
    8387
    8488    public CustomProjection() {
    85         this.pref = null;
    8689    }
    8790
    8891    public CustomProjection(String pref) {
     92        this(null, null, pref, null);
     93    }
     94
     95    /**
     96     * Constructor.
     97     *
     98     * @param name describe projection in one or two words
     99     * @param code unique code for this projection - may be null
     100     * @param pref the string that defines the custom projection
     101     * @param cacheDir cache directory name
     102     */
     103    public CustomProjection(String name, String code, String pref, String cacheDir) {
     104        this.name = name;
     105        this.code = code;
     106        this.pref = pref;
     107        this.cacheDir = cacheDir;
    89108        try {
    90             this.pref = pref;
    91109            update(pref);
    92110        } catch (ProjectionConfigurationException ex) {
     
    104122            ellps = Ellipsoid.WGS84;
    105123            datum = WGS84Datum.INSTANCE;
    106             proj = new org.openstreetmap.josm.data.projection.proj.Mercator();
     124            proj = new Mercator();
    107125            bounds = new Bounds(
    108126                    new LatLon(-85.05112877980659, -180.0),
     
    429447    @Override
    430448    public Integer getEpsgCode() {
     449        if (code != null && code.startsWith("EPSG:")) {
     450            try {
     451                return Integer.parseInt(code.substring(5));
     452            } catch (NumberFormatException e) {}
     453        }
    431454        return null;
    432455    }
     
    434457    @Override
    435458    public String toCode() {
    436         return "proj:" + (pref == null ? "ERROR" : pref);
     459        return code != null ? code : "proj:" + (pref == null ? "ERROR" : pref);
    437460    }
    438461
    439462    @Override
    440463    public String getCacheDirectoryName() {
    441         return "proj-"+Utils.md5Hex(pref == null ? "" : pref).substring(0, 4);
     464        return cacheDir != null ? cacheDir : "proj-"+Utils.md5Hex(pref == null ? "" : pref).substring(0, 4);
    442465    }
    443466
     
    452475    @Override
    453476    public String toString() {
    454         return tr("Custom Projection");
     477        return name != null ? name : tr("Custom Projection");
    455478    }
    456479}
  • trunk/src/org/openstreetmap/josm/data/projection/Projection.java

    r5266 r5548  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.projection;
    33
     
    77
    88/**
    9  * Classes implementing this are able to convert lat/lon values to
    10  * planar screen coordinates.
     9 * A projection, i.e. a class that supports conversion from lat/lon
     10 * to east/north and back.
    1111 *
    12  * @author imi
     12 * The conversion from east/north to the screen coordinates is simply a scale
     13 * factor and x/y offset.
    1314 */
    1415public interface Projection {
    1516    /**
    16      * The default scale factor in east/north units per pixel ({@link #NavigatableComponent#scale}))
     17     * The default scale factor in east/north units per pixel ({@link #NavigatableComponent#scale})).
    1718     * FIXME: misnomer
     19     * @return the scale factor
    1820     */
    1921    double getDefaultZoomInPPD();
    2022
    2123    /**
    22      * Convert from lat/lon to northing/easting.
     24     * Convert from lat/lon to easting/northing.
    2325     *
    24      * @param p     The geo point to convert. x/y members of the point are filled.
     26     * @param ll the geographical point to convert (in WGS84 lat/lon)
     27     * @return the corresponding east/north coordinates
    2528     */
    26     EastNorth latlon2eastNorth(LatLon p);
     29    EastNorth latlon2eastNorth(LatLon ll);
    2730
    2831    /**
    29      * Convert from norting/easting to lat/lon.
     32     * Convert from easting/norting to lat/lon.
    3033     *
    31      * @param p     The geo point to convert. lat/lon members of the point are filled.
     34     * @param en the geographical point to convert (in projected coordinates)
     35     * @return the corresponding lat/lon (WGS84)
    3236     */
    33     LatLon eastNorth2latlon(EastNorth p);
     37    LatLon eastNorth2latlon(EastNorth en);
    3438
    3539    /**
    36      * Describe the projection converter in one or two words.
     40     * Describe the projection in one or two words.
     41     * @return the name / description
    3742     */
    3843    String toString();
    3944
    4045    /**
    41      * Return projection code. This should be a unique identifier.
     46     * Return projection code.
     47     *
     48     * This should be a unique identifier.
    4249     * If projection supports parameters, return a different code
    4350     * for each set of parameters.
    4451     *
    4552     * The EPSG code can be used (if defined for the projection).
     53     *
     54     * @return the projection identifier
    4655     */
    4756    String toCode();
    4857
    4958    /**
    50      * Get a filename compatible string (for the cache directory)
     59     * Get a filename compatible string (for the cache directory).
     60     * @return the cache directory name (base name)
    5161     */
    5262    String getCacheDirectoryName();
    5363
    5464    /**
    55      * Get the bounds of the world
     65     * Get the bounds of the world.
     66     * @return the supported lat/lon rectangle for this projection
    5667     */
    5768    Bounds getWorldBoundsLatLon();
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r5237 r5548  
    2525import org.openstreetmap.josm.data.projection.proj.TransverseMercator;
    2626import org.openstreetmap.josm.io.MirroredInputStream;
     27import org.openstreetmap.josm.tools.Pair;
    2728
    2829/**
     
    4748     * should be compatible to PROJ.4
    4849     */
    49     public static Map<String, ProjFactory> projs = new HashMap<String, ProjFactory>();
    50     public static Map<String, Ellipsoid> ellipsoids = new HashMap<String, Ellipsoid>();
    51     public static Map<String, Datum> datums = new HashMap<String, Datum>();
    52     public static Map<String, NTV2GridShiftFileWrapper> nadgrids = new HashMap<String, NTV2GridShiftFileWrapper>();
    53     public static Map<String, String> inits = new HashMap<String, String>();
     50    final public static Map<String, ProjFactory> projs = new HashMap<String, ProjFactory>();
     51    final public static Map<String, Ellipsoid> ellipsoids = new HashMap<String, Ellipsoid>();
     52    final public static Map<String, Datum> datums = new HashMap<String, Datum>();
     53    final public static Map<String, NTV2GridShiftFileWrapper> nadgrids = new HashMap<String, NTV2GridShiftFileWrapper>();
     54    final public static Map<String, Pair<String, String>> inits = new HashMap<String, Pair<String, String>>();
    5455
    5556    static {
     
    109110
    110111    public static String getInit(String id) {
    111         return inits.get(id);
     112        return inits.get(id.toLowerCase()).b;
    112113    }
    113114
     
    116117     */
    117118    private static void loadInits() {
    118         Pattern epsgPattern = Pattern.compile("\\A<(\\d+)>(.*)<>\\Z");
     119        Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>");
    119120        try {
    120121            InputStream in = new MirroredInputStream("resource://data/epsg");
    121122            BufferedReader r = new BufferedReader(new InputStreamReader(in));
    122             String line;
     123            String line, lastline = "";
    123124            while ((line = r.readLine()) != null) {
    124125                line = line.trim();
    125126                if (!line.startsWith("#") && !line.isEmpty()) {
     127                    if (!lastline.startsWith("#")) throw new AssertionError();
     128                    String name = lastline.substring(1).trim();
    126129                    Matcher m = epsgPattern.matcher(line);
    127130                    if (m.matches()) {
    128                         inits.put("epsg:" + m.group(1), m.group(2).trim());
     131                        inits.put("epsg:" + m.group(1), Pair.create(name, m.group(2).trim()));
    129132                    } else {
    130133                        System.err.println("Warning: failed to parse line from the epsg projection definition: "+line);
    131134                    }
    132135                }
     136                lastline = line;
    133137            }
    134138        } catch (IOException ex) {
Note: See TracChangeset for help on using the changeset viewer.