Changeset 23981 in osm for applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap
- Timestamp:
- 2010-11-01T03:38:44+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java
r23979 r23981 72 72 public class AddressEditContainer implements Visitor, DataSetListener, IAddressEditContainerListener { 73 73 74 private Collection<? extends OsmPrimitive> workingSet; 74 75 /** The street dictionary collecting all streets to a set of unique street names. */ 75 76 private HashMap<String, StreetNode> streetDict = new HashMap<String, StreetNode>(100); … … 106 107 107 108 /** 109 * Gets the working set used by the container. This can by either the complete or just 110 * a subset of the current data layer. 111 * 112 * @return the workingSet 113 */ 114 protected Collection<? extends OsmPrimitive> getWorkingSet() { 115 return workingSet; 116 } 117 118 119 /** 108 120 * Adds a change listener. 109 121 * @param listener … … 146 158 * 147 159 * @param n the n 148 * @return true, if successful160 * @return true, if node has been visited 149 161 */ 150 162 private boolean hasBeenVisited(Node n) { … … 161 173 } 162 174 175 /** 176 * Checks a way for been visited. 177 * 178 * @param w the w to check 179 * @return true, if way has been visited 180 */ 163 181 private boolean hasBeenVisited(Way w) { 164 182 return visitedWays.contains(w); … … 180 198 if (aNode != null) { 181 199 addAndClassifyAddress(aNode); 182 } /*else { 183 // check, if node is referred by a way 184 for (OsmPrimitive osm : n.getReferrers()) { 185 if (osm instanceof Way) { 186 Way w = (Way) osm; 187 if (!hasBeenVisited(w)) { 188 createNodeFromWay(w); 189 } 190 } 191 } 192 193 }*/ 200 } 194 201 markNodeAsVisited(n); 195 202 } … … 234 241 private void createNodeFromWay(Way w) { 235 242 INodeEntity ne = NodeFactory.createNodeFromWay(w); 236 237 243 238 244 if (!processNode(ne, w)) { 239 240 245 // Look also into nodes for addresses (unlikely, but at least they 241 246 // get marked as visited). … … 249 254 } 250 255 } 251 } 256 } // else: node has been processed, no need to look deeper 252 257 } 253 258 … … 456 461 457 462 /** 458 * Rebuilds the street and address lists using the current data set. 463 * Rebuilds the street and address lists using the data set given 464 * in {@link AddressEditContainer#attachToDataSet(Collection)} or the 465 * full data set of the current data layer {@link Main#getCurrentDataSet()}. 459 466 */ 460 467 public void invalidate() { 461 invalidate(Main.main.getCurrentDataSet().allPrimitives()); 468 if (workingSet != null) { 469 invalidate(workingSet); 470 } else { 471 invalidate(Main.main.getCurrentDataSet().allPrimitives()); 472 } 462 473 } 463 474 … … 507 518 508 519 /** 509 * Connects the listener to the data set and revisits the data. This method should520 * Connects the listener to the given data set and revisits the data. This method should 510 521 * be called immediately after an edit session finished. 511 522 * 523 * If the given data set is not null, calls of {@link AddressEditContainer#invalidate()} will 524 * only consider the data given within this set. This can be useful to keep out unimportant 525 * areas. However, a side-effect could be that some streets are not included and leads to 526 * false alarms regarding unresolved addresses. 527 * 528 * Calling {@link AddressEditContainer#detachFromDataSet()} drops the explicit data set and uses 529 * the full data set on subsequent updates.<p> 530 * 531 * <b>Example</b><br> 512 532 * <code> 533 * attachToDataSet(osmDataSetToWorkOn); // osmDataSetToWorkOn = selected items<br> 534 * //... launch dialog or whatever<br> 513 535 * detachFromDataSet(); 514 * //... launch dialog or whatever515 * attachToDataSet();516 536 * </code> 517 */ 518 public void attachToDataSet(Collection<? extends OsmPrimitive> dataToExamine) { 519 Main.main.getCurrentDataSet().addDataSetListener(this); 520 if (dataToExamine != null && dataToExamine.size() > 0) { 521 invalidate(dataToExamine); // use given data set (usually the current selection) 537 * 538 * @param osmDataToWorkOn the data to examine 539 */ 540 public void attachToDataSet(Collection<? extends OsmPrimitive> osmDataToWorkOn) { 541 if (osmDataToWorkOn != null && !osmDataToWorkOn.isEmpty()) { 542 workingSet = new ArrayList<OsmPrimitive>(osmDataToWorkOn); 522 543 } else { 523 invalidate(); // use current data set 524 } 544 detachFromDataSet(); // drop old stuff, if present 545 } 546 invalidate(); // start our investigation... 525 547 } 526 548 … … 531 553 */ 532 554 public void detachFromDataSet() { 533 Main.main.getCurrentDataSet().removeDataSetListener(this); 555 //Main.main.getCurrentDataSet().removeDataSetListener(this); 556 if (workingSet != null) { 557 workingSet.clear(); 558 workingSet = null; 559 } 534 560 } 535 561 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixUnresolvedStreetsAction.java
r23933 r23981 48 48 @Override 49 49 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 50 /* this changes the dialog contents, so we do nothing here50 /* remember new selection for actionPerformed */ 51 51 this.newSelection = newSelection; 52 if (addressEditContainer != null) {53 addressEditContainer.invalidate(newSelection);54 }*/55 52 } 56 53
Note:
See TracChangeset
for help on using the changeset viewer.