Changeset 13598 in josm for trunk/src/org
- Timestamp:
- 2018-04-05T19:03:04+02:00 (7 years ago)
- 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 296 296 } 297 297 s = parameters.get(Param.bounds.key); 298 if (s != null) { 299 this.bounds = parseBounds(s); 300 } 298 this.bounds = s != null ? parseBounds(s) : null; 301 299 s = parameters.get(Param.wmssrs.key); 302 300 if (s != null) { … … 590 588 projParams.gamma = parseAngle(s, Param.gamma.key); 591 589 } 590 s = parameters.get(Param.lon_0.key); 591 if (s != null) { 592 projParams.lon0 = parseAngle(s, Param.lon_0.key); 593 } 592 594 s = parameters.get(Param.lon_1.key); 593 595 if (s != null) { -
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r13582 r13598 25 25 import org.openstreetmap.josm.data.projection.datum.WGS84Datum; 26 26 import org.openstreetmap.josm.data.projection.proj.AlbersEqualArea; 27 import org.openstreetmap.josm.data.projection.proj.AzimuthalEquidistant; 27 28 import org.openstreetmap.josm.data.projection.proj.CassiniSoldner; 28 29 import org.openstreetmap.josm.data.projection.proj.ClassProjFactory; 29 30 import org.openstreetmap.josm.data.projection.proj.DoubleStereographic; 31 import org.openstreetmap.josm.data.projection.proj.EquidistantCylindrical; 30 32 import org.openstreetmap.josm.data.projection.proj.LambertAzimuthalEqualArea; 31 33 import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; … … 55 57 */ 56 58 public static class ProjectionDefinition { 59 /** 60 * EPSG code 61 */ 57 62 public final String code; 63 /** 64 * Projection name 65 */ 58 66 public final String name; 67 /** 68 * projection definition (EPSG format) 69 */ 59 70 public final String definition; 60 71 … … 89 100 static { 90 101 registerBaseProjection("aea", AlbersEqualArea.class, "core"); 102 registerBaseProjection("aeqd", AzimuthalEquidistant.class, "core"); 91 103 registerBaseProjection("cass", CassiniSoldner.class, "core"); 104 registerBaseProjection("eqc", EquidistantCylindrical.class, "core"); 92 105 registerBaseProjection("laea", LambertAzimuthalEqualArea.class, "core"); 93 106 registerBaseProjection("lcc", LambertConformalConic.class, "core"); … … 199 212 } 200 213 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 */ 201 223 public static void registerBaseProjection(String id, Class<? extends Proj> projClass, String origin) { 202 224 registerBaseProjection(id, new ClassProjFactory(projClass), origin); … … 293 315 List<ProjectionDefinition> result = new ArrayList<>(); 294 316 Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>"); 295 String line, lastline = ""; 317 StringBuilder sb = new StringBuilder(); 318 String line; 296 319 while ((line = r.readLine()) != null) { 297 320 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 } 308 338 } 309 339 } 310 lastline = line; 311 } 340 } 341 if (result.isEmpty()) 342 throw new AssertionError("EPSG file seems corrupted"); 312 343 return result; 313 344 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java
r10748 r13598 155 155 } 156 156 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 157 170 // Iteratively solve equation (7-9) from Snyder. 158 171 final double cphi2(final double ts) { -
trunk/src/org/openstreetmap/josm/data/projection/proj/ProjParameters.java
r9565 r13598 2 2 package org.openstreetmap.josm.data.projection.proj; 3 3 4 import org.openstreetmap.josm.data.projection.CustomProjection.Param; 4 5 import org.openstreetmap.josm.data.projection.Ellipsoid; 5 6 6 7 /** 7 8 * Parameters to initialize a Proj object. 9 * @since 5066 8 10 */ 9 11 public class ProjParameters { 10 12 13 /** {@code +ellps} */ 11 14 public Ellipsoid ellps; 12 15 16 /** {@link Param#lat_0} */ 13 17 public Double lat0; 18 /** {@link Param#lat_1} */ 14 19 public Double lat1; 20 /** {@link Param#lat_2} */ 15 21 public Double lat2; 16 22 17 23 // Polar Stereographic and Mercator 24 /** {@link Param#lat_ts} */ 18 25 public Double lat_ts; 19 26 27 // Azimuthal Equidistant 28 /** {@link Param#lon_0} */ 29 public Double lon0; 30 20 31 // Oblique Mercator 32 /** {@link Param#lonc} */ 21 33 public Double lonc; 34 /** {@link Param#alpha} */ 22 35 public Double alpha; 36 /** {@link Param#gamma} */ 23 37 public Double gamma; 38 /** {@link Param#no_off} */ 24 39 public Boolean no_off; 40 /** {@link Param#lon_1} */ 25 41 public Double lon1; 42 /** {@link Param#lon_2} */ 26 43 public Double lon2; 27 44 }
Note:
See TracChangeset
for help on using the changeset viewer.