use meters in the filters

This commit is contained in:
Tamo 2021-09-07 12:11:03 +02:00
parent 4f69b190bc
commit e5ef0cad9a
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
3 changed files with 17 additions and 5 deletions

View file

@ -504,17 +504,20 @@ impl FilterCondition {
LowerThan(val) => (Included(f64::MIN), Excluded(*val)),
LowerThanOrEqual(val) => (Included(f64::MIN), Included(*val)),
Between(left, right) => (Included(*left), Included(*right)),
GeoLowerThan(point, distance) => {
GeoLowerThan(base_point, distance) => {
let mut result = RoaringBitmap::new();
let rtree = match index.geo_rtree(rtxn)? {
Some(rtree) => rtree,
None => return Ok(result),
};
let iter = rtree
.nearest_neighbor_iter_with_distance_2(point)
.take_while(|(_, dist)| dist <= distance);
iter.for_each(|(point, _)| drop(result.insert(point.data)));
rtree
.nearest_neighbor_iter(base_point)
.take_while(|point| {
dbg!(crate::distance_between_two_points(base_point, point.geom()))
< *distance
})
.for_each(|point| drop(result.insert(point.data)));
return Ok(result);
}