mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 01:01:00 +00:00
store the geopoint in three dimensions
This commit is contained in:
@ -5,7 +5,7 @@ use rstar::RTree;
|
||||
|
||||
use super::{Criterion, CriterionParameters, CriterionResult};
|
||||
use crate::search::criteria::{resolve_query_tree, CriteriaBuilder};
|
||||
use crate::{GeoPoint, Index, Result};
|
||||
use crate::{lat_lng_to_xyz, GeoPoint, Index, Result};
|
||||
|
||||
pub struct Geo<'t> {
|
||||
index: &'t Index,
|
||||
@ -132,10 +132,12 @@ fn geo_point(
|
||||
point: [f64; 2],
|
||||
ascending: bool,
|
||||
) -> Box<dyn Iterator<Item = RoaringBitmap>> {
|
||||
let point = lat_lng_to_xyz(&point);
|
||||
|
||||
let mut results = Vec::new();
|
||||
for point in rtree.nearest_neighbor_iter(&point) {
|
||||
if candidates.remove(point.data) {
|
||||
results.push(std::iter::once(point.data).collect());
|
||||
if candidates.remove(point.data.0) {
|
||||
results.push(std::iter::once(point.data.0).collect());
|
||||
if candidates.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ use crate::error::{Error, UserError};
|
||||
use crate::heed_codec::facet::{
|
||||
FacetLevelValueF64Codec, FacetStringLevelZeroCodec, FacetStringLevelZeroValueCodec,
|
||||
};
|
||||
use crate::{distance_between_two_points, CboRoaringBitmapCodec, FieldId, Index, Result};
|
||||
use crate::{
|
||||
distance_between_two_points, lat_lng_to_xyz, CboRoaringBitmapCodec, FieldId, Index, Result,
|
||||
};
|
||||
|
||||
/// The maximum number of filters the filter AST can process.
|
||||
const MAX_FILTER_DEPTH: usize = 2000;
|
||||
@ -402,12 +404,14 @@ impl<'a> Filter<'a> {
|
||||
None => return Ok(RoaringBitmap::new()),
|
||||
};
|
||||
|
||||
let xyz_base_point = lat_lng_to_xyz(&base_point);
|
||||
|
||||
let result = rtree
|
||||
.nearest_neighbor_iter(&base_point)
|
||||
.nearest_neighbor_iter(&xyz_base_point)
|
||||
.take_while(|point| {
|
||||
distance_between_two_points(&base_point, point.geom()) < radius
|
||||
distance_between_two_points(&base_point, &point.data.1) < radius
|
||||
})
|
||||
.map(|point| point.data)
|
||||
.map(|point| point.data.0)
|
||||
.collect();
|
||||
|
||||
Ok(result)
|
||||
|
Reference in New Issue
Block a user