Ticket #2302: tagged.2.patch
File tagged.2.patch, 14.1 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/actions/SplitWayAction.java
253 253 Way wayToAdd = new Way(); 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); 260 258 wayToAdd.nodes.addAll(chunkIt.next()); -
src/org/openstreetmap/josm/actions/search/SearchCompiler.java
314 314 315 315 private static class Untagged extends Match { 316 316 @Override public boolean match(OsmPrimitive osm) { 317 return !osm. tagged;317 return !osm.isTagged(); 318 318 } 319 319 @Override public String toString() {return "untagged";} 320 320 } -
src/org/openstreetmap/josm/actions/UnGlueAction.java
139 139 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)); 145 144 … … 188 187 return false; 189 188 190 189 selectedNode = (Node)n; 191 return selectedNode. tagged;190 return selectedNode.isTagged(); 192 191 } 193 192 194 193 /** -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
401 401 trkseg = new ArrayList<WayPoint>(); 402 402 trk.trackSegs.add(trkseg); 403 403 } 404 if (!n. tagged) {404 if (!n.isTagged()) { 405 405 doneNodes.add(n); 406 406 } 407 407 WayPoint wpt = new WayPoint(n.coor); -
src/org/openstreetmap/josm/gui/dialogs/RelationEditor.java
409 409 if (RelationEditor.this.relation == null) { 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)); 416 415 DataSet.fireSelectionChanged(Main.ds.getSelected()); -
src/org/openstreetmap/josm/io/OsmReader.java
104 104 osm.user = user; 105 105 osm.visible = visible; 106 106 osm.version = version; 107 osm.checkTagged();108 osm.checkDirectionTagged();109 107 osm.mappaintStyle = null; 110 108 } 111 109 } -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
162 162 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); 168 168 // profilerN++; … … 170 170 displaySegments(); 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); 176 176 // profilerN++; … … 254 254 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 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 260 260 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); … … 300 300 (even if the tag is negated as in oneway=false) or the way is selected */ 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 */ 306 306 boolean showOnlyHeadArrowOnly = showThisDirectionArrow && !w.selected && showHeadArrowOnly; … … 312 312 wayColor = highlightColor; 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 { 318 318 wayColor = dfltWayColor; -
src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
156 156 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 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 162 162 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); … … 244 244 the way is tagged with a direction key 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 */ 250 250 boolean showOnlyHeadArrowOnly = showDirection && !w.selected && showHeadArrowOnly; -
src/org/openstreetmap/josm/data/osm/Way.java
91 91 super.cloneFrom(osm); 92 92 nodes.clear(); 93 93 nodes.addAll(((Way)osm).nodes); 94 checkDirectionTagged();95 94 } 96 95 97 96 @Override public String toString() { -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
106 106 public User user = null; 107 107 108 108 /** 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 109 * If set to true, this object is currently selected. 123 110 */ 124 111 public volatile boolean selected = false; … … 154 141 */ 155 142 public int version = -1; 156 143 144 private static Collection<String> uninteresting = null; 157 145 /** 158 146 * Contains a list of "uninteresting" keys that do not make an object 159 147 * "tagged". 160 148 * Initialized by checkTagged() 161 149 */ 162 public static Collection<String> uninteresting = null; 150 public static Collection<String> getUninterestingKeys() { 151 if(uninteresting == null) { 152 uninteresting = Main.pref.getCollection("tags.uninteresting", 153 Arrays.asList(new String[]{"source","note","comment","converted_by","created_by"})); 154 } 155 return uninteresting; 156 } 157 163 158 159 private static Collection<String> directionKeys = null; 160 164 161 /** 165 162 * Contains a list of direction-dependent keys that make an object 166 163 * direction dependent. 167 164 * Initialized by checkDirectionTagged() 168 165 */ 169 public static Collection<String> directionKeys = null; 166 public static Collection<String> getDirectionKeys() { 167 if(directionKeys == null) { 168 directionKeys = Main.pref.getCollection("tags.direction", 169 Arrays.asList(new String[]{"oneway","incline","incline_steep","aerialway"})); 170 } 171 return directionKeys; 172 } 170 173 171 174 /** 172 175 * Implementation of the visitor scheme. Subclasses have to call the correct … … 241 244 keys = new HashMap<String, String>(); 242 245 keys.put(key, value); 243 246 } 244 checkTagged();245 checkDirectionTagged();246 247 mappaintStyle = null; 247 248 } 248 249 /** … … 254 255 if (keys.isEmpty()) 255 256 keys = null; 256 257 } 257 checkTagged();258 checkDirectionTagged();259 258 mappaintStyle = null; 260 259 } 261 260 … … 291 290 selected = osm.selected; 292 291 timestamp = osm.timestamp; 293 292 version = osm.version; 294 tagged = osm.tagged;295 293 incomplete = osm.incomplete; 296 294 clearCached(); 297 295 clearErrors(); … … 319 317 return timestamp == null ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp); 320 318 } 321 319 320 322 321 /** 323 * Updates the "tagged" flag. "keys" property should probably be made private 324 * to make sure this gets called when keys are set. 322 * true if this object is considered "tagged". To be "tagged", an object 323 * must have one or more "non-standard" tags. "created_by" and "source" 324 * are typically considered "standard" tags and do not make an object 325 * "tagged". 325 326 */ 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"})); 327 public boolean isTagged() { 328 // TODO Cache value after keys are made private 329 getUninterestingKeys(); 331 330 if (keys != null) { 332 331 for (Entry<String,String> e : keys.entrySet()) { 333 332 if (!uninteresting.contains(e.getKey())) { 334 tagged = true; 335 break; 333 return true; 336 334 } 337 335 } 338 336 } 337 return false; 339 338 } 340 339 /** 341 * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private 342 * to make sure this gets called when keys are set. 340 * true if this object has direction dependent tags (e.g. oneway) 343 341 */ 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"})); 342 public boolean hasDirectionKeys() { 343 // TODO Cache value after keys are made private 344 getDirectionKeys(); 350 345 if (keys != null) { 351 346 for (Entry<String,String> e : keys.entrySet()) { 352 347 if (directionKeys.contains(e.getKey())) { 353 hasDirectionKeys = true; 354 break; 348 return true; 355 349 } 356 350 } 357 351 } 352 return false; 358 353 } 354 359 355 } -
src/org/openstreetmap/josm/command/DeleteCommand.java
188 188 for (OsmPrimitive osm : del) { 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); 194 194 v.data.removeAll(del); … … 321 321 Way wnew2 = new Way(); 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); 328 326 cmds.add(new AddCommand(wnew2));