Changeset 24209 in osm for applications/editors/josm
- Timestamp:
- 2010-11-12T23:06:37+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/GuessAddressRunnable.java
r24165 r24209 48 48 private boolean cancelled; 49 49 50 /** 51 * @param nodes 52 */ 53 public GuessAddressRunnable(List<OSMAddress> nodes, String title) { 50 51 /** 52 * Instantiates a new guess address runnable. 53 * 54 * @param addresses the addresses to guess the values for 55 * @param title the title of progress monitor 56 */ 57 public GuessAddressRunnable(List<OSMAddress> addresses, String title) { 54 58 super(title != null ? title : tr("Searching")); 55 setAddressEditContainer(nodes); 56 } 57 59 setAddressEditContainer(addresses); 60 } 61 62 /** 63 * Sets the address edit container. 64 * 65 * @param nodes the new address edit container 66 */ 58 67 public void setAddressEditContainer(List<OSMAddress> nodes) { 59 68 if (isRunning) { … … 63 72 } 64 73 74 /** 75 * Gets the addresses to guess. 76 * 77 * @return the addresses to guess 78 */ 65 79 public List<OSMAddress> getAddressesToGuess() { 66 80 return addressesToGuess; … … 91 105 } 92 106 107 /** 108 * Fires the 'finished' event after the thread has done his work. 109 */ 93 110 protected void fireFinished() { 94 111 for (IProgressMonitorFinishedListener l : finishListeners) { … … 262 279 minDist = dist; 263 280 currentValue = TagUtils.getNameValue(w); 264 aNode.setGuessedValue(getTag(), currentValue );281 aNode.setGuessedValue(getTag(), currentValue, w); 265 282 } else { 266 283 //System.out.println(String.format("Skipped %s: %4.2f m", TagUtils.getNameValue(w), dist)); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/GuessedValueHandler.java
r24091 r24209 143 143 minDist = dist; 144 144 currentValue = n.get(tag); 145 aNode.setGuessedValue(tag, currentValue );145 aNode.setGuessedValue(tag, currentValue, n); 146 146 } 147 147 } … … 158 158 minDist = dist; 159 159 currentValue = w.get(tag); 160 aNode.setGuessedValue(tag, currentValue );160 aNode.setGuessedValue(tag, currentValue, w); 161 161 } 162 162 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMAddress.java
r24175 r24209 17 17 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 20 20 21 /** … … 30 31 /** The dictionary containing guessed values. */ 31 32 private HashMap<String, String> guessedValues = new HashMap<String, String>(); 33 /** The dictionary containing guessed objects. */ 34 private HashMap<String, OsmPrimitive> guessedObjects = new HashMap<String, OsmPrimitive>(); 32 35 /** The dictionary containing indirect values. */ 33 36 private HashMap<String, String> derivedValues = new HashMap<String, String>(); … … 116 119 117 120 /** 118 * Returns the street name guessed by the nearest-neighbo ur search.121 * Returns the street name guessed by the nearest-neighbor search. 119 122 * @return the guessedStreetName 120 123 */ … … 124 127 125 128 /** 129 * Sets the guessed street name. 130 * 126 131 * @param guessedStreetName the guessedStreetName to set 127 */ 128 public void setGuessedStreetName(String guessedStreetName) { 129 setGuessedValue(TagUtils.ADDR_STREET_TAG, guessedStreetName); 132 * @param srcObj the source object of the guess. 133 */ 134 public void setGuessedStreetName(String guessedStreetName, OsmPrimitive srcObj) { 135 setGuessedValue(TagUtils.ADDR_STREET_TAG, guessedStreetName, srcObj); 130 136 } 131 137 … … 147 153 148 154 /** 155 * Sets the guessed post code. 156 * 149 157 * @param guessedPostCode the guessedPostCode to set 150 */ 151 public void setGuessedPostCode(String guessedPostCode) { 152 setGuessedValue(TagUtils.ADDR_POSTCODE_TAG, guessedPostCode); 158 * @param srcObj srcObj the source object of the guess 159 */ 160 public void setGuessedPostCode(String guessedPostCode, OsmPrimitive srcObj) { 161 setGuessedValue(TagUtils.ADDR_POSTCODE_TAG, guessedPostCode, srcObj); 153 162 } 154 163 … … 170 179 171 180 /** 181 * Sets the guessed city. 182 * 172 183 * @param guessedCity the guessedCity to set 173 */ 174 public void setGuessedCity(String guessedCity) { 175 setGuessedValue(TagUtils.ADDR_CITY_TAG, guessedCity); 184 * @param srcObj the source object of the guess 185 */ 186 public void setGuessedCity(String guessedCity, OsmPrimitive srcObj) { 187 setGuessedValue(TagUtils.ADDR_CITY_TAG, guessedCity, srcObj); 176 188 } 177 189 … … 203 215 } 204 216 } 217 218 // Clear all guesses 205 219 guessedValues.clear(); 220 guessedObjects.clear(); 206 221 } 207 222 … … 404 419 /** 405 420 * Gets the guessed value for the given tag. 421 * 406 422 * @param tag The tag to get the guessed value for. 407 * @return 423 * @return the guessed value 408 424 */ 409 425 public String getGuessedValue(String tag) { 426 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 427 410 428 if (!hasGuessedValue(tag)) { 411 429 return null; 412 430 } 413 431 return guessedValues.get(tag); 432 } 433 434 /** 435 * Gets the guessed object. 436 * 437 * @param tag the guessed tag 438 * @return the object which has been selected for the guess 439 */ 440 public OsmPrimitive getGuessedObject(String tag) { 441 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 442 443 if (guessedObjects.containsKey(tag)) { 444 return guessedObjects.get(tag); 445 } 446 return null; 414 447 } 415 448 … … 450 483 */ 451 484 private boolean hasGuessedValue(String tag) { 485 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 486 452 487 return guessedValues.containsKey(tag) && 453 488 !StringUtils.isNullOrEmpty(guessedValues.get(tag)); … … 460 495 * @param value the value of the guessed tag. 461 496 */ 462 public void setGuessedValue(String tag, String value) { 497 public void setGuessedValue(String tag, String value, OsmPrimitive osm) { 498 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 499 CheckParameterUtil.ensureParameterNotNull(value, "value"); 500 CheckParameterUtil.ensureParameterNotNull(osm, "osm"); 501 463 502 guessedValues.put(tag, value); 503 guessedObjects.put(tag, osm); 464 504 fireEntityChanged(this); 465 505 } … … 472 512 */ 473 513 private boolean hasDerivedValue(String tag) { 514 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 515 474 516 return derivedValues.containsKey(tag) && 475 517 !StringUtils.isNullOrEmpty(derivedValues.get(tag));
Note:
See TracChangeset
for help on using the changeset viewer.