Changeset 1499 in josm for trunk/src/org
- Timestamp:
- 2009-03-18T16:13:41+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r1415 r1499 254 254 if (selectedWay.keys != null) { 255 255 wayToAdd.keys = new HashMap<String, String>(selectedWay.keys); 256 wayToAdd.checkTagged();257 wayToAdd.checkDirectionTagged();258 256 } 259 257 newWays.add(wayToAdd); -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r1429 r1499 140 140 Node c = new Node(selectedNode); 141 141 c.keys = null; 142 c.tagged = false;143 142 c.selected = false; 144 143 cmds.add(new ChangeCommand(selectedNode, c)); … … 189 188 190 189 selectedNode = (Node)n; 191 return selectedNode. tagged;190 return selectedNode.isTagged(); 192 191 } 193 192 -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r1389 r1499 17 17 import org.openstreetmap.josm.data.osm.User; 18 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.tools.DateUtils; 19 20 20 21 /** … … 146 147 147 148 if (key.equals("timestamp")) 148 value = osm.getTimeStr();149 value = DateUtils.fromDate(osm.getTimestamp()); 149 150 else 150 151 value = osm.get(key); … … 315 316 private static class Untagged extends Match { 316 317 @Override public boolean match(OsmPrimitive osm) { 317 return !osm. tagged;318 return !osm.isTagged(); 318 319 } 319 320 @Override public String toString() {return "untagged";} -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r1463 r1499 189 189 if (osm instanceof Way) { 190 190 for (Node n : ((Way) osm).nodes) { 191 if (!n. tagged) {191 if (!n.isTagged()) { 192 192 CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(Main.ds, false); 193 193 n.visit(v); … … 322 322 if (wnew.keys != null) { 323 323 wnew2.keys = new HashMap<String, String>(wnew.keys); 324 wnew2.checkTagged();325 wnew2.checkDirectionTagged();326 324 } 327 325 wnew2.nodes.addAll(n2); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r1489 r1499 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.text.ParseException; 7 import java.text.SimpleDateFormat; 6 import java.util.ArrayList; 8 7 import java.util.Arrays; 9 import java.util.ArrayList;10 8 import java.util.Collection; 11 9 import java.util.Collections; 12 10 import java.util.Date; 13 11 import java.util.HashMap; 14 import java.util.HashSet;15 12 import java.util.Map; 16 13 import java.util.Map.Entry; 17 14 15 import org.openstreetmap.josm.Main; 18 16 import org.openstreetmap.josm.data.osm.visitor.Visitor; 19 import org.openstreetmap.josm.tools.DateParser;20 import org.openstreetmap.josm.Main;21 17 import org.openstreetmap.josm.gui.mappaint.ElemStyle; 22 18 … … 107 103 108 104 /** 109 * true if this object is considered "tagged". To be "tagged", an object110 * must have one or more "non-standard" tags. "created_by" and "source"111 * are typically considered "standard" tags and do not make an object112 * "tagged".113 */114 public boolean tagged = false;115 116 /**117 * true if this object has direction dependent tags (e.g. oneway)118 */119 public boolean hasDirectionKeys = false;120 121 /**122 105 * If set to true, this object is currently selected. 123 106 */ 124 107 public volatile boolean selected = false; 125 108 126 109 /** 127 110 * If set to true, this object is highlighted. Currently this is only used to 128 * show which ways/nodes will connect 111 * show which ways/nodes will connect 129 112 */ 130 113 public volatile boolean highlighted = false; 114 115 private int timestamp; 116 117 public void setTimestamp(Date timestamp) { 118 this.timestamp = (int)(timestamp.getTime() / 1000); 119 } 131 120 132 121 /** … … 134 123 * read from the server and delivered back to the server unmodified. It is 135 124 * used to check against edit conflicts. 136 */ 137 public String timestamp = null; 138 139 /** 140 * The timestamp is only parsed when this is really necessary, and this 141 * is the cache for the result. 142 */ 143 public Date parsedTimestamp = null; 125 * 126 */ 127 public Date getTimestamp() { 128 return new Date(timestamp * 1000l); 129 } 130 131 public boolean isTimestampEmpty() { 132 return timestamp == 0; 133 } 144 134 145 135 /** … … 155 145 public int version = -1; 156 146 147 private static Collection<String> uninteresting = null; 157 148 /** 158 149 * Contains a list of "uninteresting" keys that do not make an object … … 160 151 * Initialized by checkTagged() 161 152 */ 162 public static Collection<String> uninteresting = null; 153 public static Collection<String> getUninterestingKeys() { 154 if(uninteresting == null) { 155 uninteresting = Main.pref.getCollection("tags.uninteresting", 156 Arrays.asList(new String[]{"source","note","comment","converted_by","created_by"})); 157 } 158 return uninteresting; 159 } 160 161 162 private static Collection<String> directionKeys = null; 163 163 164 164 /** … … 167 167 * Initialized by checkDirectionTagged() 168 168 */ 169 public static Collection<String> directionKeys = null; 169 public static Collection<String> getDirectionKeys() { 170 if(directionKeys == null) { 171 directionKeys = Main.pref.getCollection("tags.direction", 172 Arrays.asList(new String[]{"oneway","incline","incline_steep","aerialway"})); 173 } 174 return directionKeys; 175 } 170 176 171 177 /** … … 180 186 selected = false; 181 187 modified = true; 182 }183 184 /**185 * Returns the timestamp for this object, or the current time if none is set.186 * Internally, parses the timestamp from XML into a Date object and caches it187 * for possible repeated calls.188 */189 public Date getTimestamp() {190 if (parsedTimestamp == null) {191 try {192 parsedTimestamp = DateParser.parse(timestamp);193 } catch (ParseException ex) {194 parsedTimestamp = new Date();195 }196 }197 return parsedTimestamp;198 188 } 199 189 … … 242 232 keys.put(key, value); 243 233 } 244 checkTagged();245 checkDirectionTagged();246 234 mappaintStyle = null; 247 235 } … … 255 243 keys = null; 256 244 } 257 checkTagged();258 checkDirectionTagged();259 245 mappaintStyle = null; 260 246 } … … 292 278 timestamp = osm.timestamp; 293 279 version = osm.version; 294 tagged = osm.tagged;295 280 incomplete = osm.incomplete; 296 281 clearCached(); … … 304 289 */ 305 290 public boolean realEqual(OsmPrimitive osm, boolean semanticOnly) { 306 return 307 id == osm.id && 308 incomplete == osm.incomplete && 309 (semanticOnly || (modified == osm.modified)) && 310 deleted == osm.deleted && 311 (semanticOnly || (timestamp == null ? osm.timestamp==null : timestamp.equals(osm.timestamp))) && 312 (semanticOnly || (version==osm.version)) && 313 (semanticOnly || (user == null ? osm.user==null : user==osm.user)) && 314 (semanticOnly || (visible == osm.visible)) && 315 (keys == null ? osm.keys==null : keys.equals(osm.keys)); 316 } 317 318 public String getTimeStr() { 319 return timestamp == null ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp); 320 } 321 322 /** 323 * Updates the "tagged" flag. "keys" property should probably be made private 324 * to make sure this gets called when keys are set. 325 */ 326 public void checkTagged() { 327 tagged = false; 328 if(uninteresting == null) 329 uninteresting = Main.pref.getCollection("tags.uninteresting", 330 Arrays.asList(new String[]{"source","note","comment","converted_by","created_by"})); 291 return id == osm.id 292 && incomplete == osm.incomplete 293 && deleted == osm.deleted 294 && (semanticOnly || (modified == osm.modified 295 && timestamp == osm.timestamp 296 && version == osm.version 297 && visible == osm.visible 298 && (user == null ? osm.user==null : user==osm.user))) 299 && (keys == null ? osm.keys==null : keys.equals(osm.keys)); 300 } 301 302 /** 303 * true if this object is considered "tagged". To be "tagged", an object 304 * must have one or more "non-standard" tags. "created_by" and "source" 305 * are typically considered "standard" tags and do not make an object 306 * "tagged". 307 */ 308 public boolean isTagged() { 309 // TODO Cache value after keys are made private 310 getUninterestingKeys(); 331 311 if (keys != null) { 332 312 for (Entry<String,String> e : keys.entrySet()) { 333 313 if (!uninteresting.contains(e.getKey())) { 334 tagged = true; 335 break; 314 return true; 336 315 } 337 316 } 338 317 } 339 } 340 /** 341 * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private 342 * to make sure this gets called when keys are set. 343 */ 344 public void checkDirectionTagged() { 345 hasDirectionKeys = false; 346 if(directionKeys == null) 347 /* this list only works for keys but not for values (e.g. highway=incline won't work here) */ 348 directionKeys = Main.pref.getCollection("tags.direction", 349 Arrays.asList(new String[]{"oneway","incline","incline_steep","aerialway","junction"})); 318 return false; 319 } 320 /** 321 * true if this object has direction dependent tags (e.g. oneway) 322 */ 323 public boolean hasDirectionKeys() { 324 // TODO Cache value after keys are made private 325 getDirectionKeys(); 350 326 if (keys != null) { 351 327 for (Entry<String,String> e : keys.entrySet()) { 352 328 if (directionKeys.contains(e.getKey())) { 353 hasDirectionKeys = true; 354 break; 329 return true; 355 330 } 356 331 } 357 332 } 333 return false; 358 334 } 359 335 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1463 r1499 92 92 nodes.clear(); 93 93 nodes.addAll(((Way)osm).nodes); 94 checkDirectionTagged();95 94 } 96 95 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1439 r1499 157 157 else if (n.selected) 158 158 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 159 else if (n. tagged)159 else if (n.isTagged()) 160 160 drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 161 161 else … … 245 245 (even if the tag is negated as in oneway=false) or the way is selected */ 246 246 boolean showDirection = w.selected || ((!useRealWidth) && (showDirectionArrow 247 && (!showRelevantDirectionsOnly || w.hasDirectionKeys )));247 && (!showRelevantDirectionsOnly || w.hasDirectionKeys()))); 248 248 /* head only takes over control if the option is true, 249 249 the direction should be shown at all and not only because it's selected */ -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r1169 r1499 235 235 } 236 236 if (my.realEqual(other, true)) { 237 Date myd = my. timestamp == null ? new Date(0) : my.getTimestamp();238 Date otherd = other. timestamp == null ? new Date(0) : other.getTimestamp();237 Date myd = my.getTimestamp(); 238 Date otherd = other.getTimestamp(); 239 239 240 240 // they differ in modified/timestamp combination only. Auto-resolve it. … … 242 242 if (myd.before(otherd)) { 243 243 my.modified = other.modified; 244 my. timestamp = other.timestamp;244 my.setTimestamp(other.getTimestamp()); 245 245 } 246 246 return true; // merge done. 247 247 } 248 248 if (my.id == other.id && my.id != 0) { 249 Date myd = my. timestamp == null ? new Date(0) : my.getTimestamp();250 Date otherd = other. timestamp == null ? new Date(0) : other.getTimestamp();249 Date myd = my.getTimestamp(); 250 Date otherd = other.getTimestamp(); 251 251 252 252 if (my.incomplete || other.incomplete) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r1415 r1499 163 163 //profilerN = 0; 164 164 for (final OsmPrimitive osm : data.ways) 165 if (!osm.deleted && !osm.selected && osm. tagged)165 if (!osm.deleted && !osm.selected && osm.isTagged()) 166 166 { 167 167 osm.visit(this); … … 171 171 172 172 for (final OsmPrimitive osm : data.ways) 173 if (!osm.deleted && !osm.selected && !osm. tagged)173 if (!osm.deleted && !osm.selected && !osm.isTagged()) 174 174 { 175 175 osm.visit(this); … … 255 255 else if (n.selected) 256 256 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 257 else if(n. tagged)257 else if(n.isTagged()) 258 258 drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 259 259 else … … 301 301 302 302 boolean showThisDirectionArrow = w.selected 303 || (showDirectionArrow && (!showRelevantDirectionsOnly || w.hasDirectionKeys ));303 || (showDirectionArrow && (!showRelevantDirectionsOnly || w.hasDirectionKeys())); 304 304 /* head only takes over control if the option is true, 305 305 the direction should be shown at all and not only because it's selected */ … … 313 313 } else if(w.selected) { 314 314 wayColor = selectedColor; 315 } else if (!w. tagged) {315 } else if (!w.isTagged()) { 316 316 wayColor = untaggedWayColor; 317 317 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
r1169 r1499 36 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; 37 37 import org.openstreetmap.josm.gui.SideButton; 38 import org.openstreetmap.josm.tools.DateUtils; 38 39 import org.openstreetmap.josm.tools.GBC; 39 40 import org.openstreetmap.josm.tools.ImageProvider; … … 171 172 data.setRowCount(0); 172 173 for (HistoryItem i : orderedHistory) 173 data.addRow(new Object[]{i.osm, i.osm.timestamp, i.visible});174 data.addRow(new Object[]{i.osm, DateUtils.fromDate(i.osm.getTimestamp()), i.visible}); 174 175 historyPane.setVisible(true); 175 176 notLoaded.setVisible(false); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationEditor.java
r1448 r1499 410 410 // If the user wanted to create a new relation, but hasn't added any members or 411 411 // tags, don't add an empty relation 412 clone.checkTagged(); 413 if(clone.members.size() == 0 && !clone.tagged) 412 if(clone.members.size() == 0 && !clone.isTagged()) 414 413 return; 415 414 Main.main.undoRedo.add(new AddCommand(clone)); -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1465 r1499 68 68 import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker; 69 69 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 70 import org.openstreetmap.josm.tools.DateUtils; 70 71 import org.openstreetmap.josm.tools.DontShowAgainInfo; 71 72 import org.openstreetmap.josm.tools.GBC; … … 660 661 if(timestr != null) 661 662 { 662 timestr = timestr.replace("Z","+00:00"); 663 n.timestamp = timestr; 663 n.setTimestamp(DateUtils.fromString(timestr)); 664 664 } 665 665 ds.nodes.add(n); -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r1415 r1499 61 61 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 62 62 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 63 import org.openstreetmap.josm.tools.DateUtils; 63 64 import org.openstreetmap.josm.tools.GBC; 64 65 import org.openstreetmap.josm.tools.ImageProvider; … … 402 403 trk.trackSegs.add(trkseg); 403 404 } 404 if (!n. tagged) {405 if (!n.isTagged()) { 405 406 doneNodes.add(n); 406 407 } 407 WayPoint wpt = new WayPoint(n.coor); 408 if ( n.timestamp != null)408 WayPoint wpt = new WayPoint(n.coor); 409 if (!n.isTimestampEmpty()) 409 410 { 410 wpt.attr.put("time", n.timestamp);411 wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp())); 411 412 wpt.setTime(); 412 413 } … … 420 421 if (n.incomplete || n.deleted || doneNodes.contains(n)) continue; 421 422 WayPoint wpt = new WayPoint(n.coor); 422 if ( n.timestamp != null) {423 wpt.attr.put("time", n.timestamp);423 if (!n.isTimestampEmpty()) { 424 wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp())); 424 425 wpt.setTime(); 425 426 } -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1494 r1499 33 33 import org.openstreetmap.josm.data.osm.visitor.Visitor; 34 34 import org.openstreetmap.josm.gui.PleaseWaitDialog; 35 import org.openstreetmap.josm.tools.DateUtils; 35 36 import org.xml.sax.Attributes; 36 37 import org.xml.sax.InputSource; … … 101 102 osm.selected = selected; 102 103 osm.deleted = deleted; 103 osm. timestamp = timestamp;104 osm.setTimestamp(getTimestamp()); 104 105 osm.user = user; 105 106 osm.visible = visible; 106 107 osm.version = version; 107 osm.checkTagged();108 osm.checkDirectionTagged();109 108 osm.mappaintStyle = null; 110 109 } … … 304 303 String time = atts.getValue("timestamp"); 305 304 if (time != null && time.length() != 0) { 306 /* Do not parse the date here since it wastes a HUGE amount of time. 307 * Moved into OsmPrimitive. 308 try { 309 current.timestamp = DateParser.parse(time); 310 } catch (ParseException e) { 311 e.printStackTrace(); 312 throw new SAXException(tr("Couldn''t read time format \"{0}\".",time)); 313 } 314 */ 315 current.timestamp = time; 305 current.setTimestamp(DateUtils.fromString(time)); 316 306 } 317 307 -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r1225 r1499 16 16 import org.openstreetmap.josm.data.osm.Way; 17 17 import org.openstreetmap.josm.data.osm.visitor.Visitor; 18 import org.openstreetmap.josm.tools.DateUtils; 18 19 19 20 /** … … 201 202 out.print(" action='"+action+"'"); 202 203 } 203 if ( osm.timestamp != null) {204 out.print(" timestamp='"+ osm.timestamp+"'");204 if (!osm.isTimestampEmpty()) { 205 out.print(" timestamp='"+DateUtils.fromDate(osm.getTimestamp())+"'"); 205 206 } 206 207 // user and visible added with 0.4 API
Note:
See TracChangeset
for help on using the changeset viewer.