Changeset 23966 in osm for applications/editors/josm/plugins/FixAddresses/src
- Timestamp:
- 2010-10-31T16:16:58+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java
r23965 r23966 134 134 return; 135 135 } 136 136 137 // Address nodes are recycled in order to keep instance variables like guessed names 137 138 String aid = "" + n.getId(); 138 139 AddressNode aNode = null; … … 148 149 149 150 if (aNode != null) { 150 if (!assignAddressToStreet(aNode)) { 151 // Assignment failed: Street is not known (yet) -> add to 'unresolved' list 152 shadowUnresolvedAddresses.add(aNode); 153 } 154 155 if (!aNode.isComplete()) { 156 shadowIncompleteAddresses.add(aNode); 157 } 151 addAndClassifyAddress(aNode); 158 152 } else { 159 153 // check, if node is referred by a way … … 170 164 markNodeAsVisited(n); 171 165 } 166 167 private void addAndClassifyAddress(AddressNode aNode) { 168 if (!assignAddressToStreet(aNode)) { 169 // Assignment failed: Street is not known (yet) -> add to 'unresolved' list 170 shadowUnresolvedAddresses.add(aNode); 171 } 172 173 if (!aNode.isComplete()) { 174 shadowIncompleteAddresses.add(aNode); 175 } 176 } 172 177 173 178 /* (non-Javadoc) … … 192 197 */ 193 198 private void createNodeFromWay(Way w) { 194 StreetSegmentNode newSegment = NodeFactory.createNodeFromWay(w); 195 196 if (newSegment != null) { 197 String name = newSegment.getName(); 198 if (StringUtils.isNullOrEmpty(name)) return; 199 200 StreetNode sNode = null; 201 if (shadowStreetDict.containsKey(name)) { // street exists? 202 sNode = shadowStreetDict.get(name); 203 } else { // new street name -> add to dict 204 sNode = new StreetNode(w); 205 shadowStreetDict.put(name, sNode); 206 } 207 208 if (sNode != null) { 209 // TODO: Check if segment really belongs to the street, even if the 210 // names are the same. Then the streets should be split up... 211 sNode.addStreetSegment(newSegment); 212 } else { 213 throw new RuntimeException("Street node is null!"); 214 } 215 } 199 INodeEntity ne = NodeFactory.createNodeFromWay(w); 200 201 processNode(ne, w); 216 202 217 203 markWayAsVisited(w); … … 226 212 if (!tags.contains(key)) { 227 213 tags.add(key); 214 } 215 } 216 } 217 218 /** 219 * Process a entity node. 220 * 221 * @param ne the ne 222 * @param w the w 223 */ 224 private void processNode(INodeEntity ne, Way w) { 225 if (ne != null) { 226 if (ne instanceof StreetSegmentNode) { 227 StreetSegmentNode newSegment = (StreetSegmentNode) ne; 228 229 if (newSegment != null) { 230 String name = newSegment.getName(); 231 if (StringUtils.isNullOrEmpty(name)) return; 232 233 StreetNode sNode = null; 234 if (shadowStreetDict.containsKey(name)) { // street exists? 235 sNode = shadowStreetDict.get(name); 236 } else { // new street name -> add to dict 237 sNode = new StreetNode(w); 238 shadowStreetDict.put(name, sNode); 239 } 240 241 if (sNode != null) { 242 // TODO: Check if segment really belongs to the street, even if the 243 // names are the same. Then the streets should be split up... 244 sNode.addStreetSegment(newSegment); 245 } else { 246 throw new RuntimeException("Street node is null!"); 247 } 248 } 249 } 250 251 // Node is an address 252 if (ne instanceof AddressNode) { 253 AddressNode aNode = (AddressNode) ne; 254 addAndClassifyAddress(aNode); 228 255 } 229 256 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressNode.java
r23961 r23966 48 48 */ 49 49 public String getStreet() { 50 if (osmObject == null) return MISSING_TAG; 51 50 52 if (!TagUtils.hasAddrStreetTag(osmObject)) { 51 return MISSING_TAG; 53 // check, if referrers have a street 54 for (OsmPrimitive osm : osmObject.getReferrers()) { 55 if (TagUtils.hasAddrStreetTag(osm)) { 56 String refStreetName = TagUtils.getAddrStreetValue(osm); 57 58 if (!StringUtils.isNullOrEmpty(refStreetName)) { 59 return refStreetName; 60 } 61 } 62 } 63 return MISSING_TAG; // nothing found 52 64 } 53 65 return TagUtils.getAddrStreetValue(osmObject); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/NodeFactory.java
r23933 r23966 36 36 * @return The new node instance or null; if given way is inappropriate. 37 37 */ 38 public static StreetSegmentNodecreateNodeFromWay(Way way) {38 public static INodeEntity createNodeFromWay(Way way) { 39 39 if (TagUtils.hasHighwayTag(way)) { 40 40 return new StreetSegmentNode(way); 41 41 } 42 42 43 // Check for building with address 44 if (way.isClosed() && TagUtils.hasBuildingTag(way) && TagUtils.isAddress(way)) { 45 return new AddressNode(way); 46 } 43 47 return null; 44 48 } -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditDialog.java
r23950 r23966 256 256 List<AddressNode> unrAddresses = ev.getSelectedUnresolvedAddresses(); 257 257 if (unrAddresses != null) { 258 for (AddressNode aNode : unrAddresses) { 259 Node node = (Node) aNode.getOsmObject(); 260 mapViewer.addMapMarker(new MapMarkerDot(Color.ORANGE, node.getCoor().lat(), node.getCoor().lon())); 258 for (AddressNode aNode : unrAddresses) { 259 mapViewer.addMapMarker(new MapMarkerDot(Color.ORANGE, aNode.getCoor().lat(), aNode.getCoor().lon())); 261 260 } 262 261 }
Note:
See TracChangeset
for help on using the changeset viewer.