| | 215 | /* |
| | 216 | * This is a quick hack. The problem is that we need the |
| | 217 | * way's bounding box a *bunch* of times when it gets |
| | 218 | * inserted. It gets expensive if we have to recreate |
| | 219 | * them each time. |
| | 220 | * |
| | 221 | * An alternative would be to calculate it at .add() time |
| | 222 | * and passing it down the call chain. |
| | 223 | */ |
| | 224 | HashMap<Way,BBox> way_bbox_cache = new HashMap<Way, BBox>(); |
| | 225 | BBox way_bbox(Way w) |
| | 226 | { |
| | 227 | if (way_bbox_cache.size() > 100) |
| | 228 | way_bbox_cache.clear(); |
| | 229 | BBox b = way_bbox_cache.get(w); |
| | 230 | if (b == null) { |
| | 231 | b = new BBox(w); |
| | 232 | way_bbox_cache.put(w, b); |
| | 233 | } |
| | 234 | return b; |
| | 235 | //return new BBox(w); |
| | 236 | } |
| | 237 | |
| 372 | | /* |
| 373 | | * This is a quick hack. The problem is that we need the |
| 374 | | * way's bounding box a *bunch* of times when it gets |
| 375 | | * inserted. It gets expensive if we have to recreate |
| 376 | | * them each time. |
| 377 | | * |
| 378 | | * An alternative would be to calculate it at .add() time |
| 379 | | * and passing it down the call chain. |
| 380 | | */ |
| 381 | | HashMap<Way,BBox> way_bbox_cache = new HashMap<Way, BBox>(); |
| 382 | | BBox way_bbox(Way w) |
| 383 | | { |
| 384 | | if (way_bbox_cache.size() > 100) |
| 385 | | way_bbox_cache.clear(); |
| 386 | | BBox b = way_bbox_cache.get(w); |
| 387 | | if (b == null) { |
| 388 | | b = new BBox(w); |
| 389 | | way_bbox_cache.put(w, b); |
| 390 | | } |
| 391 | | return b; |
| 392 | | //return new BBox(w); |
| 393 | | } |
| 897 | | QBLevel bucket = root.find_exact(n); |
| | 890 | boolean ret = false; |
| | 891 | Iterator<T> i = this.iterator(); |
| | 892 | while (i.hasNext()) { |
| | 893 | T o = i.next(); |
| | 894 | if (o != removeme) |
| | 895 | continue; |
| | 896 | i.remove(); |
| | 897 | ret = true; |
| | 898 | break; |
| | 899 | } |
| | 900 | if (debug) |
| | 901 | out("qb slow remove result: " + ret); |
| | 902 | return ret; |
| | 903 | } |
| | 904 | public boolean remove(T o) |
| | 905 | { |
| | 906 | /* |
| | 907 | * We first try a locational search |
| | 908 | */ |
| | 909 | QBLevel bucket = root.find_exact(o); |
| | 910 | if (o instanceof Way) |
| | 911 | way_bbox_cache.remove(o); |
| | 912 | /* |
| | 913 | * That may fail because the object was |
| | 914 | * moved or changed in some way, so we |
| | 915 | * resort to an iterative search: |
| | 916 | */ |