24
24
//! // "Carrer de Calatrava, 68, 08017 Barcelone, Espagne"
25
25
//! println!("{:?}", res.unwrap());
26
26
//! ```
27
- use crate :: chrono:: naive:: serde:: ts_seconds:: deserialize as from_ts;
28
- use crate :: chrono:: NaiveDateTime ;
29
27
use crate :: DeserializeOwned ;
30
28
use crate :: GeocodingError ;
31
29
use crate :: InputBounds ;
@@ -34,7 +32,9 @@ use crate::UA_STRING;
34
32
use crate :: { Client , HeaderMap , HeaderValue , USER_AGENT } ;
35
33
use crate :: { Deserialize , Serialize } ;
36
34
use crate :: { Forward , Reverse } ;
37
- use num_traits:: Float ;
35
+ use chrono:: naive:: serde:: ts_seconds:: deserialize as from_ts;
36
+ use chrono:: NaiveDateTime ;
37
+ use geo_types:: CoordFloat ;
38
38
use serde:: Deserializer ;
39
39
use std:: collections:: HashMap ;
40
40
use std:: sync:: { Arc , Mutex } ;
@@ -146,7 +146,7 @@ impl<'a> Opencage<'a> {
146
146
///```
147
147
pub fn reverse_full < T > ( & self , point : & Point < T > ) -> Result < OpencageResponse < T > , GeocodingError >
148
148
where
149
- T : Float + DeserializeOwned ,
149
+ T : CoordFloat + DeserializeOwned ,
150
150
{
151
151
let q = format ! (
152
152
"{}, {}" ,
@@ -156,9 +156,9 @@ impl<'a> Opencage<'a> {
156
156
) ;
157
157
let mut query = vec ! [
158
158
( "q" , q. as_str( ) ) ,
159
- ( & "key" , & self . api_key) ,
160
- ( & "no_annotations" , "0" ) ,
161
- ( & "no_record" , "1" ) ,
159
+ ( "key" , & self . api_key) ,
160
+ ( "no_annotations" , "0" ) ,
161
+ ( "no_record" , "1" ) ,
162
162
] ;
163
163
query. extend ( self . parameters . as_query ( ) ) ;
164
164
@@ -248,7 +248,7 @@ impl<'a> Opencage<'a> {
248
248
bounds : U ,
249
249
) -> Result < OpencageResponse < T > , GeocodingError >
250
250
where
251
- T : Float + DeserializeOwned ,
251
+ T : CoordFloat + DeserializeOwned ,
252
252
U : Into < Option < InputBounds < T > > > ,
253
253
{
254
254
let ann = String :: from ( "0" ) ;
@@ -291,7 +291,7 @@ impl<'a> Opencage<'a> {
291
291
292
292
impl < ' a , T > Reverse < T > for Opencage < ' a >
293
293
where
294
- T : Float + DeserializeOwned ,
294
+ T : CoordFloat + DeserializeOwned ,
295
295
{
296
296
/// A reverse lookup of a point. More detail on the format of the
297
297
/// returned `String` can be found [here](https://blog.opencagedata.com/post/99059889253/good-looking-addresses-solving-the-berlin-berlin)
@@ -336,7 +336,7 @@ where
336
336
337
337
impl < ' a , T > Forward < T > for Opencage < ' a >
338
338
where
339
- T : Float + DeserializeOwned ,
339
+ T : CoordFloat + DeserializeOwned ,
340
340
{
341
341
/// A forward-geocoding lookup of an address. Please see [the documentation](https://opencagedata.com/api#ambiguous-results) for details
342
342
/// of best practices in order to obtain good-quality results.
@@ -511,7 +511,7 @@ where
511
511
#[ derive( Debug , Serialize , Deserialize ) ]
512
512
pub struct OpencageResponse < T >
513
513
where
514
- T : Float ,
514
+ T : CoordFloat ,
515
515
{
516
516
pub documentation : String ,
517
517
pub licenses : Vec < HashMap < String , String > > ,
@@ -528,7 +528,7 @@ where
528
528
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
529
529
pub struct Results < T >
530
530
where
531
- T : Float ,
531
+ T : CoordFloat ,
532
532
{
533
533
pub annotations : Option < Annotations < T > > ,
534
534
pub bounds : Option < Bounds < T > > ,
@@ -542,7 +542,7 @@ where
542
542
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
543
543
pub struct Annotations < T >
544
544
where
545
- T : Float ,
545
+ T : CoordFloat ,
546
546
{
547
547
pub dms : Option < HashMap < String , String > > ,
548
548
pub mgrs : Option < String > ,
@@ -615,7 +615,7 @@ pub struct Timestamp {
615
615
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
616
616
pub struct Bounds < T >
617
617
where
618
- T : Float ,
618
+ T : CoordFloat ,
619
619
{
620
620
pub northeast : HashMap < String , T > ,
621
621
pub southwest : HashMap < String , T > ,
@@ -652,7 +652,7 @@ mod test {
652
652
fn forward_test ( ) {
653
653
let oc = Opencage :: new ( "dcdbf0d783374909b3debee728c7cc10" . to_string ( ) ) ;
654
654
let address = "Schwabing, München" ;
655
- let res = oc. forward ( & address) ;
655
+ let res = oc. forward ( address) ;
656
656
assert_eq ! (
657
657
res. unwrap( ) ,
658
658
vec![ Point ( Coordinate {
@@ -678,7 +678,7 @@ mod test {
678
678
minimum_lonlat : Point :: new ( -0.13806939125061035 , 51.51989264641164 ) ,
679
679
maximum_lonlat : Point :: new ( -0.13427138328552246 , 51.52319711775629 ) ,
680
680
} ;
681
- let res = oc. forward_full ( & address, bbox) . unwrap ( ) ;
681
+ let res = oc. forward_full ( address, bbox) . unwrap ( ) ;
682
682
let first_result = & res. results [ 0 ] ;
683
683
assert ! ( first_result. formatted. contains( "UCL" ) ) ;
684
684
}
@@ -690,7 +690,7 @@ mod test {
690
690
Point :: new ( -0.13806939125061035 , 51.51989264641164 ) ,
691
691
Point :: new ( -0.13427138328552246 , 51.52319711775629 ) ,
692
692
) ;
693
- let res = oc. forward_full ( & address, bbox) . unwrap ( ) ;
693
+ let res = oc. forward_full ( address, bbox) . unwrap ( ) ;
694
694
let first_result = & res. results [ 0 ] ;
695
695
assert ! ( first_result
696
696
. formatted
@@ -704,7 +704,7 @@ mod test {
704
704
Point :: from ( ( -0.13806939125061035 , 51.51989264641164 ) ) ,
705
705
Point :: from ( ( -0.13427138328552246 , 51.52319711775629 ) ) ,
706
706
) ;
707
- let res = oc. forward_full ( & address, bbox) . unwrap ( ) ;
707
+ let res = oc. forward_full ( address, bbox) . unwrap ( ) ;
708
708
let first_result = & res. results [ 0 ] ;
709
709
assert ! ( first_result
710
710
. formatted
@@ -718,7 +718,7 @@ mod test {
718
718
( -0.13806939125061035 , 51.51989264641164 ) ,
719
719
( -0.13427138328552246 , 51.52319711775629 ) ,
720
720
) ;
721
- let res = oc. forward_full ( & address, bbox) . unwrap ( ) ;
721
+ let res = oc. forward_full ( address, bbox) . unwrap ( ) ;
722
722
let first_result = & res. results [ 0 ] ;
723
723
assert ! ( first_result
724
724
. formatted
@@ -728,7 +728,7 @@ mod test {
728
728
fn forward_full_test_nobox ( ) {
729
729
let oc = Opencage :: new ( "dcdbf0d783374909b3debee728c7cc10" . to_string ( ) ) ;
730
730
let address = "Moabit, Berlin, Germany" ;
731
- let res = oc. forward_full ( & address, NOBOX ) . unwrap ( ) ;
731
+ let res = oc. forward_full ( address, NOBOX ) . unwrap ( ) ;
732
732
let first_result = & res. results [ 0 ] ;
733
733
assert_eq ! ( first_result. formatted, "Moabit, Berlin, Germany" ) ;
734
734
}
0 commit comments