Changeset 23979 in osm for applications/editors/josm/plugins/FixAddresses/src
- Timestamp:
- 2010-11-01T02:37:25+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java
r23967 r23979 54 54 55 55 /** 56 * Provides a container serving streets and unresolved/incomplete addresses. 56 * Provides a container serving streets and unresolved/incomplete addresses. It scans through a 57 * set of OSM primitives and checks for incomplete addresses (e. g. missing addr:... tags) or 58 * addresses with unknown streets ("unresolved addresses"). 59 * 60 * It listens to changes within instances of {@link INodeEntity} to notify clients on update. 61 * 62 * {@link AddressEditContainer} is the central class used within actions and UI models to show 63 * and alter OSM data. 64 * 65 * {@see AbstractAddressEditAction} 66 * {@see AddressEditTableModel} 67 * 57 68 * @author Oliver Wieland <oliver.wieland@online.de> 58 69 * … … 60 71 61 72 public class AddressEditContainer implements Visitor, DataSetListener, IAddressEditContainerListener { 62 private HashMap<String, StreetNode> streetDict = new HashMap<String, StreetNode>(100); 73 74 /** The street dictionary collecting all streets to a set of unique street names. */ 75 private HashMap<String, StreetNode> streetDict = new HashMap<String, StreetNode>(100); 76 77 /** The unresolved addresses list. */ 63 78 private List<AddressNode> unresolvedAddresses = new ArrayList<AddressNode>(100); 79 80 /** The incomplete addresses list. */ 64 81 private List<AddressNode> incompleteAddresses = new ArrayList<AddressNode>(100); 65 82 66 private HashMap<String, StreetNode> shadowStreetDict = new HashMap<String, StreetNode>(100); 83 /** The shadow copy to assemble the street dict during update. */ 84 private HashMap<String, StreetNode> shadowStreetDict = new HashMap<String, StreetNode>(100); 85 /** The shadow copy to assemble the unresolved addresses during update. */ 67 86 private List<AddressNode> shadowUnresolvedAddresses = new ArrayList<AddressNode>(100); 87 /** The shadow copy to assemble the incomplete addresses during update. */ 68 88 private List<AddressNode> shadowIncompleteAddresses = new ArrayList<AddressNode>(100); 69 89 90 /** The visited nodes cache to increase iteration spped. */ 70 91 private HashSet<Node> visitedNodes = new HashSet<Node>(); 71 private HashSet<Way> visitedWays = new HashSet<Way>(); 92 /** The visited ways cache to increase iteration spped. */ 93 private HashSet<Way> visitedWays = new HashSet<Way>(); 94 /** The tag list used within the data area. */ 72 95 private HashSet<String> tags = new HashSet<String>(); 73 96 97 /** The change listeners. */ 74 98 private List<IAddressEditContainerListener> listeners = new ArrayList<IAddressEditContainerListener>(); 75 99 76 100 /** 77 * 101 * Creates an empty container. 78 102 */ 79 103 public AddressEditContainer() { … … 109 133 } 110 134 135 /** 136 * Marks an OSM node as visited. 137 * 138 * @param n the node to mark. 139 */ 111 140 private void markNodeAsVisited(Node n) { 112 141 visitedNodes.add(n); 113 142 } 114 143 144 /** 145 * Checks a node for been visited. 146 * 147 * @param n the n 148 * @return true, if successful 149 */ 115 150 private boolean hasBeenVisited(Node n) { 116 151 return visitedNodes.contains(n); 117 152 } 118 153 154 /** 155 * Marks a way as visited. 156 * 157 * @param w the way to mark 158 */ 119 159 private void markWayAsVisited(Way w) { 120 160 visitedWays.add(w); … … 171 211 } 172 212 173 213 /** 214 * Adds and classify an address node according to completeness. 215 * 216 * @param aNode the address node to add and check 217 */ 174 218 private void addAndClassifyAddress(AddressNode aNode) { 175 219 if (!assignAddressToStreet(aNode)) { … … 182 226 } 183 227 } 184 185 228 186 229 /** 187 230 * Creates the node from an OSM way instance. 188 231 * 189 * @param w the w 232 * @param w the way to create the entity from 190 233 */ 191 234 private void createNodeFromWay(Way w) { … … 210 253 211 254 /** 212 * Process a entity node. 255 * Process an entity node depending on the type. A street segment is added as a child to the 256 * corresponding street dictionary while an address is added to the incomplete/unresolved list 257 * depending of it's properties. 213 258 * 214 259 * @param ne the entity node. … … 411 456 412 457 /** 413 * Rebuilds the street and address lists .458 * Rebuilds the street and address lists using the current data set. 414 459 */ 415 460 public void invalidate() { … … 417 462 } 418 463 464 /** 465 * Invalidate using the given data collection. 466 * 467 * @param osmData the collection containing the osm data to work on. 468 */ 419 469 public void invalidate(final Collection<? extends OsmPrimitive> osmData) { 420 470 if (osmData == null || osmData.isEmpty()) … … 445 495 } 446 496 447 public void clearData() { 497 /** 498 * Clears the shadowed lists data and resets the 'visited' flag for every OSM object. 499 */ 500 private void clearData() { 448 501 shadowStreetDict.clear(); 449 502 shadowUnresolvedAddresses.clear(); … … 455 508 /** 456 509 * Connects the listener to the data set and revisits the data. This method should 457 * be called immediately before an edit session starts. 510 * be called immediately after an edit session finished. 511 * 512 * <code> 513 * detachFromDataSet(); 514 * //... launch dialog or whatever 515 * attachToDataSet(); 516 * </code> 458 517 */ 459 518 public void attachToDataSet(Collection<? extends OsmPrimitive> dataToExamine) { … … 468 527 /** 469 528 * Disconnects the listener from the data set. This method should 470 * be called immediately after an edit session has ended. 529 * be called immediately before an edit session started in order to 530 * prevent updates caused by e. g. a selection change within the map view. 471 531 */ 472 532 public void detachFromDataSet() { … … 474 534 } 475 535 536 /* (non-Javadoc) 537 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#dataChanged(org.openstreetmap.josm.data.osm.event.DataChangedEvent) 538 */ 476 539 @Override 477 540 public void dataChanged(DataChangedEvent event) { 478 541 } 479 542 543 /* (non-Javadoc) 544 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#nodeMoved(org.openstreetmap.josm.data.osm.event.NodeMovedEvent) 545 */ 480 546 @Override 481 547 public void nodeMoved(NodeMovedEvent event) { … … 483 549 } 484 550 551 /* (non-Javadoc) 552 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#otherDatasetChange(org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent) 553 */ 485 554 @Override 486 555 public void otherDatasetChange(AbstractDatasetChangedEvent event) { 487 556 } 488 557 558 /* (non-Javadoc) 559 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#primtivesAdded(org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent) 560 */ 489 561 @Override 490 562 public void primtivesAdded(PrimitivesAddedEvent event) { … … 492 564 } 493 565 566 /* (non-Javadoc) 567 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#primtivesRemoved(org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent) 568 */ 494 569 @Override 495 570 public void primtivesRemoved(PrimitivesRemovedEvent event) { … … 497 572 } 498 573 574 /* (non-Javadoc) 575 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#relationMembersChanged(org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent) 576 */ 499 577 @Override 500 578 public void relationMembersChanged(RelationMembersChangedEvent event) { 501 579 } 502 580 581 /* (non-Javadoc) 582 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#tagsChanged(org.openstreetmap.josm.data.osm.event.TagsChangedEvent) 583 */ 503 584 @Override 504 585 public void tagsChanged(TagsChangedEvent event) { … … 506 587 } 507 588 589 /* (non-Javadoc) 590 * @see org.openstreetmap.josm.data.osm.event.DataSetListener#wayNodesChanged(org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent) 591 */ 508 592 @Override 509 593 public void wayNodesChanged(WayNodesChangedEvent event) { 510 594 } 511 595 596 /* (non-Javadoc) 597 * @see org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener#containerChanged(org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer) 598 */ 512 599 @Override 513 600 public void containerChanged(AddressEditContainer container) { 514 515 } 516 601 invalidate(); 602 } 603 604 /* (non-Javadoc) 605 * @see org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener#entityChanged(org.openstreetmap.josm.plugins.fixAddresses.INodeEntity) 606 */ 517 607 @Override 518 608 public void entityChanged(INodeEntity entity) {
Note:
See TracChangeset
for help on using the changeset viewer.