Changeset 10216 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2016-05-15T14:48:06+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 9 edited
-
ChangesetQuery.java (modified) (2 diffs)
-
GpxReader.java (modified) (20 diffs)
-
MultiFetchServerObjectReader.java (modified) (2 diffs)
-
NoteReader.java (modified) (1 diff)
-
OsmApiPrimitiveGoneException.java (modified) (2 diffs)
-
OsmServerWriter.java (modified) (1 diff)
-
imagery/ImageryReader.java (modified) (2 diffs)
-
imagery/WMSImagery.java (modified) (3 diffs)
-
session/GeoImageSessionImporter.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r10194 r10216 400 400 else if (dates.length == 2) 401 401 return new Date[]{parseDate(dates[0], "time"), parseDate(dates[1], "time")}; 402 return n ull;402 return new Date[]{}; 403 403 } 404 404 … … 447 447 csQuery.closedAfterAndCreatedBefore(dates[0], dates[1]); 448 448 break; 449 default: 450 Main.warn("Unable to parse time: " + entry.getValue()); 449 451 } 450 452 break; -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r10212 r10216 45 45 46 46 private enum State { 47 init,48 gpx,49 metadata,50 wpt,51 rte,52 trk,53 ext,54 author,55 link,56 trkseg,57 copyright47 INIT, 48 GPX, 49 METADATA, 50 WPT, 51 RTE, 52 TRK, 53 EXT, 54 AUTHOR, 55 LINK, 56 TRKSEG, 57 COPYRIGHT 58 58 } 59 59 … … 72 72 private WayPoint currentWayPoint; 73 73 74 private State currentState = State. init;74 private State currentState = State.INIT; 75 75 76 76 private GpxLink currentLink; … … 108 108 elements.push(localName); 109 109 switch(currentState) { 110 case init:110 case INIT: 111 111 states.push(currentState); 112 currentState = State. gpx;112 currentState = State.GPX; 113 113 data.creator = atts.getValue("creator"); 114 114 version = atts.getValue("version"); … … 120 120 } 121 121 break; 122 case gpx:122 case GPX: 123 123 switch (localName) { 124 124 case "metadata": 125 125 states.push(currentState); 126 currentState = State. metadata;126 currentState = State.METADATA; 127 127 break; 128 128 case "wpt": 129 129 states.push(currentState); 130 currentState = State. wpt;130 currentState = State.WPT; 131 131 currentWayPoint = new WayPoint(parseLatLon(atts)); 132 132 break; 133 133 case "rte": 134 134 states.push(currentState); 135 currentState = State. rte;135 currentState = State.RTE; 136 136 currentRoute = new GpxRoute(); 137 137 break; 138 138 case "trk": 139 139 states.push(currentState); 140 currentState = State. trk;140 currentState = State.TRK; 141 141 currentTrack = new ArrayList<>(); 142 142 currentTrackAttr = new HashMap<>(); … … 144 144 case "extensions": 145 145 states.push(currentState); 146 currentState = State. ext;146 currentState = State.EXT; 147 147 currentExtensions = new Extensions(); 148 148 break; … … 151 151 nokiaSportsTrackerBug = true; 152 152 } 153 } 154 break; 155 case metadata: 153 break; 154 default: // Do nothing 155 } 156 break; 157 case METADATA: 156 158 switch (localName) { 157 159 case "author": 158 160 states.push(currentState); 159 currentState = State. author;161 currentState = State.AUTHOR; 160 162 break; 161 163 case "extensions": 162 164 states.push(currentState); 163 currentState = State. ext;165 currentState = State.EXT; 164 166 currentExtensions = new Extensions(); 165 167 break; 166 168 case "copyright": 167 169 states.push(currentState); 168 currentState = State. copyright;170 currentState = State.COPYRIGHT; 169 171 data.put(META_COPYRIGHT_AUTHOR, atts.getValue("author")); 170 172 break; 171 173 case "link": 172 174 states.push(currentState); 173 currentState = State. link;175 currentState = State.LINK; 174 176 currentLink = new GpxLink(atts.getValue("href")); 175 177 break; … … 180 182 parseCoord(atts.getValue("maxlat")), 181 183 parseCoord(atts.getValue("maxlon")))); 182 } 183 break; 184 case author: 185 switch (localName) { 186 case "link": 187 states.push(currentState); 188 currentState = State.link; 184 break; 185 default: // Do nothing 186 } 187 break; 188 case AUTHOR: 189 switch (localName) { 190 case "link": 191 states.push(currentState); 192 currentState = State.LINK; 189 193 currentLink = new GpxLink(atts.getValue("href")); 190 194 break; 191 195 case "email": 192 196 data.put(META_AUTHOR_EMAIL, atts.getValue("id") + '@' + atts.getValue("domain")); 193 } 194 break; 195 case trk: 197 break; 198 default: // Do nothing 199 } 200 break; 201 case TRK: 196 202 switch (localName) { 197 203 case "trkseg": 198 204 states.push(currentState); 199 currentState = State. trkseg;205 currentState = State.TRKSEG; 200 206 currentTrackSeg = new ArrayList<>(); 201 207 break; 202 208 case "link": 203 209 states.push(currentState); 204 currentState = State. link;210 currentState = State.LINK; 205 211 currentLink = new GpxLink(atts.getValue("href")); 206 212 break; 207 213 case "extensions": 208 214 states.push(currentState); 209 currentState = State. ext;215 currentState = State.EXT; 210 216 currentExtensions = new Extensions(); 211 } 212 break; 213 case trkseg: 217 break; 218 default: // Do nothing 219 } 220 break; 221 case TRKSEG: 214 222 if ("trkpt".equals(localName)) { 215 223 states.push(currentState); 216 currentState = State. wpt;224 currentState = State.WPT; 217 225 currentWayPoint = new WayPoint(parseLatLon(atts)); 218 226 } 219 227 break; 220 case wpt:221 switch (localName) { 222 case "link": 223 states.push(currentState); 224 currentState = State. link;228 case WPT: 229 switch (localName) { 230 case "link": 231 states.push(currentState); 232 currentState = State.LINK; 225 233 currentLink = new GpxLink(atts.getValue("href")); 226 234 break; 227 235 case "extensions": 228 236 states.push(currentState); 229 currentState = State. ext;237 currentState = State.EXT; 230 238 currentExtensions = new Extensions(); 231 239 break; 232 } 233 break; 234 case rte: 235 switch (localName) { 236 case "link": 237 states.push(currentState); 238 currentState = State.link; 240 default: // Do nothing 241 } 242 break; 243 case RTE: 244 switch (localName) { 245 case "link": 246 states.push(currentState); 247 currentState = State.LINK; 239 248 currentLink = new GpxLink(atts.getValue("href")); 240 249 break; 241 250 case "rtept": 242 251 states.push(currentState); 243 currentState = State. wpt;252 currentState = State.WPT; 244 253 currentWayPoint = new WayPoint(parseLatLon(atts)); 245 254 break; 246 255 case "extensions": 247 256 states.push(currentState); 248 currentState = State. ext;257 currentState = State.EXT; 249 258 currentExtensions = new Extensions(); 250 259 break; 251 } 252 break; 260 default: // Do nothing 261 } 262 break; 263 default: // Do nothing 253 264 } 254 265 accumulator.setLength(0); … … 276 287 private Map<String, Object> getAttr() { 277 288 switch (currentState) { 278 case rte: return currentRoute.attr;279 case metadata: return data.attr;280 case wpt: return currentWayPoint.attr;281 case trk: return currentTrackAttr;289 case RTE: return currentRoute.attr; 290 case METADATA: return data.attr; 291 case WPT: return currentWayPoint.attr; 292 case TRK: return currentTrackAttr; 282 293 default: return null; 283 294 } … … 289 300 elements.pop(); 290 301 switch (currentState) { 291 case gpx: // GPX 1.0292 case metadata: // GPX 1.1302 case GPX: // GPX 1.0 303 case METADATA: // GPX 1.1 293 304 switch (localName) { 294 305 case "name": … … 321 332 case "metadata": 322 333 case "gpx": 323 if ((currentState == State. metadata&& "metadata".equals(localName)) ||324 (currentState == State. gpx&& "gpx".equals(localName))) {334 if ((currentState == State.METADATA && "metadata".equals(localName)) || 335 (currentState == State.GPX && "gpx".equals(localName))) { 325 336 convertUrlToLink(data.attr); 326 337 if (currentExtensions != null && !currentExtensions.isEmpty()) { … … 337 348 } 338 349 break; 339 case author:350 case AUTHOR: 340 351 switch (localName) { 341 352 case "author": … … 351 362 data.put(META_AUTHOR_LINK, currentLink); 352 363 break; 353 } 354 break; 355 case copyright: 364 default: // Do nothing 365 } 366 break; 367 case COPYRIGHT: 356 368 switch (localName) { 357 369 case "copyright": … … 364 376 data.put(META_COPYRIGHT_LICENSE, accumulator.toString()); 365 377 break; 366 } 367 break; 368 case link: 378 default: // Do nothing 379 } 380 break; 381 case LINK: 369 382 switch (localName) { 370 383 case "text": … … 380 393 currentState = states.pop(); 381 394 break; 382 } 383 if (currentState == State.author) { 395 default: // Do nothing 396 } 397 if (currentState == State.AUTHOR) { 384 398 data.put(META_AUTHOR_LINK, currentLink); 385 } else if (currentState != State. link) {399 } else if (currentState != State.LINK) { 386 400 Map<String, Object> attr = getAttr(); 387 401 if (!attr.containsKey(META_LINKS)) { … … 391 405 } 392 406 break; 393 case wpt:407 case WPT: 394 408 switch (localName) { 395 409 case "ele": … … 437 451 data.waypoints.add(currentWayPoint); 438 452 break; 439 } 440 break; 441 case trkseg: 453 default: // Do nothing 454 } 455 break; 456 case TRKSEG: 442 457 if ("trkseg".equals(localName)) { 443 458 currentState = states.pop(); … … 445 460 } 446 461 break; 447 case trk:462 case TRK: 448 463 switch (localName) { 449 464 case "trk": … … 462 477 currentTrackAttr.put(localName, accumulator.toString()); 463 478 break; 464 } 465 break; 466 case ext: 479 default: // Do nothing 480 } 481 break; 482 case EXT: 467 483 if ("extensions".equals(localName)) { 468 484 currentState = states.pop(); … … 482 498 data.routes.add(currentRoute); 483 499 break; 500 default: // Do nothing 484 501 } 485 502 } … … 516 533 } 517 534 518 publicvoid tryToFinish() throws SAXException {535 void tryToFinish() throws SAXException { 519 536 List<String> remainingElements = new ArrayList<>(elements); 520 537 for (int i = remainingElements.size() - 1; i >= 0; i--) { -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r10212 r10216 125 125 case WAY: ways.add(id.getUniqueId()); break; 126 126 case RELATION: relations.add(id.getUniqueId()); break; 127 default: throw new AssertionError(); 127 128 } 128 129 } … … 580 581 for (long id : pkg) { 581 582 try { 582 String msg = "";583 String msg; 583 584 switch (type) { 584 585 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, baseUrl); break; 585 586 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, baseUrl); break; 586 587 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, baseUrl); break; 588 default: throw new AssertionError(); 587 589 } 588 590 progressMonitor.setCustomText(msg); -
trunk/src/org/openstreetmap/josm/io/NoteReader.java
r10136 r10216 126 126 } 127 127 break; 128 default: // Do nothing 128 129 } 129 130 } -
trunk/src/org/openstreetmap/josm/io/OsmApiPrimitiveGoneException.java
r8510 r10216 11 11 * Represents an exception thrown by the OSM API if JOSM tries to update or delete a primitive 12 12 * which is already deleted on the server. 13 * 13 * @since 2198 14 14 */ 15 15 public class OsmApiPrimitiveGoneException extends OsmApiException { … … 19 19 public static final String ERROR_HEADER_PATTERN = "The (\\S+) with the id (\\d+) has already been deleted"; 20 20 /** the type of the primitive which is gone on the server */ 21 private OsmPrimitiveType type; 21 private final OsmPrimitiveType type; 22 22 /** the id of the primitive */ 23 private long id; 23 private final long id; 24 24 25 /** 26 * Constructs a new {@code OsmApiPrimitiveGoneException}. 27 * @param errorHeader error header 28 * @param errorBody error body 29 */ 25 30 public OsmApiPrimitiveGoneException(String errorHeader, String errorBody) { 26 31 super(HttpURLConnection.HTTP_GONE, errorHeader, errorBody); 27 if (errorHeader == null) return; 28 Pattern p = Pattern.compile(ERROR_HEADER_PATTERN); 29 Matcher m = p.matcher(errorHeader); 30 if (m.matches()) { 31 type = OsmPrimitiveType.from(m.group(1)); 32 id = Long.parseLong(m.group(2)); 32 if (errorHeader != null) { 33 Matcher m = Pattern.compile(ERROR_HEADER_PATTERN).matcher(errorHeader); 34 if (m.matches()) { 35 type = OsmPrimitiveType.from(m.group(1)); 36 id = Long.parseLong(m.group(2)); 37 } else { 38 type = null; 39 id = 0; 40 } 41 } else { 42 type = null; 43 id = 0; 33 44 } 34 45 } -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r10181 r10216 219 219 break; 220 220 case CHUNKED_DATASET_STRATEGY: 221 default: 221 222 uploadChangesInChunks(primitives, monitor.createSubTaskMonitor(0, false), strategy.getChunkSize()); 222 223 break; -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r9977 r10216 228 228 } 229 229 break; 230 default: // Do nothing 230 231 } 231 232 /** … … 433 434 entry.setEpsg4326To3857Supported(Boolean.valueOf(accumulator.toString())); 434 435 break; 436 default: // Do nothing 435 437 } 436 438 break; -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r10212 r10216 55 55 private List<String> formats; 56 56 57 /** 58 * Returns the list of layers. 59 * @return the list of layers 60 */ 57 61 public List<LayerDetails> getLayers() { 58 62 return layers; 59 63 } 60 64 65 /** 66 * Returns the service URL. 67 * @return the service URL 68 */ 61 69 public URL getServiceUrl() { 62 70 return serviceUrl; 63 71 } 64 72 73 /** 74 * Returns the list of supported formats. 75 * @return the list of supported formats 76 */ 65 77 public List<String> getFormats() { 66 78 return Collections.unmodifiableList(formats); … … 311 323 content.append(node.getNodeValue()); 312 324 break; 325 default: // Do nothing 313 326 } 314 327 } … … 371 384 return this.name; 372 385 } 373 374 386 } 375 387 } -
trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java
r9455 r10216 49 49 Node attrNode = attrNodes.item(j); 50 50 if (attrNode.getNodeType() == Node.ELEMENT_NODE) { 51 Element attrElem = (Element) attrNode; 52 try { 53 switch(attrElem.getTagName()) { 54 case "file": 55 entry.setFile(new File(attrElem.getTextContent())); 56 break; 57 case "position": 58 double lat = Double.parseDouble(attrElem.getAttribute("lat")); 59 double lon = Double.parseDouble(attrElem.getAttribute("lon")); 60 entry.setPos(new LatLon(lat, lon)); 61 break; 62 case "speed": 63 entry.setSpeed(Double.valueOf(attrElem.getTextContent())); 64 break; 65 case "elevation": 66 entry.setElevation(Double.valueOf(attrElem.getTextContent())); 67 break; 68 case "gps-time": 69 entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 70 break; 71 case "exif-orientation": 72 entry.setExifOrientation(Integer.valueOf(attrElem.getTextContent())); 73 break; 74 case "exif-time": 75 entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent()))); 76 break; 77 case "exif-gps-time": 78 entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 79 break; 80 case "exif-coordinates": 81 entry.setExifCoor(new LatLon( 82 Double.parseDouble(attrElem.getAttribute("lat")), 83 Double.parseDouble(attrElem.getAttribute("lon")))); 84 break; 85 case "exif-image-direction": 86 entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent())); 87 break; 88 case "is-new-gps-data": 89 if (Boolean.parseBoolean(attrElem.getTextContent())) { 90 entry.flagNewGpsData(); 91 } 92 } 93 // TODO: handle thumbnail loading 94 } catch (NumberFormatException e) { 95 // do nothing 96 if (Main.isTraceEnabled()) { 97 Main.trace(e.getMessage()); 98 } 99 } 51 handleElement(entry, (Element) attrNode); 100 52 } 101 53 } … … 118 70 return new GeoImageLayer(entries, gpxLayer, useThumbs); 119 71 } 72 73 private static void handleElement(ImageEntry entry, Element attrElem) { 74 try { 75 switch(attrElem.getTagName()) { 76 case "file": 77 entry.setFile(new File(attrElem.getTextContent())); 78 break; 79 case "position": 80 double lat = Double.parseDouble(attrElem.getAttribute("lat")); 81 double lon = Double.parseDouble(attrElem.getAttribute("lon")); 82 entry.setPos(new LatLon(lat, lon)); 83 break; 84 case "speed": 85 entry.setSpeed(Double.valueOf(attrElem.getTextContent())); 86 break; 87 case "elevation": 88 entry.setElevation(Double.valueOf(attrElem.getTextContent())); 89 break; 90 case "gps-time": 91 entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 92 break; 93 case "exif-orientation": 94 entry.setExifOrientation(Integer.valueOf(attrElem.getTextContent())); 95 break; 96 case "exif-time": 97 entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent()))); 98 break; 99 case "exif-gps-time": 100 entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 101 break; 102 case "exif-coordinates": 103 entry.setExifCoor(new LatLon( 104 Double.parseDouble(attrElem.getAttribute("lat")), 105 Double.parseDouble(attrElem.getAttribute("lon")))); 106 break; 107 case "exif-image-direction": 108 entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent())); 109 break; 110 case "is-new-gps-data": 111 if (Boolean.parseBoolean(attrElem.getTextContent())) { 112 entry.flagNewGpsData(); 113 } 114 break; 115 default: // Do nothing 116 } 117 // TODO: handle thumbnail loading 118 } catch (NumberFormatException e) { 119 if (Main.isTraceEnabled()) { 120 Main.trace(e.getMessage()); 121 } 122 } 123 } 120 124 }
Note:
See TracChangeset
for help on using the changeset viewer.
