Changeset 24220 in osm for applications/editors/josm/plugins
- Timestamp:
- 2010-11-14T16:45:11+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMAddress.java
r24210 r24220 28 28 public static final String INTERPOLATION_TAG = "x..y"; 29 29 30 private boolean isPartOfInterpolation; 30 31 /** True, if address is part of an address interpolation. */ 32 private boolean isPartOfInterpolation; 33 /** 34 * True, if address has derived values from an associated street relation. 35 */ 36 private boolean isPartOfAssocStreetRel; 31 37 32 38 /** The dictionary containing guessed values. */ … … 48 54 super.setOsmObject(osmObject); 49 55 50 isPartOfInterpolation = OsmUtils.getValuesFromAddressInterpolation(this); 51 52 String streetNameViaRel = OsmUtils.getAssociatedStreet(this.osmObject); 53 if (!StringUtils.isNullOrEmpty(streetNameViaRel)) { 54 setDerivedValue(TagUtils.ADDR_STREET_TAG, streetNameViaRel); 55 } 56 isPartOfInterpolation = OsmUtils.getValuesFromAddressInterpolation(this); 57 isPartOfAssocStreetRel = OsmUtils.getValuesFromRelation(this); 56 58 } 57 59 … … 116 118 */ 117 119 public boolean hasStreetName() { 118 return TagUtils.hasAddrStreetTag(osmObject) || hasDerivedValue(TagUtils.ADDR_STREET_TAG);120 return hasTag(TagUtils.ADDR_STREET_TAG); 119 121 } 120 122 … … 282 284 protected boolean isPartOfInterpolation() { 283 285 return isPartOfInterpolation; 286 } 287 288 /** 289 * Checks if this address is part of an 'associated street' relation. 290 * 291 * @return true, if is part of interpolation 292 */ 293 protected boolean isPartOfRelation() { 294 return isPartOfAssocStreetRel; 284 295 } 285 296 -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmUtils.java
r24171 r24220 100 100 * Gets the associated street name via relation of the address node, if present. 101 101 * 102 * @param addr Node the OSM node containing the address.103 * @return t he associated street or null, if noassociated street has been found.102 * @param address the address 103 * @return true, if an associated street has been found. 104 104 */ 105 public static String getAssociatedStreet(OsmPrimitive addrNode) {106 if (addr Node== null) {107 return null;105 public static boolean getValuesFromRelation(OSMAddress address) { 106 if (address == null) { 107 return false; 108 108 } 109 110 boolean hasValuesFromRel = false; /* true, if we applied some address props from the relation */ 111 OsmPrimitive addrNode = address.getOsmObject(); 109 112 110 113 for (OsmPrimitive osm : addrNode.getReferrers()) { … … 118 121 OsmPrimitive street = rm.getMember(); 119 122 if (TagUtils.hasHighwayTag(street)) { 120 return TagUtils.getNameValue(street); 121 } // TODO: Issue a warning here 123 String streetName = TagUtils.getNameValue(street); 124 if (!StringUtils.isNullOrEmpty(streetName)) { 125 address.setDerivedValue(TagUtils.ADDR_STREET_TAG, streetName); 126 hasValuesFromRel = true; 127 break; 128 } 129 } // TODO: Issue a warning here 122 130 } 131 } 132 133 // Check for other address properties 134 if (TagUtils.hasAddrCityTag(r)) { // city 135 address.setDerivedValue(TagUtils.ADDR_CITY_TAG, TagUtils.getAddrCityValue(r)); 136 hasValuesFromRel = true; 137 } 138 if (TagUtils.hasAddrCountryTag(r)) { // country 139 address.setDerivedValue(TagUtils.ADDR_COUNTRY_TAG, TagUtils.getAddrCountryValue(r)); 140 hasValuesFromRel = true; 141 } 142 if (TagUtils.hasAddrPostcodeTag(r)) { // postcode 143 address.setDerivedValue(TagUtils.ADDR_POSTCODE_TAG, TagUtils.getAddrPostcodeValue(r)); 144 hasValuesFromRel = true; 123 145 } 124 146 } 125 147 } 126 return null;148 return hasValuesFromRel; 127 149 } 128 150
Note:
See TracChangeset
for help on using the changeset viewer.