- Timestamp:
- 2007-10-11T21:35:15+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r343 r362 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.text.ParseException; 4 5 import java.text.SimpleDateFormat; 5 6 import java.util.ArrayList; … … 12 13 13 14 import org.openstreetmap.josm.data.osm.visitor.Visitor; 15 import org.openstreetmap.josm.tools.DateParser; 14 16 15 17 … … 88 90 * used to check against edit conflicts. 89 91 */ 90 public Date timestamp = null; 91 92 public String timestamp = null; 93 94 /** 95 * The timestamp is only parsed when this is really necessary, and this 96 * is the cache for the result. 97 */ 98 public Date parsedTimestamp = null; 99 92 100 /** 93 101 * If set to true, this object is incomplete, which means only the id … … 108 116 modified = true; 109 117 } 118 119 /** 120 * Returns the timestamp for this object, or the current time if none is set. 121 * Internally, parses the timestamp from XML into a Date object and caches it 122 * for possible repeated calls. 123 */ 124 public Date getTimestamp() { 125 if (parsedTimestamp == null) { 126 try { 127 parsedTimestamp = DateParser.parse(timestamp); 128 } catch (ParseException ex) { 129 parsedTimestamp = new Date(); 130 } 131 } 132 return parsedTimestamp; 133 } 110 134 111 135 /** -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r343 r362 288 288 private <P extends OsmPrimitive> boolean mergeAfterId(Map<P,P> merged, Collection<P> primitives, P other) { 289 289 for (P my : primitives) { 290 Date d1 = my.timestamp == null ? new Date(0) : my.timestamp;291 Date d2 = other.timestamp == null ? new Date(0) : other.timestamp;292 290 if (my.realEqual(other, false)) { 293 291 if (merged != null) … … 299 297 if (merged != null) 300 298 merged.put(other, my); 301 if ( d1.before(d2)) {299 if (my.getTimestamp().before(other.getTimestamp())) { 302 300 my.modified = other.modified; 303 301 my.timestamp = other.timestamp; … … 311 309 merged.put(other, my); 312 310 } else if (!my.modified && !other.modified) { 313 if ( d1.before(d2)) {311 if (my.getTimestamp().before(other.getTimestamp())) { 314 312 cloneFromExceptIncomplete(my, other); 315 313 if (merged != null) … … 317 315 } 318 316 } else if (other.modified) { 319 if ( d1.after(d2)) {317 if (my.getTimestamp().after(other.getTimestamp())) { 320 318 conflicts.put(my, other); 321 319 if (merged != null) … … 327 325 } 328 326 } else if (my.modified) { 329 if ( d2.after(d1)) {327 if (my.getTimestamp().before(other.getTimestamp())) { 330 328 conflicts.put(my, other); 331 329 if (merged != null) -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r343 r362 8 8 import java.io.InputStreamReader; 9 9 import java.text.ParseException; 10 import java.util.ArrayList; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; 13 import java.util.Date; 12 14 import java.util.HashMap; 13 15 import java.util.HashSet; … … 150 152 current = new OsmPrimitiveData(); 151 153 readCommon(atts, current); 152 ways.put((OsmPrimitiveData)current, new LinkedList<Long>());154 ways.put((OsmPrimitiveData)current, new ArrayList<Long>()); 153 155 } else if (qName.equals("nd")) { 154 156 Collection<Long> list = ways.get(current); … … 224 226 String time = atts.getValue("timestamp"); 225 227 if (time != null && time.length() != 0) { 228 /* Do not parse the date here since it wastes a HUGE amount of time. 229 * Moved into OsmPrimitive. 226 230 try { 227 231 current.timestamp = DateParser.parse(time); … … 230 234 throw new SAXException(tr("Couldn't read time format \"{0}\".",time)); 231 235 } 236 */ 237 current.timestamp = time; 232 238 } 233 239 … … 290 296 adder.visit(w); 291 297 } 298 292 299 } 293 300 … … 393 400 throw new SAXException(e1); 394 401 } 395 if (pleaseWaitDlg != null) { 402 403 if (pleaseWaitDlg != null) { 396 404 pleaseWaitDlg.progress.setValue(0); 397 405 pleaseWaitDlg.currentAction.setText(tr("Preparing data...")); 398 406 } 407 399 408 for (Node n : osm.nodes.values()) 400 409 osm.adder.visit(n);
Note:
See TracChangeset
for help on using the changeset viewer.