Package org.ka2ddo.yaac.osm.rtree
Class RTreeNode
java.lang.Object
org.ka2ddo.yaac.osm.rtree.RTreeNode
This class represents one node in an R-tree, optimized for working with
YAAC-encoded OpenStreetMap
Way
s and Node
s.- Author:
- Andrew Pavlin, KA2DDO
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Test if this RTreeNode's bounding box contains the specified OSMNode
.boolean
Test if this RTreeNode's bounding box contains the specified OSMWay
.void
fitMBR
(NodeSizeFunction nsf) Recompute the minimum bounding box for this RTreeNode.int
Get the number of direct children (not further descendents) of this RTreeNode.int
Get the number of OSM elements in this RTreeNode.int
Get the maximum depth of descendents of this RTreeNode.int
Get the total number of RTreeNodes in this r-tree.long
Compute the total amount of overlap between sibling child nodes in the RTree.void
Insert a new OSMNode
into this RTreeNode.void
Insert a new OSMWay
into this RTreeNode.boolean
intersects
(int minLat, int maxLat, int minLon, int maxLon) Test if the specified bounding box intersects the minimum bounding box of this RTreeNode.boolean
Test if this RTreeNode contains too many elements which should be split into sub-nodes.search
(int minLat, int maxLat, int minLon, int maxLon, NodeSizeFunction nsf) Search this RTreeNode hierarchy for all OSM elements that match the specified bounding box.void
split
(boolean min90PctFit, NodeSizeFunction nsf) Split all the elements of this node into subnodes for minimized overlap between the subnodes.toString()
Returns a string representation of the object.
-
Constructor Details
-
RTreeNode
public RTreeNode()Create a top-level (root) RTreeNode.
-
-
Method Details
-
contains
Test if this RTreeNode's bounding box contains the specified OSMNode
.- Parameters:
node
-Node
to test- Returns:
- boolean true if Node is contained inside this RtreeNode's bounds
-
insertGTN
Insert a new OSMNode
into this RTreeNode. Typically used to preload a root node prior to splitting into an r-tree hierarchy.- Parameters:
node
- OSMNode
to add to this RTreeNode's elements
-
contains
Test if this RTreeNode's bounding box contains the specified OSMWay
.- Parameters:
way
-Way
to test- Returns:
- boolean true if Way is contained inside this RtreeNode's bounds
-
insertGTN
Insert a new OSMWay
into this RTreeNode. Typically used to preload a root node prior to splitting into an r-tree hierarchy.- Parameters:
way
- OSMWay
to add to this RTreeNode's elements
-
isOverfull
public boolean isOverfull()Test if this RTreeNode contains too many elements which should be split into sub-nodes.- Returns:
- boolean true if element count >
maxCapacity
-
fitMBR
Recompute the minimum bounding box for this RTreeNode.- Parameters:
nsf
- NodeSizeFunction to determine the radius of Node objects
-
intersects
public boolean intersects(int minLat, int maxLat, int minLon, int maxLon) Test if the specified bounding box intersects the minimum bounding box of this RTreeNode.- Parameters:
minLat
- int minimum latitude in millionths of degrees NorthmaxLat
- int maximum latitude in millionths of degrees NorthminLon
- int minimum longitude in millionths of degrees EastmaxLon
- int maximum longitude in millionths of degrees East- Returns:
- boolean true if bounding boxes intersect (including one entirely containing the other)
-
split
Split all the elements of this node into subnodes for minimized overlap between the subnodes. This should not be called unlesselements
.size() >maxCapacity
.- Parameters:
min90PctFit
- boolean true if element should not be moved to a child RTreeNode if element is larger than cellnsf
- NodeSizeFunction to calculate bounding box of aNode
-
search
public List<GenericTaggedNode<?>> search(int minLat, int maxLat, int minLon, int maxLon, NodeSizeFunction nsf) Search this RTreeNode hierarchy for all OSM elements that match the specified bounding box.- Parameters:
minLat
- int minimum latitude in millionths of degrees NorthmaxLat
- int maximum latitude in millionths of degrees NorthminLon
- int minimum longitude in millionths of degrees EastmaxLon
- int maximum longitude in millionths of degrees Eastnsf
- NodeSizeFunction to calculate bounding box of OSMNode
s- Returns:
- List of GenericTaggedNode (OSM) elements overlapping the specified bounding box
-
toString
Returns a string representation of the object. -
getElementCount
public int getElementCount()Get the number of OSM elements in this RTreeNode. This does not recurse into child nodes.- Returns:
- count of
GenericTaggedNode
elements stored in this RTreeNode
-
getChildRTreeNodeCount
public int getChildRTreeNodeCount()Get the number of direct children (not further descendents) of this RTreeNode.- Returns:
- int child count
-
getMaxDepth
public int getMaxDepth()Get the maximum depth of descendents of this RTreeNode.- Returns:
- largest quantity of linear descendent RTreeNodes on any branch
-
getTotalOverlap
public long getTotalOverlap()Compute the total amount of overlap between sibling child nodes in the RTree.- Returns:
- total overlap in millionths of a degree squared
-
getNodeCount
public int getNodeCount()Get the total number of RTreeNodes in this r-tree.- Returns:
- count of RTreeNodes in the tree
-