Changeset 25373 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-02-20T10:50:59+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ 14 14 /** 15 * This program is free software: you can redistribute it and/or modify it under 16 * the terms of the GNU General Public License as published by the 17 * Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 21 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 * See the GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along with this program. 15 * This program is free software: you can redistribute it and/or modify it under 16 * the terms of the GNU General Public License as published by the 17 * Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 21 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 * See the GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along with this program. 25 25 * If not, see <http://www.gnu.org/licenses/>. 26 26 */ … … 58 58 * set of OSM primitives and checks for incomplete addresses (e. g. missing addr:... tags) or 59 59 * addresses with unknown streets ("unresolved addresses"). 60 * 61 * It listens to changes within instances of {@link IOSMEntity} to notify clients on update. 62 * 60 * 61 * It listens to changes within instances of {@link IOSMEntity} to notify clients on update. 62 * 63 63 * {@link AddressEditContainer} is the central class used within actions and UI models to show 64 64 * and alter OSM data. 65 * 65 * 66 66 * {@see AbstractAddressEditAction} 67 67 * {@see AddressEditTableModel} 68 * 68 * 69 69 * @author Oliver Wieland <oliver.wieland@online.de> 70 * 70 * 71 71 */ 72 72 73 73 public class AddressEditContainer implements Visitor, DataSetListener, IAddressEditContainerListener, IProblemVisitor, IAllKnowingTrashHeap { 74 74 75 75 private Collection<? extends OsmPrimitive> workingSet; 76 76 /** The street dictionary collecting all streets to a set of unique street names. */ 77 77 private HashMap<String, OSMStreet> streetDict = new HashMap<String, OSMStreet>(100); 78 78 79 79 /** The unresolved addresses list. */ 80 80 private List<OSMAddress> unresolvedAddresses = new ArrayList<OSMAddress>(100); 81 81 82 82 /** The incomplete addresses list. */ 83 83 private List<OSMAddress> incompleteAddresses = new ArrayList<OSMAddress>(100); 84 84 85 85 /** The shadow copy to assemble the street dict during update. */ 86 86 private HashMap<String, OSMStreet> shadowStreetDict = new HashMap<String, OSMStreet>(100); … … 89 89 /** The shadow copy to assemble the incomplete addresses during update. */ 90 90 private List<OSMAddress> shadowIncompleteAddresses = new ArrayList<OSMAddress>(100); 91 91 92 92 /** The visited nodes cache to increase iteration speed. */ 93 93 private HashSet<Node> visitedNodes = new HashSet<Node>(); 94 94 /** The visited ways cache to increase iteration speed. */ 95 private HashSet<Way> visitedWays = new HashSet<Way>(); 95 private HashSet<Way> visitedWays = new HashSet<Way>(); 96 96 /** The tag list used within the data area. */ 97 97 private HashSet<String> tags = new HashSet<String>(); 98 98 /** The tag list used within the data area. */ 99 99 private HashMap<String, String> values = new HashMap<String, String>(); 100 100 101 101 /** The list containing the problems */ 102 102 private List<IProblem> problems = new ArrayList<IProblem>(); 103 103 104 104 /** The change listeners. */ 105 105 private List<IAddressEditContainerListener> listeners = new ArrayList<IAddressEditContainerListener>(); 106 107 /** 108 * Creates an empty container. 106 107 /** 108 * Creates an empty container. 109 109 */ 110 110 public AddressEditContainer() { … … 130 130 listeners.add(listener); 131 131 } 132 132 133 133 /** 134 134 * Removes a change listener. … … 138 138 listeners.remove(listener); 139 139 } 140 140 141 141 /** 142 142 * Notifies clients that the address container changed. 143 143 */ 144 144 protected void fireContainerChanged() { 145 List<IAddressEditContainerListener> shadowListeners = 145 List<IAddressEditContainerListener> shadowListeners = 146 146 new ArrayList<IAddressEditContainerListener>(listeners); 147 147 148 148 for (IAddressEditContainerListener listener : shadowListeners) { 149 149 listener.containerChanged(this); 150 150 } 151 151 } 152 152 153 153 /** 154 154 * Notifies clients that an entity within the address container changed. … … 156 156 protected void fireEntityChanged(IOSMEntity entity) { 157 157 if (entity == null) throw new RuntimeException("Entity must not be null"); 158 159 List<IAddressEditContainerListener> shadowListeners = 158 159 List<IAddressEditContainerListener> shadowListeners = 160 160 new ArrayList<IAddressEditContainerListener>(listeners); 161 161 162 162 for (IAddressEditContainerListener listener : shadowListeners) { 163 163 listener.entityChanged(entity); 164 164 } 165 165 } 166 166 167 167 /** 168 168 * Marks an OSM node as visited. … … 173 173 visitedNodes.add(n); 174 174 } 175 175 176 176 /** 177 177 * Checks a node for been visited. … … 183 183 return visitedNodes.contains(n); 184 184 } 185 185 186 186 /** 187 187 * Marks a way as visited. … … 192 192 visitedWays.add(w); 193 193 } 194 194 195 195 /** 196 196 * Checks a way for been visited. … … 202 202 return visitedWays.contains(w); 203 203 } 204 204 205 205 /* (non-Javadoc) 206 206 * @see org.openstreetmap.josm.data.osm.visitor.Visitor#visit(org.openstreetmap.josm.data.osm.Node) … … 215 215 // Address nodes are recycled in order to keep instance variables like guessed names 216 216 aNode = OsmFactory.createNode(n); 217 217 218 218 if (aNode != null) { 219 219 addAndClassifyAddress(aNode); 220 220 aNode.visit(this, this); 221 } 221 } 222 222 markNodeAsVisited(n); 223 223 } 224 224 225 225 /* (non-Javadoc) 226 226 * @see org.openstreetmap.josm.data.osm.visitor.Visitor#visit(org.openstreetmap.josm.data.osm.Way) … … 228 228 @Override 229 229 public void visit(Way w) { 230 // This doesn't matter, we just need the street name 230 // This doesn't matter, we just need the street name 231 231 //if (w.isIncomplete()) return; 232 232 233 233 if (hasBeenVisited(w)) { 234 234 return; 235 235 } 236 236 237 237 createNodeFromWay(w); 238 238 markWayAsVisited(w); … … 246 246 private void addAndClassifyAddress(OSMAddress aNode) { 247 247 if (!assignAddressToStreet(aNode)) { 248 // Assignment failed: Street is not known (yet) -> add to 'unresolved' list 248 // Assignment failed: Street is not known (yet) -> add to 'unresolved' list 249 249 shadowUnresolvedAddresses.add(aNode); 250 250 } … … 262 262 private void createNodeFromWay(Way w) { 263 263 IOSMEntity ne = OsmFactory.createNodeFromWay(w); 264 264 265 265 if (!processNode(ne, w)) { 266 266 // Look also into nodes for addresses (unlikely, but at least they … … 274 274 tags.add(key); 275 275 } 276 276 277 277 String v = w.get(key); 278 278 if (!values.containsKey(v)) { … … 286 286 * Process an entity node depending on the type. A street segment is added as a child to the 287 287 * corresponding street dictionary while an address is added to the incomplete/unresolved list 288 * depending of it's properties. 288 * depending of it's properties. 289 289 * 290 290 * @param ne the entity node. … … 321 321 } 322 322 323 // Node is an address 323 // Node is an address 324 324 if (ne instanceof OSMAddress) { 325 325 OSMAddress aNode = (OSMAddress) ne; … … 352 352 return streetDict; 353 353 } 354 354 355 355 /** 356 356 * Gets the unresolved (addresses without valid street name) addresses. … … 376 376 * @return the street list 377 377 */ 378 public List<OSMStreet> getStreetList() { 378 public List<OSMStreet> getStreetList() { 379 379 ArrayList<OSMStreet> sortedList = new ArrayList<OSMStreet>(streetDict.values()); 380 380 Collections.sort(sortedList); … … 397 397 return tags; 398 398 } 399 399 400 400 /** 401 401 * @return the values … … 412 412 return streetDict != null ? streetDict.size() : 0; 413 413 } 414 414 415 415 /** 416 416 * Get the number of incomplete addresses. … … 420 420 return incompleteAddresses != null ? incompleteAddresses.size() : 0; 421 421 } 422 422 423 423 /** 424 424 * Gets the number of unresolved addresses. … … 428 428 return unresolvedAddresses != null ? unresolvedAddresses.size() : 0; 429 429 } 430 430 431 431 /** 432 432 * Gets the number of invalid (unresolved and/or incomplete) addresses. … … 437 437 return getNumberOfIncompleteAddresses() + getNumberOfUnresolvedAddresses(); 438 438 } 439 439 440 440 /** 441 441 * Gets the number of guessed tags. … … 444 444 public int getNumberOfGuesses() { 445 445 int sum = 0; 446 446 447 447 for (OSMAddress aNode : getAllAddressesToFix()) { 448 448 if (aNode.hasGuesses()) { … … 452 452 return sum; 453 453 } 454 454 455 455 /** 456 456 * Gets all (incomplete and/or unresolved) address nodes to fix. … … 465 465 } 466 466 } 467 468 return all; 469 } 470 467 468 return all; 469 } 470 471 471 /** 472 472 * @return the problems … … 475 475 return problems; 476 476 } 477 477 478 478 /** 479 479 * Clears the problem list. … … 489 489 private boolean assignAddressToStreet(OSMAddress aNode) { 490 490 String streetName = aNode.getStreetName(); 491 491 492 492 if (streetName != null && shadowStreetDict.containsKey(streetName)) { 493 493 OSMStreet sNode = shadowStreetDict.get(streetName); … … 495 495 return true; 496 496 } 497 497 498 498 return false; 499 499 } 500 500 501 501 /** 502 502 * Walks through the list of unassigned addresses and tries to assign them to streets. … … 507 507 if (assignAddressToStreet(node)) { 508 508 resolvedAddresses.add(node); 509 } 510 } 511 509 } 510 } 511 512 512 /* Remove all resolves nodes from unresolved list */ 513 513 for (OSMAddress resolved : resolvedAddresses) { … … 515 515 } 516 516 } 517 517 518 518 /** 519 519 * Rebuilds the street and address lists using the data set given 520 * in {@link AddressEditContainer#attachToDataSet(Collection)} or the 521 * full data set of the current data layer {@link Main#getCurrentDataSet()}. 520 * in {@link AddressEditContainer#attachToDataSet(Collection)} or the 521 * full data set of the current data layer {@link Main#getCurrentDataSet()}. 522 522 */ 523 523 public void invalidate() { … … 530 530 } 531 531 } 532 532 533 533 /** 534 534 * Invalidate using the given data collection. … … 543 543 clearData(); 544 544 clearProblems(); 545 545 546 546 for (OsmPrimitive osmPrimitive : osmData) { 547 547 osmPrimitive.visit(this); … … 561 561 shadowUnresolvedAddresses.clear(); 562 562 shadowIncompleteAddresses.clear(); 563 563 564 564 // update clients 565 565 fireContainerChanged(); 566 566 } 567 567 } 568 568 569 569 /** 570 570 * Clears the shadowed lists data and resets the 'visited' flag for every OSM object. … … 577 577 visitedWays.clear(); 578 578 } 579 579 580 580 /** 581 581 * Connects the listener to the given data set and revisits the data. This method should 582 582 * be called immediately after an edit session finished. 583 * 583 * 584 584 * If the given data set is not null, calls of {@link AddressEditContainer#invalidate()} will 585 585 * only consider the data given within this set. This can be useful to keep out unimportant 586 586 * areas. However, a side-effect could be that some streets are not included and leads to 587 587 * false alarms regarding unresolved addresses. 588 * 588 * 589 589 * Calling {@link AddressEditContainer#detachFromDataSet()} drops the explicit data set and uses 590 590 * the full data set on subsequent updates.<p> 591 * 591 * 592 592 * <b>Example</b><br> 593 593 * <code> … … 600 600 */ 601 601 public void attachToDataSet(Collection<? extends OsmPrimitive> osmDataToWorkOn) { 602 if (osmDataToWorkOn != null && !osmDataToWorkOn.isEmpty()) { 602 if (osmDataToWorkOn != null && !osmDataToWorkOn.isEmpty()) { 603 603 workingSet = new ArrayList<OsmPrimitive>(osmDataToWorkOn); 604 604 } else { … … 607 607 invalidate(); // start our investigation... 608 608 } 609 609 610 610 /** 611 611 * Disconnects the listener from the data set. This method should 612 * be called immediately before an edit session started in order to 612 * be called immediately before an edit session started in order to 613 613 * prevent updates caused by e. g. a selection change within the map view. 614 614 */ 615 615 public void detachFromDataSet() { 616 //Main.main.getCurrentDataSet().removeDataSetListener(this); 616 //Main.main.getCurrentDataSet().removeDataSetListener(this); 617 617 if (workingSet != null) { 618 618 workingSet.clear(); … … 633 633 @Override 634 634 public void nodeMoved(NodeMovedEvent event) { 635 635 636 636 } 637 637 … … 671 671 @Override 672 672 public void tagsChanged(TagsChangedEvent event) { 673 invalidate(); 673 invalidate(); 674 674 } 675 675 … … 694 694 @Override 695 695 public void entityChanged(IOSMEntity entity) { 696 fireEntityChanged(entity); 697 } 698 696 fireEntityChanged(entity); 697 } 698 699 699 /* (non-Javadoc) 700 700 * @see org.openstreetmap.josm.plugins.fixAddresses.IProblemVisitor#addProblem(org.openstreetmap.josm.plugins.fixAddresses.IProblem) … … 711 711 public void removeProblemsOfSource(IOSMEntity entity) { 712 712 CheckParameterUtil.ensureParameterNotNull(entity, "entity"); 713 713 714 714 List<IProblem> problemsToRemove = new ArrayList<IProblem>(); 715 715 for (IProblem problem : problems) { … … 718 718 } 719 719 } 720 720 721 721 for (IProblem iProblem : problemsToRemove) { 722 722 problems.remove(iProblem); … … 730 730 public String getClosestStreetName(String name) { 731 731 List<String> matches = getClosestStreetNames(name, 1); 732 732 733 733 if (matches != null && matches.size() > 0) { 734 734 return matches.get(0); 735 735 } 736 736 737 737 return null; 738 738 } … … 744 744 public List<String> getClosestStreetNames(String name, int maxEntries) { 745 745 CheckParameterUtil.ensureParameterNotNull(name, "name"); 746 746 747 747 // ensure right number of entries 748 748 if (maxEntries < 1) maxEntries = 1; 749 749 750 750 List<StreetScore> scores = new ArrayList<StreetScore>(); 751 751 List<String> matches = new ArrayList<String>(); 752 752 753 753 // Find the longest common sub string 754 for (String 754 for (String streetName : streetDict.keySet()) { 755 755 int score = StringUtils.lcsLength(name, streetName); 756 756 757 757 if (score > 3) { // reasonable value? 758 758 StreetScore sc = new StreetScore(streetName, score); … … 760 760 } 761 761 } 762 762 763 763 // sort by score 764 764 Collections.sort(scores); 765 765 766 766 // populate result list 767 767 int n = Math.min(maxEntries, scores.size()); … … 769 769 matches.add(scores.get(i).getName()); 770 770 } 771 771 772 772 return matches; 773 773 } … … 779 779 public boolean isValidStreetName(String name) { 780 780 if (streetDict == null) return false; 781 781 782 782 return streetDict.containsKey(name); 783 783 } 784 784 785 785 /** 786 786 * Internal class to handle results of {@link AddressEditContainer#getClosestStreetNames(String, int)}. … … 789 789 private String name; 790 790 private int score; 791 791 792 792 /** 793 793 * @param name Name of the street. … … 817 817 public int compareTo(StreetScore arg0) { 818 818 if (arg0 == null) return 1; 819 819 820 820 return new Integer(score).compareTo(new Integer(arg0.score)); 821 821 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressProblem.java
r24979 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 52 52 this(source, description, solutions, ProblemType.Warning); 53 53 } 54 54 55 55 /** 56 56 * Instantiates a new problem with type 'warning' and without solutions. … … 71 71 } 72 72 } 73 73 74 74 /* (non-Javadoc) 75 75 * @see org.openstreetmap.josm.plugins.fixAddresses.IProblem#addSolution(org.openstreetmap.josm.plugins.fixAddresses.ISolution) … … 78 78 public void addSolution(ISolution solution) { 79 79 CheckParameterUtil.ensureParameterNotNull(solution, "solution"); 80 80 81 81 lazyCreateSolutions(); 82 82 solutions.add(solution); … … 89 89 public void applySolution(ISolution solution) { 90 90 CheckParameterUtil.ensureParameterNotNull(solution, "solution"); 91 92 solution.solve(); 91 92 solution.solve(); 93 93 } 94 94 … … 99 99 public void clearSolutions() { 100 100 if (solutions == null) return; 101 101 102 102 solutions.clear(); 103 103 } … … 134 134 if (solutions == null ) throw new RuntimeException("Solution list is null"); 135 135 if (solutions.size() == 0) throw new RuntimeException("Solution list is empty"); 136 136 137 137 CheckParameterUtil.ensureParameterNotNull(solution, "solution"); 138 138 solutions.remove(solution); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressSolution.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 23 23 private String description; 24 24 private SolutionType type; 25 25 26 26 /** 27 27 * @param description The solution description. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesMapMode.java
r24112 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 26 26 27 27 public FixAddressesMapMode(MapFrame mapFrame) { 28 super(tr("Fix adresses"), "incompleteaddress_24", 29 tr("Show dialog with incomplete addresses"), 30 mapFrame, 28 super(tr("Fix adresses"), "incompleteaddress_24", 29 tr("Show dialog with incomplete addresses"), 30 mapFrame, 31 31 Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 32 32 } 33 33 34 34 35 35 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java
r24977 r25373 1 1 /** 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 27 27 public class FixAddressesPlugin extends Plugin { 28 28 private static IncompleteAddressesDialog incompleteAddrDlg; 29 private static FixAddressesPreferences preferences; 29 private static FixAddressesPreferences preferences; 30 30 31 31 /** … … 35 35 public FixAddressesPlugin(PluginInformation info) { 36 36 super(info); 37 37 38 38 // Create actions... 39 FixUnresolvedStreetsAction action = new FixUnresolvedStreetsAction(); 39 FixUnresolvedStreetsAction action = new FixUnresolvedStreetsAction(); 40 40 SelectIncompleteAddressesAction incAddrAction = new SelectIncompleteAddressesAction(); 41 41 42 42 // ... and add them to the tools menu in main 43 43 Main.main.menu.toolsMenu.addSeparator(); 44 45 46 47 48 44 Main.main.menu.toolsMenu.add(action); 45 Main.main.menu.toolsMenu.add(incAddrAction); 46 47 // create preferences instance 48 preferences = (FixAddressesPreferences) new FixAddressesPreferences.Factory().createPreferenceSetting(); 49 49 } 50 50 … … 56 56 // TODO Auto-generated method stub 57 57 super.mapFrameInitialized(oldFrame, newFrame); 58 58 59 59 if (newFrame != null) { 60 60 incompleteAddrDlg = new IncompleteAddressesDialog(); 61 61 FixAddressesMapMode faMode = new FixAddressesMapMode(Main.map); 62 62 IconToggleButton faModeButton = new IconToggleButton(faMode); 63 63 faModeButton.setVisible(true); 64 newFrame.addToggleDialog(incompleteAddrDlg); 64 newFrame.addToggleDialog(incompleteAddrDlg); 65 65 } 66 66 } 67 68 67 68 69 69 70 70 /** … … 74 74 return incompleteAddrDlg; 75 75 } 76 76 77 77 /** 78 78 * Gets the preferences instance for this plugin. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPreferences.java
r24230 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 23 23 24 24 public static class Factory implements PreferenceSettingFactory { 25 26 27 28 29 25 public PreferenceSetting createPreferenceSetting() { 26 return new FixAddressesPreferences(); 27 } 28 } 29 30 30 @Override 31 31 public void addGui(PreferenceTabbedPane gui) { 32 32 // TODO Auto-generated method stub 33 33 34 34 } 35 35 … … 59 59 this.selectGuessedObjects = selectGuessedObjects; 60 60 } 61 62 63 61 62 63 64 64 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixUnresolvedStreetsAction.java
r24112 r25373 18 18 * Action to find and fix addresses without (valid) streets. It launches an dialog 19 19 * instance of {@link AddressEditDialog}. 20 * 20 * 21 21 * @author Oliver Wieland <oliver.wieland@online.de> 22 22 */ … … 34 34 Shortcut.GROUP_MENU, InputEvent.ALT_DOWN_MASK 35 35 | InputEvent.SHIFT_DOWN_MASK), false); 36 37 setEnabled(false); 38 addressEditContainer = new AddressEditContainer(); 39 DataSet.addSelectionListener(this); 36 37 setEnabled(false); 38 addressEditContainer = new AddressEditContainer(); 39 DataSet.addSelectionListener(this); 40 40 } 41 41 … … 53 53 */ 54 54 @Override 55 public void actionPerformed(ActionEvent arg0) { 55 public void actionPerformed(ActionEvent arg0) { 56 56 if (addressEditContainer != null) { 57 57 addressEditContainer.attachToDataSet(newSelection); … … 65 65 } 66 66 } 67 67 68 68 69 69 /* (non-Javadoc) … … 79 79 Collection<? extends OsmPrimitive> selection) { 80 80 // Enable button if there is either a selection or at least a data set 81 setEnabled( selection != null && !selection.isEmpty() ||81 setEnabled( selection != null && !selection.isEmpty() || 82 82 (getCurrentDataSet() != null)); 83 83 } … … 87 87 @SuppressWarnings("unused") 88 88 private void generateTagCode(AddressEditContainer addrVisitor) { 89 89 90 90 for (String tag : addrVisitor.getTags()) { 91 91 String methodName = createMethodName(tag); … … 109 109 .toUpperCase().replaceAll(":", "_"), tag)); 110 110 } 111 111 112 112 for (String value : addrVisitor.getValues().keySet()) { 113 113 String tag = addrVisitor.getValues().get(value); 114 115 String tags = tag.toUpperCase().replaceAll(":", "_"); 114 115 String tags = tag.toUpperCase().replaceAll(":", "_"); 116 116 String values = value.toUpperCase().replaceAll(":", "_"); 117 117 System.out.println(String.format( -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/GuessAddressRunnable.java
r24209 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 35 35 /** 36 36 * The class GuessAddressRunnable scans the data set to find the best guess for a missing address field. 37 * 38 * The guessing procedure itself is implemented by defining "guessers" using the {@link GuessedValueHandler} 39 * class. A guessed field does not modify the corresponding property of {@link OSMAddress} itself, but 40 * adds the guessed value to a shadowed field by calling {@link OSMAddress#setGuessedValue(String, String)}. 37 * 38 * The guessing procedure itself is implemented by defining "guessers" using the {@link GuessedValueHandler} 39 * class. A guessed field does not modify the corresponding property of {@link OSMAddress} itself, but 40 * adds the guessed value to a shadowed field by calling {@link OSMAddress#setGuessedValue(String, String)}. 41 41 */ 42 42 public class GuessAddressRunnable extends PleaseWaitRunnable implements Visitor { … … 45 45 private double minDist; 46 46 private OSMAddress curAddressNode; 47 private boolean isRunning = false; 47 private boolean isRunning = false; 48 48 private boolean cancelled; 49 50 49 50 51 51 /** 52 52 * Instantiates a new guess address runnable. … … 57 57 public GuessAddressRunnable(List<OSMAddress> addresses, String title) { 58 58 super(title != null ? title : tr("Searching")); 59 setAddressEditContainer(addresses); 59 setAddressEditContainer(addresses); 60 60 } 61 61 … … 69 69 throw new ConcurrentModificationException(); 70 70 } 71 this.addressesToGuess = nodes; 71 this.addressesToGuess = nodes; 72 72 } 73 73 … … 86 86 return isRunning; 87 87 } 88 88 89 89 /** 90 90 * Adds a finish listener. … … 95 95 finishListeners.add(l); 96 96 } 97 97 98 98 /** 99 99 * Removes a finish listener. … … 127 127 LatLon ll = curAddressNode.getCoor(); 128 128 if (ll == null) return; 129 129 130 130 double dist = ll.greatCircleDistance(n.getCoor()); 131 131 132 132 if (dist < minDist) { 133 133 minDist = dist; … … 141 141 public void visit(Way w) { 142 142 // skip non-streets and streets without name 143 if (!TagUtils.hasHighwayTag(w)) return; 143 if (!TagUtils.hasHighwayTag(w)) return; 144 144 if (!TagUtils.hasNameTag(w)) return; 145 145 146 146 for (Node node : w.getNodes()) { 147 147 visit(node); 148 } 148 } 149 149 } 150 150 … … 154 154 @Override 155 155 public void visit(Relation e) { 156 // nothing to do yet 156 // nothing to do yet 157 157 } 158 158 … … 170 170 @Override 171 171 protected void cancel() { 172 cancelled = true; 172 cancelled = true; 173 173 } 174 174 … … 191 191 isRunning = true; 192 192 cancelled = false; 193 193 194 194 // Start progress monitor to guess address values 195 195 progressMonitor.subTask(tr("Searching") + "..."); 196 196 197 197 try { 198 198 progressMonitor.setTicksCount(addressesToGuess.size()); 199 200 201 199 200 201 202 202 List<OSMAddress> shadowCopy = new ArrayList<OSMAddress>(addressesToGuess); 203 for (OSMAddress aNode : shadowCopy) { 203 for (OSMAddress aNode : shadowCopy) { 204 204 minDist = Double.MAX_VALUE; 205 205 curAddressNode = aNode; 206 206 207 207 // setup guessing handlers for address tags 208 208 GuessedValueHandler[] guessers = new GuessedValueHandler[]{ 209 new GuessStreetValueHandler(TagUtils.ADDR_STREET_TAG, aNode), 209 new GuessStreetValueHandler(TagUtils.ADDR_STREET_TAG, aNode), 210 210 new GuessedValueHandler(TagUtils.ADDR_POSTCODE_TAG, aNode, 500.0), 211 211 new GuessedValueHandler(TagUtils.ADDR_CITY_TAG, aNode, 5000.0), … … 214 214 new GuessedValueHandler(TagUtils.ADDR_CITY_TAG, aNode, 2000.0) 215 215 }; 216 217 if (!aNode.needsGuess()) { // nothing to do 216 217 if (!aNode.needsGuess()) { // nothing to do 218 218 progressMonitor.worked(1); 219 219 continue; 220 220 } 221 221 222 222 // check for cancel 223 223 if (cancelled) { … … 232 232 break; 233 233 } 234 235 // guess values 234 235 // guess values 236 236 for (int i = 0; i < guessers.length; i++) { 237 237 osmPrimitive.visit(guessers[i]); 238 238 239 239 if (guessers[i].currentValue == null && i == 0) { 240 240 //System.err.println("Guess #" + i + " failed for " + aNode); … … 242 242 } 243 243 } 244 244 245 245 // report progress 246 progressMonitor.worked(1); 246 progressMonitor.worked(1); 247 247 } 248 248 } finally { … … 251 251 } 252 252 } 253 253 254 254 private class GuessStreetValueHandler extends GuessedValueHandler { 255 255 … … 270 270 */ 271 271 @Override 272 public void visit(Way w) { 272 public void visit(Way w) { 273 273 if (TagUtils.isStreetSupportingHousenumbers(w)) { 274 274 OSMAddress aNode = getAddressNode(); 275 275 double dist = OsmUtils.getMinimumDistanceToWay(aNode.getCoor(), w); 276 276 277 277 if (dist < minDist && dist < getMaxDistance()) { 278 278 //System.out.println(String.format("New guess %s: %4.2f m", TagUtils.getNameValue(w), dist)); 279 279 minDist = dist; 280 currentValue = TagUtils.getNameValue(w); 280 currentValue = TagUtils.getNameValue(w); 281 281 aNode.setGuessedValue(getTag(), currentValue, w); 282 282 } else { -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/GuessedValueHandler.java
r24209 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 24 24 * The guess is determined by finding the closest way/node with the given tag. If no appropriate node 25 25 * is found within maximum distance, no guess is made. 26 * 26 * 27 27 * The default maximum distance is 100m. 28 28 */ 29 29 public class GuessedValueHandler implements Visitor { 30 30 31 31 /** Default maximum distance (100m) */ 32 32 private static final double DEFAULT_MAX_DIST = 100.0; 33 33 34 34 private String tag; 35 35 protected double minDist; … … 37 37 private OSMAddress aNode; 38 38 private double maxDist = DEFAULT_MAX_DIST; 39 39 40 40 /** 41 41 * Instantiates a new guessed value handler. … … 48 48 this(tag, aNode, DEFAULT_MAX_DIST); 49 49 } 50 50 51 51 /** 52 52 * Instantiates a new guessed value handler. … … 58 58 public GuessedValueHandler(String tag, OSMAddress aNode, double maxDist) { 59 59 super(); 60 60 61 61 if (StringUtils.isNullOrEmpty(tag)) { 62 62 throw new RuntimeException("Tag must not be empty or null!"); 63 63 } 64 64 65 65 if (aNode == null) { 66 throw new RuntimeException("Address node must not be null!"); 66 throw new RuntimeException("Address node must not be null!"); 67 67 } 68 68 69 69 if (maxDist < 1.0) { // clip value 70 70 maxDist = 1.0; 71 71 } 72 72 this.tag = tag; 73 73 74 74 minDist = Double.MAX_VALUE; 75 75 this.aNode = aNode; 76 this.maxDist = maxDist; 76 this.maxDist = maxDist; 77 77 } 78 78 79 79 /** 80 80 * Gets the address node to make the guess for. … … 87 87 88 88 /** 89 * Gets the max distance allowed to consider a node as guess. 90 * If the distance of the node is greater than maxDist, the 89 * Gets the max distance allowed to consider a node as guess. 90 * If the distance of the node is greater than maxDist, the 91 91 * node/way will be ignored. 92 92 * … … 123 123 return currentValue; 124 124 } 125 125 126 126 /** 127 127 * Check if we need to visit the OSM data … … 132 132 return aNode.needsGuessedValue(tag); 133 133 } 134 134 135 135 /* (non-Javadoc) 136 136 * @see org.openstreetmap.josm.data.osm.visitor.Visitor#visit(org.openstreetmap.josm.data.osm.Node) … … 142 142 if (dist < minDist && dist < maxDist) { 143 143 minDist = dist; 144 currentValue = n.get(tag); 144 currentValue = n.get(tag); 145 145 aNode.setGuessedValue(tag, currentValue, n); 146 146 } … … 157 157 if (dist < minDist && dist < maxDist) { 158 158 minDist = dist; 159 currentValue = w.get(tag); 159 currentValue = w.get(tag); 160 160 aNode.setGuessedValue(tag, currentValue, w); 161 161 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/IAddressEditContainerListener.java
r24089 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 21 21 */ 22 22 public void containerChanged(AddressEditContainer container); 23 23 24 24 /** 25 25 * Notifies clients that an entity has been changed. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/IAllKnowingTrashHeap.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 17 17 18 18 public interface IAllKnowingTrashHeap { 19 19 20 20 /** 21 21 * Gets the list containing the best matching (closest) street names. … … 26 26 */ 27 27 public List<String> getClosestStreetNames(String name, int maxEntries); 28 28 29 29 /** 30 30 * Gets the closest street name to the given name. … … 34 34 */ 35 35 public String getClosestStreetName(String name); 36 36 37 37 /** 38 38 * Checks if the given street name is valid. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/ICommandListener.java
r24089 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/IOSMEntity.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 23 23 * around OSM objects in order to ease up some tasks like tag handling. 24 24 * @author Oliver Wieland <oliver.wieland@online.de> 25 * 25 * 26 26 */ 27 27 … … 32 32 */ 33 33 public OsmPrimitive getOsmObject(); 34 34 35 35 /** 36 36 * Checks if underlying OSM object has a name. … … 38 38 */ 39 39 public boolean hasName(); 40 40 41 41 /** 42 42 * Gets the name of the entity node. … … 44 44 */ 45 45 public String getName(); 46 46 47 47 /** 48 48 * Gets the children of the entity node. … … 50 50 */ 51 51 public List<IOSMEntity> getChildren(); 52 52 53 53 /** 54 54 * Gets the coordinate of the node. If the the underlying object is a 55 * node, it just returns the node coordinate. For ways and areas, this 56 * method returns the coordinate of the center (balance point). 55 * node, it just returns the node coordinate. For ways and areas, this 56 * method returns the coordinate of the center (balance point). 57 57 * @return 58 58 */ 59 59 public LatLon getCoor(); 60 60 61 61 /** 62 62 * Adds a command listener. … … 64 64 */ 65 65 public void addCommandListener(ICommandListener listener); 66 66 67 67 /** 68 68 * Removes a command listener. … … 70 70 */ 71 71 public void removeCommandListener(ICommandListener listener); 72 72 73 73 /** 74 74 * Collects problems and possible solutions. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/IProblem.java
r24978 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 17 17 18 18 public interface IProblem { 19 19 20 20 /** 21 21 * Gets the OSM entity which causes the problem. … … 24 24 */ 25 25 public IOSMEntity getSource(); 26 26 27 27 /** 28 28 * Gets the problem description. … … 31 31 */ 32 32 public String getDescription(); 33 33 34 34 /** 35 35 * Gets the problem type. … … 38 38 */ 39 39 public ProblemType getType(); 40 40 41 41 /** 42 42 * Gets the available solutions for this problem. … … 45 45 */ 46 46 public List<ISolution> getSolutions(); 47 47 48 48 /** 49 49 * Adds a possible solution to the problem. … … 52 52 */ 53 53 public void addSolution(ISolution solution); 54 54 55 55 /** 56 56 * Removes a solution from this problem. … … 59 59 */ 60 60 public void removeSolution(ISolution solution); 61 61 62 62 /** 63 63 * Removes all solutions from this problem. 64 64 */ 65 65 public void clearSolutions(); 66 66 67 67 /** 68 68 * Applies a {@link ISolution} instance on the problem. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/IProblemVisitor.java
r24978 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 22 22 */ 23 23 public void addProblem(IProblem problem); 24 24 25 25 /** 26 26 * Removes the problems of the given source. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/IProgressMonitorFinishedListener.java
r24023 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/ISolution.java
r24978 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 17 17 18 18 public interface ISolution { 19 19 20 20 /** 21 21 * Gets the description of the solution. … … 24 24 */ 25 25 public String getDescription(); 26 26 27 27 /** 28 28 * Gets the action to execute for solving the problem. … … 31 31 */ 32 32 public JosmAction getAction(); 33 33 34 34 /** 35 35 * Gets the solution type. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMAddress.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 24 24 25 25 /** 26 * The class OSMAddress represents a single address node of OSM. It is a lightweight 26 * The class OSMAddress represents a single address node of OSM. It is a lightweight 27 27 * wrapper for a OSM node in order to simplify tag handling. 28 28 */ … … 30 30 public static final String MISSING_TAG = "?"; 31 31 public static final String INTERPOLATION_TAG = "x..y"; 32 33 34 /** True, if address is part of an address interpolation. */ 35 private boolean isPartOfInterpolation; 36 /** 37 * True, if address has derived values from an associated street relation. 32 33 34 /** True, if address is part of an address interpolation. */ 35 private boolean isPartOfInterpolation; 36 /** 37 * True, if address has derived values from an associated street relation. 38 38 */ 39 39 private boolean isPartOfAssocStreetRel; 40 40 41 41 /** The dictionary containing guessed values. */ 42 42 private HashMap<String, String> guessedValues = new HashMap<String, String>(); … … 49 49 super(osmObject); 50 50 } 51 51 52 52 /* (non-Javadoc) 53 53 * @see org.openstreetmap.josm.plugins.addressEdit.NodeEntityBase#setOsmObject(org.openstreetmap.josm.data.osm.OsmPrimitive) … … 56 56 public void setOsmObject(OsmPrimitive osmObject) { 57 57 super.setOsmObject(osmObject); 58 59 isPartOfInterpolation = OsmUtils.getValuesFromAddressInterpolation(this); 58 59 isPartOfInterpolation = OsmUtils.getValuesFromAddressInterpolation(this); 60 60 isPartOfAssocStreetRel = OsmUtils.getValuesFromRelation(this); 61 61 } 62 62 63 63 /** 64 64 * Checks if the underlying address node has all tags usually needed to describe an address. … … 66 66 */ 67 67 public boolean isComplete() { 68 boolean isComplete = hasCity() &&68 boolean isComplete = hasCity() && 69 69 hasHouseNumber() && 70 (hasPostalCode() &&71 PostalCodeChecker.hasValidPostalCode(this)) &&72 hasCity() && 70 (hasPostalCode() && 71 PostalCodeChecker.hasValidPostalCode(this)) && 72 hasCity() && 73 73 hasStreetName(); 74 74 75 75 // Check, if "addr:state" is required (US and AU) 76 76 if (TagUtils.isStateRequired()) { 77 77 isComplete = isComplete && hasState(); 78 78 } 79 79 80 80 return isComplete; 81 81 } 82 82 83 83 /** 84 84 * Gets the name of the street associated with this address. … … 88 88 return getTagValueWithGuess(TagUtils.ADDR_STREET_TAG); 89 89 } 90 90 91 91 /** 92 92 * Gets the tag value with guess. If the object does not have the given tag, this method looks for … … 99 99 if (StringUtils.isNullOrEmpty(tag)) return MISSING_TAG; 100 100 if (osmObject == null) return MISSING_TAG; 101 101 102 102 if (!osmObject.hasKey(tag) || StringUtils.isNullOrEmpty(osmObject.get(tag))) { 103 103 if (!hasDerivedValue(tag)) { … … 109 109 return MISSING_TAG; 110 110 } 111 } else { // ok, use derived value known via associated relation or way 111 } else { // ok, use derived value known via associated relation or way 112 112 return getDerivedValue(tag); 113 113 } 114 114 } else { // get existing tag value 115 return osmObject.get(tag); 116 } 117 } 118 115 return osmObject.get(tag); 116 } 117 } 118 119 119 /** 120 120 * Returns <tt>true</tt>, if this address node has a street name. … … 124 124 return hasTag(TagUtils.ADDR_STREET_TAG); 125 125 } 126 126 127 127 /** 128 128 * Returns the street name guessed by the nearest-neighbor search. … … 142 142 setGuessedValue(TagUtils.ADDR_STREET_TAG, guessedStreetName, srcObj); 143 143 } 144 144 145 145 /** 146 146 * Checks for a guessed street name. … … 151 151 return hasGuessedValue(TagUtils.ADDR_STREET_TAG); 152 152 } 153 153 154 154 /** 155 155 * @return the guessedPostCode … … 168 168 setGuessedValue(TagUtils.ADDR_POSTCODE_TAG, guessedPostCode, srcObj); 169 169 } 170 170 171 171 /** 172 172 * Checks for a guessed post code. … … 209 209 */ 210 210 public boolean hasGuesses() { 211 return guessedValues.size() > 0; 212 } 213 211 return guessedValues.size() > 0; 212 } 213 214 214 /** 215 215 * Applies all guessed tags for this node. … … 219 219 applyGuessForTag(tag); 220 220 } 221 221 222 222 // Clear all guesses 223 223 guessedValues.clear(); 224 224 guessedObjects.clear(); 225 225 } 226 226 227 227 /** 228 228 * Apply the guessed value for the given tag. … … 234 234 String val = guessedValues.get(tag); 235 235 if (!StringUtils.isNullOrEmpty(val)) { 236 setOSMTag(tag, val); 236 setOSMTag(tag, val); 237 237 } 238 238 } … … 245 245 public String getPostalCode() { 246 246 String pc = getTagValueWithGuess(TagUtils.ADDR_POSTCODE_TAG); 247 248 247 248 249 249 if (!MISSING_TAG.equals(pc) && !PostalCodeChecker.hasValidPostalCode(getCountry(), pc)) { 250 250 pc = "(!)" + pc; … … 252 252 return pc; 253 253 } 254 254 255 255 /** 256 256 * Checks if this instance has a valid postal code. … … 261 261 return PostalCodeChecker.hasValidPostalCode(this); 262 262 } 263 263 264 264 /** 265 265 * Checks for post code tag. … … 270 270 return hasTag(TagUtils.ADDR_POSTCODE_TAG); 271 271 } 272 272 273 273 /** 274 274 * Gets the name of the house number associated with this address. … … 285 285 return TagUtils.getAddrHousenumberValue(osmObject); 286 286 } 287 287 288 288 /** 289 289 * Checks for house number. … … 294 294 return TagUtils.hasAddrHousenumberTag(osmObject) || isPartOfInterpolation; 295 295 } 296 296 297 297 /* (non-Javadoc) 298 298 * @see org.openstreetmap.josm.plugins.fixAddresses.OSMEntityBase#getName() … … 303 303 return TagUtils.getAddrHousenameValue(osmObject); 304 304 } 305 305 306 306 return ""; 307 307 } 308 308 309 309 /** 310 310 * Checks if this address is part of a address interpolation. … … 315 315 return isPartOfInterpolation; 316 316 } 317 317 318 318 /** 319 319 * Checks if this address is part of an 'associated street' relation. … … 332 332 return getTagValueWithGuess(TagUtils.ADDR_CITY_TAG); 333 333 } 334 334 335 335 /** 336 336 * Checks for city tag. … … 341 341 return hasTag(TagUtils.ADDR_CITY_TAG); 342 342 } 343 343 344 344 /** 345 345 * Gets the name of the state associated with this address. … … 349 349 return getTagValueWithGuess(TagUtils.ADDR_STATE_TAG); 350 350 } 351 351 352 352 /** 353 353 * Checks for state tag. … … 366 366 return getTagValueWithGuess(TagUtils.ADDR_COUNTRY_TAG); 367 367 } 368 368 369 369 /** 370 370 * Checks for country tag. … … 375 375 return hasTag(TagUtils.ADDR_COUNTRY_TAG); 376 376 } 377 377 378 378 /** 379 379 * Removes all address-related tags from the node or way. … … 387 387 removeOSMTag(TagUtils.ADDR_STREET_TAG); 388 388 } 389 389 390 390 /** 391 391 * Checks if the associated OSM object has the given tag or if the tag is available via a referrer. … … 396 396 public boolean hasTag(String tag) { 397 397 if (StringUtils.isNullOrEmpty(tag)) return false; 398 398 399 399 return TagUtils.hasTag(osmObject, tag) || hasDerivedValue(tag); 400 400 } 401 401 402 402 /* (non-Javadoc) 403 403 * @see org.openstreetmap.josm.plugins.addressEdit.NodeEntityBase#compareTo(org.openstreetmap.josm.plugins.addressEdit.INodeEntity) … … 409 409 } 410 410 OSMAddress other = (OSMAddress) o; 411 411 412 412 int cc = 0; 413 413 cc = this.getCountry().compareTo(other.getCountry()); 414 414 if ( cc == 0) { 415 cc = this.getState().compareTo(other.getState()); 415 cc = this.getState().compareTo(other.getState()); 416 416 if (cc == 0) { 417 cc = this.getCity().compareTo(other.getCity()); 417 cc = this.getCity().compareTo(other.getCity()); 418 418 if (cc == 0) { 419 cc = this.getStreetName().compareTo(other.getStreetName()); 419 cc = this.getStreetName().compareTo(other.getStreetName()); 420 420 if (cc == 0) { 421 if (hasGuessedStreetName()) { 421 if (hasGuessedStreetName()) { 422 422 if (other.hasStreetName()) { 423 423 // Compare guessed name with the real name … … 441 441 } 442 442 } 443 443 444 444 return cc; 445 445 } 446 446 447 447 /** 448 448 * Applies the street name from the specified street node. … … 451 451 public void assignStreet(OSMStreet node) { 452 452 if (node == null || !node.hasName()) return; 453 453 454 454 if (!node.getName().equals(getStreetName())) { 455 setStreetName(node.getName()); 455 setStreetName(node.getName()); 456 456 node.addAddress(this); 457 457 fireEntityChanged(this); 458 458 } 459 459 } 460 460 461 461 /** 462 462 * Gets the guessed value for the given tag. … … 467 467 public String getGuessedValue(String tag) { 468 468 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 469 469 470 470 if (!hasGuessedValue(tag)) { 471 return null; 471 return null; 472 472 } 473 473 return guessedValues.get(tag); 474 474 } 475 475 476 476 /** 477 477 * Gets the guessed object. … … 482 482 public OsmPrimitive getGuessedObject(String tag) { 483 483 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 484 484 485 485 if (guessedObjects.containsKey(tag)) { 486 486 return guessedObjects.get(tag); … … 488 488 return null; 489 489 } 490 490 491 491 /** 492 492 * Gets all guessed objects or an empty list, if no guesses have been made yet. … … 496 496 public Collection<OsmPrimitive> getGuessedObjects() { 497 497 if (guessedObjects == null) return null; 498 498 499 499 return guessedObjects.values(); 500 500 } 501 501 502 502 /** 503 503 * Check if this instance needs guessed values. This is the case, if the underlying OSM node … … 506 506 * @return true, if this instance needs at least one guessed value. 507 507 */ 508 public boolean needsGuess() { 509 return 508 public boolean needsGuess() { 509 return needsGuessedValue(TagUtils.ADDR_CITY_TAG) || 510 510 needsGuessedValue(TagUtils.ADDR_POSTCODE_TAG) || 511 511 needsGuessedValue(TagUtils.ADDR_COUNTRY_TAG) || … … 513 513 needsGuessedValue(TagUtils.ADDR_STREET_TAG); 514 514 } 515 515 516 516 /** 517 517 * Check if this instance needs guessed value for a given tag. … … 521 521 return MISSING_TAG.equals(getTagValueWithGuess(tag)); 522 522 } 523 523 524 524 /** 525 525 * Clears all guessed values. … … 528 528 guessedValues.clear(); 529 529 } 530 530 531 531 /** 532 532 * Checks if given tag has a guessed value (tag exists and has a non-empty value). … … 537 537 private boolean hasGuessedValue(String tag) { 538 538 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 539 540 return guessedValues.containsKey(tag) && 539 540 return guessedValues.containsKey(tag) && 541 541 !StringUtils.isNullOrEmpty(guessedValues.get(tag)); 542 542 } 543 543 544 544 /** 545 545 * Sets the guessed value with the given tag. … … 559 559 } 560 560 } 561 561 562 562 /** 563 563 * Checks if given tag has a derived value (value is available via a referrer). … … 568 568 private boolean hasDerivedValue(String tag) { 569 569 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 570 571 return derivedValues.containsKey(tag) && 570 571 return derivedValues.containsKey(tag) && 572 572 !StringUtils.isNullOrEmpty(derivedValues.get(tag)); 573 573 } 574 574 575 575 /** 576 576 * Returns true, if this instance has derived values from any referrer. … … 578 578 */ 579 579 public boolean hasDerivedValues() { 580 return derivedValues.size() > 0; 581 } 582 580 return derivedValues.size() > 0; 581 } 582 583 583 /** 584 584 * Gets the derived value for the given tag. … … 588 588 public String getDerivedValue(String tag) { 589 589 if (!hasDerivedValue(tag)) { 590 return null; 590 return null; 591 591 } 592 592 return derivedValues.get(tag); 593 593 } 594 594 595 595 /** 596 596 * Sets the value known indirectly via a referrer with the given tag. … … 600 600 */ 601 601 public void setDerivedValue(String tag, String value) { 602 derivedValues.put(tag, value); 603 } 604 602 derivedValues.put(tag, value); 603 } 604 605 605 /** 606 606 * Sets the street name of the address node. … … 609 609 public void setStreetName(String streetName) { 610 610 if (streetName != null && streetName.length() == 0) return; 611 611 612 612 setOSMTag(TagUtils.ADDR_STREET_TAG, streetName); 613 613 } 614 614 615 615 616 616 /** 617 617 * Sets the state of the address node. … … 620 620 public void setState(String state) { 621 621 if (state != null && state.length() == 0) return; 622 622 623 623 setOSMTag(TagUtils.ADDR_STATE_TAG, state); 624 624 } 625 625 626 626 /** 627 627 * Sets the country of the address node. … … 630 630 public void setCountry(String country) { 631 631 if (country != null && country.length() == 0) return; 632 632 633 633 setOSMTag(TagUtils.ADDR_COUNTRY_TAG, country); 634 634 } 635 635 636 636 /** 637 637 * Sets the post code of the address node. … … 640 640 public void setPostCode(String postCode) { 641 641 if (postCode != null && postCode.length() == 0) return; 642 642 643 643 setOSMTag(TagUtils.ADDR_POSTCODE_TAG, postCode); 644 644 } 645 645 646 646 /* (non-Javadoc) 647 647 * @see org.openstreetmap.josm.plugins.fixAddresses.OSMEntityBase#visit(org.openstreetmap.josm.plugins.fixAddresses.IProblemVisitor) … … 650 650 public void visit(IAllKnowingTrashHeap trashHeap, IProblemVisitor visitor) { 651 651 CheckParameterUtil.ensureParameterNotNull(visitor, "visitor"); 652 652 653 653 // Check for street 654 654 if (!hasStreetName()) { … … 664 664 AddressProblem p = new AddressProblem(this, tr("Address has no valid street")); 665 665 String match = trashHeap.getClosestStreetName(getStreetName()); 666 666 667 667 if (!StringUtils.isNullOrEmpty(match)) { 668 668 setGuessedStreetName(match, null); … … 671 671 visitor.addProblem(p); 672 672 } 673 673 674 674 // Check for postal code 675 675 if (!hasPostalCode()) { … … 682 682 visitor.addProblem(p); 683 683 } 684 684 685 685 // Check for city 686 686 if (!hasCity()) { … … 693 693 visitor.addProblem(p); 694 694 } 695 695 696 696 // Check for country 697 697 if (!hasCountry()) { … … 711 711 private void addGuessValueSolution(AddressProblem p, String tag) { 712 712 AddressSolution s = new AddressSolution( 713 String.format("%s '%s'", tr("Assign to"), getGuessedValue(tag)), 713 String.format("%s '%s'", tr("Assign to"), getGuessedValue(tag)), 714 714 new ApplyAllGuessesAction(tag), 715 715 SolutionType.Change); 716 716 717 717 p.addSolution(s); 718 718 } 719 719 720 720 /** 721 721 * Adds the remove address tags solution entry to a problem. … … 725 725 private void addRemoveAddressTagsSolution(IProblem problem) { 726 726 CheckParameterUtil.ensureParameterNotNull(problem, "problem"); 727 727 728 728 AddressSolution s = new AddressSolution( 729 tr("Remove all address tags"), 729 tr("Remove all address tags"), 730 730 new RemoveAddressTagsAction(), 731 731 SolutionType.Remove); 732 732 problem.addSolution(s); 733 733 } 734 734 735 735 /* (non-Javadoc) 736 736 * @see org.openstreetmap.josm.plugins.fixAddresses.OSMEntityBase#toString() … … 754 754 if (!StringUtils.isNullOrEmpty(guessed) && MISSING_TAG.equals(sName)) { 755 755 sName = String.format("(%s)", guessed); 756 } 757 758 return String.format("%s %s, %s-%s %s (%s) ", 756 } 757 758 return String.format("%s %s, %s-%s %s (%s) ", 759 759 sName, 760 760 node.getHouseNumber(), -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMEntityBase.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 30 30 /** 31 31 * The class OSMEntityBase provides a base implementation for the {@link IOSMEntity} interface. 32 * 32 * 33 33 * The implementation comprises 34 34 * <ol> … … 42 42 private static List<IAddressEditContainerListener> containerListeners = new ArrayList<IAddressEditContainerListener>(); 43 43 private List<ICommandListener> cmdListeners = new ArrayList<ICommandListener>(); 44 44 45 45 protected OsmPrimitive osmObject; 46 46 47 47 /** 48 48 * @param osmObject … … 52 52 this.osmObject = osmObject; 53 53 } 54 54 55 55 /** 56 56 * @param osmObject the osmObject to set … … 69 69 containerListeners.add(listener); 70 70 } 71 71 72 72 /** 73 73 * Removes a change listener. … … 78 78 containerListeners.remove(listener); 79 79 } 80 80 81 81 /** 82 82 * Notifies clients that the address container changed. … … 88 88 } 89 89 } 90 90 91 91 /** 92 92 * Adds a command listener. … … 97 97 cmdListeners.add(listener); 98 98 } 99 99 100 100 /** 101 101 * Removes a command listener. … … 106 106 cmdListeners.remove(listener); 107 107 } 108 108 109 109 /** 110 110 * Notifies clients that an entity has issued a command. … … 118 118 throw new RuntimeException("Object has no TX context: " + this); 119 119 } 120 120 121 121 for (ICommandListener l : cmdListeners) { 122 122 l.commandIssued(this, command); 123 123 } 124 } 124 } 125 125 126 126 public OsmPrimitive getOsmObject() { … … 144 144 return ""; 145 145 } 146 146 147 147 /* (non-Javadoc) 148 148 * @see org.openstreetmap.josm.plugins.addressEdit.INodeEntity#hasName() … … 152 152 return TagUtils.hasNameTag(osmObject); 153 153 } 154 154 155 155 /** 156 156 * Internal helper method which changes the given property and … … 162 162 */ 163 163 protected void setOSMTag(String tag, String newValue) { 164 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 164 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 165 165 if (StringUtils.isNullOrEmpty(tag)) return; 166 166 167 167 if (osmObject != null) { 168 if ((osmObject.hasKey(tag) && newValue == null) || newValue != null) { 168 if ((osmObject.hasKey(tag) && newValue == null) || newValue != null) { 169 169 fireCommandIssued(new ChangePropertyCommand(osmObject, tag, newValue)); 170 170 fireEntityChanged(this); 171 171 } 172 } 173 } 174 172 } 173 } 174 175 175 /** 176 176 * Removes the given tag from the OSM object. … … 202 202 return this.getName().compareTo(o.getName()); 203 203 } 204 204 205 205 /* (non-Javadoc) 206 206 * @see org.openstreetmap.josm.plugins.fixAddresses.IOSMEntity#visit(org.openstreetmap.josm.plugins.fixAddresses.IAllKnowingTrashHeap, org.openstreetmap.josm.plugins.fixAddresses.IProblemVisitor) … … 218 218 OsmPrimitive osm = getOsmObject(); 219 219 if (osm == null) return null; 220 220 221 221 if (osm instanceof Node) { 222 222 return ((Node)osm).getCoor(); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMStreet.java
r24107 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 24 24 * This class is the container for all street segments with the same name. Every street 25 25 * consists at least of one segment. 26 * 26 * 27 27 * @author Oliver Wieland <oliver.wieland@online.de> 28 28 */ … … 30 30 private List<IOSMEntity> children; 31 31 private List<OSMAddress> addresses; 32 32 33 33 /** 34 34 * @param osmPrimitive … … 41 41 return children; 42 42 } 43 43 44 44 /** 45 45 * Adds a street segment to the street node. … … 48 48 public void addStreetSegment(OSMStreetSegment segment) { 49 49 lazyCreateChildren(); 50 50 51 51 children.add(segment); 52 52 Collections.sort(children); 53 53 } 54 54 55 55 /** 56 56 * Lazy creation of children list. … … 61 61 } 62 62 } 63 63 64 64 /** 65 65 * Adds an associated address to the street. … … 69 69 public void addAddress(OSMAddress aNode) { 70 70 lazyCreateAddresses(); 71 addresses.add(aNode); 71 addresses.add(aNode); 72 72 } 73 73 … … 80 80 } 81 81 } 82 82 83 83 /** 84 84 * Checks for addresses. … … 89 89 return addresses != null && addresses.size() > 0; 90 90 } 91 91 92 92 public List<OSMAddress> getAddresses() { 93 93 return addresses; 94 94 } 95 95 96 96 public void setAddresses(List<OSMAddress> addresses) { 97 97 this.addresses = addresses; 98 98 } 99 99 100 100 /** 101 101 * Gets the number of addresses associated with this street. … … 104 104 public int getNumberOfAddresses() { 105 105 if (addresses == null) return 0; 106 106 107 107 return addresses.size(); 108 108 } 109 109 110 110 /** 111 111 * Gets the number of street segments of this street. … … 114 114 public int getNumberOfSegments() { 115 115 if (children == null) return 0; 116 116 117 117 int sc = 0; 118 118 for (IOSMEntity node : children) { … … 123 123 return sc; 124 124 } 125 125 126 126 /** 127 127 * Gets the road type(s) of this street. If the street has different types, 128 * they are separated by comma. 128 * they are separated by comma. 129 129 * @return 130 130 */ 131 131 public String getType() { 132 132 List<String> types = new ArrayList<String>(); 133 133 134 134 for (IOSMEntity seg : getChildren()) { 135 135 OsmPrimitive osmPrim = seg.getOsmObject(); … … 141 141 } 142 142 } 143 143 144 144 StringBuffer sb = new StringBuffer(20); 145 145 for (String string : types) { … … 148 148 } 149 149 sb.append(string); 150 150 151 151 } 152 152 return sb.toString(); 153 153 } 154 154 155 155 /** 156 156 * Checks if the attached way has an associated street relation. … … 170 170 return false; 171 171 } 172 172 173 173 /* (non-Javadoc) 174 174 * @see org.openstreetmap.josm.plugins.addressEdit.NodeEntityBase#toString() … … 177 177 public String toString() { 178 178 StringBuffer sb = new StringBuffer(getName()); 179 179 180 180 if (children != null) { 181 181 sb.append(String.format(", %d segments", children.size())); 182 182 } 183 183 184 184 if (addresses != null) { 185 185 sb.append(String.format(", %d address entries", addresses.size())); 186 186 } 187 187 188 188 return sb.toString(); 189 189 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMStreetSegment.java
r24094 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 21 21 * Represents a single segment of a street. In many cases a segment may represent the complete street, but 22 22 * sometimes a street is separated into many segments, e. g. due to different speed limits, bridges, etc.. 23 * 23 * 24 24 * @author Oliver Wieland <oliver.wieland@online.de> 25 * 25 * 26 26 */ 27 27 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmFactory.java
r24095 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 21 21 public class OsmFactory { 22 22 private static HashMap<String, OSMAddress> addressCache = new HashMap<String, OSMAddress>(); 23 23 24 24 /** 25 25 * Creates an address node from an OSM node, if possible. … … 30 30 if (TagUtils.isAddress(node)) { 31 31 String aid = "" + node.getId(); 32 32 33 33 OSMAddress aNode = lookup(aid); 34 34 if (aNode == null) { … … 40 40 return aNode; 41 41 } 42 42 43 43 return null; 44 44 } 45 45 46 46 /** 47 47 * Creates an node entity from an OSM way, if possible. … … 53 53 return new OSMStreetSegment(way); 54 54 } 55 55 56 56 // Check for building with address 57 57 if (way.isClosed() && TagUtils.hasBuildingTag(way) && TagUtils.isAddress(way)) { 58 58 String aid = "" + way.getId(); 59 59 60 60 OSMAddress aNode = lookup(aid); 61 61 if (aNode == null) { … … 65 65 aNode.setOsmObject(way); 66 66 } 67 68 return aNode; 67 68 return aNode; 69 69 } 70 70 return null; 71 71 } 72 73 private static OSMAddress lookup(String aid) { 72 73 private static OSMAddress lookup(String aid) { 74 74 if (addressCache.containsKey(aid)) { 75 return addressCache.get(aid); 75 return addressCache.get(aid); 76 76 } 77 77 return null; -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmUtils.java
r24946 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 34 34 */ 35 35 public class OsmUtils { 36 36 37 37 /** 38 38 * Instantiates a new osm utils. 39 39 */ 40 40 private OsmUtils() {} 41 41 42 42 /** The cached locale. */ 43 43 private static String cachedLocale = null; 44 44 45 45 /** 46 46 * Gets the minimum distance of single coordinate to a way. … … 52 52 public static double getMinimumDistanceToWay(LatLon coor, Way w) { 53 53 if (coor == null || w == null) return Double.POSITIVE_INFINITY; 54 54 55 55 double minDist = Double.MAX_VALUE; 56 56 List<Pair<Node,Node>> x = w.getNodePairs(true); 57 57 58 58 for (Pair<Node, Node> pair : x) { 59 59 LatLon ap = pair.a.getCoor(); 60 60 LatLon bp = pair.b.getCoor(); 61 61 62 62 double dist = findMinimum(ap, bp, coor); 63 63 if (dist < minDist) { … … 67 67 return minDist; 68 68 } 69 69 70 70 /** 71 71 * Find the minimum distance between a point and two way coordinates recursively. … … 80 80 CheckParameterUtil.ensureParameterNotNull(b, "b"); 81 81 CheckParameterUtil.ensureParameterNotNull(a, "a"); 82 82 83 83 LatLon mid = new LatLon((a.lat() + b.lat()) / 2, (a.lon() + b.lon()) / 2); 84 84 85 85 double ac = a.greatCircleDistance(c); 86 86 double bc = b.greatCircleDistance(c); 87 87 double mc = mid.greatCircleDistance(c); 88 88 89 89 double min = Math.min(Math.min(ac, mc), bc); 90 91 90 91 92 92 if (min < 5.0) { // close enough? 93 93 return min; 94 94 } 95 96 if (mc < ac && mc < bc) { 95 96 if (mc < ac && mc < bc) { 97 97 // mid point has lower distance than a and b 98 98 if (ac > bc) { // recurse … … 105 105 } 106 106 } 107 107 108 108 /** 109 109 * Checks, if the given address has a relation hosting the address values. This method looks 110 110 * for a relation of type 'associatedStreet' and checks the members for address values, if present. 111 111 * If the member has address values, this methods sets the derived properties of the address 112 * node accordingly. 112 * node accordingly. 113 113 * 114 114 * @param address The address to check. … … 119 119 return false; 120 120 } 121 121 122 122 boolean hasValuesFromRel = false; /* true, if we applied some address props from the relation */ 123 123 OsmPrimitive addrNode = address.getOsmObject(); 124 124 125 125 // check all referrers of the node 126 126 for (OsmPrimitive osm : addrNode.getReferrers()) { … … 129 129 // Relation has the right type? 130 130 if (!TagUtils.isAssociatedStreetRelation(r)) continue; 131 132 // check for 'street' members 131 132 // check for 'street' members 133 133 for (RelationMember rm : r.getMembers()) { 134 134 if (TagUtils.isStreetMember(rm)) { 135 135 OsmPrimitive street = rm.getMember(); 136 if (TagUtils.hasHighwayTag(street)) { 136 if (TagUtils.hasHighwayTag(street)) { 137 137 String streetName = TagUtils.getNameValue(street); 138 138 if (!StringUtils.isNullOrEmpty(streetName)) { … … 142 142 break; 143 143 } // else: Street has no name: Ooops 144 } // else: Street member, but no highway tag: Ooops 144 } // else: Street member, but no highway tag: Ooops 145 145 } 146 146 } 147 147 148 148 // Check for other address properties 149 149 if (TagUtils.hasAddrCityTag(r)) { // city … … 163 163 return hasValuesFromRel; 164 164 } 165 165 166 166 /** 167 167 * Gets the tag values from an address interpolation ref, if present. … … 172 172 public static boolean getValuesFromAddressInterpolation(OSMAddress address) { 173 173 if (address == null) return false; 174 174 175 175 OsmPrimitive osmAddr = address.getOsmObject(); 176 176 177 177 for (OsmPrimitive osm : osmAddr.getReferrers()) { 178 178 if (osm instanceof Way) { … … 188 188 } 189 189 } 190 190 191 191 return false; 192 192 } 193 193 194 194 /** 195 195 * Gets the local code as string. … … 205 205 return cachedLocale; 206 206 } 207 207 208 208 /** 209 209 * Zooms to the given addresses. … … 213 213 public static void zoomAddresses(List<OSMAddress> addressList) { 214 214 CheckParameterUtil.ensureParameterNotNull(addressList, "addressList"); 215 216 if (Main.map == null && Main.map.mapView == null) return; 217 if (addressList.size() == 0) return; 218 215 216 if (Main.map == null && Main.map.mapView == null) return; // nothing to do 217 if (addressList.size() == 0) return; // dto. 218 219 219 // compute bounding box 220 220 BoundingXYVisitor bbox = new BoundingXYVisitor(); 221 222 223 224 225 226 227 228 // zoom to calculated bounding box 229 230 221 for (OSMAddress source : addressList) { 222 OsmPrimitive osm = source.getOsmObject(); 223 Bounds b = new Bounds(osm.getBBox().getTopLeft(), osm.getBBox().getBottomRight()); 224 bbox.visit(b); 225 } 226 227 if (bbox.getBounds() != null) { 228 // zoom to calculated bounding box 229 Main.map.mapView.zoomTo(bbox.getBounds()); 230 } 231 231 } 232 232 … … 241 241 CheckParameterUtil.ensureParameterNotNull(address, "address"); 242 242 CheckParameterUtil.ensureParameterNotNull(w, "way"); 243 244 if (!address.hasTag(tag) && TagUtils.hasTag(w, tag)) { 243 244 if (!address.hasTag(tag) && TagUtils.hasTag(w, tag)) { 245 245 address.setDerivedValue(tag, w.get(tag)); 246 246 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/PostalCodeChecker.java
r24321 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 24 24 public class PostalCodeChecker { 25 25 private static HashMap<String, String> postalCodePatternMap = new HashMap<String, String>(); 26 26 27 27 static { 28 28 fillMap(); 29 29 } 30 30 31 31 /** 32 32 * Checks if given address has a valid postal code. 33 33 * 34 34 * @param address the address to check the postal code for 35 * @return true, if postal code is valid (this implies 35 * @return true, if postal code is valid (this implies 36 36 * also that a country is NOT supported); otherwise false. 37 37 */ 38 38 public static boolean hasValidPostalCode(OSMAddress address) { 39 39 CheckParameterUtil.ensureParameterNotNull(address, "address"); 40 40 41 41 if (!address.hasPostalCode()) { 42 42 return false; // no postal code available 43 43 } 44 44 45 45 String ctry = getCountry(address); 46 46 String postalCode = address.getPostalCode(); 47 47 48 48 return hasValidPostalCode(ctry, postalCode); 49 49 } 50 50 51 51 /** 52 52 * Checks if postal code is valid for the country reported by the Java VM. … … 68 68 public static boolean hasValidPostalCode(String country, String postalCode) { 69 69 // Get country-specific pattern for postal code 70 if (postalCodePatternMap.containsKey(country)) { 70 if (postalCodePatternMap.containsKey(country)) { 71 71 String pattern = postalCodePatternMap.get(country); 72 72 // Check if postal code matches pattern … … 74 74 } else { 75 75 // we cannot validate; assume postal code as valid until we know better 76 return true; 77 } 78 } 79 76 return true; 77 } 78 } 79 80 80 /** 81 81 * Checks if validation for the given country is supported. … … 88 88 return postalCodePatternMap.containsKey(country.toUpperCase()); 89 89 } 90 90 91 91 /** 92 92 * Checks if validation for the given address is supported. … … 97 97 public static boolean isValidationSupported(OSMAddress address) { 98 98 CheckParameterUtil.ensureParameterNotNull(address, "address"); 99 99 100 100 String ctry = getCountry(address); 101 101 return postalCodePatternMap.containsKey(ctry); 102 102 } 103 103 104 104 /** 105 105 * Gets the current country. … … 126 126 return ctry; 127 127 } 128 128 129 129 /** 130 130 * Fills the country-postal code pattern map. … … 133 133 /* 134 134 String[] countries = Locale.getISOCountries(); 135 135 136 136 for (int i = 0; i < countries.length; i++) { 137 137 System.out.println("//postalCodePatternMap.put(\"" + countries[i] + "\", \"[0-9]{5}\");"); 138 138 } 139 139 140 140 String x = "A9999AAA"; 141 141 142 142 if (x.matches("[A-Z]{1}[0-9]{4}[A-Z]{3}")) { 143 143 System.out.println("YES"); 144 144 } 145 145 146 146 String xx = "99999-999"; 147 // "[0-9]{5}\-[0-9]{3}"); // 147 // "[0-9]{5}\-[0-9]{3}"); // 148 148 if (xx.matches("[0-9]{5}-[0-9]{3}")) { 149 149 System.out.println("YES"); 150 150 } 151 152 153 String[] xxx = new String[]{"A9 9AA", "A99 9AA", "A9A 9AA", 151 152 153 String[] xxx = new String[]{"A9 9AA", "A99 9AA", "A9A 9AA", "AA9 9AA", "AA99 9AA", "AA9A 9AA"}; 154 154 for (int i = 0; i < xxx.length; i++) { 155 155 if (!xxx[i].matches("[A-Z]{1,2}[0-9]{1,2}[A-Z]? [0-9]{1}[A-Z]{2}")) { … … 158 158 }*/ 159 159 // see http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html for country codes 160 // 161 160 // 161 162 162 //postalCodePatternMap.put("AD", "[0-9]{5}"); 163 163 //postalCodePatternMap.put("AE", "[0-9]{5}"); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/ProblemType.java
r24978 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/SolutionType.java
r24978 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/StringUtils.java
r23933 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 19 19 /** 20 20 * Checks, if a string is either null or empty. 21 * 21 * 22 22 * @param txt 23 23 * Text to check … … 30 30 /** 31 31 * Gets the length of the longest common substring of a and b 32 * 32 * 33 33 * @param a 34 34 * First string … … 83 83 /** 84 84 * Gets the longest common substring of a and b. 85 * 85 * 86 86 * @param a The first string. 87 87 * @param b The second string. … … 117 117 return sb.toString(); 118 118 } 119 119 120 120 /** 121 121 * @param needle The string to find the best match for. … … 127 127 String bestMatch = null; 128 128 double maxRatio = Double.MIN_VALUE; 129 129 130 130 if (StringUtils.isNullOrEmpty(needle)) { 131 131 return null; … … 134 134 return null; 135 135 } 136 136 137 137 int lNeedle = needle.length(); 138 138 for (String curString : haystack) { … … 143 143 bestMatch = curString; 144 144 } 145 145 146 146 } 147 147 148 148 return bestMatch; 149 149 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/TagUtils.java
r24208 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 22 22 * Contains the tags used within OSM. FIXME: Maybe there is a class or similar 23 23 * within JOSM which already defines them, but I have not found it so far. 24 * 24 * 25 25 * @author Oliver Wieland <oliver.wieland@online.de> 26 * 26 * 27 27 */ 28 28 public final class TagUtils { 29 29 private static String COUNTRIES_REQUIRE_STATE[] = { 30 "en_US", 31 "en_AU" 30 "en_US", /* USA */ 31 "en_AU" /* Australia */ 32 32 }; 33 33 34 34 /** 35 35 * Checks if the given OSM object has a (non-empty) value for the given tag. … … 37 37 * @param osm the osm object to inspect. 38 38 * @param tag the tag to look for. 39 * @return true, if osm object has a non-empty value for this tag 39 * @return true, if osm object has a non-empty value for this tag 40 40 */ 41 41 public static boolean hasTag(OsmPrimitive osm, String tag) { 42 42 return osm != null && !StringUtils.isNullOrEmpty(osm.get(tag)); 43 43 } 44 44 45 45 /** 46 46 * Checks if the given OSM primitive is an address node. … … 48 48 */ 49 49 public static boolean isAddress(OsmPrimitive osmObject) { 50 return 50 return TagUtils.hasAddrCityTag(osmObject) || TagUtils.hasAddrCountryTag(osmObject) || 51 51 TagUtils.hasAddrHousenumberTag(osmObject) || TagUtils.hasAddrPostcodeTag(osmObject) || 52 52 TagUtils.hasAddrStateTag(osmObject) || TagUtils.hasAddrStreetTag(osmObject); 53 53 } 54 54 55 55 /** 56 56 * Check if OSM primitive has a tag 'parking'. 57 * 57 * 58 58 * @param osmPrimitive 59 59 * The OSM entity to check. … … 65 65 /** 66 66 * Gets the value of tag 'parking'. 67 * 67 * 68 68 * @param osmPrimitive 69 69 * The OSM entity to check. … … 75 75 /** 76 76 * Check if OSM primitive has a tag 'shop'. 77 * 77 * 78 78 * @param osmPrimitive 79 79 * The OSM entity to check. … … 85 85 /** 86 86 * Gets the value of tag 'shop'. 87 * 87 * 88 88 * @param osmPrimitive 89 89 * The OSM entity to check. … … 95 95 /** 96 96 * Check if OSM primitive has a tag 'craft'. 97 * 97 * 98 98 * @param osmPrimitive 99 99 * The OSM entity to check. … … 105 105 /** 106 106 * Gets the value of tag 'craft'. 107 * 107 * 108 108 * @param osmPrimitive 109 109 * The OSM entity to check. … … 115 115 /** 116 116 * Check if OSM primitive has a tag 'surface'. 117 * 117 * 118 118 * @param osmPrimitive 119 119 * The OSM entity to check. … … 125 125 /** 126 126 * Gets the value of tag 'surface'. 127 * 127 * 128 128 * @param osmPrimitive 129 129 * The OSM entity to check. … … 135 135 /** 136 136 * Check if OSM primitive has a tag 'cuisine'. 137 * 137 * 138 138 * @param osmPrimitive 139 139 * The OSM entity to check. … … 145 145 /** 146 146 * Gets the value of tag 'cuisine'. 147 * 147 * 148 148 * @param osmPrimitive 149 149 * The OSM entity to check. … … 155 155 /** 156 156 * Check if OSM primitive has a tag 'wood'. 157 * 157 * 158 158 * @param osmPrimitive 159 159 * The OSM entity to check. … … 165 165 /** 166 166 * Gets the value of tag 'wood'. 167 * 167 * 168 168 * @param osmPrimitive 169 169 * The OSM entity to check. … … 175 175 /** 176 176 * Check if OSM primitive has a tag 'foot'. 177 * 177 * 178 178 * @param osmPrimitive 179 179 * The OSM entity to check. … … 185 185 /** 186 186 * Gets the value of tag 'foot'. 187 * 187 * 188 188 * @param osmPrimitive 189 189 * The OSM entity to check. … … 195 195 /** 196 196 * Check if OSM primitive has a tag 'name:de'. 197 * 197 * 198 198 * @param osmPrimitive 199 199 * The OSM entity to check. … … 205 205 /** 206 206 * Gets the value of tag 'name:de'. 207 * 207 * 208 208 * @param osmPrimitive 209 209 * The OSM entity to check. … … 215 215 /** 216 216 * Check if OSM primitive has a tag 'nat_ref'. 217 * 217 * 218 218 * @param osmPrimitive 219 219 * The OSM entity to check. … … 225 225 /** 226 226 * Gets the value of tag 'nat_ref'. 227 * 227 * 228 228 * @param osmPrimitive 229 229 * The OSM entity to check. … … 235 235 /** 236 236 * Check if OSM primitive has a tag 'note:de'. 237 * 237 * 238 238 * @param osmPrimitive 239 239 * The OSM entity to check. … … 245 245 /** 246 246 * Gets the value of tag 'note:de'. 247 * 247 * 248 248 * @param osmPrimitive 249 249 * The OSM entity to check. … … 255 255 /** 256 256 * Check if OSM primitive has a tag 'addr:street'. 257 * 257 * 258 258 * @param osmPrimitive 259 259 * The OSM entity to check. … … 266 266 /** 267 267 * Gets the value of tag 'addr:street'. 268 * 268 * 269 269 * @param osmPrimitive 270 270 * The OSM entity to check. … … 276 276 /** 277 277 * Check if OSM primitive has a tag 'type'. 278 * 278 * 279 279 * @param osmPrimitive 280 280 * The OSM entity to check. … … 286 286 /** 287 287 * Gets the value of tag 'type'. 288 * 288 * 289 289 * @param osmPrimitive 290 290 * The OSM entity to check. … … 296 296 /** 297 297 * Check if OSM primitive has a tag 'addr:city'. 298 * 298 * 299 299 * @param osmPrimitive 300 300 * The OSM entity to check. … … 307 307 /** 308 308 * Gets the value of tag 'addr:city'. 309 * 309 * 310 310 * @param osmPrimitive 311 311 * The OSM entity to check. … … 317 317 /** 318 318 * Check if OSM primitive has a tag 'boundary'. 319 * 319 * 320 320 * @param osmPrimitive 321 321 * The OSM entity to check. … … 327 327 /** 328 328 * Gets the value of tag 'boundary'. 329 * 329 * 330 330 * @param osmPrimitive 331 331 * The OSM entity to check. … … 337 337 /** 338 338 * Check if OSM primitive has a tag 'smoothness'. 339 * 339 * 340 340 * @param osmPrimitive 341 341 * The OSM entity to check. … … 348 348 /** 349 349 * Gets the value of tag 'smoothness'. 350 * 350 * 351 351 * @param osmPrimitive 352 352 * The OSM entity to check. … … 358 358 /** 359 359 * Check if OSM primitive has a tag 'opening_hours'. 360 * 360 * 361 361 * @param osmPrimitive 362 362 * The OSM entity to check. … … 369 369 /** 370 370 * Gets the value of tag 'opening_hours'. 371 * 371 * 372 372 * @param osmPrimitive 373 373 * The OSM entity to check. … … 380 380 /** 381 381 * Check if OSM primitive has a tag 'bicycle'. 382 * 382 * 383 383 * @param osmPrimitive 384 384 * The OSM entity to check. … … 390 390 /** 391 391 * Gets the value of tag 'bicycle'. 392 * 392 * 393 393 * @param osmPrimitive 394 394 * The OSM entity to check. … … 400 400 /** 401 401 * Check if OSM primitive has a tag 'religion'. 402 * 402 * 403 403 * @param osmPrimitive 404 404 * The OSM entity to check. … … 410 410 /** 411 411 * Gets the value of tag 'religion'. 412 * 412 * 413 413 * @param osmPrimitive 414 414 * The OSM entity to check. … … 420 420 /** 421 421 * Check if OSM primitive has a tag 'barrier'. 422 * 422 * 423 423 * @param osmPrimitive 424 424 * The OSM entity to check. … … 430 430 /** 431 431 * Gets the value of tag 'barrier'. 432 * 432 * 433 433 * @param osmPrimitive 434 434 * The OSM entity to check. … … 440 440 /** 441 441 * Check if OSM primitive has a tag 'power'. 442 * 442 * 443 443 * @param osmPrimitive 444 444 * The OSM entity to check. … … 450 450 /** 451 451 * Gets the value of tag 'power'. 452 * 452 * 453 453 * @param osmPrimitive 454 454 * The OSM entity to check. … … 460 460 /** 461 461 * Check if OSM primitive has a tag 'landuse'. 462 * 462 * 463 463 * @param osmPrimitive 464 464 * The OSM entity to check. … … 470 470 /** 471 471 * Gets the value of tag 'landuse'. 472 * 472 * 473 473 * @param osmPrimitive 474 474 * The OSM entity to check. … … 480 480 /** 481 481 * Check if OSM primitive has a tag 'fireplace'. 482 * 482 * 483 483 * @param osmPrimitive 484 484 * The OSM entity to check. … … 491 491 /** 492 492 * Gets the value of tag 'fireplace'. 493 * 493 * 494 494 * @param osmPrimitive 495 495 * The OSM entity to check. … … 501 501 /** 502 502 * Check if OSM primitive has a tag 'int_ref'. 503 * 503 * 504 504 * @param osmPrimitive 505 505 * The OSM entity to check. … … 511 511 /** 512 512 * Gets the value of tag 'int_ref'. 513 * 513 * 514 514 * @param osmPrimitive 515 515 * The OSM entity to check. … … 521 521 /** 522 522 * Check if OSM primitive has a tag 'whitewater:section_grade'. 523 * 523 * 524 524 * @param osmPrimitive 525 525 * The OSM entity to check. … … 532 532 /** 533 533 * Gets the value of tag 'whitewater:section_grade'. 534 * 534 * 535 535 * @param osmPrimitive 536 536 * The OSM entity to check. … … 544 544 /** 545 545 * Check if OSM primitive has a tag 'denomination'. 546 * 546 * 547 547 * @param osmPrimitive 548 548 * The OSM entity to check. … … 555 555 /** 556 556 * Gets the value of tag 'denomination'. 557 * 557 * 558 558 * @param osmPrimitive 559 559 * The OSM entity to check. … … 565 565 /** 566 566 * Check if OSM primitive has a tag 'addr:postcode'. 567 * 567 * 568 568 * @param osmPrimitive 569 569 * The OSM entity to check. … … 576 576 /** 577 577 * Gets the value of tag 'addr:postcode'. 578 * 578 * 579 579 * @param osmPrimitive 580 580 * The OSM entity to check. … … 587 587 /** 588 588 * Check if OSM primitive has a tag 'wires'. 589 * 589 * 590 590 * @param osmPrimitive 591 591 * The OSM entity to check. … … 597 597 /** 598 598 * Gets the value of tag 'wires'. 599 * 599 * 600 600 * @param osmPrimitive 601 601 * The OSM entity to check. … … 607 607 /** 608 608 * Check if OSM primitive has a tag 'loc_ref'. 609 * 609 * 610 610 * @param osmPrimitive 611 611 * The OSM entity to check. … … 617 617 /** 618 618 * Gets the value of tag 'loc_ref'. 619 * 619 * 620 620 * @param osmPrimitive 621 621 * The OSM entity to check. … … 627 627 /** 628 628 * Check if OSM primitive has a tag 'width'. 629 * 629 * 630 630 * @param osmPrimitive 631 631 * The OSM entity to check. … … 637 637 /** 638 638 * Gets the value of tag 'width'. 639 * 639 * 640 640 * @param osmPrimitive 641 641 * The OSM entity to check. … … 647 647 /** 648 648 * Check if OSM primitive has a tag 'tourism'. 649 * 649 * 650 650 * @param osmPrimitive 651 651 * The OSM entity to check. … … 657 657 /** 658 658 * Gets the value of tag 'tourism'. 659 * 659 * 660 660 * @param osmPrimitive 661 661 * The OSM entity to check. … … 667 667 /** 668 668 * Check if OSM primitive has a tag 'leisure'. 669 * 669 * 670 670 * @param osmPrimitive 671 671 * The OSM entity to check. … … 677 677 /** 678 678 * Gets the value of tag 'leisure'. 679 * 679 * 680 680 * @param osmPrimitive 681 681 * The OSM entity to check. … … 687 687 /** 688 688 * Check if OSM primitive has a tag 'electrified'. 689 * 689 * 690 690 * @param osmPrimitive 691 691 * The OSM entity to check. … … 698 698 /** 699 699 * Gets the value of tag 'electrified'. 700 * 700 * 701 701 * @param osmPrimitive 702 702 * The OSM entity to check. … … 708 708 /** 709 709 * Check if OSM primitive has a tag 'junction'. 710 * 710 * 711 711 * @param osmPrimitive 712 712 * The OSM entity to check. … … 718 718 /** 719 719 * Gets the value of tag 'junction'. 720 * 720 * 721 721 * @param osmPrimitive 722 722 * The OSM entity to check. … … 728 728 /** 729 729 * Check if OSM primitive has a tag 'railway'. 730 * 730 * 731 731 * @param osmPrimitive 732 732 * The OSM entity to check. … … 738 738 /** 739 739 * Gets the value of tag 'railway'. 740 * 740 * 741 741 * @param osmPrimitive 742 742 * The OSM entity to check. … … 748 748 /** 749 749 * Check if OSM primitive has a tag 'voltage'. 750 * 750 * 751 751 * @param osmPrimitive 752 752 * The OSM entity to check. … … 758 758 /** 759 759 * Gets the value of tag 'voltage'. 760 * 760 * 761 761 * @param osmPrimitive 762 762 * The OSM entity to check. … … 768 768 /** 769 769 * Check if OSM primitive has a tag 'bridge'. 770 * 770 * 771 771 * @param osmPrimitive 772 772 * The OSM entity to check. … … 778 778 /** 779 779 * Gets the value of tag 'bridge'. 780 * 780 * 781 781 * @param osmPrimitive 782 782 * The OSM entity to check. … … 788 788 /** 789 789 * Check if OSM primitive has a tag 'motor_vehicle'. 790 * 790 * 791 791 * @param osmPrimitive 792 792 * The OSM entity to check. … … 799 799 /** 800 800 * Gets the value of tag 'motor_vehicle'. 801 * 801 * 802 802 * @param osmPrimitive 803 803 * The OSM entity to check. … … 810 810 /** 811 811 * Check if OSM primitive has a tag 'comment'. 812 * 812 * 813 813 * @param osmPrimitive 814 814 * The OSM entity to check. … … 820 820 /** 821 821 * Gets the value of tag 'comment'. 822 * 822 * 823 823 * @param osmPrimitive 824 824 * The OSM entity to check. … … 830 830 /** 831 831 * Check if OSM primitive has a tag 'maxspeed'. 832 * 832 * 833 833 * @param osmPrimitive 834 834 * The OSM entity to check. … … 840 840 /** 841 841 * Gets the value of tag 'maxspeed'. 842 * 842 * 843 843 * @param osmPrimitive 844 844 * The OSM entity to check. … … 850 850 /** 851 851 * Check if OSM primitive has a tag 'natural'. 852 * 852 * 853 853 * @param osmPrimitive 854 854 * The OSM entity to check. … … 860 860 /** 861 861 * Gets the value of tag 'natural'. 862 * 862 * 863 863 * @param osmPrimitive 864 864 * The OSM entity to check. … … 870 870 /** 871 871 * Check if OSM primitive has a tag 'sac_scale'. 872 * 872 * 873 873 * @param osmPrimitive 874 874 * The OSM entity to check. … … 881 881 /** 882 882 * Gets the value of tag 'sac_scale'. 883 * 883 * 884 884 * @param osmPrimitive 885 885 * The OSM entity to check. … … 891 891 /** 892 892 * Check if OSM primitive has a tag 'tunnel'. 893 * 893 * 894 894 * @param osmPrimitive 895 895 * The OSM entity to check. … … 901 901 /** 902 902 * Gets the value of tag 'tunnel'. 903 * 903 * 904 904 * @param osmPrimitive 905 905 * The OSM entity to check. … … 911 911 /** 912 912 * Check if OSM primitive has a tag 'waterway'. 913 * 913 * 914 914 * @param osmPrimitive 915 915 * The OSM entity to check. … … 921 921 /** 922 922 * Gets the value of tag 'waterway'. 923 * 923 * 924 924 * @param osmPrimitive 925 925 * The OSM entity to check. … … 931 931 /** 932 932 * Check if OSM primitive has a tag 'trail_visibility'. 933 * 933 * 934 934 * @param osmPrimitive 935 935 * The OSM entity to check. … … 942 942 /** 943 943 * Gets the value of tag 'trail_visibility'. 944 * 944 * 945 945 * @param osmPrimitive 946 946 * The OSM entity to check. … … 953 953 /** 954 954 * Check if OSM primitive has a tag 'highway'. 955 * 955 * 956 956 * @param osmPrimitive 957 957 * The OSM entity to check. … … 963 963 /** 964 964 * Gets the value of tag 'highway'. 965 * 965 * 966 966 * @param osmPrimitive 967 967 * The OSM entity to check. … … 973 973 /** 974 974 * Check if OSM primitive has a tag 'vehicle'. 975 * 975 * 976 976 * @param osmPrimitive 977 977 * The OSM entity to check. … … 983 983 /** 984 984 * Gets the value of tag 'vehicle'. 985 * 985 * 986 986 * @param osmPrimitive 987 987 * The OSM entity to check. … … 993 993 /** 994 994 * Check if OSM primitive has a tag 'horse'. 995 * 995 * 996 996 * @param osmPrimitive 997 997 * The OSM entity to check. … … 1003 1003 /** 1004 1004 * Gets the value of tag 'horse'. 1005 * 1005 * 1006 1006 * @param osmPrimitive 1007 1007 * The OSM entity to check. … … 1013 1013 /** 1014 1014 * Check if OSM primitive has a tag 'goods'. 1015 * 1015 * 1016 1016 * @param osmPrimitive 1017 1017 * The OSM entity to check. … … 1023 1023 /** 1024 1024 * Gets the value of tag 'goods'. 1025 * 1025 * 1026 1026 * @param osmPrimitive 1027 1027 * The OSM entity to check. … … 1033 1033 /** 1034 1034 * Check if OSM primitive has a tag 'frequency'. 1035 * 1035 * 1036 1036 * @param osmPrimitive 1037 1037 * The OSM entity to check. … … 1044 1044 /** 1045 1045 * Gets the value of tag 'frequency'. 1046 * 1046 * 1047 1047 * @param osmPrimitive 1048 1048 * The OSM entity to check. … … 1054 1054 /** 1055 1055 * Check if OSM primitive has a tag 'man_made'. 1056 * 1056 * 1057 1057 * @param osmPrimitive 1058 1058 * The OSM entity to check. … … 1064 1064 /** 1065 1065 * Gets the value of tag 'man_made'. 1066 * 1066 * 1067 1067 * @param osmPrimitive 1068 1068 * The OSM entity to check. … … 1074 1074 /** 1075 1075 * Check if OSM primitive has a tag 'addr:housenumber'. 1076 * 1076 * 1077 1077 * @param osmPrimitive 1078 1078 * The OSM entity to check. … … 1085 1085 /** 1086 1086 * Gets the value of tag 'addr:housenumber'. 1087 * 1087 * 1088 1088 * @param osmPrimitive 1089 1089 * The OSM entity to check. … … 1093 1093 : null; 1094 1094 } 1095 1095 1096 1096 /** 1097 1097 * Check if OSM primitive has a tag 'addr:housename'. 1098 * 1098 * 1099 1099 * @param osmPrimitive 1100 1100 * The OSM entity to check. … … 1107 1107 /** 1108 1108 * Gets the value of tag 'addr:housename'. 1109 * 1109 * 1110 1110 * @param osmPrimitive 1111 1111 * The OSM entity to check. … … 1118 1118 /** 1119 1119 * Check if OSM primitive has a tag 'area'. 1120 * 1120 * 1121 1121 * @param osmPrimitive 1122 1122 * The OSM entity to check. … … 1128 1128 /** 1129 1129 * Gets the value of tag 'area'. 1130 * 1130 * 1131 1131 * @param osmPrimitive 1132 1132 * The OSM entity to check. … … 1138 1138 /** 1139 1139 * Check if OSM primitive has a tag 'building:levels'. 1140 * 1140 * 1141 1141 * @param osmPrimitive 1142 1142 * The OSM entity to check. … … 1149 1149 /** 1150 1150 * Gets the value of tag 'building:levels'. 1151 * 1151 * 1152 1152 * @param osmPrimitive 1153 1153 * The OSM entity to check. … … 1160 1160 /** 1161 1161 * Check if OSM primitive has a tag 'wheelchair'. 1162 * 1162 * 1163 1163 * @param osmPrimitive 1164 1164 * The OSM entity to check. … … 1171 1171 /** 1172 1172 * Gets the value of tag 'wheelchair'. 1173 * 1173 * 1174 1174 * @param osmPrimitive 1175 1175 * The OSM entity to check. … … 1181 1181 /** 1182 1182 * Check if OSM primitive has a tag 'name'. 1183 * 1183 * 1184 1184 * @param osmPrimitive 1185 1185 * The OSM entity to check. … … 1191 1191 /** 1192 1192 * Gets the value of tag 'name'. 1193 * 1193 * 1194 1194 * @param osmPrimitive 1195 1195 * The OSM entity to check. … … 1201 1201 /** 1202 1202 * Check if OSM primitive has a tag 'oneway'. 1203 * 1203 * 1204 1204 * @param osmPrimitive 1205 1205 * The OSM entity to check. … … 1211 1211 /** 1212 1212 * Gets the value of tag 'oneway'. 1213 * 1213 * 1214 1214 * @param osmPrimitive 1215 1215 * The OSM entity to check. … … 1221 1221 /** 1222 1222 * Check if OSM primitive has a tag 'FIXME'. 1223 * 1223 * 1224 1224 * @param osmPrimitive 1225 1225 * The OSM entity to check. … … 1231 1231 /** 1232 1232 * Gets the value of tag 'FIXME'. 1233 * 1233 * 1234 1234 * @param osmPrimitive 1235 1235 * The OSM entity to check. … … 1241 1241 /** 1242 1242 * Check if OSM primitive has a tag 'capacity'. 1243 * 1243 * 1244 1244 * @param osmPrimitive 1245 1245 * The OSM entity to check. … … 1251 1251 /** 1252 1252 * Gets the value of tag 'capacity'. 1253 * 1253 * 1254 1254 * @param osmPrimitive 1255 1255 * The OSM entity to check. … … 1261 1261 /** 1262 1262 * Check if OSM primitive has a tag 'motorcycle'. 1263 * 1263 * 1264 1264 * @param osmPrimitive 1265 1265 * The OSM entity to check. … … 1272 1272 /** 1273 1273 * Gets the value of tag 'motorcycle'. 1274 * 1274 * 1275 1275 * @param osmPrimitive 1276 1276 * The OSM entity to check. … … 1282 1282 /** 1283 1283 * Check if OSM primitive has a tag 'hgv'. 1284 * 1284 * 1285 1285 * @param osmPrimitive 1286 1286 * The OSM entity to check. … … 1292 1292 /** 1293 1293 * Gets the value of tag 'hgv'. 1294 * 1294 * 1295 1295 * @param osmPrimitive 1296 1296 * The OSM entity to check. … … 1302 1302 /** 1303 1303 * Check if OSM primitive has a tag 'construction'. 1304 * 1304 * 1305 1305 * @param osmPrimitive 1306 1306 * The OSM entity to check. … … 1313 1313 /** 1314 1314 * Gets the value of tag 'construction'. 1315 * 1315 * 1316 1316 * @param osmPrimitive 1317 1317 * The OSM entity to check. … … 1323 1323 /** 1324 1324 * Check if OSM primitive has a tag 'addr:state'. 1325 * 1325 * 1326 1326 * @param osmPrimitive 1327 1327 * The OSM entity to check. … … 1334 1334 /** 1335 1335 * Gets the value of tag 'addr:state'. 1336 * 1336 * 1337 1337 * @param osmPrimitive 1338 1338 * The OSM entity to check. … … 1344 1344 /** 1345 1345 * Check if OSM primitive has a tag 'lanes'. 1346 * 1346 * 1347 1347 * @param osmPrimitive 1348 1348 * The OSM entity to check. … … 1354 1354 /** 1355 1355 * Gets the value of tag 'lanes'. 1356 * 1356 * 1357 1357 * @param osmPrimitive 1358 1358 * The OSM entity to check. … … 1364 1364 /** 1365 1365 * Check if OSM primitive has a tag 'note'. 1366 * 1366 * 1367 1367 * @param osmPrimitive 1368 1368 * The OSM entity to check. … … 1374 1374 /** 1375 1375 * Gets the value of tag 'note'. 1376 * 1376 * 1377 1377 * @param osmPrimitive 1378 1378 * The OSM entity to check. … … 1384 1384 /** 1385 1385 * Check if OSM primitive has a tag 'lit'. 1386 * 1386 * 1387 1387 * @param osmPrimitive 1388 1388 * The OSM entity to check. … … 1394 1394 /** 1395 1395 * Gets the value of tag 'lit'. 1396 * 1396 * 1397 1397 * @param osmPrimitive 1398 1398 * The OSM entity to check. … … 1404 1404 /** 1405 1405 * Check if OSM primitive has a tag 'building'. 1406 * 1406 * 1407 1407 * @param osmPrimitive 1408 1408 * The OSM entity to check. … … 1414 1414 /** 1415 1415 * Gets the value of tag 'building'. 1416 * 1416 * 1417 1417 * @param osmPrimitive 1418 1418 * The OSM entity to check. … … 1424 1424 /** 1425 1425 * Check if OSM primitive has a tag 'segregated'. 1426 * 1426 * 1427 1427 * @param osmPrimitive 1428 1428 * The OSM entity to check. … … 1435 1435 /** 1436 1436 * Gets the value of tag 'segregated'. 1437 * 1437 * 1438 1438 * @param osmPrimitive 1439 1439 * The OSM entity to check. … … 1445 1445 /** 1446 1446 * Check if OSM primitive has a tag 'addr:inclusion'. 1447 * 1447 * 1448 1448 * @param osmPrimitive 1449 1449 * The OSM entity to check. … … 1456 1456 /** 1457 1457 * Gets the value of tag 'addr:inclusion'. 1458 * 1458 * 1459 1459 * @param osmPrimitive 1460 1460 * The OSM entity to check. … … 1467 1467 /** 1468 1468 * Check if OSM primitive has a tag 'layer'. 1469 * 1469 * 1470 1470 * @param osmPrimitive 1471 1471 * The OSM entity to check. … … 1477 1477 /** 1478 1478 * Gets the value of tag 'layer'. 1479 * 1479 * 1480 1480 * @param osmPrimitive 1481 1481 * The OSM entity to check. … … 1487 1487 /** 1488 1488 * Check if OSM primitive has a tag 'sport'. 1489 * 1489 * 1490 1490 * @param osmPrimitive 1491 1491 * The OSM entity to check. … … 1497 1497 /** 1498 1498 * Gets the value of tag 'sport'. 1499 * 1499 * 1500 1500 * @param osmPrimitive 1501 1501 * The OSM entity to check. … … 1507 1507 /** 1508 1508 * Check if OSM primitive has a tag 'addr:interpolation'. 1509 * 1509 * 1510 1510 * @param osmPrimitive 1511 1511 * The OSM entity to check. … … 1518 1518 /** 1519 1519 * Gets the value of tag 'addr:interpolation'. 1520 * 1520 * 1521 1521 * @param osmPrimitive 1522 1522 * The OSM entity to check. … … 1529 1529 /** 1530 1530 * Check if OSM primitive has a tag 'cutting'. 1531 * 1531 * 1532 1532 * @param osmPrimitive 1533 1533 * The OSM entity to check. … … 1539 1539 /** 1540 1540 * Gets the value of tag 'cutting'. 1541 * 1541 * 1542 1542 * @param osmPrimitive 1543 1543 * The OSM entity to check. … … 1549 1549 /** 1550 1550 * Check if OSM primitive has a tag 'amenity'. 1551 * 1551 * 1552 1552 * @param osmPrimitive 1553 1553 * The OSM entity to check. … … 1559 1559 /** 1560 1560 * Gets the value of tag 'amenity'. 1561 * 1561 * 1562 1562 * @param osmPrimitive 1563 1563 * The OSM entity to check. … … 1569 1569 /** 1570 1570 * Check if OSM primitive has a tag 'access'. 1571 * 1571 * 1572 1572 * @param osmPrimitive 1573 1573 * The OSM entity to check. … … 1579 1579 /** 1580 1580 * Gets the value of tag 'access'. 1581 * 1581 * 1582 1582 * @param osmPrimitive 1583 1583 * The OSM entity to check. … … 1589 1589 /** 1590 1590 * Check if OSM primitive has a tag 'agricultural'. 1591 * 1591 * 1592 1592 * @param osmPrimitive 1593 1593 * The OSM entity to check. … … 1600 1600 /** 1601 1601 * Gets the value of tag 'agricultural'. 1602 * 1602 * 1603 1603 * @param osmPrimitive 1604 1604 * The OSM entity to check. … … 1610 1610 /** 1611 1611 * Check if OSM primitive has a tag 'capacity:disabled'. 1612 * 1612 * 1613 1613 * @param osmPrimitive 1614 1614 * The OSM entity to check. … … 1621 1621 /** 1622 1622 * Gets the value of tag 'capacity:disabled'. 1623 * 1623 * 1624 1624 * @param osmPrimitive 1625 1625 * The OSM entity to check. … … 1632 1632 /** 1633 1633 * Check if OSM primitive has a tag 'operator'. 1634 * 1634 * 1635 1635 * @param osmPrimitive 1636 1636 * The OSM entity to check. … … 1642 1642 /** 1643 1643 * Gets the value of tag 'operator'. 1644 * 1644 * 1645 1645 * @param osmPrimitive 1646 1646 * The OSM entity to check. … … 1652 1652 /** 1653 1653 * Check if OSM primitive has a tag 'ref'. 1654 * 1654 * 1655 1655 * @param osmPrimitive 1656 1656 * The OSM entity to check. … … 1662 1662 /** 1663 1663 * Gets the value of tag 'ref'. 1664 * 1664 * 1665 1665 * @param osmPrimitive 1666 1666 * The OSM entity to check. … … 1672 1672 /** 1673 1673 * Check if OSM primitive has a tag 'noexit'. 1674 * 1674 * 1675 1675 * @param osmPrimitive 1676 1676 * The OSM entity to check. … … 1682 1682 /** 1683 1683 * Gets the value of tag 'noexit'. 1684 * 1684 * 1685 1685 * @param osmPrimitive 1686 1686 * The OSM entity to check. … … 1692 1692 /** 1693 1693 * Check if OSM primitive has a tag 'admin_level'. 1694 * 1694 * 1695 1695 * @param osmPrimitive 1696 1696 * The OSM entity to check. … … 1703 1703 /** 1704 1704 * Gets the value of tag 'admin_level'. 1705 * 1705 * 1706 1706 * @param osmPrimitive 1707 1707 * The OSM entity to check. … … 1713 1713 /** 1714 1714 * Check if OSM primitive has a tag 'source'. 1715 * 1715 * 1716 1716 * @param osmPrimitive 1717 1717 * The OSM entity to check. … … 1723 1723 /** 1724 1724 * Gets the value of tag 'source'. 1725 * 1725 * 1726 1726 * @param osmPrimitive 1727 1727 * The OSM entity to check. … … 1733 1733 /** 1734 1734 * Check if OSM primitive has a tag 'tracktype'. 1735 * 1735 * 1736 1736 * @param osmPrimitive 1737 1737 * The OSM entity to check. … … 1744 1744 /** 1745 1745 * Gets the value of tag 'tracktype'. 1746 * 1746 * 1747 1747 * @param osmPrimitive 1748 1748 * The OSM entity to check. … … 1754 1754 /** 1755 1755 * Check if OSM primitive has a tag 'addr:country'. 1756 * 1756 * 1757 1757 * @param osmPrimitive 1758 1758 * The OSM entity to check. … … 1765 1765 /** 1766 1766 * Gets the value of tag 'addr:country'. 1767 * 1767 * 1768 1768 * @param osmPrimitive 1769 1769 * The OSM entity to check. … … 1775 1775 /** 1776 1776 * Check if OSM primitive has a tag 'route'. 1777 * 1777 * 1778 1778 * @param osmPrimitive 1779 1779 * The OSM entity to check. … … 1785 1785 /** 1786 1786 * Gets the value of tag 'route'. 1787 * 1787 * 1788 1788 * @param osmPrimitive 1789 1789 * The OSM entity to check. … … 1795 1795 /** 1796 1796 * Check if OSM primitive has a tag 'cables'. 1797 * 1797 * 1798 1798 * @param osmPrimitive 1799 1799 * The OSM entity to check. … … 1805 1805 /** 1806 1806 * Gets the value of tag 'cables'. 1807 * 1807 * 1808 1808 * @param osmPrimitive 1809 1809 * The OSM entity to check. … … 1815 1815 /** 1816 1816 * Check if OSM primitive has a tag 'service'. 1817 * 1817 * 1818 1818 * @param osmPrimitive 1819 1819 * The OSM entity to check. … … 1825 1825 /** 1826 1826 * Gets the value of tag 'service'. 1827 * 1827 * 1828 1828 * @param osmPrimitive 1829 1829 * The OSM entity to check. … … 1835 1835 /** 1836 1836 * Check if OSM primitive has a tag 'motorcar'. 1837 * 1837 * 1838 1838 * @param osmPrimitive 1839 1839 * The OSM entity to check. … … 1845 1845 /** 1846 1846 * Gets the value of tag 'motorcar'. 1847 * 1847 * 1848 1848 * @param osmPrimitive 1849 1849 * The OSM entity to check. … … 1855 1855 /** 1856 1856 * Check if OSM primitive has a tag 'whitewater'. 1857 * 1857 * 1858 1858 * @param osmPrimitive 1859 1859 * The OSM entity to check. … … 1866 1866 /** 1867 1867 * Gets the value of tag 'whitewater'. 1868 * 1868 * 1869 1869 * @param osmPrimitive 1870 1870 * The OSM entity to check. … … 1876 1876 /** 1877 1877 * Check if OSM primitive has a tag 'embankment'. 1878 * 1878 * 1879 1879 * @param osmPrimitive 1880 1880 * The OSM entity to check. … … 1887 1887 /** 1888 1888 * Gets the value of tag 'embankment'. 1889 * 1889 * 1890 1890 * @param osmPrimitive 1891 1891 * The OSM entity to check. … … 1894 1894 return osmPrimitive != null ? osmPrimitive.get(EMBANKMENT_TAG) : null; 1895 1895 } 1896 1897 /** 1898 * Checks if the given street supporting housenumbers. Usually motor ways and primary roads have 1896 1897 /** 1898 * Checks if the given street supporting housenumbers. Usually motor ways and primary roads have 1899 1899 * no addresses, also no paths or tracks. 1900 1900 * … … 1907 1907 return false; 1908 1908 } 1909 1909 1910 1910 // TODO: Should be configurable 1911 1911 1912 1912 /* Allow everything until this can be configured */ 1913 1913 return true; 1914 1914 /* 1915 1915 String hwType = getHighwayValue(w); 1916 return 1916 return !(TagUtils.HIGHWAY_MOTORWAY_LINK_VALUE.equals(hwType) || 1917 1917 TagUtils.HIGHWAY_MOTORWAY_VALUE.equals(hwType) || 1918 1918 TagUtils.HIGHWAY_FOOTWAY_VALUE.equals(hwType) || 1919 TagUtils.HIGHWAY_TRACK_VALUE.equals(hwType) 1919 TagUtils.HIGHWAY_TRACK_VALUE.equals(hwType) 1920 1920 );*/ 1921 1921 } 1922 1922 1923 1923 // Relation support 1924 1924 1925 1925 /** 1926 1926 * Check if OSM relation is a 'associatedStreet' relation. 1927 * 1927 * 1928 1928 * @param osmPrimitive 1929 1929 * The OSM entity to check. 1930 1930 */ 1931 1931 public static boolean isAssociatedStreetRelation(Relation rel) { 1932 return rel != null && 1933 rel.hasKey(RELATION_TYPE) && 1932 return rel != null && 1933 rel.hasKey(RELATION_TYPE) && 1934 1934 ASSOCIATEDSTREET_RELATION_TYPE.equals(rel.get(RELATION_TYPE)); 1935 1935 } 1936 1936 1937 1937 /** 1938 1938 * Checks if given relation member has role "street". … … 1944 1944 return relMember != null && STREET_RELATION_ROLE.equals(relMember.getRole()); 1945 1945 } 1946 1946 1947 1947 /** 1948 1948 * Checks if given relation member has role "house". … … 1954 1954 return relMember != null && STREET_RELATION_ROLE.equals(relMember.getRole()); 1955 1955 } 1956 1957 1958 1956 1957 1958 1959 1959 /** 1960 1960 * Checks if "addr:state" tag is required. … … 1964 1964 public static boolean isStateRequired() { 1965 1965 String loc = OsmUtils.getLocale(); 1966 1967 for (int i = 0; i < COUNTRIES_REQUIRE_STATE.length; i++) { 1966 1967 for (int i = 0; i < COUNTRIES_REQUIRE_STATE.length; i++) { 1968 1968 if (COUNTRIES_REQUIRE_STATE[i].equals(loc)) { 1969 1969 return true; 1970 1970 } 1971 1971 } 1972 1972 1973 1973 return false; 1974 1974 } … … 2065 2065 public static final String EMBANKMENT_TAG = "embankment"; 2066 2066 public static final String ADDR_HOUSENAME_TAG = "addr:housename"; 2067 2067 2068 2068 /* Highway types */ 2069 2069 public static final String HIGHWAY_CYCLEWAY_VALUE = "cycleway"; … … 2085 2085 2086 2086 /* Relation keys */ 2087 2087 2088 2088 // Associated street: See http://wiki.openstreetmap.org/wiki/Proposed_features/De:Hausnummern 2089 2089 public static final String RELATION_TYPE = "type"; -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditDialog.java
r24944 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 74 74 private static final String OK_COMMAND = tr("Close"); 75 75 private static final String SELECT_AND_CLOSE = tr("Select and close"); 76 76 77 77 private AddressEditContainer editContainer; 78 78 private JTable unresolvedTable; 79 79 private JTable streetTable; 80 80 81 81 /* Actions */ 82 82 private AssignAddressToStreetAction resolveAction = new AssignAddressToStreetAction(); … … 87 87 private ConvertToRelationAction convertToRelationAction = new ConvertToRelationAction(); 88 88 private ConvertAllToRelationAction convertAllToRelationAction = new ConvertAllToRelationAction(); 89 89 90 90 private AbstractAddressEditAction[] actions = new AbstractAddressEditAction[] { 91 91 resolveAction, … … 100 100 private JLabel unresolvedAddressesLabel; 101 101 private JMapViewer mapViewer; 102 103 102 103 104 104 /** 105 105 * @param arg0 … … 108 108 public AddressEditDialog(AddressEditContainer addressEditContainer) throws HeadlessException { 109 109 super(JOptionPane.getFrameForComponent(Main.parent), tr("Fix unresolved addresses"), false); 110 111 this.editContainer = addressEditContainer; 110 111 this.editContainer = addressEditContainer; 112 112 this.editContainer.addChangedListener(this); 113 113 setLayout(new BorderLayout()); 114 114 setSize(1024,600); 115 115 setLocationRelativeTo(null); 116 116 117 117 if (addressEditContainer != null) { 118 118 /* Panel for street table */ … … 122 122 streetTable.getSelectionModel().addListSelectionListener(this); 123 123 streetTable.addKeyListener(new JumpToEntryListener(1)); 124 124 125 125 JScrollPane scroll1 = new JScrollPane(streetTable); 126 126 streetPanel.add(scroll1, BorderLayout.CENTER); 127 127 128 128 streetLabel = createHeaderLabel(STREET_HEADER_FMT, 129 129 tr(STREETS), 130 130 editContainer.getNumberOfStreets()); 131 131 132 132 JPanel headerPanel = new JPanel(new GridLayout(1, 4)); 133 133 headerPanel.setMinimumSize(new Dimension(100, 30)); 134 134 headerPanel.add(streetLabel); 135 135 136 136 /* 137 137 JPanel streetButtonPanel = new JPanel(new GridLayout(1, 3)); 138 SideButton convertToRel = new SideButton(convertToRelationAction); 138 SideButton convertToRel = new SideButton(convertToRelationAction); 139 139 streetButtonPanel.add(convertToRel); 140 // SideButton convertAllToRel = new SideButton(convertAllToRelationAction); 140 // SideButton convertAllToRel = new SideButton(convertAllToRelationAction); 141 141 // streetButtonPanel.add(convertAllToRel); 142 142 // add filler 143 143 streetButtonPanel.add(new JPanel()); 144 144 streetButtonPanel.add(new JPanel()); 145 146 145 146 147 147 streetPanel.add(streetButtonPanel, BorderLayout.SOUTH); 148 148 */ 149 149 streetPanel.add(headerPanel, BorderLayout.NORTH); 150 150 streetPanel.setMinimumSize(new Dimension(500, 200)); 151 151 152 152 /* Panel for unresolved addresses table */ 153 153 JPanel unresolvedPanel = new JPanel(new BorderLayout()); … … 158 158 unresolvedTable.getSelectionModel().addListSelectionListener(new IncompleteAddressListener()); 159 159 unresolvedTable.addMouseListener(applyAllGuessesAction); 160 160 161 161 JTableHeader header = unresolvedTable.getTableHeader(); 162 162 header.addMouseListener(uaModel.new ColumnListener(unresolvedTable)); 163 163 164 164 JScrollPane scroll2 = new JScrollPane(unresolvedTable); 165 165 unresolvedPanel.add(scroll2, BorderLayout.CENTER); 166 166 unresolvedAddressesLabel = createHeaderLabel( 167 UNRESOLVED_HEADER_FMT, 168 tr(UNRESOLVED_ADDRESS), 167 UNRESOLVED_HEADER_FMT, 168 tr(UNRESOLVED_ADDRESS), 169 169 editContainer.getNumberOfUnresolvedAddresses()); 170 170 171 171 JPanel headerPanel2 = new JPanel(new GridLayout(1, 4)); 172 172 headerPanel2.setMinimumSize(new Dimension(100, 30)); … … 174 174 unresolvedPanel.add(headerPanel2 , BorderLayout.NORTH); 175 175 unresolvedPanel.setMinimumSize(new Dimension(500, 200)); 176 177 176 177 178 178 try { 179 179 JPanel unresolvedButtons = new JPanel(new GridLayout(2,5, 5, 5)); 180 SideButton assign = new SideButton(resolveAction); 180 SideButton assign = new SideButton(resolveAction); 181 181 unresolvedButtons.add(assign); 182 183 SideButton guess = new SideButton(guessAddressAction); 182 183 SideButton guess = new SideButton(guessAddressAction); 184 184 unresolvedButtons.add(guess); 185 SideButton applyAllGuesses = new SideButton(applyAllGuessesAction); 185 SideButton applyAllGuesses = new SideButton(applyAllGuessesAction); 186 186 unresolvedButtons.add(applyAllGuesses); 187 188 SideButton removeAddressTags = new SideButton(removeAddressTagsAction); 187 188 SideButton removeAddressTags = new SideButton(removeAddressTagsAction); 189 189 unresolvedButtons.add(removeAddressTags); 190 190 191 191 unresolvedButtons.add(new JPanel()); 192 193 SideButton selectInMap = new SideButton(selectAddressesInMapAction); 192 193 SideButton selectInMap = new SideButton(selectAddressesInMapAction); 194 194 unresolvedButtons.add(selectInMap); 195 195 headerPanel2.setMinimumSize(new Dimension(100, 70)); 196 197 unresolvedPanel.add(unresolvedButtons, BorderLayout.SOUTH); 198 } catch (Exception e) { 196 197 unresolvedPanel.add(unresolvedButtons, BorderLayout.SOUTH); 198 } catch (Exception e) { 199 199 e.printStackTrace(); 200 } 201 200 } 201 202 202 /* Map Panel */ 203 203 JPanel mapPanel = new JPanel(new BorderLayout()); … … 206 206 mapPanel.setMinimumSize(new Dimension(200, 200)); 207 207 mapViewer.setVisible(false); 208 208 209 209 JPanel mapControl = new JPanel(new GridLayout(1, 4)); 210 210 JLabel mapL1 = new JLabel(tr("Complete Addresses")); 211 211 mapL1.setForeground(Color.BLUE); 212 212 mapControl.add(mapL1); 213 213 214 214 JLabel mapL2 = new JLabel(tr("Incomplete Addresses")); 215 215 mapL2.setForeground(Color.RED); 216 216 mapControl.add(mapL2); 217 217 218 218 JLabel mapL3 = new JLabel(tr("Selected Addresses")); 219 219 mapL3.setForeground(Color.ORANGE); 220 220 mapControl.add(mapL3); 221 221 222 222 JLabel mapL4 = new JLabel(tr("Selected Street")); 223 223 mapL4.setForeground(Color.GREEN); 224 224 mapControl.add(mapL4); 225 225 226 226 mapPanel.add(mapControl, BorderLayout.SOUTH); 227 227 228 228 /* Combine panels */ 229 JSplitPane unresSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, streetPanel, unresolvedPanel); 229 JSplitPane unresSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, streetPanel, unresolvedPanel); 230 230 JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, unresSplitPane, mapPanel); 231 231 232 232 this.getContentPane().add(pane, BorderLayout.CENTER); 233 233 //this.getContentPane().add(mapPanel, BorderLayout.SOUTH); … … 235 235 this.getContentPane().add(new JLabel(tr("(No data)")), BorderLayout.CENTER); 236 236 } 237 237 238 238 for (int i = 0; i < actions.length; i++) { 239 239 actions[i].setContainer(addressEditContainer); 240 240 } 241 241 242 242 JPanel buttonPanel = new JPanel(new GridLayout(1,10)); 243 243 JButton ok = new JButton(OK_COMMAND, ImageProvider.getIfAvailable(null, "ok")); … … 245 245 JButton selectAndClose = new JButton(SELECT_AND_CLOSE); 246 246 selectAndClose.addActionListener(this); 247 247 248 248 // Murks 249 249 for (int i = 0; i < 8; i++) { … … 252 252 253 253 buttonPanel.add(ok); 254 255 254 255 256 256 this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); 257 257 } 258 258 259 259 /** 260 * Creates a header label in the form "title (number)" with bold font. 260 * Creates a header label in the form "title (number)" with bold font. 261 261 * @param fmtString The format string having a string and a numeric placeholder. 262 262 * @param title The title of the header. … … 270 270 return label; 271 271 } 272 272 273 273 /** 274 274 * Updates the list headings. … … 299 299 @Override 300 300 public void valueChanged(ListSelectionEvent e) { 301 301 302 302 AddressEditSelectionEvent ev = new AddressEditSelectionEvent(e.getSource(), 303 303 streetTable, unresolvedTable, null, editContainer); 304 304 305 305 for (AbstractAddressEditAction action : actions) { 306 306 action.setEvent(ev); 307 307 } 308 308 309 309 clearMapViewer(); 310 310 OSMStreet sNode = ev.getSelectedStreet(); 311 311 if (sNode != null) { 312 312 313 313 //mapViewer.addMapRectangle(new BBoxMapRectangle(bb)); 314 314 for (IOSMEntity seg : sNode.getChildren()) { 315 315 Way way = (Way) seg.getOsmObject(); 316 316 //BBox bb = way.getBBox(); 317 317 318 318 for (Node node : way.getNodes()) { 319 319 mapViewer.addMapMarker(new MapMarkerDot(Color.GREEN, node.getCoor().lat(), node.getCoor().lon())); 320 320 } 321 } 322 321 } 322 323 323 // show addresses as blue marker 324 324 if (sNode.hasAddresses()) { … … 331 331 } 332 332 } 333 } 334 333 } 334 335 335 List<OSMAddress> unrAddresses = ev.getSelectedUnresolvedAddresses(); 336 336 if (unrAddresses != null) { 337 for (OSMAddress aNode : unrAddresses) { 337 for (OSMAddress aNode : unrAddresses) { 338 338 mapViewer.addMapMarker(new MapMarkerDot(Color.ORANGE, aNode.getCoor().lat(), aNode.getCoor().lon())); 339 339 } … … 356 356 public void containerChanged(AddressEditContainer container) { 357 357 updateHeaders(); 358 358 359 359 for (int i = 0; i < actions.length; i++) { 360 360 actions[i].setEvent(null); … … 367 367 updateHeaders(); 368 368 } 369 370 /** 371 * Special listener to react on selection changes in the incomplete address list. 369 370 /** 371 * Special listener to react on selection changes in the incomplete address list. 372 372 * It searches the street table for the streets which matches best matching to the 373 373 * street name given in the address. 374 * 375 * @author Oliver Wieland <oliver.wieland@online.de> 376 */ 374 * 375 * @author Oliver Wieland <oliver.wieland@online.de> 376 */ 377 377 class IncompleteAddressListener implements ListSelectionListener { 378 378 … … 382 382 String streetOfAddr = (String) unresolvedTable. 383 383 getModel().getValueAt(unresolvedTable.getSelectedRow(), 0); 384 384 385 385 int maxScore = 0, score = 0, row = -1; 386 386 for (int i = 0; i < streetTable.getRowCount(); i++) { 387 387 String streetName = (String) streetTable.getModel().getValueAt(i, 1); 388 388 389 389 score = StringUtils.lcsLength(streetOfAddr, streetName); 390 390 if (score > maxScore) { 391 391 maxScore = score; 392 row = i; 392 row = i; 393 393 } 394 394 } 395 395 396 396 if (row > 0) { 397 397 streetTable.getSelectionModel().clearSelection(); … … 399 399 streetTable.scrollRectToVisible(streetTable.getCellRect(row, 0, true)); 400 400 } 401 } 402 } 403 404 } 405 401 } 402 } 403 404 } 405 406 406 /** 407 407 * The listener interface for receiving key events of a table. … … 416 416 */ 417 417 class JumpToEntryListener implements KeyListener { 418 private int column; 419 418 private int column; 419 420 420 /** 421 421 * Instantiates a new jump-to-entry listener. … … 430 430 public void keyPressed(KeyEvent arg0) { 431 431 // TODO Auto-generated method stub 432 432 433 433 } 434 434 … … 436 436 public void keyReleased(KeyEvent arg0) { 437 437 // TODO Auto-generated method stub 438 438 439 439 } 440 440 … … 442 442 public void keyTyped(KeyEvent arg0) { 443 443 JTable table = (JTable) arg0.getSource(); 444 444 445 445 if (table == null) return; 446 446 447 447 TableModel model = table.getModel(); 448 448 449 449 if (model == null || model.getColumnCount() == 0) { 450 450 return; … … 452 452 // clip column 453 453 if (column < 0 || column >= model.getColumnCount()) { 454 column = 0; // use the first column 455 } 456 454 column = 0; // use the first column 455 } 456 457 457 char firstChar = Character.toLowerCase(arg0.getKeyChar()); 458 458 … … 469 469 } 470 470 } 471 } 471 } 472 472 } 473 473 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditModel.java
r24093 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 33 33 private DefaultMutableTreeNode unresolvedRoot; 34 34 private DefaultMutableTreeNode incompleteRoot; 35 35 36 36 /** 37 37 * @param streets … … 44 44 this.unresolvedAddresses = unresolvedAddresses; 45 45 } 46 46 47 47 public TreeNode getStreetsTree() { 48 48 if (streets == null) return new DefaultMutableTreeNode(tr("(No data)")); 49 49 50 50 if (streetRoot == null) { 51 51 streetRoot = new DefaultMutableTreeNode(); 52 52 for (OSMStreet sNode : streets) { 53 53 DefaultMutableTreeNode treeStreetNode = new DefaultMutableTreeNode(sNode); 54 54 55 55 DefaultMutableTreeNode segmentsNode = new DefaultMutableTreeNode(tr("Segments")); 56 56 treeStreetNode.add(segmentsNode); 57 57 58 58 // Add street segment(s) 59 59 for (IOSMEntity child : sNode.getChildren()) { 60 60 segmentsNode.add(new DefaultMutableTreeNode(child)); 61 61 } 62 62 63 63 if (sNode.hasAddresses()) { 64 64 // Add address nodes 65 65 DefaultMutableTreeNode addressNode = new DefaultMutableTreeNode(tr("Addresses")); 66 66 treeStreetNode.add(addressNode); 67 67 68 68 for (OSMAddress addr : sNode.getAddresses()) { 69 69 addressNode.add(new DefaultMutableTreeNode(addr)); … … 76 76 } 77 77 } 78 78 79 79 return streetRoot; 80 80 } 81 81 82 82 /** 83 83 * Gets the tree node containing all unresolved addresses. … … 89 89 if (unresolvedRoot == null) { 90 90 unresolvedRoot = new DefaultMutableTreeNode(); 91 91 92 92 for (OSMAddress addr : unresolvedAddresses) { 93 // Add address nodes 93 // Add address nodes 94 94 unresolvedRoot.add(new DefaultMutableTreeNode(addr)); 95 95 } 96 96 } 97 97 98 98 return unresolvedRoot; 99 99 } 100 100 101 101 /** 102 102 * Gets the tree node containing all incomplete addresses. … … 108 108 if (incompleteRoot == null) { 109 109 incompleteRoot = new DefaultMutableTreeNode(); 110 110 111 111 for (OSMAddress addr : incompleteAddresses) { 112 // Add address nodes 112 // Add address nodes 113 113 incompleteRoot.add(new DefaultMutableTreeNode(addr)); 114 114 } 115 115 } 116 116 117 117 return incompleteRoot; 118 118 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditSelectionEvent.java
r24129 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 26 26 public class AddressEditSelectionEvent extends ActionEvent { 27 27 /** 28 * 28 * 29 29 */ 30 30 private static final long serialVersionUID = -93034483427803409L; … … 33 33 private JTable incompleteAddressTable; 34 34 private AddressEditContainer addressContainer; 35 35 36 36 private List<OSMAddress> unresolvedCache; 37 37 private List<OSMAddress> incompleteCache; 38 38 39 39 /** 40 40 * Creates a new 'AddressEditSelectionEvent'. … … 52 52 this.addressContainer = container; 53 53 } 54 54 55 55 /** 56 56 * Gets the street table component. … … 68 68 return unresolvedAddressTable; 69 69 } 70 70 71 71 /** 72 72 * @return the incompleteAddressTable … … 84 84 return addressContainer; 85 85 } 86 86 87 87 /** 88 88 * Gets the selected street of the street table. … … 92 92 if (streetTable != null && addressContainer != null && addressContainer.getStreetList() != null) { 93 93 int selRows = streetTable.getSelectedRow(); 94 94 95 95 if (selRows < 0 || selRows >= addressContainer.getNumberOfStreets()) { 96 96 return null; 97 97 } 98 98 99 99 return addressContainer.getStreetList().get(selRows); 100 100 } 101 101 return null; 102 102 } 103 103 104 104 /** 105 105 * Checks for addresses. … … 110 110 return hasIncompleteAddresses() || hasUnresolvedAddresses(); 111 111 } 112 112 113 113 /** 114 114 * Checks for incomplete addresses. … … 119 119 return getSelectedIncompleteAddresses() != null; 120 120 } 121 121 122 122 /** 123 123 * Checks for unresolved addresses. … … 128 128 return getSelectedUnresolvedAddresses() != null; 129 129 } 130 130 131 131 /** 132 132 * Checks for addresses with guesses. … … 142 142 } 143 143 } 144 144 145 145 if (hasUnresolvedAddresses()) { 146 146 for (OSMAddress addr : getSelectedUnresolvedAddresses()) { … … 150 150 } 151 151 } 152 152 153 153 return false; 154 154 } 155 155 156 156 /** 157 157 * Gets the list containing the selected items of the 'unresolved addresses ' table. … … 159 159 */ 160 160 public List<OSMAddress> getSelectedUnresolvedAddresses() { 161 if (unresolvedAddressTable != null && 162 addressContainer != null && 161 if (unresolvedAddressTable != null && 162 addressContainer != null && 163 163 unresolvedCache == null) { 164 164 165 165 int[] selRows = unresolvedAddressTable.getSelectedRows(); 166 166 167 167 unresolvedCache = new ArrayList<OSMAddress>(); 168 168 for (int i = 0; i < selRows.length; i++) { … … 176 176 } 177 177 } 178 178 179 179 /** 180 180 * Gets the selected incomplete addresses. … … 183 183 */ 184 184 public List<OSMAddress> getSelectedIncompleteAddresses() { 185 if (incompleteAddressTable != null && 186 addressContainer != null && 185 if (incompleteAddressTable != null && 186 addressContainer != null && 187 187 incompleteCache == null) { 188 188 189 189 int[] selRows = incompleteAddressTable.getSelectedRows(); 190 190 191 191 incompleteCache = new ArrayList<OSMAddress>(); 192 192 for (int i = 0; i < selRows.length; i++) { -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditTableModel.java
r24174 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 31 31 public abstract class AddressEditTableModel extends DefaultTableModel implements 32 32 IAddressEditContainerListener { 33 33 34 34 protected AddressEditContainer addressContainer; 35 35 protected int sortCol = 0; … … 58 58 * Gets the node entity for the given row or null; if row contains no 59 59 * entity. 60 * 60 * 61 61 * @param row 62 62 * The row to get the entity object for. … … 68 68 * Gets the row for the given node entity or -1; if the model does not 69 69 * contain the entity. 70 * 70 * 71 71 * @param entity 72 72 * The entity to get the row for. … … 77 77 /** 78 78 * Sorts the model data by the given column. 79 * 79 * 80 80 * @param column 81 81 * the column … … 85 85 protected abstract void sortByColumn(int column, boolean ascending); 86 86 87 87 88 88 /** 89 89 * The listener interface for receiving column events. … … 135 135 136 136 //Collections.sort(addressContainer, new MyComparator(isSortAsc)); 137 137 138 138 sortByColumn(sortCol, isSortAsc); 139 139 table.tableChanged(new TableModelEvent(AddressEditTableModel.this)); … … 141 141 } 142 142 } 143 143 144 144 /** 145 145 * Internal base class to sort items by different columns. … … 148 148 private int column; 149 149 private boolean ascending; 150 150 151 151 /** 152 152 * Instantiates a new address sorter. … … 159 159 this.ascending = ascending; 160 160 } 161 161 162 162 /** 163 163 * Gets the index of the column to sort. … … 168 168 return column; 169 169 } 170 170 171 171 /** 172 172 * Checks if sort mode is ascending or not. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/BBoxMapRectangle.java
r23931 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 23 23 public class BBoxMapRectangle implements MapRectangle { 24 24 private BBox bbox; 25 25 26 26 /** 27 27 * @param bbox -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/IncompleteAddressesDialog.java
r24942 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 59 59 private ApplyAllGuessesAction applyGuessesAction = new ApplyAllGuessesAction(); 60 60 private RemoveAddressTagsAction removeTagsAction = new RemoveAddressTagsAction(); 61 61 62 62 // Array containing the available actions 63 63 private AbstractAddressEditAction[] actions = new AbstractAddressEditAction[]{ … … 70 70 71 71 private JTable incompleteAddr; 72 72 73 73 /** 74 74 * Instantiates a new "incomplete addresses" dialog. … … 77 77 public IncompleteAddressesDialog() { 78 78 super(FIXED_DIALOG_TITLE, "incompleteaddress_24", tr("Show incomplete addresses"), null, 150); 79 79 80 80 this.container = new AddressEditContainer(); 81 81 container.addChangedListener(this); … … 85 85 IncompleteAddressesTableModel model = new IncompleteAddressesTableModel(container); 86 86 incompleteAddr = new JTable(model); 87 87 JTableHeader header = incompleteAddr.getTableHeader(); 88 88 header.addMouseListener(model.new ColumnListener(incompleteAddr)); 89 89 incompleteAddr.getSelectionModel().addListSelectionListener(this); 90 90 91 91 // Scroll pane hosting the table 92 92 JScrollPane sp = new JScrollPane(incompleteAddr); 93 93 p.add(sp, BorderLayout.CENTER); 94 94 this.add(p); 95 95 96 96 // Button panel containing the commands 97 97 JPanel buttonPanel = getButtonPanel(actions.length); 98 98 99 99 // Populate panel with actions 100 100 for (int i = 0; i < actions.length; i++) { … … 102 102 buttonPanel.add(sb); 103 103 } 104 104 105 105 this.add(buttonPanel, BorderLayout.SOUTH); 106 106 107 107 // Link actions with address container 108 108 for (AbstractAddressEditAction action : actions) { … … 110 110 } 111 111 } 112 112 113 113 /* (non-Javadoc) 114 114 * @see org.openstreetmap.josm.gui.dialogs.ToggleDialog#hideNotify() … … 133 133 */ 134 134 @Override 135 public void dataChanged(DataChangedEvent event) { 135 public void dataChanged(DataChangedEvent event) { 136 136 container.invalidate(); 137 137 } … … 142 142 @Override 143 143 public void nodeMoved(NodeMovedEvent event) { 144 144 145 145 } 146 146 … … 151 151 public void otherDatasetChange(AbstractDatasetChangedEvent event) { 152 152 // TODO Auto-generated method stub 153 153 154 154 } 155 155 … … 160 160 public void primtivesAdded(PrimitivesAddedEvent event) { 161 161 container.invalidate(); 162 162 163 163 } 164 164 … … 168 168 @Override 169 169 public void primtivesRemoved(PrimitivesRemovedEvent event) { 170 container.invalidate(); 170 container.invalidate(); 171 171 } 172 172 … … 176 176 @Override 177 177 public void relationMembersChanged(RelationMembersChangedEvent event) { 178 container.invalidate(); 178 container.invalidate(); 179 179 } 180 180 … … 185 185 public void tagsChanged(TagsChangedEvent event) { 186 186 container.invalidate(); 187 187 188 188 } 189 189 … … 193 193 @Override 194 194 public void wayNodesChanged(WayNodesChangedEvent event) { 195 container.invalidate(); 195 container.invalidate(); 196 196 } 197 197 … … 202 202 public void valueChanged(ListSelectionEvent e) { 203 203 AddressEditSelectionEvent event = new AddressEditSelectionEvent(e, null, null, incompleteAddr, container); 204 204 205 205 for (AbstractAddressEditAction action : actions) { 206 206 action.setEvent(event); 207 } 208 207 } 208 209 209 OsmUtils.zoomAddresses(event.getSelectedIncompleteAddresses()); 210 210 } … … 218 218 setTitle(String.format("%s (%d %s)", FIXED_DIALOG_TITLE, container.getNumberOfIncompleteAddresses(), tr("items"))); 219 219 } else { 220 setTitle(String.format("%s (%s)", FIXED_DIALOG_TITLE, tr("no items"))); 220 setTitle(String.format("%s (%s)", FIXED_DIALOG_TITLE, tr("no items"))); 221 221 } 222 222 } … … 228 228 public void entityChanged(IOSMEntity node) { 229 229 // TODO Auto-generated method stub 230 230 231 231 } 232 232 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/IncompleteAddressesTableModel.java
r24942 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 24 24 public class IncompleteAddressesTableModel extends AddressEditTableModel { 25 25 /** 26 * 26 * 27 27 */ 28 28 private static final long serialVersionUID = -5951629033395186324L; 29 29 30 30 // TODO: Add "state" column, if required 31 31 private static final int NUMBER_OF_COLUMNS = 5; 32 private static final String[] COLUMN_NAMES = new String[]{tr("Country"), tr("City"), tr("Postcode"), tr("Street"), tr("Number")}; 32 private static final String[] COLUMN_NAMES = new String[]{tr("Country"), tr("City"), tr("Postcode"), tr("Street"), tr("Number")}; 33 33 private static final Class<?>[] COLUMN_CLASSES = new Class<?>[]{ 34 34 String.class, String.class, String.class, String.class, String.class, String.class}; 35 36 35 36 37 37 /** 38 38 * Instantiates a new incomplete addresses table model. … … 75 75 */ 76 76 @Override 77 public Object getValueAt(int row, int column) { 77 public Object getValueAt(int row, int column) { 78 78 OSMAddress aNode = (OSMAddress) getEntityOfRow(row); 79 79 80 80 if (aNode == null) { 81 81 return null; 82 82 } 83 83 84 84 switch (column) { 85 85 case 0: … … 90 90 return aNode.getPostalCode(); 91 91 case 3: 92 return aNode.getStreetName(); 92 return aNode.getStreetName(); 93 93 case 4: 94 94 return aNode.getHouseNumber(); … … 96 96 throw new RuntimeException("Invalid column index: " + column); 97 97 } 98 99 } 100 98 99 } 100 101 101 /* (non-Javadoc) 102 102 * @see javax.swing.table.AbstractTableModel#getColumnClass(int) … … 137 137 return -1; 138 138 } 139 139 140 140 return addressContainer.getIncompleteAddresses().indexOf(entity); 141 141 } 142 142 143 143 144 144 /* (non-Javadoc) … … 148 148 protected void sortByColumn(int column, boolean ascending) { 149 149 if (addressContainer.getNumberOfIncompleteAddresses() == 0) return; 150 151 Collections.sort(addressContainer.getIncompleteAddresses(), 150 151 Collections.sort(addressContainer.getIncompleteAddresses(), 152 152 new IncompleteAddressModelSorter(column, ascending)); 153 153 } 154 154 155 155 /** 156 156 * Internal class StreetModelSorter. … … 174 174 public int compare(OSMAddress arg0, OSMAddress arg1) { 175 175 int cc = 0; 176 176 177 177 switch (getColumn()) { 178 case 0: 178 case 0: 179 179 cc=arg0.getCountry().compareTo(arg1.getCountry()); 180 180 break; … … 193 193 default: 194 194 throw new RuntimeException("Invalid column index: " + getColumn()); 195 } 196 195 } 196 197 197 if (!isAscending()) { 198 198 cc = -cc; 199 199 } 200 200 201 201 return cc; 202 202 } 203 203 } 204 205 204 205 206 206 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/StreetTableModel.java
r24174 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 25 25 public class StreetTableModel extends AddressEditTableModel { 26 26 private static final int NUMBER_OF_COLUMNS = 3; 27 private static final String[] COLUMN_NAMES = new String[]{tr("Type"), tr("Name"), tr("Addresses")}; 27 private static final String[] COLUMN_NAMES = new String[]{tr("Type"), tr("Name"), tr("Addresses")}; 28 28 private static final Class<?>[] COLUMN_CLASSES = new Class<?>[]{String.class, String.class, Integer.class}; 29 29 /** … … 50 50 return COLUMN_NAMES[column]; 51 51 } 52 52 53 53 /* (non-Javadoc) 54 54 * @see javax.swing.table.AbstractTableModel#getColumnClass(int) … … 74 74 */ 75 75 @Override 76 public Object getValueAt(int row, int column) { 76 public Object getValueAt(int row, int column) { 77 77 OSMStreet sNode = (OSMStreet) getEntityOfRow(row); 78 78 79 79 if (sNode == null) { 80 80 return null; 81 81 } 82 82 83 83 switch (column) { 84 84 case 0: … … 95 95 throw new RuntimeException("Invalid column index: " + column); 96 96 } 97 97 98 98 } 99 99 … … 112 112 return null; 113 113 } 114 return addressContainer.getStreetList().get(row); 114 return addressContainer.getStreetList().get(row); 115 115 } 116 116 117 117 @Override 118 118 public int getRowOfEntity(IOSMEntity entity) { … … 120 120 return -1; 121 121 } 122 122 123 123 return addressContainer.getStreetList().indexOf(entity); 124 124 } … … 131 131 Collections.sort(addressContainer.getStreetList(), new StreetModelSorter(column, ascending)); 132 132 } 133 133 134 134 /** 135 135 * Internal class StreetModelSorter. … … 143 143 public int compare(OSMStreet arg0, OSMStreet arg1) { 144 144 if (arg0 == null || arg1 == null) return 0; 145 145 146 146 switch (getColumn()) { 147 147 case 0: -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/UnresolvedAddressesTableModel.java
r24227 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ 14 14 /** 15 * This program is free software: you can redistribute it and/or modify it under 16 * the terms of the GNU General Public License as published by the 17 * Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 21 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 * See the GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along with this program. 15 * This program is free software: you can redistribute it and/or modify it under 16 * the terms of the GNU General Public License as published by the 17 * Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 21 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 * See the GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along with this program. 25 25 * If not, see <http://www.gnu.org/licenses/>. 26 26 */ … … 39 39 /** 40 40 * Provides a table model to show unresolved addresses. 41 * 41 * 42 42 * @author Oliver Wieland <oliver.wieland@online.de> 43 * 43 * 44 44 */ 45 45 … … 55 55 56 56 /** 57 * 57 * 58 58 */ 59 59 private static final long serialVersionUID = 424009321818130586L; … … 68 68 /* 69 69 * (non-Javadoc) 70 * 70 * 71 71 * @see javax.swing.table.DefaultTableModel#getColumnCount() 72 72 */ … … 78 78 /* 79 79 * (non-Javadoc) 80 * 80 * 81 81 * @see javax.swing.table.DefaultTableModel#getColumnName(int) 82 82 */ … … 88 88 /* 89 89 * (non-Javadoc) 90 * 90 * 91 91 * @see javax.swing.table.DefaultTableModel#getRowCount() 92 92 */ … … 102 102 /* 103 103 * (non-Javadoc) 104 * 104 * 105 105 * @see javax.swing.table.DefaultTableModel#getValueAt(int, int) 106 106 */ … … 132 132 /* 133 133 * (non-Javadoc) 134 * 134 * 135 135 * @see javax.swing.table.AbstractTableModel#getColumnClass(int) 136 136 */ … … 142 142 /* 143 143 * (non-Javadoc) 144 * 144 * 145 145 * @see javax.swing.table.DefaultTableModel#isCellEditable(int, int) 146 146 */ … … 152 152 /* 153 153 * (non-Javadoc) 154 * 154 * 155 155 * @see 156 156 * org.openstreetmap.josm.plugins.fixAddresses.gui.AddressEditTableModel … … 181 181 /* 182 182 * (non-Javadoc) 183 * 183 * 184 184 * @see 185 185 * org.openstreetmap.josm.plugins.fixAddresses.gui.AddressEditTableModel … … 206 206 /* 207 207 * (non-Javadoc) 208 * 208 * 209 209 * @see 210 210 * org.openstreetmap.josm.plugins.fixAddresses.gui.AddressEditTableModel -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/AbstractAddressEditAction.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 37 37 * Most actions will work in both cases, so it is recommended to have one single method which 38 38 * accepts a list of addresses or streets and executes the tasks to be done by this action. 39 * 39 * 40 40 * @author Oliver Wieland <oliver.wieland@online.de> 41 41 */ 42 42 43 43 @SuppressWarnings("serial") 44 public abstract class AbstractAddressEditAction extends JosmAction implements IAddressEditContainerListener, ICommandListener { 44 public abstract class AbstractAddressEditAction extends JosmAction implements IAddressEditContainerListener, ICommandListener { 45 45 private AddressEditSelectionEvent event; 46 46 protected AddressEditContainer container; … … 54 54 public AbstractAddressEditAction(String name, String iconName, String tooltip) { 55 55 super(name, iconName, tooltip, null, true); 56 56 57 57 setEnabled(false); 58 58 } … … 64 64 this(name, null, ""); 65 65 } 66 66 67 67 /** 68 68 * Gets the current address container. … … 101 101 updateEnabledState(); 102 102 } 103 103 104 104 /* (non-Javadoc) 105 105 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) … … 108 108 public void actionPerformed(ActionEvent arg0) { 109 109 if (event != null) { // use the event acquired previously. 110 addressEditActionPerformed(event); 110 addressEditActionPerformed(event); 111 111 event = null; // consume event 112 112 } else { 113 113 if (container != null) { 114 114 addressEditActionPerformed(container); 115 } else { 115 } else { 116 116 throw new RuntimeException("AbstractAddressEditAction has no container or event"); 117 117 } … … 141 141 */ 142 142 protected abstract void updateEnabledState(AddressEditContainer container); 143 143 144 144 /** 145 145 * Updates 'enabled' state depending on the current selection. … … 154 154 */ 155 155 public abstract void addressEditActionPerformed(AddressEditSelectionEvent ev); 156 156 157 157 /** 158 158 * Redirected action handler for doing actions on an address container. … … 160 160 */ 161 161 public abstract void addressEditActionPerformed(AddressEditContainer container); 162 163 162 163 164 164 /* (non-Javadoc) 165 165 * @see org.openstreetmap.josm.plugins.fixAddresses.IAddressEditContainerListener#containerChanged(org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer) … … 176 176 public void entityChanged(IOSMEntity node) { 177 177 container.removeProblemsOfSource(node); // clear problems of changed node... 178 node.visit(container, container); 179 updateEnabledState(); 180 } 181 178 node.visit(container, container); // .. and revisit it. 179 updateEnabledState(); 180 } 181 182 182 /** 183 183 * Begins the transaction (command sequence). Must be called by every subclass before … … 190 190 throw new RuntimeException("TX has not been closed (missing finishTransaction?)"); 191 191 } 192 192 193 193 commands = new ArrayList<Command>(); 194 194 if (StringUtils.isNullOrEmpty(txName)) { … … 197 197 this.txName = txName; 198 198 } 199 199 200 200 /** 201 201 * Finishes the transaction and passes the command sequence to the framework. … … 210 210 container.invalidate(); 211 211 } 212 212 213 213 /** 214 214 * Begins the transaction for a single object. … … 223 223 } 224 224 } 225 225 226 226 /** 227 227 * Finishes the transaction for a single object. … … 236 236 } 237 237 } 238 238 239 239 /* (non-Javadoc) 240 240 * @see org.openstreetmap.josm.plugins.fixAddresses.ICommandListener#commandIssued(org.openstreetmap.josm.plugins.fixAddresses.IOSMEntity, org.openstreetmap.josm.command.Command) -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/ApplyAllGuessesAction.java
r24982 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 32 32 33 33 /** 34 * Applies the guessed values for a set of addresses. 34 * Applies the guessed values for a set of addresses. 35 35 * @author Oliver Wieland <oliver.wieland@online.de> 36 * 36 * 37 37 */ 38 38 … … 43 43 * Instantiates a new "apply all guesses" action. 44 44 */ 45 public ApplyAllGuessesAction(String tag) { 45 public ApplyAllGuessesAction(String tag) { 46 46 super(tr("Apply"), "applyguesses_24", tr("Turns all guesses into the corresponding tag values.")); 47 47 this.tag = tag; 48 48 } 49 49 50 50 /** 51 51 * Instantiates a new "apply all guesses" action. 52 52 */ 53 public ApplyAllGuessesAction() { 53 public ApplyAllGuessesAction() { 54 54 this(null); 55 55 } … … 61 61 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 62 62 if (ev == null) return; 63 63 64 64 if (ev.getSelectedUnresolvedAddresses() != null) { 65 65 List<OSMAddress> addrToFix = ev.getSelectedUnresolvedAddresses(); 66 66 applyGuesses(addrToFix); 67 67 } 68 68 69 69 if (ev.getSelectedIncompleteAddresses() != null) { 70 70 List<OSMAddress> addrToFix = ev.getSelectedIncompleteAddresses(); … … 91 91 for (OSMAddress aNode : addrToFixShadow) { 92 92 beginObjectTransaction(aNode); 93 93 94 94 if (StringUtils.isNullOrEmpty(tag)) { // tag given? 95 95 aNode.applyAllGuesses(); // no -> apply all guesses … … 116 116 public void addressEditActionPerformed(AddressEditContainer container) { 117 117 if (container == null || container.getNumberOfIncompleteAddresses() == 0) return; 118 118 119 119 List<OSMAddress> addrToFix = container.getUnresolvedAddresses(); 120 applyGuesses(addrToFix); 121 120 applyGuesses(addrToFix); 121 122 122 addrToFix = container.getIncompleteAddresses(); 123 123 applyGuesses(addrToFix); … … 131 131 JTable table = (JTable)e.getSource(); 132 132 Point p = e.getPoint(); 133 if(e.getClickCount() == 2) { 133 if(e.getClickCount() == 2) { 134 134 AddressEditTableModel model = (AddressEditTableModel) table.getModel(); 135 135 if (model != null) { … … 140 140 beginObjectTransaction(node); 141 141 OSMAddress aNode = (OSMAddress) node; 142 142 143 143 aNode.applyAllGuesses(); 144 144 145 145 finishObjectTransaction(node); 146 146 finishTransaction(); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/AssignAddressToStreetAction.java
r24165 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 22 22 23 23 /** 24 * Assigns one or more selected addresses to a street, i. e. the name of the street is 25 * used as value for the addr:street tag. 24 * Assigns one or more selected addresses to a street, i. e. the name of the street is 25 * used as value for the addr:street tag. 26 26 * @author Oliver Wieland <oliver.wieland@online.de> 27 * 27 * 28 28 */ 29 29 public class AssignAddressToStreetAction extends AbstractAddressEditAction { … … 33 33 */ 34 34 public AssignAddressToStreetAction() { 35 super(tr("Assign address to street"), "assignstreet_24", 35 super(tr("Assign address to street"), "assignstreet_24", 36 36 tr("Assign the selected address(es) to the selected street.")); 37 37 } 38 38 39 39 /** 40 * 40 * 41 41 */ 42 42 private static final long serialVersionUID = -6180491357232121384L; … … 46 46 */ 47 47 @Override 48 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 48 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 49 49 OSMStreet streetNode = ev.getSelectedStreet(); 50 50 51 51 if (streetNode != null && ev.getSelectedUnresolvedAddresses() != null) { 52 52 beginTransaction(tr("Set street name") + " '" + streetNode.getName() + "'"); … … 58 58 finishTransaction(); 59 59 } 60 60 61 61 } 62 62 … … 77 77 @Override 78 78 public void addressEditActionPerformed(AddressEditContainer container) { 79 // we only accept a selection: nothing to do here 79 // we only accept a selection: nothing to do here 80 80 } 81 81 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/ConvertAllToRelationAction.java
r24165 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 23 23 public class ConvertAllToRelationAction extends ConvertToRelationAction { 24 24 public ConvertAllToRelationAction() { 25 super(tr("Convert ALL streets."), "convert2rel_24", 25 super(tr("Convert ALL streets."), "convert2rel_24", 26 26 tr("Create relation between street and related addresses for ALL streets in the current layer.")); 27 27 } 28 28 29 29 @Override 30 30 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { … … 50 50 setEnabled(hasStreetsToConvert()); 51 51 } 52 52 53 53 /** 54 54 * Checks for streets to convert to a relation. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/ConvertToRelationAction.java
r24165 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 30 30 31 31 public ConvertToRelationAction() { 32 super(tr("Convert to relation."), "convert2rel_24", 32 super(tr("Convert to relation."), "convert2rel_24", 33 33 tr("Create relation between street and related addresses.")); 34 34 } 35 35 36 36 /** 37 37 * Instantiates a new convert to relation action. … … 42 42 */ 43 43 public ConvertToRelationAction(String name, String iconName, String tooltip) { 44 super(name, iconName, tooltip); 44 super(name, iconName, tooltip); 45 45 } 46 46 … … 51 51 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 52 52 OSMStreet streetNode = ev.getSelectedStreet(); 53 53 54 54 if (streetNode != null) { 55 55 createRelationForStreet(streetNode); … … 65 65 protected void createRelationForStreet(OSMStreet streetNode) { 66 66 if (streetNode == null || !streetNode.hasAddresses()) return; 67 67 68 68 beginTransaction(tr("Create address relation for ") + " '" + streetNode.getName() + "'"); 69 69 // Create the relation … … 74 74 // add street with role 'street' 75 75 r.addMember(new RelationMember(TagUtils.STREET_RELATION_ROLE, streetNode.getOsmObject())); 76 76 77 77 // add address members 78 78 for (OSMAddress addrNode : streetNode.getAddresses()) { 79 beginObjectTransaction(addrNode); 79 beginObjectTransaction(addrNode); 80 80 r.addMember(new RelationMember(TagUtils.HOUSE_RELATION_ROLE, addrNode.getOsmObject())); 81 81 addrNode.setStreetName(null); // remove street name … … 107 107 protected void updateEnabledState(AddressEditSelectionEvent event) { 108 108 if (event == null) return; 109 109 110 110 OSMStreet street = event.getSelectedStreet(); 111 111 setEnabled(street != null && street.hasAddresses() && !street.hasAssociatedStreetRelation()); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/GuessAddressDataAction.java
r24231 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 28 28 * Guesses address tags by picking the closest street node with a name. The same is done 29 29 * with city, post code, state,... However, I strongly encourage you to check the result. 30 * 30 * 31 31 * @author Oliver Wieland <oliver.wieland@online.de> 32 32 */ … … 64 64 public void addressEditActionPerformed(AddressEditContainer container) { 65 65 if (container == null || container.getNumberOfInvalidAddresses() == 0) return; 66 66 67 67 internalGuessAddresses(container.getAllAddressesToFix()); 68 68 } … … 74 74 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 75 75 if (ev == null || !ev.hasAddresses()) return; 76 77 // guess tags for selected addresses only 76 77 // guess tags for selected addresses only 78 78 internalGuessAddresses(ev.getSelectedIncompleteAddresses()); 79 79 internalGuessAddresses(ev.getSelectedUnresolvedAddresses()); 80 80 } 81 81 82 82 /** 83 83 * Internal method to start several threads guessing tag values for the given list of addresses. … … 86 86 private void internalGuessAddresses(List<OSMAddress> nodes) { 87 87 if (nodes == null) return; 88 88 89 89 // Launch address guessing thread 90 90 GuessAddressRunnable aft = new GuessAddressRunnable(nodes, tr("Guessing address values")); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/RemoveAddressTagsAction.java
r24231 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 43 43 aNode.removeAllAddressTags(); 44 44 finishObjectTransaction(aNode); 45 } 45 } 46 46 } 47 47 finishTransaction(); … … 63 63 setEnabled(false); 64 64 } 65 65 66 66 setEnabled(event.hasAddresses()); 67 67 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/SelectAddressesInMapAction.java
r24210 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ 14 14 /** 15 * This program is free software: you can redistribute it and/or modify it under 16 * the terms of the GNU General Public License as published by the 17 * Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 21 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 * See the GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along with this program. 15 * This program is free software: you can redistribute it and/or modify it under 16 * the terms of the GNU General Public License as published by the 17 * Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 21 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 * See the GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along with this program. 25 25 * If not, see <http://www.gnu.org/licenses/>. 26 26 */ … … 43 43 * 44 44 * @author Oliver Wieland <oliver.wieland@online.de> 45 * 45 * 46 46 */ 47 47 … … 62 62 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 63 63 if (ev == null) return; 64 64 65 65 if (ev.hasUnresolvedAddresses()) { 66 66 internalSelectAddresses(ev.getSelectedUnresolvedAddresses()); … … 72 72 @Override 73 73 public void addressEditActionPerformed(AddressEditContainer container) { 74 // do nothing 74 // do nothing 75 75 } 76 76 … … 92 92 93 93 /** 94 * Internal helper to select the given addresses in the map. 94 * Internal helper to select the given addresses in the map. 95 95 * @param addrToSel 96 96 */ 97 97 private void internalSelectAddresses(List<OSMAddress> addrToSel) { 98 98 if (addrToSel == null) return; 99 99 100 100 List<OsmPrimitive> sel = new ArrayList<OsmPrimitive>(); 101 101 102 102 getCurrentDataSet().clearSelection(); 103 103 for (OSMAddress aNode : addrToSel) { 104 104 sel.add(aNode.getOsmObject()); 105 105 106 106 // Select also guessed objects, if wished 107 107 if (FixAddressesPlugin.getPreferences().isSelectGuessedObjects()) { -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/SelectIncompleteAddressesAction.java
r24977 r25373 1 1 /* 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 2 * This program is free software: you can redistribute it and/or modify it under 3 * the terms of the GNU General Public License as published by the 4 * Free Software Foundation, either version 3 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 8 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 * See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along with this program. 12 12 * If not, see <http://www.gnu.org/licenses/>. 13 13 */ … … 28 28 public class SelectIncompleteAddressesAction extends JosmAction { 29 29 30 30 31 31 private AddressEditContainer addressEditContainer; 32 32 33 33 public SelectIncompleteAddressesAction() { 34 34 super(tr("Select incomplete addresses"), "select_invaddr_24", 35 tr("Selects all addresses with incomplete data."), null, false); 35 tr("Selects all addresses with incomplete data."), null, false); 36 36 } 37 37 … … 40 40 addressEditContainer = new AddressEditContainer(); 41 41 addressEditContainer.invalidate(); 42 42 43 43 if (addressEditContainer.getIncompleteAddresses() != null) { 44 44 List<OsmPrimitive> osms = new ArrayList<OsmPrimitive>(); 45 45 46 46 for (OSMAddress aNode : addressEditContainer.getIncompleteAddresses()) { 47 47 osms.add(aNode.getOsmObject());
Note:
See TracChangeset
for help on using the changeset viewer.