From 6dff9c6037fcdbd7efbcae97d20bb997c8c37b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Tue, 10 Aug 2021 13:19:13 +0200 Subject: [PATCH 1/5] update dependencies, fix all clippy lints --- Cargo.toml | 14 ++++++++++---- src/geoadmin.rs | 28 +++++++++++++++------------- src/lib.rs | 12 ++++++------ src/opencage.rs | 39 ++++++++++++++++++++------------------- src/openstreetmap.rs | 24 +++++++++++++----------- 5 files changed, 64 insertions(+), 53 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 21f5b10..550f1e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,10 @@ name = "geocoding" description = "Geocoding library for Rust" version = "0.3.1" -authors = ["Stephan Hügel ", "Blake Grotewold "] +authors = [ + "Stephan Hügel ", + "Blake Grotewold ", +] license = "MIT OR Apache-2.0" repository = "https://github.com/georust/geocoding" keywords = ["gecoding", "geo", "gis", "geospatial"] @@ -11,12 +14,15 @@ edition = "2018" [dependencies] thiserror = "1.0" -geo-types = "0.6" +geo-types = "0.7" num-traits = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -reqwest = { version = "0.10", default-features = false, features = ["blocking", "json"] } -hyper = "0.13.6" +reqwest = { version = "0.11", default-features = false, features = [ + "blocking", + "json", +] } +hyper = "0.14" chrono = { version = "0.4", features = ["serde"] } [features] diff --git a/src/geoadmin.rs b/src/geoadmin.rs index 7f0a78c..da667eb 100644 --- a/src/geoadmin.rs +++ b/src/geoadmin.rs @@ -15,6 +15,8 @@ //! let res = geoadmin.forward(&address); //! assert_eq!(res.unwrap(), vec![Point::new(7.451352119445801, 46.92793655395508)]); //! ``` +use std::fmt::Debug; + use crate::Deserialize; use crate::GeocodingError; use crate::InputBounds; @@ -34,7 +36,7 @@ pub struct GeoAdmin { /// An instance of a parameter builder for GeoAdmin geocoding pub struct GeoAdminParams<'a, T> where - T: Float, + T: Float + Debug, { searchtext: &'a str, origins: &'a str, @@ -44,7 +46,7 @@ where impl<'a, T> GeoAdminParams<'a, T> where - T: Float, + T: Float + Debug, { /// Create a new GeoAdmin parameter builder /// # Example: @@ -159,7 +161,7 @@ impl GeoAdmin { params: &GeoAdminParams, ) -> Result, GeocodingError> where - T: Float, + T: Float + Debug, for<'de> T: Deserialize<'de>, { // For lifetime issues @@ -219,7 +221,7 @@ impl Default for GeoAdmin { impl Forward for GeoAdmin where - T: Float, + T: Float + Debug, for<'de> T: Deserialize<'de>, { /// A forward-geocoding lookup of an address. Please see [the documentation](https://api3.geo.admin.ch/services/sdiservices.html#search) for details. @@ -258,7 +260,7 @@ where impl Reverse for GeoAdmin where - T: Float, + T: Float + Debug, for<'de> T: Deserialize<'de>, { /// A reverse lookup of a point. More detail on the format of the @@ -309,7 +311,7 @@ where // See [the documentation](https://www.swisstopo.admin.ch/content/swisstopo-internet/en/online/calculation-services/_jcr_content/contentPar/tabs/items/documents_publicatio/tabPar/downloadlist/downloadItems/19_1467104393233.download/ch1903wgs84_e.pdf) for more details fn wgs84_to_lv03(p: &Point) -> Point where - T: Float, + T: Float + Debug, { let lambda = (p.x().to_f64().unwrap() * 3600.0 - 26782.5) / 10000.0; let phi = (p.y().to_f64().unwrap() * 3600.0 - 169028.66) / 10000.0; @@ -356,7 +358,7 @@ where #[derive(Debug, Deserialize)] pub struct GeoAdminForwardResponse where - T: Float, + T: Float + Debug, { pub features: Vec>, } @@ -365,7 +367,7 @@ where #[derive(Debug, Deserialize)] pub struct GeoAdminForwardLocation where - T: Float, + T: Float + Debug, { id: Option, pub properties: ForwardLocationProperties, @@ -454,7 +456,7 @@ mod test { fn new_with_sr_forward_test() { let geoadmin = GeoAdmin::new().with_sr("2056"); let address = "Seftigenstrasse 264, 3084 Wabern"; - let res = geoadmin.forward(&address); + let res = geoadmin.forward(address); assert_eq!(res.unwrap(), vec![Point::new(2_600_968.75, 1_197_427.0)]); } @@ -463,7 +465,7 @@ mod test { let geoadmin = GeoAdmin::new().with_endpoint("https://api3.geo.admin.ch/rest/services/api/"); let address = "Seftigenstrasse 264, 3084 Wabern"; - let res = geoadmin.forward(&address); + let res = geoadmin.forward(address); assert_eq!( res.unwrap(), vec![Point::new(7.451352119445801, 46.92793655395508)] @@ -474,7 +476,7 @@ mod test { fn with_sr_forward_full_test() { let geoadmin = GeoAdmin::new().with_sr("2056"); let bbox = InputBounds::new((2_600_967.75, 1_197_426.0), (2_600_969.75, 1_197_428.0)); - let params = GeoAdminParams::new(&"Seftigenstrasse Bern") + let params = GeoAdminParams::new("Seftigenstrasse Bern") .with_origins("address") .with_bbox(&bbox) .build(); @@ -490,7 +492,7 @@ mod test { fn forward_full_test() { let geoadmin = GeoAdmin::new(); let bbox = InputBounds::new((7.4513398, 46.92792859), (7.4513662, 46.9279467)); - let params = GeoAdminParams::new(&"Seftigenstrasse Bern") + let params = GeoAdminParams::new("Seftigenstrasse Bern") .with_origins("address") .with_bbox(&bbox) .build(); @@ -506,7 +508,7 @@ mod test { fn forward_test() { let geoadmin = GeoAdmin::new(); let address = "Seftigenstrasse 264, 3084 Wabern"; - let res = geoadmin.forward(&address); + let res = geoadmin.forward(address); assert_eq!( res.unwrap(), vec![Point::new(7.451352119445801, 46.92793655395508)] diff --git a/src/lib.rs b/src/lib.rs index f953c85..4279819 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,7 +27,6 @@ static UA_STRING: &str = "Rust-Geocoding"; -use chrono; pub use geo_types::{Coordinate, Point}; use num_traits::Float; use reqwest::blocking::Client; @@ -35,6 +34,7 @@ use reqwest::header::ToStrError; use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; +use std::fmt::Debug; use std::num::ParseIntError; use thiserror::Error; @@ -85,7 +85,7 @@ pub enum GeocodingError { /// ``` pub trait Reverse where - T: Float, + T: Float + Debug, { // NOTE TO IMPLEMENTERS: Point coordinates are lon, lat (x, y) // You may have to provide these coordinates in reverse order, @@ -113,7 +113,7 @@ where /// ``` pub trait Forward where - T: Float, + T: Float + Debug, { // NOTE TO IMPLEMENTERS: while returned provider point data may not be in // lon, lat (x, y) order, Geocoding requires this order in its output Point @@ -128,7 +128,7 @@ where #[derive(Copy, Clone, Debug)] pub struct InputBounds where - T: Float, + T: Float + Debug, { pub minimum_lonlat: Point, pub maximum_lonlat: Point, @@ -136,7 +136,7 @@ where impl InputBounds where - T: Float, + T: Float + Debug, { /// Create a new `InputBounds` struct by passing 2 `Point`s defining: /// - minimum (bottom-left) longitude and latitude coordinates @@ -155,7 +155,7 @@ where /// Convert borrowed input bounds into the correct String representation impl From> for String where - T: Float, + T: Float + Debug, { fn from(ip: InputBounds) -> String { // Return in lon, lat order diff --git a/src/opencage.rs b/src/opencage.rs index b9a5bc7..5ea9dbc 100644 --- a/src/opencage.rs +++ b/src/opencage.rs @@ -24,8 +24,6 @@ //! // "Carrer de Calatrava, 68, 08017 Barcelone, Espagne" //! println!("{:?}", res.unwrap()); //! ``` -use crate::chrono::naive::serde::ts_seconds::deserialize as from_ts; -use crate::chrono::NaiveDateTime; use crate::DeserializeOwned; use crate::GeocodingError; use crate::InputBounds; @@ -34,9 +32,12 @@ use crate::UA_STRING; use crate::{Client, HeaderMap, HeaderValue, USER_AGENT}; use crate::{Deserialize, Serialize}; use crate::{Forward, Reverse}; +use chrono::naive::serde::ts_seconds::deserialize as from_ts; +use chrono::NaiveDateTime; use num_traits::Float; use serde::Deserializer; use std::collections::HashMap; +use std::fmt::Debug; use std::sync::{Arc, Mutex}; macro_rules! add_optional_param { @@ -146,7 +147,7 @@ impl<'a> Opencage<'a> { ///``` pub fn reverse_full(&self, point: &Point) -> Result, GeocodingError> where - T: Float + DeserializeOwned, + T: Float + DeserializeOwned + Debug, { let q = format!( "{}, {}", @@ -156,9 +157,9 @@ impl<'a> Opencage<'a> { ); let mut query = vec![ ("q", q.as_str()), - (&"key", &self.api_key), - (&"no_annotations", "0"), - (&"no_record", "1"), + ("key", &self.api_key), + ("no_annotations", "0"), + ("no_record", "1"), ]; query.extend(self.parameters.as_query()); @@ -248,7 +249,7 @@ impl<'a> Opencage<'a> { bounds: U, ) -> Result, GeocodingError> where - T: Float + DeserializeOwned, + T: Float + DeserializeOwned + Debug, U: Into>>, { let ann = String::from("0"); @@ -291,7 +292,7 @@ impl<'a> Opencage<'a> { impl<'a, T> Reverse for Opencage<'a> where - T: Float + DeserializeOwned, + T: Float + DeserializeOwned + Debug, { /// A reverse lookup of a point. More detail on the format of the /// returned `String` can be found [here](https://blog.opencagedata.com/post/99059889253/good-looking-addresses-solving-the-berlin-berlin) @@ -336,7 +337,7 @@ where impl<'a, T> Forward for Opencage<'a> where - T: Float + DeserializeOwned, + T: Float + DeserializeOwned + Debug, { /// A forward-geocoding lookup of an address. Please see [the documentation](https://opencagedata.com/api#ambiguous-results) for details /// of best practices in order to obtain good-quality results. @@ -511,7 +512,7 @@ where #[derive(Debug, Serialize, Deserialize)] pub struct OpencageResponse where - T: Float, + T: Float + Debug, { pub documentation: String, pub licenses: Vec>, @@ -528,7 +529,7 @@ where #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Results where - T: Float, + T: Float + Debug, { pub annotations: Option>, pub bounds: Option>, @@ -542,7 +543,7 @@ where #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Annotations where - T: Float, + T: Float + Debug, { pub dms: Option>, pub mgrs: Option, @@ -615,7 +616,7 @@ pub struct Timestamp { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Bounds where - T: Float, + T: Float + Debug, { pub northeast: HashMap, pub southwest: HashMap, @@ -652,7 +653,7 @@ mod test { fn forward_test() { let oc = Opencage::new("dcdbf0d783374909b3debee728c7cc10".to_string()); let address = "Schwabing, München"; - let res = oc.forward(&address); + let res = oc.forward(address); assert_eq!( res.unwrap(), vec![Point(Coordinate { @@ -678,7 +679,7 @@ mod test { minimum_lonlat: Point::new(-0.13806939125061035, 51.51989264641164), maximum_lonlat: Point::new(-0.13427138328552246, 51.52319711775629), }; - let res = oc.forward_full(&address, bbox).unwrap(); + let res = oc.forward_full(address, bbox).unwrap(); let first_result = &res.results[0]; assert_eq!( first_result.formatted, @@ -693,7 +694,7 @@ mod test { Point::new(-0.13806939125061035, 51.51989264641164), Point::new(-0.13427138328552246, 51.52319711775629), ); - let res = oc.forward_full(&address, bbox).unwrap(); + let res = oc.forward_full(address, bbox).unwrap(); let first_result = &res.results[0]; assert_eq!( first_result.formatted, @@ -708,7 +709,7 @@ mod test { Point::from((-0.13806939125061035, 51.51989264641164)), Point::from((-0.13427138328552246, 51.52319711775629)), ); - let res = oc.forward_full(&address, bbox).unwrap(); + let res = oc.forward_full(address, bbox).unwrap(); let first_result = &res.results[0]; assert_eq!( first_result.formatted, @@ -723,7 +724,7 @@ mod test { (-0.13806939125061035, 51.51989264641164), (-0.13427138328552246, 51.52319711775629), ); - let res = oc.forward_full(&address, bbox).unwrap(); + let res = oc.forward_full(address, bbox).unwrap(); let first_result = &res.results[0]; assert_eq!( first_result.formatted, @@ -734,7 +735,7 @@ mod test { fn forward_full_test_nobox() { let oc = Opencage::new("dcdbf0d783374909b3debee728c7cc10".to_string()); let address = "Moabit, Berlin, Germany"; - let res = oc.forward_full(&address, NOBOX).unwrap(); + let res = oc.forward_full(address, NOBOX).unwrap(); let first_result = &res.results[0]; assert_eq!(first_result.formatted, "Moabit, Berlin, Germany"); } diff --git a/src/openstreetmap.rs b/src/openstreetmap.rs index b223809..d4cdc11 100644 --- a/src/openstreetmap.rs +++ b/src/openstreetmap.rs @@ -16,6 +16,8 @@ //! let res = osm.forward(&address); //! assert_eq!(res.unwrap(), vec![Point::new(11.5884858, 48.1700887)]); //! ``` +use std::fmt::Debug; + use crate::GeocodingError; use crate::InputBounds; use crate::Point; @@ -34,7 +36,7 @@ pub struct Openstreetmap { /// An instance of a parameter builder for Openstreetmap geocoding pub struct OpenstreetmapParams<'a, T> where - T: Float, + T: Float + Debug, { query: &'a str, addressdetails: bool, @@ -43,7 +45,7 @@ where impl<'a, T> OpenstreetmapParams<'a, T> where - T: Float, + T: Float + Debug, { /// Create a new OpenStreetMap parameter builder /// # Example: @@ -144,7 +146,7 @@ impl Openstreetmap { params: &OpenstreetmapParams, ) -> Result, GeocodingError> where - T: Float, + T: Float + Debug, for<'de> T: Deserialize<'de>, { let format = String::from("geojson"); @@ -182,7 +184,7 @@ impl Default for Openstreetmap { impl Forward for Openstreetmap where - T: Float, + T: Float + Debug, for<'de> T: Deserialize<'de>, { /// A forward-geocoding lookup of an address. Please see [the documentation](https://nominatim.org/release-docs/develop/api/Search/) for details. @@ -206,7 +208,7 @@ where impl Reverse for Openstreetmap where - T: Float, + T: Float + Debug, for<'de> T: Deserialize<'de>, { /// A reverse lookup of a point. More detail on the format of the @@ -283,7 +285,7 @@ where #[derive(Debug, Serialize, Deserialize)] pub struct OpenstreetmapResponse where - T: Float, + T: Float + Debug, { pub r#type: String, pub licence: String, @@ -294,7 +296,7 @@ where #[derive(Debug, Serialize, Deserialize)] pub struct OpenstreetmapResult where - T: Float, + T: Float + Debug, { pub r#type: String, pub properties: ResultProperties, @@ -337,7 +339,7 @@ pub struct AddressDetails { #[derive(Debug, Serialize, Deserialize)] pub struct ResultGeometry where - T: Float, + T: Float + Debug, { pub r#type: String, pub coordinates: (T, T), @@ -352,7 +354,7 @@ mod test { let osm = Openstreetmap::new_with_endpoint("https://nominatim.openstreetmap.org/".to_string()); let address = "Schwabing, München"; - let res = osm.forward(&address); + let res = osm.forward(address); assert_eq!(res.unwrap(), vec![Point::new(11.5884858, 48.1700887)]); } @@ -363,7 +365,7 @@ mod test { (-0.13806939125061035, 51.51989264641164), (-0.13427138328552246, 51.52319711775629), ); - let params = OpenstreetmapParams::new(&"UCL CASA") + let params = OpenstreetmapParams::new("UCL CASA") .with_addressdetails(true) .with_viewbox(&viewbox) .build(); @@ -379,7 +381,7 @@ mod test { fn forward_test() { let osm = Openstreetmap::new(); let address = "Schwabing, München"; - let res = osm.forward(&address); + let res = osm.forward(address); assert_eq!(res.unwrap(), vec![Point::new(11.5884858, 48.1700887)]); } From 1db0b13524d6dd1d98eb60dd8c0a3de5360bf5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Thu, 12 Aug 2021 10:43:27 +0200 Subject: [PATCH 2/5] use CoordFloat --- src/geoadmin.rs | 19 ++++++++++--------- src/lib.rs | 12 ++++++------ src/opencage.rs | 18 +++++++++--------- src/openstreetmap.rs | 18 +++++++++--------- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/geoadmin.rs b/src/geoadmin.rs index da667eb..91dc212 100644 --- a/src/geoadmin.rs +++ b/src/geoadmin.rs @@ -24,7 +24,8 @@ use crate::Point; use crate::UA_STRING; use crate::{Client, HeaderMap, HeaderValue, USER_AGENT}; use crate::{Forward, Reverse}; -use num_traits::{Float, Pow}; +use geo_types::CoordFloat; +use num_traits::Pow; /// An instance of the GeoAdmin geocoding service pub struct GeoAdmin { @@ -36,7 +37,7 @@ pub struct GeoAdmin { /// An instance of a parameter builder for GeoAdmin geocoding pub struct GeoAdminParams<'a, T> where - T: Float + Debug, + T: CoordFloat, { searchtext: &'a str, origins: &'a str, @@ -46,7 +47,7 @@ where impl<'a, T> GeoAdminParams<'a, T> where - T: Float + Debug, + T: CoordFloat, { /// Create a new GeoAdmin parameter builder /// # Example: @@ -161,7 +162,7 @@ impl GeoAdmin { params: &GeoAdminParams, ) -> Result, GeocodingError> where - T: Float + Debug, + T: CoordFloat, for<'de> T: Deserialize<'de>, { // For lifetime issues @@ -221,7 +222,7 @@ impl Default for GeoAdmin { impl Forward for GeoAdmin where - T: Float + Debug, + T: CoordFloat, for<'de> T: Deserialize<'de>, { /// A forward-geocoding lookup of an address. Please see [the documentation](https://api3.geo.admin.ch/services/sdiservices.html#search) for details. @@ -260,7 +261,7 @@ where impl Reverse for GeoAdmin where - T: Float + Debug, + T: CoordFloat, for<'de> T: Deserialize<'de>, { /// A reverse lookup of a point. More detail on the format of the @@ -311,7 +312,7 @@ where // See [the documentation](https://www.swisstopo.admin.ch/content/swisstopo-internet/en/online/calculation-services/_jcr_content/contentPar/tabs/items/documents_publicatio/tabPar/downloadlist/downloadItems/19_1467104393233.download/ch1903wgs84_e.pdf) for more details fn wgs84_to_lv03(p: &Point) -> Point where - T: Float + Debug, + T: CoordFloat, { let lambda = (p.x().to_f64().unwrap() * 3600.0 - 26782.5) / 10000.0; let phi = (p.y().to_f64().unwrap() * 3600.0 - 169028.66) / 10000.0; @@ -358,7 +359,7 @@ where #[derive(Debug, Deserialize)] pub struct GeoAdminForwardResponse where - T: Float + Debug, + T: CoordFloat, { pub features: Vec>, } @@ -367,7 +368,7 @@ where #[derive(Debug, Deserialize)] pub struct GeoAdminForwardLocation where - T: Float + Debug, + T: CoordFloat, { id: Option, pub properties: ForwardLocationProperties, diff --git a/src/lib.rs b/src/lib.rs index 4279819..3c18559 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,8 @@ static UA_STRING: &str = "Rust-Geocoding"; +use geo_types::CoordFloat; pub use geo_types::{Coordinate, Point}; -use num_traits::Float; use reqwest::blocking::Client; use reqwest::header::ToStrError; use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT}; @@ -85,7 +85,7 @@ pub enum GeocodingError { /// ``` pub trait Reverse where - T: Float + Debug, + T: CoordFloat, { // NOTE TO IMPLEMENTERS: Point coordinates are lon, lat (x, y) // You may have to provide these coordinates in reverse order, @@ -113,7 +113,7 @@ where /// ``` pub trait Forward where - T: Float + Debug, + T: CoordFloat, { // NOTE TO IMPLEMENTERS: while returned provider point data may not be in // lon, lat (x, y) order, Geocoding requires this order in its output Point @@ -128,7 +128,7 @@ where #[derive(Copy, Clone, Debug)] pub struct InputBounds where - T: Float + Debug, + T: CoordFloat, { pub minimum_lonlat: Point, pub maximum_lonlat: Point, @@ -136,7 +136,7 @@ where impl InputBounds where - T: Float + Debug, + T: CoordFloat, { /// Create a new `InputBounds` struct by passing 2 `Point`s defining: /// - minimum (bottom-left) longitude and latitude coordinates @@ -155,7 +155,7 @@ where /// Convert borrowed input bounds into the correct String representation impl From> for String where - T: Float + Debug, + T: CoordFloat, { fn from(ip: InputBounds) -> String { // Return in lon, lat order diff --git a/src/opencage.rs b/src/opencage.rs index 5ea9dbc..e2c6804 100644 --- a/src/opencage.rs +++ b/src/opencage.rs @@ -34,7 +34,7 @@ use crate::{Deserialize, Serialize}; use crate::{Forward, Reverse}; use chrono::naive::serde::ts_seconds::deserialize as from_ts; use chrono::NaiveDateTime; -use num_traits::Float; +use geo_types::CoordFloat; use serde::Deserializer; use std::collections::HashMap; use std::fmt::Debug; @@ -147,7 +147,7 @@ impl<'a> Opencage<'a> { ///``` pub fn reverse_full(&self, point: &Point) -> Result, GeocodingError> where - T: Float + DeserializeOwned + Debug, + T: CoordFloat + DeserializeOwned, { let q = format!( "{}, {}", @@ -249,7 +249,7 @@ impl<'a> Opencage<'a> { bounds: U, ) -> Result, GeocodingError> where - T: Float + DeserializeOwned + Debug, + T: CoordFloat + DeserializeOwned, U: Into>>, { let ann = String::from("0"); @@ -292,7 +292,7 @@ impl<'a> Opencage<'a> { impl<'a, T> Reverse for Opencage<'a> where - T: Float + DeserializeOwned + Debug, + T: CoordFloat + DeserializeOwned, { /// A reverse lookup of a point. More detail on the format of the /// returned `String` can be found [here](https://blog.opencagedata.com/post/99059889253/good-looking-addresses-solving-the-berlin-berlin) @@ -337,7 +337,7 @@ where impl<'a, T> Forward for Opencage<'a> where - T: Float + DeserializeOwned + Debug, + T: CoordFloat + DeserializeOwned, { /// A forward-geocoding lookup of an address. Please see [the documentation](https://opencagedata.com/api#ambiguous-results) for details /// of best practices in order to obtain good-quality results. @@ -512,7 +512,7 @@ where #[derive(Debug, Serialize, Deserialize)] pub struct OpencageResponse where - T: Float + Debug, + T: CoordFloat, { pub documentation: String, pub licenses: Vec>, @@ -529,7 +529,7 @@ where #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Results where - T: Float + Debug, + T: CoordFloat, { pub annotations: Option>, pub bounds: Option>, @@ -543,7 +543,7 @@ where #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Annotations where - T: Float + Debug, + T: CoordFloat, { pub dms: Option>, pub mgrs: Option, @@ -616,7 +616,7 @@ pub struct Timestamp { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Bounds where - T: Float + Debug, + T: CoordFloat, { pub northeast: HashMap, pub southwest: HashMap, diff --git a/src/openstreetmap.rs b/src/openstreetmap.rs index d4cdc11..610dfc0 100644 --- a/src/openstreetmap.rs +++ b/src/openstreetmap.rs @@ -25,7 +25,7 @@ use crate::UA_STRING; use crate::{Client, HeaderMap, HeaderValue, USER_AGENT}; use crate::{Deserialize, Serialize}; use crate::{Forward, Reverse}; -use num_traits::Float; +use geo_types::CoordFloat; /// An instance of the Openstreetmap geocoding service pub struct Openstreetmap { @@ -36,7 +36,7 @@ pub struct Openstreetmap { /// An instance of a parameter builder for Openstreetmap geocoding pub struct OpenstreetmapParams<'a, T> where - T: Float + Debug, + T: CoordFloat, { query: &'a str, addressdetails: bool, @@ -45,7 +45,7 @@ where impl<'a, T> OpenstreetmapParams<'a, T> where - T: Float + Debug, + T: CoordFloat, { /// Create a new OpenStreetMap parameter builder /// # Example: @@ -146,7 +146,7 @@ impl Openstreetmap { params: &OpenstreetmapParams, ) -> Result, GeocodingError> where - T: Float + Debug, + T: CoordFloat, for<'de> T: Deserialize<'de>, { let format = String::from("geojson"); @@ -184,7 +184,7 @@ impl Default for Openstreetmap { impl Forward for Openstreetmap where - T: Float + Debug, + T: CoordFloat, for<'de> T: Deserialize<'de>, { /// A forward-geocoding lookup of an address. Please see [the documentation](https://nominatim.org/release-docs/develop/api/Search/) for details. @@ -208,7 +208,7 @@ where impl Reverse for Openstreetmap where - T: Float + Debug, + T: CoordFloat, for<'de> T: Deserialize<'de>, { /// A reverse lookup of a point. More detail on the format of the @@ -285,7 +285,7 @@ where #[derive(Debug, Serialize, Deserialize)] pub struct OpenstreetmapResponse where - T: Float + Debug, + T: CoordFloat, { pub r#type: String, pub licence: String, @@ -296,7 +296,7 @@ where #[derive(Debug, Serialize, Deserialize)] pub struct OpenstreetmapResult where - T: Float + Debug, + T: CoordFloat, { pub r#type: String, pub properties: ResultProperties, @@ -339,7 +339,7 @@ pub struct AddressDetails { #[derive(Debug, Serialize, Deserialize)] pub struct ResultGeometry where - T: Float + Debug, + T: CoordFloat, { pub r#type: String, pub coordinates: (T, T), From 1379f6de02b5675938b45baf53bda310b2938080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Wed, 18 Aug 2021 20:12:12 +0200 Subject: [PATCH 3/5] remove unused use (which clippy did not complain about) --- src/lib.rs | 1 - src/opencage.rs | 1 - src/openstreetmap.rs | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3c18559..c7ff612 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,6 @@ use reqwest::header::ToStrError; use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; -use std::fmt::Debug; use std::num::ParseIntError; use thiserror::Error; diff --git a/src/opencage.rs b/src/opencage.rs index 813226c..6f6e95f 100644 --- a/src/opencage.rs +++ b/src/opencage.rs @@ -37,7 +37,6 @@ use chrono::NaiveDateTime; use geo_types::CoordFloat; use serde::Deserializer; use std::collections::HashMap; -use std::fmt::Debug; use std::sync::{Arc, Mutex}; macro_rules! add_optional_param { diff --git a/src/openstreetmap.rs b/src/openstreetmap.rs index 8365592..d4aa86e 100644 --- a/src/openstreetmap.rs +++ b/src/openstreetmap.rs @@ -16,8 +16,6 @@ //! let res = osm.forward(&address); //! assert_eq!(res.unwrap(), vec![Point::new(11.5884858, 48.1700887)]); //! ``` -use std::fmt::Debug; - use crate::GeocodingError; use crate::InputBounds; use crate::Point; From 3e7770c6eae7e3b43d9548ffc3c27336578a934d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Wed, 18 Aug 2021 20:14:57 +0200 Subject: [PATCH 4/5] remove unused "use" --- src/geoadmin.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/geoadmin.rs b/src/geoadmin.rs index 91dc212..2135f3c 100644 --- a/src/geoadmin.rs +++ b/src/geoadmin.rs @@ -15,8 +15,6 @@ //! let res = geoadmin.forward(&address); //! assert_eq!(res.unwrap(), vec![Point::new(7.451352119445801, 46.92793655395508)]); //! ``` -use std::fmt::Debug; - use crate::Deserialize; use crate::GeocodingError; use crate::InputBounds; From f71c2a156e6dfdffdeeeb91eb310e06f92dab1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Fri, 12 Nov 2021 19:49:16 +0100 Subject: [PATCH 5/5] set correct feature for reqwest --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3265bc3..f3eb7fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ num-traits = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" reqwest = { version = "0.11", default-features = false, features = [ - "default-tls", "blocking", "json", ] } @@ -24,5 +23,5 @@ hyper = "0.14" chrono = { version = "0.4", features = ["serde"] } [features] -default = ["reqwest/default"] +default = ["reqwest/default-tls"] rustls-tls = ["reqwest/rustls-tls"]