Changeset 2441 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-11-12T22:09:45+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r2440 r2441 361 361 private List<T> search_contents(BBox search_bbox) 362 362 { 363 String size = "null"; 364 if (content != null) { 365 size = ""+content.size(); 366 } 367 if (debug) { 368 out("searching contents (size: "+size+") for " + search_bbox); 363 if (debug) { 364 out("searching contents (size: " + content == null?"<null>":content.size() + ") for " + search_bbox); 369 365 } 370 366 /* … … 441 437 boolean hasContent() 442 438 { 443 if (content == null) 444 return false; 445 return true; 439 return content != null; 446 440 } 447 441 QBLevel nextSibling() … … 469 463 QBLevel ret = null; 470 464 for (QBLevel child : this.children) { 471 if (child == null) 465 if (child == null) { 472 466 continue; 467 } 473 468 ret = child; 474 469 break; … … 494 489 out("["+next.level+"] next node ("+next+") is a branch (content: "+next.hasContent()+"), moving down..."); 495 490 } 496 if (child == null) 491 if (child == null) { 497 492 abort("branch node had no children"); 493 } 498 494 next = child; 499 495 } … … 1105 1101 { 1106 1102 BBox bbox = new BBox(point.lon() - radius, point.lat() - radius, 1107 1103 point.lon() + radius, point.lat() + radius); 1108 1104 if (debug) { 1109 1105 out("search bbox before sanity: " + bbox); … … 1169 1165 search_cache = root; 1170 1166 } 1167 1168 // Save parent because search_cache might change during search call 1169 QBLevel tmp = search_cache.parent; 1170 1171 1171 ret = search_cache.search(search_bbox); 1172 1172 if (ret == null) { 1173 1173 ret = new ArrayList<T>(); 1174 1174 } 1175 1175 1176 // A way that spans this bucket may be stored in one 1176 1177 // of the nodes which is a parent of the search cache 1177 QBLevel tmp = search_cache.parent;1178 1178 while (tmp != null) { 1179 1179 List<T> content_result = tmp.search_contents(search_bbox); … … 1188 1188 return ret; 1189 1189 } 1190 1191 public void printTree() { 1192 printTreeRecursive(root, 0); 1193 } 1194 1195 private void printTreeRecursive(QBLevel level, int indent) { 1196 if (level == null) { 1197 printIndented(indent, "<empty child>"); 1198 return; 1199 } 1200 printIndented(indent, level); 1201 if (level.hasContent()) { 1202 for (T o:level.content) { 1203 printIndented(indent, o); 1204 } 1205 } 1206 if (level.children != null) { 1207 for (QBLevel child:level.children) { 1208 printTreeRecursive(child, indent + 2); 1209 } 1210 } 1211 } 1212 1213 private void printIndented(int indent, Object msg) { 1214 for (int i=0; i<indent; i++) { 1215 System.out.print(' '); 1216 } 1217 System.out.println(msg); 1218 } 1190 1219 }
Note:
See TracChangeset
for help on using the changeset viewer.