From 2c411bffcb21d771e352d90db24c1d4fd32638e8 Mon Sep 17 00:00:00 2001 From: GuillaumeGANGLOFF <148479543+GuillaumeGANGLOFF@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:59:04 +0200 Subject: [PATCH] add coord gps in result --- common/src/google/nearly_place_model.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/src/google/nearly_place_model.rs b/common/src/google/nearly_place_model.rs index 8782e09..3456665 100644 --- a/common/src/google/nearly_place_model.rs +++ b/common/src/google/nearly_place_model.rs @@ -75,15 +75,19 @@ pub struct Emplacement { rating: f64, address: String, picture: String, + lat: f64, + long: f64, } impl Emplacement { - fn new(name: String, rating: f64, address: String, picture: String) -> Self { + fn new(name: String, rating: f64, address: String, picture: String, lat: f64, long: f64) -> Self { Self { name, rating, address, picture, + lat, + long } } } @@ -105,8 +109,9 @@ pub fn exploit_json(value: Value) -> Result, anyhow::Error> { }; let rating = place.rating.unwrap_or_else(|| 0.0); - - let place = Emplacement::new(place.name, rating, place.vicinity, picture); + let lat = place.geometry.location.lat; + let long = place.geometry.location.lng; + let place = Emplacement::new(place.name, rating, place.vicinity, picture, lat, long); place_list.push(place); } Ok(place_list)