| Modifier and Type | Class and Description |
|---|---|
static class |
RTree.Builder
RTree Builder.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CHILDREN_DEFAULT_GUTTMAN
Benchmarks show that this is a good choice for up to O(10,000) entries
when using Quadratic splitter (Guttman).
|
static int |
MAX_CHILDREN_DEFAULT_STAR
Benchmarks show that this is the sweet spot for up to O(10,000) entries
when using R*-tree heuristics.
|
| Modifier and Type | Method and Description |
|---|---|
RTree<T,S> |
add(Entry<? extends T,? extends S> entry)
Returns an immutable copy of the RTree with the addition of given entry.
|
RTree<T,S> |
add(Iterable<Entry<T,S>> entries)
Returns an immutable RTree with the current entries and the additional
entries supplied as a parameter.
|
rx.Observable<RTree<T,S>> |
add(rx.Observable<Entry<T,S>> entries)
Returns the Observable sequence of trees created by progressively adding
entries.
|
RTree<T,S> |
add(T value,
S geometry)
Returns an immutable copy of the RTree with the addition of an entry
comprised of the given value and Geometry.
|
String |
asString()
Returns a human readable form of the RTree.
|
int |
calculateDepth()
The tree is scanned for depth and the depth returned.
|
Context<T,S> |
context()
Returns a
Context containing the configuration of the RTree at
the time of instantiation. |
static <T,S extends Geometry> |
create()
Returns a new Builder instance for
RTree. |
RTree<T,S> |
delete(Entry<? extends T,? extends S> entry)
Deletes one entry if it exists, returning an immutable copy of the RTree
without that entry.
|
RTree<T,S> |
delete(Entry<? extends T,? extends S> entry,
boolean all)
Deletes one or all matching entries depending on the value of
all. |
RTree<T,S> |
delete(Iterable<Entry<T,S>> entries)
Returns a new R-tree with the given entries deleted but only one matching
occurence of each entry is deleted.
|
RTree<T,S> |
delete(Iterable<Entry<T,S>> entries,
boolean all)
Returns a new R-tree with the given entries deleted.
|
rx.Observable<RTree<T,S>> |
delete(rx.Observable<Entry<T,S>> entries,
boolean all)
Returns the Observable sequence of trees created by progressively
deleting entries.
|
RTree<T,S> |
delete(T value,
S geometry)
Deletes maximum one entry matching the given value and geometry.
|
RTree<T,S> |
delete(T value,
S geometry,
boolean all)
If
all is false deletes one entry matching the given value
and Geometry. |
rx.Observable<Entry<T,S>> |
entries()
Returns all entries in the tree as an
Observable sequence. |
static rx.functions.Func1<Geometry,Boolean> |
intersects(Rectangle r)
Returns a predicate function that indicates if
Geometry
intersects with a given rectangle. |
boolean |
isEmpty()
Returns true if and only if the R-tree is empty of entries.
|
static RTree.Builder |
maxChildren(int maxChildren)
Sets the max number of children in an R-tree node.
|
com.github.davidmoten.guavamini.Optional<Rectangle> |
mbr()
If the RTree has no entries returns
Optional.absent() otherwise
returns the minimum bounding rectangle of all entries in the RTree. |
static RTree.Builder |
minChildren(int minChildren)
When the number of children in an R-tree node drops below this number the
node is deleted and the children are added on to the R-tree again.
|
rx.Observable<Entry<T,S>> |
nearest(Point p,
double maxDistance,
int maxCount)
Returns the nearest k entries (k=maxCount) to the given point where the
entries are strictly less than a given maximum distance from the point.
|
rx.Observable<Entry<T,S>> |
nearest(Rectangle r,
double maxDistance,
int maxCount)
Returns the nearest k entries (k=maxCount) to the given rectangle where
the entries are strictly less than a given maximum distance from the
rectangle.
|
com.github.davidmoten.guavamini.Optional<? extends Node<T,S>> |
root() |
rx.Observable<Entry<T,S>> |
search(Circle circle) |
rx.Observable<Entry<T,S>> |
search(Line line) |
rx.Observable<Entry<T,S>> |
search(Point p)
Returns an
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangle intersects with the given point. |
rx.Observable<Entry<T,S>> |
search(Point p,
double maxDistance)
Returns an
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangles are within maxDistance from the
given point. |
<R extends Geometry> |
search(R g,
double maxDistance,
rx.functions.Func2<? super S,? super R,Double> distance)
Returns all entries strictly less than
maxDistance from the
given geometry. |
rx.Observable<Entry<T,S>> |
search(Rectangle r)
Returns an
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangle intersects with the given
rectangle. |
rx.Observable<Entry<T,S>> |
search(Rectangle r,
double maxDistance)
Returns an
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangles are strictly less than
maxDistance from the given rectangle. |
<R extends Geometry> |
search(R g,
rx.functions.Func2<? super S,? super R,Boolean> intersects)
Returns the intersections with the the given (arbitrary) geometry using
an intersection function to filter the search results returned from a
search of the mbr of
g. |
static RTree.Builder |
selector(Selector selector)
Sets the node
Selector which decides which branches to follow
when inserting or searching. |
int |
size()
Returns the number of entries in the RTree.
|
static RTree.Builder |
splitter(Splitter splitter)
Sets the
Splitter to use when maxChildren is reached. |
static RTree.Builder |
star()
Sets the splitter to
SplitterRStar and selector to
SelectorRStar and defaults to minChildren=10. |
Visualizer |
visualize(int width,
int height)
Returns a
Visualizer for an image of given width and height and
restricted to the the smallest view that fully contains the coordinates. |
Visualizer |
visualize(int width,
int height,
Rectangle view)
Returns a
Visualizer for an image of given width and height and
restricted to the given view of the coordinates. |
public static final int MAX_CHILDREN_DEFAULT_GUTTMAN
public static final int MAX_CHILDREN_DEFAULT_STAR
public static <T,S extends Geometry> RTree<T,S> create()
RTree. Defaults to
maxChildren=128, minChildren=64, splitter=QuadraticSplitter.T - the value type of the entries in the treeS - the geometry type of the entries in the treepublic int calculateDepth()
log(n) in complexity.public static RTree.Builder minChildren(int minChildren)
minChildren - less than this number of children in a node triggers a node
deletion and redistribution of its memberspublic static RTree.Builder maxChildren(int maxChildren)
maxChildren - max number of children in an R-tree nodepublic static RTree.Builder splitter(Splitter splitter)
Splitter to use when maxChildren is reached.splitter - the splitter algorithm to usepublic static RTree.Builder selector(Selector selector)
Selector which decides which branches to follow
when inserting or searching.selector - determines which branches to follow when inserting or
searchingpublic static RTree.Builder star()
SplitterRStar and selector to
SelectorRStar and defaults to minChildren=10.public RTree<T,S> add(Entry<? extends T,? extends S> entry)
entry - item to add to the R-tree.public RTree<T,S> add(T value, S geometry)
public RTree<T,S> add(Iterable<Entry<T,S>> entries)
entries - entries to addpublic rx.Observable<RTree<T,S>> add(rx.Observable<Entry<T,S>> entries)
entries - the entries to addpublic rx.Observable<RTree<T,S>> delete(rx.Observable<Entry<T,S>> entries, boolean all)
entries - the entries to addall - if true delete all matching otherwise just first matchingpublic RTree<T,S> delete(Iterable<Entry<T,S>> entries, boolean all)
all
is false deletes only one if exists. If all is true deletes
all matching entries.entries - entries to deleteall - if false deletes one if exists else deletes allpublic RTree<T,S> delete(Iterable<Entry<T,S>> entries)
entries - entries to deletepublic RTree<T,S> delete(T value, S geometry, boolean all)
all is false deletes one entry matching the given value
and Geometry. If all is true deletes all entries matching
the given value and geometry. This method has no effect if the entry is
not present. The entry must match on both value and geometry to be
deleted.value - the value of the Entry to be deletedgeometry - the geometry of the Entry to be deletedall - if false deletes one if exists else deletes allpublic RTree<T,S> delete(T value, S geometry)
value - the value to be matched for deletiongeometry - the geometry to be matched for deletionpublic RTree<T,S> delete(Entry<? extends T,? extends S> entry, boolean all)
all. If multiple copies of the entry are in the R-tree only
one will be deleted if all is false otherwise all matching entries will
be deleted. The entry must match on both value and geometry to be
deleted.entry - the Entry to be deletedall - if true deletes all matches otherwise deletes first foundpublic RTree<T,S> delete(Entry<? extends T,? extends S> entry)
entry - the Entry to be deletedpublic static rx.functions.Func1<Geometry,Boolean> intersects(Rectangle r)
Geometry
intersects with a given rectangle.r - the rectangle to check intersection withpublic rx.Observable<Entry<T,S>> search(Rectangle r)
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangle intersects with the given
rectangle.r - rectangle to check intersection with the entry mbrpublic rx.Observable<Entry<T,S>> search(Point p)
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangle intersects with the given point.p - point to check intersection with the entry mbrpublic rx.Observable<Entry<T,S>> search(Rectangle r, double maxDistance)
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangles are strictly less than
maxDistance from the given rectangle.r - rectangle to measure distance frommaxDistance - entries returned must be within this distance from rectangle rpublic <R extends Geometry> rx.Observable<Entry<T,S>> search(R g, rx.functions.Func2<? super S,? super R,Boolean> intersects)
g.R - type of geometry being searched for intersection withg - geometry being searched for intersection withintersects - function to determine if the two geometries intersectpublic <R extends Geometry> rx.Observable<Entry<T,S>> search(R g, double maxDistance, rx.functions.Func2<? super S,? super R,Double> distance)
maxDistance from the
given geometry. Because the geometry may be of an arbitrary type it is
necessary to also pass a distance function.R - type of the geometry being searched forg - geometry to search for entries within maxDistance ofmaxDistance - strict max distance that entries must be from gdistance - function to calculate the distance between geometries of type
S and R.public rx.Observable<Entry<T,S>> search(Point p, double maxDistance)
Observable sequence of all Entrys in the
R-tree whose minimum bounding rectangles are within maxDistance from the
given point.p - point to measure distance frommaxDistance - entries returned must be within this distance from point ppublic rx.Observable<Entry<T,S>> nearest(Rectangle r, double maxDistance, int maxCount)
r - rectanglemaxDistance - max distance of returned entries from the rectanglemaxCount - max number of entries to returnpublic rx.Observable<Entry<T,S>> nearest(Point p, double maxDistance, int maxCount)
p - pointmaxDistance - max distance of returned entries from the pointmaxCount - max number of entries to returnpublic rx.Observable<Entry<T,S>> entries()
Observable sequence.public Visualizer visualize(int width, int height, Rectangle view)
Visualizer for an image of given width and height and
restricted to the given view of the coordinates. The points in the view
are scaled to match the aspect ratio defined by the width and height.width - of the image in pixelsheight - of the image in pixelsview - using the coordinate system of the entriespublic Visualizer visualize(int width, int height)
Visualizer for an image of given width and height and
restricted to the the smallest view that fully contains the coordinates.
The points in the view are scaled to match the aspect ratio defined by
the width and height.width - of the image in pixelsheight - of the image in pixelspublic com.github.davidmoten.guavamini.Optional<Rectangle> mbr()
Optional.absent() otherwise
returns the minimum bounding rectangle of all entries in the RTree.public boolean isEmpty()
public int size()
public Context<T,S> context()
Context containing the configuration of the RTree at
the time of instantiation.public String asString()
mbr=Rectangle [x1=10.0, y1=4.0, x2=62.0, y2=85.0]
mbr=Rectangle [x1=28.0, y1=4.0, x2=34.0, y2=85.0]
entry=Entry [value=2, geometry=Point [x=29.0, y=4.0]]
entry=Entry [value=1, geometry=Point [x=28.0, y=19.0]]
entry=Entry [value=4, geometry=Point [x=34.0, y=85.0]]
mbr=Rectangle [x1=10.0, y1=45.0, x2=62.0, y2=63.0]
entry=Entry [value=5, geometry=Point [x=62.0, y=45.0]]
entry=Entry [value=3, geometry=Point [x=10.0, y=63.0]]
Copyright © 2013–2016. All rights reserved.