mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
use geoutils instead of haversine
This commit is contained in:
parent
3fc145c254
commit
cfc62a1c15
@ -16,7 +16,7 @@ flate2 = "1.0.20"
|
|||||||
fst = "0.4.5"
|
fst = "0.4.5"
|
||||||
fxhash = "0.2.1"
|
fxhash = "0.2.1"
|
||||||
grenad = { version = "0.3.1", default-features = false, features = ["tempfile"] }
|
grenad = { version = "0.3.1", default-features = false, features = ["tempfile"] }
|
||||||
haversine = "0.2.1"
|
geoutils = "0.4.1"
|
||||||
heed = { git = "https://github.com/Kerollmops/heed", tag = "v0.12.1", default-features = false, features = ["lmdb", "sync-read-txn"] }
|
heed = { git = "https://github.com/Kerollmops/heed", tag = "v0.12.1", default-features = false, features = ["lmdb", "sync-read-txn"] }
|
||||||
human_format = "1.0.3"
|
human_format = "1.0.3"
|
||||||
levenshtein_automata = { version = "0.2.0", features = ["fst_automaton"] }
|
levenshtein_automata = { version = "0.2.0", features = ["fst_automaton"] }
|
||||||
|
@ -145,10 +145,10 @@ where
|
|||||||
/// Return the distance between two points in meters. Each points are composed of two f64,
|
/// Return the distance between two points in meters. Each points are composed of two f64,
|
||||||
/// one latitude and one longitude.
|
/// one latitude and one longitude.
|
||||||
pub fn distance_between_two_points(a: &[f64; 2], b: &[f64; 2]) -> f64 {
|
pub fn distance_between_two_points(a: &[f64; 2], b: &[f64; 2]) -> f64 {
|
||||||
let a = haversine::Location { latitude: a[0], longitude: a[1] };
|
let a = geoutils::Location::new(a[0], a[1]);
|
||||||
let b = haversine::Location { latitude: b[0], longitude: b[1] };
|
let b = geoutils::Location::new(b[0], b[1]);
|
||||||
|
|
||||||
haversine::distance(a, b, haversine::Units::Kilometers) * 1000.
|
a.haversine_distance_to(&b).meters()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user