Changeset 24129 in osm for applications/editors/josm
- Timestamp:
- 2010-11-07T19:28:18+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java
r24095 r24129 422 422 public int getNumberOfUnresolvedAddresses() { 423 423 return unresolvedAddresses != null ? unresolvedAddresses.size() : 0; 424 } 425 426 /** 427 * Gets the number of invalid (unresolved and/or incomplete) addresses. 428 * 429 * @return the number of invalid addresses 430 */ 431 public int getNumberOfInvalidAddresses() { 432 return getNumberOfIncompleteAddresses() + getNumberOfUnresolvedAddresses(); 424 433 } 425 434 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMAddress.java
r24115 r24129 24 24 public class OSMAddress extends OSMEntityBase { 25 25 public static final String MISSING_TAG = "?"; 26 public static final String INTERPOLATION_TAG = "..."; 27 28 private boolean isPartOfInterpolation; 26 29 27 30 /** The dictionary containing guessed values. */ … … 41 44 super.setOsmObject(osmObject); 42 45 43 OsmUtils.getValuesFromAddressInterpolation(this);46 isPartOfInterpolation = OsmUtils.getValuesFromAddressInterpolation(this); 44 47 45 48 String streetNameViaRel = OsmUtils.getAssociatedStreet(this.osmObject); … … 54 57 */ 55 58 public boolean isComplete() { 56 return TagUtils.hasAddrCityTag(osmObject) && TagUtils.hasAddrCountryTag(osmObject) && 57 TagUtils.hasAddrHousenumberTag(osmObject) && TagUtils.hasAddrPostcodeTag(osmObject) && 58 TagUtils.hasAddrStateTag(osmObject) && 59 (TagUtils.hasAddrStreetTag(osmObject) || hasDerivedValue(TagUtils.ADDR_STREET_TAG)); 59 return hasCity() && 60 hasHouseNumber() && 61 hasPostCode() && 62 hasCity() && 63 hasState() && 64 hasStreetName(); 60 65 } 61 66 … … 218 223 public String getHouseNumber() { 219 224 if (!TagUtils.hasAddrHousenumberTag(osmObject)) { 220 return MISSING_TAG; 225 if (!isPartOfInterpolation) { 226 return MISSING_TAG; 227 } else { 228 return INTERPOLATION_TAG; 229 } 221 230 } 222 231 return TagUtils.getAddrHousenumberValue(osmObject); 223 232 } 224 233 234 /** 235 * Checks for house number. 236 * 237 * @return true, if successful 238 */ 239 public boolean hasHouseNumber() { 240 return TagUtils.hasAddrHousenumberTag(osmObject) || isPartOfInterpolation; 241 } 242 243 /** 244 * Checks if this address is part of a address interpolation. 245 * 246 * @return true, if is part of interpolation 247 */ 248 protected boolean isPartOfInterpolation() { 249 return isPartOfInterpolation; 250 } 251 225 252 /** 226 253 * Gets the name of the city associated with this address. -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmUtils.java
r24119 r24129 133 133 if (osm instanceof Way) { 134 134 Way w = (Way) osm; 135 if (TagUtils.hasAddrInterpolationTag(w)) { 135 if (TagUtils.hasAddrInterpolationTag(w)) { 136 System.out.println("Found interpolation for " + address); 136 137 applyDerivedValue(address, w, TagUtils.ADDR_POSTCODE_TAG); 137 138 applyDerivedValue(address, w, TagUtils.ADDR_CITY_TAG); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditSelectionEvent.java
r24114 r24129 34 34 private AddressEditContainer addressContainer; 35 35 36 private List<OSMAddress> unresolvedCache; 37 private List<OSMAddress> incompleteCache; 38 36 39 /** 37 40 * Creates a new 'AddressEditSelectionEvent'. … … 100 103 101 104 /** 105 * Checks for addresses. 106 * 107 * @return true, if successful 108 */ 109 public boolean hasAddresses() { 110 return hasIncompleteAddresses() || hasUnresolvedAddresses(); 111 } 112 113 /** 114 * Checks for incomplete addresses. 115 * 116 * @return true, if successful 117 */ 118 public boolean hasIncompleteAddresses() { 119 return getSelectedIncompleteAddresses() != null; 120 } 121 122 /** 123 * Checks for unresolved addresses. 124 * 125 * @return true, if successful 126 */ 127 public boolean hasUnresolvedAddresses() { 128 return getSelectedUnresolvedAddresses() != null; 129 } 130 131 /** 132 * Checks for addresses with guesses. 133 * 134 * @return true, if successful 135 */ 136 public boolean hasAddressesWithGuesses() { 137 if (hasIncompleteAddresses()) { 138 for (OSMAddress addr : getSelectedIncompleteAddresses()) { 139 if (addr.hasGuesses()) { 140 return true; 141 } 142 } 143 } 144 145 if (hasUnresolvedAddresses()) { 146 for (OSMAddress addr : getSelectedUnresolvedAddresses()) { 147 if (addr.hasGuesses()) { 148 return true; 149 } 150 } 151 } 152 153 return false; 154 } 155 156 /** 102 157 * Gets the list containing the selected items of the 'unresolved addresses ' table. 103 158 * @return … … 106 161 if (unresolvedAddressTable != null && 107 162 addressContainer != null && 108 addressContainer.getUnresolvedAddresses() != null) {163 unresolvedCache == null) { 109 164 110 165 int[] selRows = unresolvedAddressTable.getSelectedRows(); 111 166 112 List<OSMAddress> nodes= new ArrayList<OSMAddress>();167 unresolvedCache = new ArrayList<OSMAddress>(); 113 168 for (int i = 0; i < selRows.length; i++) { 114 169 if (selRows[i] >= 0 && selRows[i] < addressContainer.getNumberOfUnresolvedAddresses()) { 115 nodes.add(addressContainer.getUnresolvedAddresses().get(selRows[i])); 116 } 117 } 118 return nodes; 119 } 120 return null; 170 unresolvedCache.add(addressContainer.getUnresolvedAddresses().get(selRows[i])); 171 } 172 } 173 return unresolvedCache; 174 } else { 175 return unresolvedCache; 176 } 121 177 } 122 178 … … 129 185 if (incompleteAddressTable != null && 130 186 addressContainer != null && 131 addressContainer.getUnresolvedAddresses() != null) {187 incompleteCache == null) { 132 188 133 189 int[] selRows = incompleteAddressTable.getSelectedRows(); 134 190 135 List<OSMAddress> nodes= new ArrayList<OSMAddress>();191 incompleteCache = new ArrayList<OSMAddress>(); 136 192 for (int i = 0; i < selRows.length; i++) { 137 193 if (selRows[i] >= 0 && selRows[i] < addressContainer.getNumberOfIncompleteAddresses()) { 138 nodes.add(addressContainer.getIncompleteAddresses().get(selRows[i])); 139 } 140 } 141 return nodes; 142 } 143 return null; 194 incompleteCache.add(addressContainer.getIncompleteAddresses().get(selRows[i])); 195 } 196 } 197 return incompleteCache; 198 } else { 199 return incompleteCache; // equals null, if no data is present 200 } 144 201 } 145 202 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/IncompleteAddressesDialog.java
r24114 r24129 41 41 import org.openstreetmap.josm.plugins.fixAddresses.IOSMEntity; 42 42 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction; 43 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.ApplyAllGuessesAction; 44 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.RemoveAddressTagsAction; 43 45 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.SelectAddressesInMapAction; 44 46 … … 47 49 private static final String FIXED_DIALOG_TITLE = tr("Incomplete Addresses"); 48 50 49 50 51 private AddressEditContainer container; 51 52 52 53 53 private SelectAddressesInMapAction selectAction = new SelectAddressesInMapAction(); 54 private ApplyAllGuessesAction applyGuessesAction = new ApplyAllGuessesAction(); 55 private RemoveAddressTagsAction removeTagsAction = new RemoveAddressTagsAction(); 54 56 55 57 private AbstractAddressEditAction[] actions = new AbstractAddressEditAction[]{ 56 selectAction 58 selectAction, 59 applyGuessesAction, 60 removeTagsAction 57 61 }; 58 62 … … 79 83 this.add(p); 80 84 81 JPanel buttonPanel = getButtonPanel( 5);85 JPanel buttonPanel = getButtonPanel(actions.length); 82 86 83 SideButton sb = new SideButton(selectAction); 84 buttonPanel.add(sb); 87 for (int i = 0; i < actions.length; i++) { 88 SideButton sb = new SideButton(actions[i]); 89 buttonPanel.add(sb); 90 } 85 91 86 92 this.add(buttonPanel, BorderLayout.SOUTH); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/ApplyAllGuessesAction.java
r24120 r24129 93 93 @Override 94 94 protected void updateEnabledState(AddressEditSelectionEvent event) { 95 setEnabled(event.getSelectedIncompleteAddresses() != null || 96 event.getSelectedIncompleteAddresses() != null); 95 setEnabled(event.hasAddressesWithGuesses()); 97 96 } 98 97 … … 102 101 @Override 103 102 public void addressEditActionPerformed(AddressEditContainer container) { 104 if (container == null || container.get UnresolvedAddresses() == null) return;103 if (container == null || container.getNumberOfIncompleteAddresses() == 0) return; 105 104 106 105 List<OSMAddress> addrToFix = container.getUnresolvedAddresses(); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/AssignAddressToStreetAction.java
r24105 r24129 62 62 @Override 63 63 public void updateEnabledState(AddressEditSelectionEvent ev) { 64 setEnabled(ev.getSelectedStreet() != null && ev. getSelectedUnresolvedAddresses() != null);64 setEnabled(ev.getSelectedStreet() != null && ev.hasUnresolvedAddresses()); 65 65 } 66 66 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/GuessAddressDataAction.java
r24105 r24129 61 61 public void addressEditActionPerformed(AddressEditContainer container) { 62 62 if (container == null) return; 63 if (container.get UnresolvedAddresses() == null) return;63 if (container.getNumberOfUnresolvedAddresses() == 0) return; 64 64 65 internalGuessAddresses(container.get IncompleteAddresses());65 internalGuessAddresses(container.getAllAddressesToFix()); 66 66 } 67 67 … … 73 73 if (ev == null || ev.getSelectedUnresolvedAddresses() == null) return; 74 74 75 // guess tags for selected addresses only 76 internalGuessAddresses(ev.getSelectedUnresolvedAddresses()); 75 // guess tags for selected addresses only 76 internalGuessAddresses(ev.getSelectedIncompleteAddresses()); 77 internalGuessAddresses(ev.getSelectedUnresolvedAddresses()); 77 78 } 78 79 … … 82 83 */ 83 84 private void internalGuessAddresses(List<OSMAddress> nodes) { 85 if (nodes == null) return; 86 84 87 GuessAddressRunnable aft = new GuessAddressRunnable(nodes, tr("Guess street names")); 85 88 aft.addFinishListener(this); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/RemoveAddressTagsAction.java
r24105 r24129 30 30 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { 31 31 beginTransaction(tr("Remove address tags")); 32 for (OSMAddress aNode : ev.getSelectedUnresolvedAddresses()) { 33 beginObjectTransaction(aNode); 34 aNode.removeAllAddressTags(); 35 finishObjectTransaction(aNode); 32 if (ev.hasUnresolvedAddresses()) { 33 for (OSMAddress aNode : ev.getSelectedUnresolvedAddresses()) { 34 beginObjectTransaction(aNode); 35 aNode.removeAllAddressTags(); 36 finishObjectTransaction(aNode); 37 } 36 38 } 37 finishTransaction(); 39 40 if (ev.hasIncompleteAddresses()) { 41 for (OSMAddress aNode : ev.getSelectedIncompleteAddresses()) { 42 beginObjectTransaction(aNode); 43 aNode.removeAllAddressTags(); 44 finishObjectTransaction(aNode); 45 } 46 finishTransaction(); 47 } 38 48 } 39 49 … … 54 64 } 55 65 56 setEnabled(event. getSelectedUnresolvedAddresses() != null);66 setEnabled(event.hasAddresses()); 57 67 } 58 68 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/SelectAddressesInMapAction.java
r24116 r24129 50 50 public SelectAddressesInMapAction() { 51 51 // we simply use the existing icon :-| 52 super(tr("Select in map"), "selectall", "Selects selected addresses in the map");52 super(tr("Select"), "selectall", "Selects selected addresses in the map"); 53 53 } 54 54 … … 60 60 if (ev == null) return; 61 61 62 if (ev. getSelectedUnresolvedAddresses() != null) {62 if (ev.hasUnresolvedAddresses()) { 63 63 internalSelectAddresses(ev.getSelectedUnresolvedAddresses()); 64 } else if (ev. getSelectedIncompleteAddresses() != null) {64 } else if (ev.hasIncompleteAddresses()) { 65 65 internalSelectAddresses(ev.getSelectedIncompleteAddresses()); 66 66 } … … 85 85 @Override 86 86 protected void updateEnabledState(AddressEditSelectionEvent event) { 87 setEnabled(event != null && (event.getSelectedUnresolvedAddresses() != null || event.getSelectedIncompleteAddresses() != null));87 setEnabled(event != null && event.hasAddresses()); 88 88 } 89 89
Note:
See TracChangeset
for help on using the changeset viewer.