- Timestamp:
- 2010-01-09T15:49:04+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/LambertEST.java
r2516 r2789 58 58 } 59 59 60 public static double IterateAngle(double e, double t)60 public static double iterateAngle(double e, double t) 61 61 { 62 62 double a1 = 0.0; … … 88 88 double theta = Math.atan((p.getX() - ef) / (rf - p.getY() + nf)); 89 89 double y = (theta / n + lonf) ; 90 double x = (IterateAngle(ee, T));90 double x = iterateAngle(ee, T); 91 91 return new LatLon(Math.toDegrees(x),Math.toDegrees(y)); 92 92 } -
trunk/src/org/openstreetmap/josm/data/projection/Puwg.java
r2676 r2789 46 46 double scale = z.getPuwgScaleFactor(); 47 47 double center = z.getPuwgCentralMeridian(); /* in radians */ 48 EastNorth a = MapLatLonToXY(Math.toRadians(p.lat()), Math.toRadians(p.lon()), center);48 EastNorth a = mapLatLonToXY(Math.toRadians(p.lat()), Math.toRadians(p.lon()), center); 49 49 return new EastNorth(a.east() * scale + easting, a.north() * scale + northing); 50 50 } … … 57 57 double scale = z.getPuwgScaleFactor(); 58 58 double center = z.getPuwgCentralMeridian(); /* in radians */ 59 return MapXYToLatLon((p.east() - easting)/scale, (p.north() - northing)/scale, center);59 return mapXYToLatLon((p.east() - easting)/scale, (p.north() - northing)/scale, center); 60 60 } 61 61 -
trunk/src/org/openstreetmap/josm/data/projection/UTM.java
r2516 r2789 12 12 import javax.swing.JPanel; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.data.Bounds; 16 15 import org.openstreetmap.josm.data.coor.EastNorth; … … 29 28 private int zone = DEFAULT_ZONE; 30 29 31 final private double UTMScaleFactor = 0.9996;30 final private static double UTMScaleFactor = 0.9996; 32 31 33 32 /* Ellipsoid model constants (WGS84) - TODO Use Elliposid class here too */ 34 final private double sm_EccSquared = 6.69437999013e-03;33 //final private double sm_EccSquared = 6.69437999013e-03; 35 34 36 35 /* 37 * ArcLengthOfMeridian38 *39 * Computes the ellipsoidal distance from the equator to a point at a40 * given latitude.41 *42 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J.,43 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994.44 *45 * Inputs:46 * phi - Latitude of the point, in radians.47 *48 * Globals:49 * Ellipsoid.GRS80.a - Ellipsoid model major axis.50 * Ellipsoid.GRS80.b - Ellipsoid model minor axis.51 *52 * Returns:53 * The ellipsoidal distance of the point from the equator, in meters.54 *55 */36 * ArcLengthOfMeridian 37 * 38 * Computes the ellipsoidal distance from the equator to a point at a 39 * given latitude. 40 * 41 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 42 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 43 * 44 * Inputs: 45 * phi - Latitude of the point, in radians. 46 * 47 * Globals: 48 * Ellipsoid.GRS80.a - Ellipsoid model major axis. 49 * Ellipsoid.GRS80.b - Ellipsoid model minor axis. 50 * 51 * Returns: 52 * The ellipsoidal distance of the point from the equator, in meters. 53 * 54 */ 56 55 private double ArcLengthOfMeridian(double phi) 57 56 { … … 61 60 /* Precalculate alpha */ 62 61 double alpha = ((Ellipsoid.GRS80.a + Ellipsoid.GRS80.b) / 2.0) 63 62 * (1.0 + (Math.pow (n, 2.0) / 4.0) + (Math.pow (n, 4.0) / 64.0)); 64 63 65 64 /* Precalculate beta */ 66 65 double beta = (-3.0 * n / 2.0) + (9.0 * Math.pow (n, 3.0) / 16.0) 67 66 + (-3.0 * Math.pow (n, 5.0) / 32.0); 68 67 69 68 /* Precalculate gamma */ 70 69 double gamma = (15.0 * Math.pow (n, 2.0) / 16.0) 71 70 + (-15.0 * Math.pow (n, 4.0) / 32.0); 72 71 73 72 /* Precalculate delta */ 74 73 double delta = (-35.0 * Math.pow (n, 3.0) / 48.0) 75 74 + (105.0 * Math.pow (n, 5.0) / 256.0); 76 75 77 76 /* Precalculate epsilon */ … … 81 80 return alpha 82 81 * (phi + (beta * Math.sin (2.0 * phi)) 83 + (gamma * Math.sin (4.0 * phi))84 + (delta * Math.sin (6.0 * phi))85 + (epsilon * Math.sin (8.0 * phi)));82 + (gamma * Math.sin (4.0 * phi)) 83 + (delta * Math.sin (6.0 * phi)) 84 + (epsilon * Math.sin (8.0 * phi))); 86 85 } 87 86 88 87 /* 89 * UTMCentralMeridian90 *91 * Determines the central meridian for the given UTM zone.92 *93 * Inputs:94 * zone - An integer value designating the UTM zone, range [1,60].95 *96 * Returns:97 * The central meridian for the given UTM zone, in radians, or zero98 * if the UTM zone parameter is outside the range [1,60].99 * Range of the central meridian is the radian equivalent of [-177,+177].100 *101 */88 * UTMCentralMeridian 89 * 90 * Determines the central meridian for the given UTM zone. 91 * 92 * Inputs: 93 * zone - An integer value designating the UTM zone, range [1,60]. 94 * 95 * Returns: 96 * The central meridian for the given UTM zone, in radians, or zero 97 * if the UTM zone parameter is outside the range [1,60]. 98 * Range of the central meridian is the radian equivalent of [-177,+177]. 99 * 100 */ 102 101 private double UTMCentralMeridian(int zone) 103 102 { … … 110 109 111 110 /* 112 * FootpointLatitude113 *114 * Computes the footpoint latitude for use in converting transverse115 * Mercator coordinates to ellipsoidal coordinates.116 *117 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J.,118 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994.119 *120 * Inputs:121 * y - The UTM northing coordinate, in meters.122 *123 * Returns:124 * The footpoint latitude, in radians.125 *126 */111 * FootpointLatitude 112 * 113 * Computes the footpoint latitude for use in converting transverse 114 * Mercator coordinates to ellipsoidal coordinates. 115 * 116 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 117 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 118 * 119 * Inputs: 120 * y - The UTM northing coordinate, in meters. 121 * 122 * Returns: 123 * The footpoint latitude, in radians. 124 * 125 */ 127 126 private double FootpointLatitude(double y) 128 127 { … … 133 132 /* (Same as alpha in Eq. 10.17) */ 134 133 double alpha_ = ((Ellipsoid.GRS80.a + Ellipsoid.GRS80.b) / 2.0) 135 134 * (1 + (Math.pow (n, 2.0) / 4) + (Math.pow (n, 4.0) / 64)); 136 135 137 136 /* Precalculate y_ (Eq. 10.23) */ … … 140 139 /* Precalculate beta_ (Eq. 10.22) */ 141 140 double beta_ = (3.0 * n / 2.0) + (-27.0 * Math.pow (n, 3.0) / 32.0) 142 141 + (269.0 * Math.pow (n, 5.0) / 512.0); 143 142 144 143 /* Precalculate gamma_ (Eq. 10.22) */ 145 144 double gamma_ = (21.0 * Math.pow (n, 2.0) / 16.0) 146 145 + (-55.0 * Math.pow (n, 4.0) / 32.0); 147 146 148 147 /* Precalculate delta_ (Eq. 10.22) */ 149 148 double delta_ = (151.0 * Math.pow (n, 3.0) / 96.0) 150 149 + (-417.0 * Math.pow (n, 5.0) / 128.0); 151 150 152 151 /* Precalculate epsilon_ (Eq. 10.22) */ … … 155 154 /* Now calculate the sum of the series (Eq. 10.21) */ 156 155 return y_ + (beta_ * Math.sin (2.0 * y_)) 157 158 159 156 + (gamma_ * Math.sin (4.0 * y_)) 157 + (delta_ * Math.sin (6.0 * y_)) 158 + (epsilon_ * Math.sin (8.0 * y_)); 160 159 } 161 160 162 161 /* 163 * MapLatLonToXY164 *165 * Converts a latitude/longitude pair to x and y coordinates in the166 * Transverse Mercator projection. Note that Transverse Mercator is not167 * the same as UTM; a scale factor is required to convert between them.168 *169 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J.,170 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994.171 *172 * Inputs:173 * phi - Latitude of the point, in radians.174 * lambda - Longitude of the point, in radians.175 * lambda0 - Longitude of the central meridian to be used, in radians.176 *177 * Outputs:178 * xy - A 2-element array containing the x and y coordinates179 * of the computed point.180 *181 * Returns:182 * The function does not return a value.183 *184 */185 public EastNorth MapLatLonToXY(double phi, double lambda, double lambda0)162 * MapLatLonToXY 163 * 164 * Converts a latitude/longitude pair to x and y coordinates in the 165 * Transverse Mercator projection. Note that Transverse Mercator is not 166 * the same as UTM; a scale factor is required to convert between them. 167 * 168 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 169 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 170 * 171 * Inputs: 172 * phi - Latitude of the point, in radians. 173 * lambda - Longitude of the point, in radians. 174 * lambda0 - Longitude of the central meridian to be used, in radians. 175 * 176 * Outputs: 177 * xy - A 2-element array containing the x and y coordinates 178 * of the computed point. 179 * 180 * Returns: 181 * The function does not return a value. 182 * 183 */ 184 public EastNorth mapLatLonToXY(double phi, double lambda, double lambda0) 186 185 { 187 186 /* Precalculate ep2 */ … … 197 196 double t = Math.tan (phi); 198 197 double t2 = t * t; 199 double tmp = (t2 * t2 * t2) - Math.pow (t, 6.0);200 198 201 199 /* Precalculate l */ … … 211 209 212 210 double l5coef = 5.0 - 18.0 * t2 + (t2 * t2) + 14.0 * nu2 213 211 - 58.0 * t2 * nu2; 214 212 215 213 double l6coef = 61.0 - 58.0 * t2 + (t2 * t2) + 270.0 * nu2 216 214 - 330.0 * t2 * nu2; 217 215 218 216 double l7coef = 61.0 - 479.0 * t2 + 179.0 * (t2 * t2) - (t2 * t2 * t2); … … 221 219 222 220 return new EastNorth( 223 /* Calculate easting (x) */224 N * Math.cos (phi) * l225 + (N / 6.0 * Math.pow (Math.cos (phi), 3.0) * l3coef * Math.pow (l, 3.0))226 + (N / 120.0 * Math.pow (Math.cos (phi), 5.0) * l5coef * Math.pow (l, 5.0))227 + (N / 5040.0 * Math.pow (Math.cos (phi), 7.0) * l7coef * Math.pow (l, 7.0)),228 /* Calculate northing (y) */229 ArcLengthOfMeridian (phi)230 + (t / 2.0 * N * Math.pow (Math.cos (phi), 2.0) * Math.pow (l, 2.0))231 + (t / 24.0 * N * Math.pow (Math.cos (phi), 4.0) * l4coef * Math.pow (l, 4.0))232 + (t / 720.0 * N * Math.pow (Math.cos (phi), 6.0) * l6coef * Math.pow (l, 6.0))233 + (t / 40320.0 * N * Math.pow (Math.cos (phi), 8.0) * l8coef * Math.pow (l, 8.0)));221 /* Calculate easting (x) */ 222 N * Math.cos (phi) * l 223 + (N / 6.0 * Math.pow (Math.cos (phi), 3.0) * l3coef * Math.pow (l, 3.0)) 224 + (N / 120.0 * Math.pow (Math.cos (phi), 5.0) * l5coef * Math.pow (l, 5.0)) 225 + (N / 5040.0 * Math.pow (Math.cos (phi), 7.0) * l7coef * Math.pow (l, 7.0)), 226 /* Calculate northing (y) */ 227 ArcLengthOfMeridian (phi) 228 + (t / 2.0 * N * Math.pow (Math.cos (phi), 2.0) * Math.pow (l, 2.0)) 229 + (t / 24.0 * N * Math.pow (Math.cos (phi), 4.0) * l4coef * Math.pow (l, 4.0)) 230 + (t / 720.0 * N * Math.pow (Math.cos (phi), 6.0) * l6coef * Math.pow (l, 6.0)) 231 + (t / 40320.0 * N * Math.pow (Math.cos (phi), 8.0) * l8coef * Math.pow (l, 8.0))); 234 232 } 235 233 236 234 /* 237 * MapXYToLatLon238 *239 * Converts x and y coordinates in the Transverse Mercator projection to240 * a latitude/longitude pair. Note that Transverse Mercator is not241 * the same as UTM; a scale factor is required to convert between them.242 *243 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J.,244 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994.245 *246 * Inputs:247 * x - The easting of the point, in meters.248 * y - The northing of the point, in meters.249 * lambda0 - Longitude of the central meridian to be used, in radians.250 *251 * Outputs:252 * philambda - A 2-element containing the latitude and longitude253 * in radians.254 *255 * Returns:256 * The function does not return a value.257 *258 * Remarks:259 * The local variables Nf, nuf2, tf, and tf2 serve the same purpose as260 * N, nu2, t, and t2 in MapLatLonToXY, but they are computed with respect261 * to the footpoint latitude phif.262 *263 * x1frac, x2frac, x2poly, x3poly, etc. are to enhance readability and264 * to optimize computations.265 *266 */267 public LatLon MapXYToLatLon(double x, double y, double lambda0)235 * MapXYToLatLon 236 * 237 * Converts x and y coordinates in the Transverse Mercator projection to 238 * a latitude/longitude pair. Note that Transverse Mercator is not 239 * the same as UTM; a scale factor is required to convert between them. 240 * 241 * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J., 242 * GPS: Theory and Practice, 3rd ed. New York: Springer-Verlag Wien, 1994. 243 * 244 * Inputs: 245 * x - The easting of the point, in meters. 246 * y - The northing of the point, in meters. 247 * lambda0 - Longitude of the central meridian to be used, in radians. 248 * 249 * Outputs: 250 * philambda - A 2-element containing the latitude and longitude 251 * in radians. 252 * 253 * Returns: 254 * The function does not return a value. 255 * 256 * Remarks: 257 * The local variables Nf, nuf2, tf, and tf2 serve the same purpose as 258 * N, nu2, t, and t2 in MapLatLonToXY, but they are computed with respect 259 * to the footpoint latitude phif. 260 * 261 * x1frac, x2frac, x2poly, x3poly, etc. are to enhance readability and 262 * to optimize computations. 263 * 264 */ 265 public LatLon mapXYToLatLon(double x, double y, double lambda0) 268 266 { 269 267 /* Get the value of phif, the footpoint latitude. */ … … 272 270 /* Precalculate ep2 */ 273 271 double ep2 = (Math.pow (Ellipsoid.GRS80.a, 2.0) - Math.pow (Ellipsoid.GRS80.b, 2.0)) 274 272 / Math.pow (Ellipsoid.GRS80.b, 2.0); 275 273 276 274 /* Precalculate cos (phif) */ … … 325 323 326 324 return new LatLon( 327 /* Calculate latitude */328 Math.toDegrees(329 phif + x2frac * x2poly * (x * x)330 + x4frac * x4poly * Math.pow (x, 4.0)331 + x6frac * x6poly * Math.pow (x, 6.0)332 + x8frac * x8poly * Math.pow (x, 8.0)),333 Math.toDegrees(334 /* Calculate longitude */335 lambda0 + x1frac * x336 + x3frac * x3poly * Math.pow (x, 3.0)337 + x5frac * x5poly * Math.pow (x, 5.0)338 + x7frac * x7poly * Math.pow (x, 7.0)));325 /* Calculate latitude */ 326 Math.toDegrees( 327 phif + x2frac * x2poly * (x * x) 328 + x4frac * x4poly * Math.pow (x, 4.0) 329 + x6frac * x6poly * Math.pow (x, 6.0) 330 + x8frac * x8poly * Math.pow (x, 8.0)), 331 Math.toDegrees( 332 /* Calculate longitude */ 333 lambda0 + x1frac * x 334 + x3frac * x3poly * Math.pow (x, 3.0) 335 + x5frac * x5poly * Math.pow (x, 5.0) 336 + x7frac * x7poly * Math.pow (x, 7.0))); 339 337 } 340 338 341 339 public EastNorth latlon2eastNorth(LatLon p) { 342 EastNorth a = MapLatLonToXY(Math.toRadians(p.lat()), Math.toRadians(p.lon()), UTMCentralMeridian(getzone()));340 EastNorth a = mapLatLonToXY(Math.toRadians(p.lat()), Math.toRadians(p.lon()), UTMCentralMeridian(getzone())); 343 341 return new EastNorth(a.east() * UTMScaleFactor + 3500000.0, a.north() * UTMScaleFactor); 344 342 } 345 343 346 344 public LatLon eastNorth2latlon(EastNorth p) { 347 return MapXYToLatLon((p.east()-3500000.0)/UTMScaleFactor, p.north()/UTMScaleFactor, UTMCentralMeridian(getzone()));345 return mapXYToLatLon((p.east()-3500000.0)/UTMScaleFactor, p.north()/UTMScaleFactor, UTMCentralMeridian(getzone())); 348 346 } 349 347 … … 414 412 { 415 413 zone = Integer.parseInt(s); 416 if(zone <= 0 || zone > 60) 414 if(zone <= 0 || zone > 60) { 417 415 zone = DEFAULT_ZONE; 416 } 418 417 break; 419 418 } … … 430 429 int zoneval = Integer.parseInt(zonestring); 431 430 if(zoneval > 0 && zoneval <= 60) 432 {433 431 return Collections.singleton(zonestring); 434 }435 432 } catch(NumberFormatException e) {} 436 433 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r2711 r2789 333 333 * the cancel / close action 334 334 */ 335 class CancelAction extends AbstractAction {335 static class CancelAction extends AbstractAction { 336 336 public CancelAction() { 337 337 putValue(NAME, tr("Close")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java
r2728 r2789 67 67 HtmlPanel pnl = new HtmlPanel(); 68 68 pnl.setText( 69 "<html><body>" 70 + tr("Please enter or paste an URL to retrieve changesets from the OSM API.")71 72 73 74 75 76 77 + "host, port and path of the URL entered below.", OsmApi.getOsmApi().getBaseUrl())78 + "</body></html>"69 "<html><body>" 70 + tr("Please enter or paste an URL to retrieve changesets from the OSM API.") 71 + "<p><strong>" + tr("Examples") + "</strong></p>" 72 + "<ul>" 73 + "<li><a href=\"http://www.openstreetmap.org/browse/changesets?open=true\">http://www.openstreetmap.org/browse/changesets?open=true</a></li>" 74 + "<li><a href=\"http://api.openstreetmap.org/api/0.6/changesets?open=true\">http://api.openstreetmap.org/api/0.6/changesets?open=true</a></li>" 75 + "</ul>" 76 + tr("Note that changeset queries are currently always submitted to ''{0}'', regardless of the " 77 + "host, port and path of the URL entered below.", OsmApi.getOsmApi().getBaseUrl()) 78 + "</body></html>" 79 79 ); 80 80 pnl.getEditorPane().addHyperlinkListener( … … 91 91 } 92 92 93 protected ChangesetQuery buildChangesetQueryFromUrlQuery(String query) {94 if (query == null)95 return new ChangesetQuery();96 query = query.trim();97 return null;98 }99 100 93 protected void build() { 101 94 setLayout(new GridBagLayout()); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java
r2711 r2789 35 35 private Collection<OsmPrimitive> children; 36 36 private OsmDataLayer curLayer; 37 private MemberTableModel memberTableModel;38 37 private MultiFetchServerObjectReader objectReader; 39 38 … … 43 42 this.children = children; 44 43 this.curLayer = curLayer; 45 this.memberTableModel = memberTableModel;46 44 } 47 45 … … 51 49 this.children = children; 52 50 this.curLayer = curLayer; 53 this.memberTableModel = memberTableModel;54 51 } 55 52 -
trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java
r2781 r2789 103 103 JosmUserIdentityManager im = null; 104 104 try { 105 im = JosmUserIdentityManager.getInstance(); 105 106 OsmServerUserInfoReader reader = new OsmServerUserInfoReader(); 106 107 UserInfo info = reader.fetchUserInfo(getProgressMonitor().createSubTaskMonitor(1, false)); 107 im = JosmUserIdentityManager.getInstance();108 108 im.setFullyIdentified(info.getDisplayName(), info); 109 109 } catch(OsmTransferException e) { -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTable.java
r2512 r2789 19 19 Mode mode = (Mode)evt.getNewValue(); 20 20 switch(mode) { 21 case EDITING_DATA: setEnabled(true); 22 case UPLOADING_AND_SAVING: setEnabled(false); 21 case EDITING_DATA: setEnabled(true); 22 break; 23 case UPLOADING_AND_SAVING: setEnabled(false); 24 break; 23 25 } 24 26 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PrefJPanel.java
r2787 r2789 27 27 * If someone wants to merge it with ShortcutPreference.java, feel free. 28 28 */ 29 public class prefJPanel extends javax.swing.JPanel {29 public class PrefJPanel extends javax.swing.JPanel { 30 30 31 31 // table of shortcuts … … 96 96 /** Creates new form prefJPanel */ 97 97 // Ain't those auto-generated comments helpful or what? <g> 98 public prefJPanel(TableModel model) {98 public PrefJPanel(TableModel model) { 99 99 this.model = model; 100 100 initComponents(); … … 372 372 // more expirience with GUI coding than I have. 373 373 private class cbAction extends javax.swing.AbstractAction implements ListSelectionListener { 374 private prefJPanel panel;375 public cbAction ( prefJPanel panel) {374 private PrefJPanel panel; 375 public cbAction (PrefJPanel panel) { 376 376 this.panel = panel; 377 377 } -
trunk/src/org/openstreetmap/josm/gui/preferences/ShortcutPreference.java
r2745 r2789 30 30 tr("Changing keyboard shortcuts manually."), false); 31 31 32 prefJPanel prefpanel = new prefJPanel(new scListModel());32 PrefJPanel prefpanel = new PrefJPanel(new scListModel()); 33 33 p.add(prefpanel, GBC.eol().fill(GBC.BOTH)); 34 34 -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r2711 r2789 334 334 value = value.substring(0,value.length() - 1) + "GMT+00:00"; 335 335 } 336 DateFormat formatter = new SimpleDateFormat("MM/dd/yy"); 337 formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); 336 DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); 338 337 try { 339 338 return formatter.parse(value); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r2512 r2789 41 41 */ 42 42 public GpxData data; 43 public enum state { init, metadata, wpt, rte, trk, ext, author, link, trkseg, copyright}43 public enum State { init, metadata, wpt, rte, trk, ext, author, link, trkseg, copyright} 44 44 45 45 private class Parser extends DefaultHandler { … … 51 51 private WayPoint currentWayPoint; 52 52 53 private state currentState = state.init;53 private State currentState = State.init; 54 54 55 55 private GpxLink currentLink; 56 private Stack< state> states;56 private Stack<State> states; 57 57 58 58 private StringBuffer accumulator = new StringBuffer(); … … 62 62 @Override public void startDocument() { 63 63 accumulator = new StringBuffer(); 64 states = new Stack< state>();64 states = new Stack<State>(); 65 65 currentData = new GpxData(); 66 66 } … … 82 82 @Override public void startElement(String namespaceURI, String qName, String rqName, Attributes atts) throws SAXException { 83 83 switch(currentState) { 84 85 86 87 currentState = state.metadata;88 89 90 currentState = state.wpt;91 92 93 94 currentState = state.rte;95 96 97 98 currentState = state.trk;99 100 101 102 currentState = state.ext;103 104 105 106 107 108 109 110 currentState = state.link;111 112 113 114 115 116 117 118 119 currentState = state.trkseg;120 121 122 123 currentState = state.link;124 125 126 127 currentState = state.ext;128 129 130 131 132 133 currentState = state.author;134 135 136 currentState = state.ext;137 138 139 currentState = state.copyright;140 141 142 143 currentState = state.link;144 145 146 147 148 149 150 currentState = state.wpt;151 152 153 154 155 156 157 currentState = state.link;158 159 160 161 currentState = state.ext;162 163 164 165 166 167 currentState = state.link;168 169 170 171 currentState = state.wpt;172 173 174 175 currentState = state.ext;176 177 178 84 case init: 85 if (qName.equals("metadata")) { 86 states.push(currentState); 87 currentState = State.metadata; 88 } else if (qName.equals("wpt")) { 89 states.push(currentState); 90 currentState = State.wpt; 91 currentWayPoint = new WayPoint(parseLatLon(atts)); 92 } else if (qName.equals("rte")) { 93 states.push(currentState); 94 currentState = State.rte; 95 currentRoute = new GpxRoute(); 96 } else if (qName.equals("trk")) { 97 states.push(currentState); 98 currentState = State.trk; 99 currentTrack = new GpxTrack(); 100 } else if (qName.equals("extensions")) { 101 states.push(currentState); 102 currentState = State.ext; 103 } else if (qName.equals("gpx") && atts.getValue("creator") != null && atts.getValue("creator").startsWith("Nokia Sports Tracker")) { 104 nokiaSportsTrackerBug = true; 105 } 106 break; 107 case author: 108 if (qName.equals("link")) { 109 states.push(currentState); 110 currentState = State.link; 111 currentLink = new GpxLink(atts.getValue("href")); 112 } else if (qName.equals("email")) { 113 currentData.attr.put(GpxData.META_AUTHOR_EMAIL, atts.getValue("id") + "@" + atts.getValue("domain")); 114 } 115 break; 116 case trk: 117 if (qName.equals("trkseg")) { 118 states.push(currentState); 119 currentState = State.trkseg; 120 currentTrackSeg = new ArrayList<WayPoint>(); 121 } else if (qName.equals("link")) { 122 states.push(currentState); 123 currentState = State.link; 124 currentLink = new GpxLink(atts.getValue("href")); 125 } else if (qName.equals("extensions")) { 126 states.push(currentState); 127 currentState = State.ext; 128 } 129 break; 130 case metadata: 131 if (qName.equals("author")) { 132 states.push(currentState); 133 currentState = State.author; 134 } else if (qName.equals("extensions")) { 135 states.push(currentState); 136 currentState = State.ext; 137 } else if (qName.equals("copyright")) { 138 states.push(currentState); 139 currentState = State.copyright; 140 currentData.attr.put(GpxData.META_COPYRIGHT_AUTHOR, atts.getValue("author")); 141 } else if (qName.equals("link")) { 142 states.push(currentState); 143 currentState = State.link; 144 currentLink = new GpxLink(atts.getValue("href")); 145 } 146 break; 147 case trkseg: 148 if (qName.equals("trkpt")) { 149 states.push(currentState); 150 currentState = State.wpt; 151 currentWayPoint = new WayPoint(parseLatLon(atts)); 152 } 153 break; 154 case wpt: 155 if (qName.equals("link")) { 156 states.push(currentState); 157 currentState = State.link; 158 currentLink = new GpxLink(atts.getValue("href")); 159 } else if (qName.equals("extensions")) { 160 states.push(currentState); 161 currentState = State.ext; 162 } 163 break; 164 case rte: 165 if (qName.equals("link")) { 166 states.push(currentState); 167 currentState = State.link; 168 currentLink = new GpxLink(atts.getValue("href")); 169 } else if (qName.equals("rtept")) { 170 states.push(currentState); 171 currentState = State.wpt; 172 currentWayPoint = new WayPoint(parseLatLon(atts)); 173 } else if (qName.equals("extensions")) { 174 states.push(currentState); 175 currentState = State.ext; 176 } 177 break; 178 default: 179 179 } 180 180 accumulator.setLength(0); … … 201 201 private Map<String, Object> getAttr() { 202 202 switch (currentState) { 203 case rte: return currentRoute.attr; 204 case metadata: return currentData.attr; 205 case wpt: return currentWayPoint.attr; 206 case trk: return currentTrack.attr; 207 default: return null; 208 } 209 } 210 203 case rte: return currentRoute.attr; 204 case metadata: return currentData.attr; 205 case wpt: return currentWayPoint.attr; 206 case trk: return currentTrack.attr; 207 default: return null; 208 } 209 } 210 211 @SuppressWarnings("unchecked") 211 212 @Override public void endElement(String namespaceURI, String qName, String rqName) { 212 213 switch (currentState) { 213 case metadata: 214 if (qName.equals("name")) { 215 currentData.attr.put(GpxData.META_NAME, accumulator.toString()); 216 } else if (qName.equals("desc")) { 217 currentData.attr.put(GpxData.META_DESC, accumulator.toString()); 218 } else if (qName.equals("time")) { 219 currentData.attr.put(GpxData.META_TIME, accumulator.toString()); 220 } else if (qName.equals("keywords")) { 221 currentData.attr.put(GpxData.META_KEYWORDS, accumulator.toString()); 222 } else if (qName.equals("metadata")) { 223 currentState = states.pop(); 214 case metadata: 215 if (qName.equals("name")) { 216 currentData.attr.put(GpxData.META_NAME, accumulator.toString()); 217 } else if (qName.equals("desc")) { 218 currentData.attr.put(GpxData.META_DESC, accumulator.toString()); 219 } else if (qName.equals("time")) { 220 currentData.attr.put(GpxData.META_TIME, accumulator.toString()); 221 } else if (qName.equals("keywords")) { 222 currentData.attr.put(GpxData.META_KEYWORDS, accumulator.toString()); 223 } else if (qName.equals("metadata")) { 224 currentState = states.pop(); 225 } 226 //TODO: parse bounds, extensions 227 break; 228 case author: 229 if (qName.equals("author")) { 230 currentState = states.pop(); 231 } else if (qName.equals("name")) { 232 currentData.attr.put(GpxData.META_AUTHOR_NAME, accumulator.toString()); 233 } else if (qName.equals("email")) { 234 // do nothing, has been parsed on startElement 235 } else if (qName.equals("link")) { 236 currentData.attr.put(GpxData.META_AUTHOR_LINK, currentLink); 237 } 238 break; 239 case copyright: 240 if (qName.equals("copyright")) { 241 currentState = states.pop(); 242 } else if (qName.equals("year")) { 243 currentData.attr.put(GpxData.META_COPYRIGHT_YEAR, accumulator.toString()); 244 } else if (qName.equals("license")) { 245 currentData.attr.put(GpxData.META_COPYRIGHT_LICENSE, accumulator.toString()); 246 } 247 break; 248 case link: 249 if (qName.equals("text")) { 250 currentLink.text = accumulator.toString(); 251 } else if (qName.equals("type")) { 252 currentLink.type = accumulator.toString(); 253 } else if (qName.equals("link")) { 254 if (currentLink.uri == null && accumulator != null && accumulator.toString().length() != 0) { 255 currentLink = new GpxLink(accumulator.toString()); 224 256 } 225 //TODO: parse bounds, extensions 226 break; 227 case author: 228 if (qName.equals("author")) { 229 currentState = states.pop(); 230 } else if (qName.equals("name")) { 231 currentData.attr.put(GpxData.META_AUTHOR_NAME, accumulator.toString()); 232 } else if (qName.equals("email")) { 233 // do nothing, has been parsed on startElement 234 } else if (qName.equals("link")) { 235 currentData.attr.put(GpxData.META_AUTHOR_LINK, currentLink); 257 currentState = states.pop(); 258 } 259 if (currentState == State.author) { 260 currentData.attr.put(GpxData.META_AUTHOR_LINK, currentLink); 261 } else if (currentState != State.link) { 262 Map<String, Object> attr = getAttr(); 263 if (!attr.containsKey(GpxData.META_LINKS)) { 264 attr.put(GpxData.META_LINKS, new LinkedList<GpxLink>()); 236 265 } 237 break; 238 case copyright: 239 if (qName.equals("copyright")) { 240 currentState = states.pop(); 241 } else if (qName.equals("year")) { 242 currentData.attr.put(GpxData.META_COPYRIGHT_YEAR, accumulator.toString()); 243 } else if (qName.equals("license")) { 244 currentData.attr.put(GpxData.META_COPYRIGHT_LICENSE, accumulator.toString()); 266 ((Collection<GpxLink>) attr.get(GpxData.META_LINKS)).add(currentLink); 267 } 268 break; 269 case wpt: 270 if ( qName.equals("ele") || qName.equals("magvar") 271 || qName.equals("name") || qName.equals("geoidheight") 272 || qName.equals("type") || qName.equals("sym")) { 273 currentWayPoint.attr.put(qName, accumulator.toString()); 274 } else if(qName.equals("hdop") /*|| qName.equals("vdop") || 275 qName.equals("pdop")*/) { 276 try { 277 currentWayPoint.attr.put(qName, Float.parseFloat(accumulator.toString())); 278 } catch(Exception e) { 279 currentWayPoint.attr.put(qName, new Float(0)); 245 280 } 246 break; 247 case link: 248 if (qName.equals("text")) { 249 currentLink.text = accumulator.toString(); 250 } else if (qName.equals("type")) { 251 currentLink.type = accumulator.toString(); 252 } else if (qName.equals("link")) { 253 if (currentLink.uri == null && accumulator != null && accumulator.toString().length() != 0) { 254 currentLink = new GpxLink(accumulator.toString()); 255 } 256 currentState = states.pop(); 257 } 258 if (currentState == state.author) { 259 currentData.attr.put(GpxData.META_AUTHOR_LINK, currentLink); 260 } else if (currentState != state.link) { 261 Map<String, Object> attr = getAttr(); 262 if (!attr.containsKey(GpxData.META_LINKS)) { 263 attr.put(GpxData.META_LINKS, new LinkedList<GpxLink>()); 264 } 265 ((Collection<GpxLink>) attr.get(GpxData.META_LINKS)).add(currentLink); 266 } 267 break; 268 case wpt: 269 if ( qName.equals("ele") || qName.equals("magvar") 270 || qName.equals("name") || qName.equals("geoidheight") 271 || qName.equals("type") || qName.equals("sym")) { 272 currentWayPoint.attr.put(qName, accumulator.toString()); 273 } else if(qName.equals("hdop") /*|| qName.equals("vdop") || 274 qName.equals("pdop")*/) { 275 try { 276 currentWayPoint.attr.put(qName, Float.parseFloat(accumulator.toString())); 277 } catch(Exception e) { 278 currentWayPoint.attr.put(qName, new Float(0)); 279 } 280 } else if (qName.equals("time")) { 281 currentWayPoint.attr.put(qName, accumulator.toString()); 282 currentWayPoint.setTime(); 283 } else if (qName.equals("cmt") || qName.equals("desc")) { 284 currentWayPoint.attr.put(qName, accumulator.toString()); 285 currentWayPoint.setTime(); 286 } else if (qName.equals("rtept")) { 287 currentState = states.pop(); 288 currentRoute.routePoints.add(currentWayPoint); 289 } else if (qName.equals("trkpt")) { 290 currentState = states.pop(); 291 currentTrackSeg.add(currentWayPoint); 292 } else if (qName.equals("wpt")) { 293 currentState = states.pop(); 294 currentData.waypoints.add(currentWayPoint); 295 } 296 break; 297 case trkseg: 298 if (qName.equals("trkseg")) { 299 currentState = states.pop(); 300 currentTrack.trackSegs.add(currentTrackSeg); 301 } 302 break; 303 case trk: 304 if (qName.equals("trk")) { 305 currentState = states.pop(); 306 currentData.tracks.add(currentTrack); 307 } else if (qName.equals("name") || qName.equals("cmt") 308 || qName.equals("desc") || qName.equals("src") 309 || qName.equals("type") || qName.equals("number") 310 || qName.equals("url")) { 311 currentTrack.attr.put(qName, accumulator.toString()); 312 } 313 break; 314 case ext: 315 if (qName.equals("extensions")) { 316 currentState = states.pop(); 317 } 318 break; 319 default: 320 if (qName.equals("wpt")) { 321 currentState = states.pop(); 322 } else if (qName.equals("rte")) { 323 currentState = states.pop(); 324 currentData.routes.add(currentRoute); 325 } 281 } else if (qName.equals("time")) { 282 currentWayPoint.attr.put(qName, accumulator.toString()); 283 currentWayPoint.setTime(); 284 } else if (qName.equals("cmt") || qName.equals("desc")) { 285 currentWayPoint.attr.put(qName, accumulator.toString()); 286 currentWayPoint.setTime(); 287 } else if (qName.equals("rtept")) { 288 currentState = states.pop(); 289 currentRoute.routePoints.add(currentWayPoint); 290 } else if (qName.equals("trkpt")) { 291 currentState = states.pop(); 292 currentTrackSeg.add(currentWayPoint); 293 } else if (qName.equals("wpt")) { 294 currentState = states.pop(); 295 currentData.waypoints.add(currentWayPoint); 296 } 297 break; 298 case trkseg: 299 if (qName.equals("trkseg")) { 300 currentState = states.pop(); 301 currentTrack.trackSegs.add(currentTrackSeg); 302 } 303 break; 304 case trk: 305 if (qName.equals("trk")) { 306 currentState = states.pop(); 307 currentData.tracks.add(currentTrack); 308 } else if (qName.equals("name") || qName.equals("cmt") 309 || qName.equals("desc") || qName.equals("src") 310 || qName.equals("type") || qName.equals("number") 311 || qName.equals("url")) { 312 currentTrack.attr.put(qName, accumulator.toString()); 313 } 314 break; 315 case ext: 316 if (qName.equals("extensions")) { 317 currentState = states.pop(); 318 } 319 break; 320 default: 321 if (qName.equals("wpt")) { 322 currentState = states.pop(); 323 } else if (qName.equals("rte")) { 324 currentState = states.pop(); 325 currentData.routes.add(currentRoute); 326 } 326 327 } 327 328 } -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r2688 r2789 49 49 reference = reference.getParent(); 50 50 } 51 if (reference == null || ! (reference instanceof Window))51 if (reference == null) 52 52 return new WindowGeometry(new Point(0,0), extent); 53 53 parentWindow = (Window)reference; -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java
r2252 r2789 14 14 15 15 @Test 16 public void HistoryNode() {16 public void historyNode() { 17 17 Date d = new Date(); 18 18 HistoryNode node = new HistoryNode(
Note:
See TracChangeset
for help on using the changeset viewer.