Ignore:
Timestamp:
2018-04-05T19:03:04+02:00 (6 years ago)
Author:
Don-vip
Message:

see #16129 - add new projections and support for new format of ESRI file

Location:
trunk/src/org/openstreetmap/josm/data/projection
Files:
2 added
4 edited

Legend:

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

    r13182 r13598  
    296296            }
    297297            s = parameters.get(Param.bounds.key);
    298             if (s != null) {
    299                 this.bounds = parseBounds(s);
    300             }
     298            this.bounds = s != null ? parseBounds(s) : null;
    301299            s = parameters.get(Param.wmssrs.key);
    302300            if (s != null) {
     
    590588            projParams.gamma = parseAngle(s, Param.gamma.key);
    591589        }
     590        s = parameters.get(Param.lon_0.key);
     591        if (s != null) {
     592            projParams.lon0 = parseAngle(s, Param.lon_0.key);
     593        }
    592594        s = parameters.get(Param.lon_1.key);
    593595        if (s != null) {
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r13582 r13598  
    2525import org.openstreetmap.josm.data.projection.datum.WGS84Datum;
    2626import org.openstreetmap.josm.data.projection.proj.AlbersEqualArea;
     27import org.openstreetmap.josm.data.projection.proj.AzimuthalEquidistant;
    2728import org.openstreetmap.josm.data.projection.proj.CassiniSoldner;
    2829import org.openstreetmap.josm.data.projection.proj.ClassProjFactory;
    2930import org.openstreetmap.josm.data.projection.proj.DoubleStereographic;
     31import org.openstreetmap.josm.data.projection.proj.EquidistantCylindrical;
    3032import org.openstreetmap.josm.data.projection.proj.LambertAzimuthalEqualArea;
    3133import org.openstreetmap.josm.data.projection.proj.LambertConformalConic;
     
    5557     */
    5658    public static class ProjectionDefinition {
     59        /**
     60         * EPSG code
     61         */
    5762        public final String code;
     63        /**
     64         * Projection name
     65         */
    5866        public final String name;
     67        /**
     68         * projection definition (EPSG format)
     69         */
    5970        public final String definition;
    6071
     
    89100    static {
    90101        registerBaseProjection("aea", AlbersEqualArea.class, "core");
     102        registerBaseProjection("aeqd", AzimuthalEquidistant.class, "core");
    91103        registerBaseProjection("cass", CassiniSoldner.class, "core");
     104        registerBaseProjection("eqc", EquidistantCylindrical.class, "core");
    92105        registerBaseProjection("laea", LambertAzimuthalEqualArea.class, "core");
    93106        registerBaseProjection("lcc", LambertConformalConic.class, "core");
     
    199212    }
    200213
     214    /**
     215     * Plugins can register additional base projections.
     216     *
     217     * @param id The "official" PROJ.4 id. In case the projection is not supported
     218     * by PROJ.4, use some prefix, e.g. josm:myproj or gdal:otherproj.
     219     * @param projClass The base projection class.
     220     * @param origin Multiple plugins may implement the same base projection.
     221     * Provide plugin name or similar string, so it be differentiated.
     222     */
    201223    public static void registerBaseProjection(String id, Class<? extends Proj> projClass, String origin) {
    202224        registerBaseProjection(id, new ClassProjFactory(projClass), origin);
     
    293315        List<ProjectionDefinition> result = new ArrayList<>();
    294316        Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>");
    295         String line, lastline = "";
     317        StringBuilder sb = new StringBuilder();
     318        String line;
    296319        while ((line = r.readLine()) != null) {
    297320            line = line.trim();
    298             if (!line.startsWith("#") && !line.isEmpty()) {
    299                 if (!lastline.startsWith("#")) throw new AssertionError("EPSG file seems corrupted");
    300                 String name = lastline.substring(1).trim();
    301                 Matcher m = epsgPattern.matcher(line);
    302                 if (m.matches()) {
    303                     String code = "EPSG:" + m.group(1);
    304                     String definition = m.group(2).trim();
    305                     result.add(new ProjectionDefinition(code, name, definition));
    306                 } else {
    307                     Logging.warn("Failed to parse line from the EPSG projection definition: "+line);
     321            if (!line.isEmpty()) {
     322                if (!line.startsWith("#")) {
     323                    Matcher m = epsgPattern.matcher(line);
     324                    if (m.matches()) {
     325                        String code = "EPSG:" + m.group(1);
     326                        String definition = m.group(2).trim();
     327                        result.add(new ProjectionDefinition(code, sb.toString(), definition));
     328                    } else {
     329                        Logging.warn("Failed to parse line from the EPSG projection definition: "+line);
     330                    }
     331                    sb.setLength(0);
     332                } else if (!line.startsWith("# area: ")) {
     333                    if (sb.length() == 0) {
     334                        sb.append(line.substring(1).trim());
     335                    } else {
     336                        sb.append('(').append(line.substring(1).trim()).append(')');
     337                    }
    308338                }
    309339            }
    310             lastline = line;
    311         }
     340        }
     341        if (result.isEmpty())
     342            throw new AssertionError("EPSG file seems corrupted");
    312343        return result;
    313344    }
  • trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java

    r10748 r13598  
    155155    }
    156156
     157    /**
     158     * Tolerant asin that will just return the limits of its output range if the input is out of range
     159     * @param v the value whose arc sine is to be returned.
     160     * @return the arc sine of the argument.
     161     */
     162    protected final double aasin(double v) {
     163        double av = Math.abs(v);
     164        if (av >= 1.) {
     165            return (v < 0. ? -Math.PI / 2 : Math.PI / 2);
     166        }
     167        return Math.asin(v);
     168    }
     169
    157170    // Iteratively solve equation (7-9) from Snyder.
    158171    final double cphi2(final double ts) {
  • trunk/src/org/openstreetmap/josm/data/projection/proj/ProjParameters.java

    r9565 r13598  
    22package org.openstreetmap.josm.data.projection.proj;
    33
     4import org.openstreetmap.josm.data.projection.CustomProjection.Param;
    45import org.openstreetmap.josm.data.projection.Ellipsoid;
    56
    67/**
    78 * Parameters to initialize a Proj object.
     9 * @since 5066
    810 */
    911public class ProjParameters {
    1012
     13    /** {@code +ellps} */
    1114    public Ellipsoid ellps;
    1215
     16    /** {@link Param#lat_0} */
    1317    public Double lat0;
     18    /** {@link Param#lat_1} */
    1419    public Double lat1;
     20    /** {@link Param#lat_2} */
    1521    public Double lat2;
    1622
    1723    // Polar Stereographic and Mercator
     24    /** {@link Param#lat_ts} */
    1825    public Double lat_ts;
    1926
     27    // Azimuthal Equidistant
     28    /** {@link Param#lon_0} */
     29    public Double lon0;
     30
    2031    // Oblique Mercator
     32    /** {@link Param#lonc} */
    2133    public Double lonc;
     34    /** {@link Param#alpha} */
    2235    public Double alpha;
     36    /** {@link Param#gamma} */
    2337    public Double gamma;
     38    /** {@link Param#no_off} */
    2439    public Boolean no_off;
     40    /** {@link Param#lon_1} */
    2541    public Double lon1;
     42    /** {@link Param#lon_2} */
    2643    public Double lon2;
    2744}
Note: See TracChangeset for help on using the changeset viewer.