Changeset 29325 in osm for applications/editors/josm/plugins/proj4j/src
- Timestamp:
- 2013-03-03T13:47:40+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/Registry.java
r27902 r29325 19 19 public Registry() { 20 20 super(); 21 initialize(); 21 22 } 22 23 … … 111 112 112 113 public Projection getProjection( String name ) { 113 if ( projRegistry == null ) 114 initialize(); 114 // if ( projRegistry == null ) 115 // initialize(); 115 116 Class cls = (Class)projRegistry.get( name ); 116 117 if ( cls != null ) { … … 131 132 } 132 133 133 private void initialize() { 134 private synchronized void initialize() { 135 // guard against race condition 136 if (projRegistry != null) 137 return; 134 138 projRegistry = new HashMap(); 135 139 register( "aea", AlbersProjection.class, "Albers Equal Area" ); -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/parser/ParameterUtil.java
r26409 r29325 1 1 package org.osgeo.proj4j.parser; 2 2 3 import org.osgeo.proj4j.units.Angle; 3 4 import org.osgeo.proj4j.units.AngleFormat; 4 5 … … 7 8 public static final AngleFormat format = new AngleFormat( AngleFormat.ddmmssPattern, true ); 8 9 10 /** 11 * 12 * @param s 13 * @return 14 * @deprecated 15 * @see Angle#parse(String) 16 */ 9 17 public static double parseAngle( String s ) { 10 18 return format.parse( s, null ).doubleValue(); -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/parser/Proj4Keyword.java
r26409 r29325 54 54 private static Set<String> supportedParams = null; 55 55 56 public static Set supportedParameters() 56 public static synchronized Set supportedParameters() 57 57 { 58 58 if (supportedParams == null) { -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/parser/Proj4Parser.java
r27902 r29325 5 5 6 6 import org.osgeo.proj4j.*; 7 import org.osgeo.proj4j.Registry;8 7 import org.osgeo.proj4j.datum.Datum; 9 8 import org.osgeo.proj4j.datum.Ellipsoid; 10 9 import org.osgeo.proj4j.proj.Projection; 11 10 import org.osgeo.proj4j.proj.TransverseMercatorProjection; 11 import org.osgeo.proj4j.units.Angle; 12 12 import org.osgeo.proj4j.units.AngleFormat; 13 13 import org.osgeo.proj4j.units.Unit; 14 14 import org.osgeo.proj4j.units.Units; 15 import org.osgeo.proj4j.util.ProjectionMath; 15 16 16 17 public class Proj4Parser 17 18 { 18 /* SECONDS_TO_RAD = Pi/180/3600 */19 private static final double SECONDS_TO_RAD = 4.84813681109535993589914102357e-6;20 private static final double MILLION = 1000000.0;21 22 19 private Registry registry; 23 20 … … 44 41 return new CoordinateReferenceSystem(name, args, datum, proj); 45 42 } 46 47 /*48 43 49 // not currently used50 private final static double SIXTH = .1666666666666666667; // 1/651 private final static double RA4 = .04722222222222222222; // 17/36052 private final static double RA6 = .02215608465608465608; // 67/302453 private final static double RV4 = .06944444444444444444; // 5/7254 private final static double RV6 = .04243827160493827160; // 55/129655 */56 57 private static AngleFormat format = new AngleFormat( AngleFormat.ddmmssPattern, true );58 59 44 /** 60 45 * Creates a {@link Projection} … … 73 58 74 59 projection.setEllipsoid(ellipsoid); 75 76 // not sure what CSes use this??77 /*78 s = (String)params.get( "init" );79 if ( s != null ) {80 projection = createFromName( s ).getProjection();81 if ( projection == null )82 throw new ProjectionException( "Unknown projection: "+s );83 a = projection.getEquatorRadius();84 es = projection.getEllipsoid().getEccentricitySquared();85 }86 */87 88 60 89 61 //TODO: better error handling for things like bad number syntax. 90 62 // Should be able to report the original param string in the error message 91 // Also should the exception be lib specific? (Say ParseException) 92 93 // Other parameters 94 // projection.setProjectionLatitudeDegrees( 0 ); 95 // projection.setProjectionLatitude1Degrees( 0 ); 96 // projection.setProjectionLatitude2Degrees( 0 ); 63 // Should the exception be lib-specific? (e.g. ParseException) 64 97 65 s = (String)params.get( Proj4Keyword.alpha ); 98 66 if ( s != null ) … … 158 126 // this must be done last, since behaviour depends on other params being set (eg +south) 159 127 if (projection instanceof TransverseMercatorProjection) { 160 s = (String) params.get( "zone");128 s = (String) params.get(Proj4Keyword.zone); 161 129 if (s != null) 162 130 ((TransverseMercatorProjection) projection).setUTMZone(Integer … … 199 167 param[i] = Double.parseDouble(numStr[i]); 200 168 } 201 202 // optimization to detect 3-parameter transform 203 if (param[3] == 0.0 204 && param[4] == 0.0 205 && param[5] == 0.0 206 && param[6] == 0.0 207 ) { 208 param = new double[] { param[0], param[1], param[2] }; 169 if (param.length > 3) { 170 // optimization to detect 3-parameter transform 171 if (param[3] == 0.0 172 && param[4] == 0.0 173 && param[5] == 0.0 174 && param[6] == 0.0 175 ) { 176 param = new double[] { param[0], param[1], param[2] }; 177 } 209 178 } 210 179 … … 216 185 */ 217 186 if (param.length > 3) { 218 param[3] *= SECONDS_TO_RAD; 219 param[4] *= SECONDS_TO_RAD; 220 param[5] *= SECONDS_TO_RAD; 221 param[6] = (param[6]/MILLION) + 1; 187 param[3] *= ProjectionMath.SECONDS_TO_RAD; 188 param[4] *= ProjectionMath.SECONDS_TO_RAD; 189 param[5] *= ProjectionMath.SECONDS_TO_RAD; 190 param[6] = (param[6]/ProjectionMath.MILLION) + 1; 222 191 } 223 192 … … 328 297 for (int i = 0; i < args.length; i++) { 329 298 String arg = args[i]; 299 // strip leading "+" if any 330 300 if (arg.startsWith("+")) { 331 int index = arg.indexOf('='); 332 if (index != -1) { 333 // params of form +pppp=vvvv 334 String key = arg.substring(1, index); 335 String value = arg.substring(index + 1); 336 params.put(key, value); 337 } else { 338 // params of form +ppppp 339 String key = arg.substring(1); 340 params.put(key, null); 341 } 301 arg = arg.substring(1); 342 302 } 303 int index = arg.indexOf('='); 304 if (index != -1) { 305 // param of form pppp=vvvv 306 String key = arg.substring(0, index); 307 String value = arg.substring(index + 1); 308 params.put(key, value); 309 } else { 310 // param of form ppppp 311 //String key = arg.substring(1); 312 params.put(arg, null); 313 } 343 314 } 344 315 return params; … … 346 317 347 318 private static double parseAngle( String s ) { 348 return format.parse(s, null ).doubleValue();319 return Angle.parse(s); 349 320 } 350 321 -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/proj/RobinsonProjection.java
r26409 r29325 57 57 0.372, 0.0123598, -1.3935e-05, 4.39588e-06, 58 58 0.434, 0.0125501, 5.20034e-05, -1.00051e-05, 59 0.49 68, 0.0123198, -9.80735e-05, 9.22397e-06,59 0.4958, 0.0123198, -9.80735e-05, 9.22397e-06, 60 60 0.5571, 0.0120308, 4.02857e-05, -5.2901e-06, 61 61 0.6176, 0.0120369, -3.90662e-05, 7.36117e-07, -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/proj/SimpleConicProjection.java
r26409 r29325 64 64 break; 65 65 case PCONIC: 66 rho = c2 * (c1 - Math.tan(lpphi)); 66 rho = c2 * (c1 - Math.tan(lpphi - sig)); 67 67 break; 68 68 default: -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/proj/SineTangentSeriesProjection.java
r26409 r29325 61 61 c = Math.cos(lp.y = tan_mode ? Math.atan(xyy) : ProjectionMath.asin(xyy)); 62 62 lp.y /= C_p; 63 /= C_p));63 lp.x = xyx / (C_x * Math.cos(lp.y)); 64 64 if (tan_mode) 65 65 lp.x /= c * c; -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/proj/StereographicAzimuthalProjection.java
r26409 r29325 213 213 cosphi = Math.cos( tp = 2. * Math.atan2(rho * cosphi0 , akm1) ); 214 214 sinphi = Math.sin(tp); 215 phi_l = Math.asin(cosphi * sinphi0 + (y * sinphi * cosphi0 / rho)); 215 if (rho <= 0) { 216 phi_l = Math.asin(cosphi * sinphi0); 217 } 218 else { 219 phi_l = Math.asin(cosphi * sinphi0 + (y * sinphi * cosphi0 / rho)); 220 } 216 221 tp = Math.tan(.5 * (ProjectionMath.HALFPI + phi_l)); 217 222 x *= sinphi; -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/proj/TransverseMercatorProjection.java
r27902 r29325 88 88 } 89 89 90 public int getRowFromNearestParallel(double latitude) { 90 public static int getRowFromNearestParallel(double latitude) { 91 91 int degrees = (int)ProjectionMath.radToDeg(ProjectionMath.normalizeLatitude(latitude)); 92 92 if (degrees < -80 || degrees > 84) … … 97 97 } 98 98 99 public int getZoneFromNearestMeridian(double longitude) { 99 public static int getZoneFromNearestMeridian(double longitude) { 100 100 int zone = (int)Math.floor((ProjectionMath.normalizeLongitude(longitude) + Math.PI) * 30.0 / Math.PI) + 1; 101 101 if (zone < 1) -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/units/AngleFormat.java
r26409 r29325 28 28 */ 29 29 public class AngleFormat extends NumberFormat { 30 31 public static final char CH_MIN_SYMBOL = '\''; 32 public static final String STR_SEC_SYMBOL = "\""; 33 public static final char CH_DEG_SYMBOL = '\u00b0'; 34 public static final char CH_DEG_ABBREV = 'd'; 35 public static final char CH_MIN_ABBREV = 'm'; 36 public static final String STR_SEC_ABBREV = "s"; 37 38 public static final char CH_N = 'N'; 39 public static final char CH_E = 'E'; 40 public static final char CH_S = 'S'; 41 public static final char CH_W = 'W'; 30 42 31 43 public final static String ddmmssPattern = "DdM"; … … 108 120 case 'W': 109 121 if (negative) 110 result.append( 'W');122 result.append(CH_W); 111 123 else 112 result.append( 'E');124 result.append(CH_E); 113 125 break; 114 126 case 'N': 115 127 if (negative) 116 result.append( 'S');128 result.append(CH_S); 117 129 else 118 result.append( 'N');130 result.append(CH_N); 119 131 break; 120 132 default: … … 126 138 } 127 139 140 /** 141 * 142 * @param s 143 * @return 144 * @deprecated 145 * @see Angle#parse(String) 146 */ 128 147 public Number parse(String text, ParsePosition parsePosition) { 129 148 double d = 0, m = 0, s = 0; -
applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/util/ProjectionMath.java
r27902 r29325 473 473 return nf*Math.pow(10., expv); 474 474 } 475 476 /* SECONDS_TO_RAD = Pi/180/3600 */ 477 public static final double SECONDS_TO_RAD = 4.84813681109535993589914102357e-6; 478 public static final double MILLION = 1000000.0; 475 479 }
Note:
See TracChangeset
for help on using the changeset viewer.