| 1 | package uk.me.parabola.util; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.HashSet; |
| 5 | import java.util.LinkedHashSet; |
| 6 | import java.util.Set; |
| 7 | |
| 8 | import uk.me.parabola.imgfmt.app.Area; |
| 9 | import uk.me.parabola.mkgmap.reader.osm.Element; |
| 10 | |
| 11 | public class ElementQuadTree { |
| 12 | |
| 13 | private final ElementQuadTreeNode root; |
| 14 | |
| 15 | public ElementQuadTree(Area bbox, Collection<Element> elements) { |
| 16 | this.root = new ElementQuadTreeNode(bbox, elements); |
| 17 | } |
| 18 | |
| 19 | public Set<Element> get(Area bbox) { |
| 20 | HashSet<Element> res = new LinkedHashSet<>(); |
| 21 | root.get(bbox, res); |
| 22 | return res; |
| 23 | } |
| 24 | |
| 25 | public int getDepth() { |
| 26 | return root.getDepth(); |
| 27 | } |
| 28 | |
| 29 | public boolean isEmpty() { |
| 30 | return root.isEmpty(); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | public void clear() { |
| 35 | root.clear(); |
| 36 | } |
| 37 | } |