RTree<T> class
R-tree spatial index for efficient geofence proximity queries.
Supports O(log n) circle and bounding-box queries, enabling 10,000+ geofences with sub-millisecond lookup times.
Uses a classic R-tree with configurable branching factor maxEntries. On each location update, call queryCircle to find geofences within the proximity radius instead of iterating all geofences.
final tree = RTree<String>(maxEntries: 8);
tree.insert(37.7749, -122.4194, 200, 'home');
tree.insert(40.7128, -74.0060, 500, 'office');
final nearby = tree.queryCircle(37.7750, -122.4190, 1000);
print(nearby); // ['home']
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the tree is empty.
no setter
- maxEntries → int
-
Maximum entries per node before splitting.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Number of entries in the tree.
no setter
Methods
-
clear(
) → void - Clear all entries.
-
insert(
double lat, double lng, double radius, T data) → void - Insert a geofence into the tree.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
queryBBox(
double minLat, double minLng, double maxLat, double maxLng) → List< T> - Find all entries whose bounding boxes intersect the given bbox.
-
queryCircle(
double lat, double lng, double radiusMeters) → List< T> -
Find all entries within
radiusMetersof (lat,lng). -
remove(
T data) → bool -
Remove the first entry matching
data(by identity/equality). -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited