@@ -364,15 +364,27 @@ impl Curve for SphericalLineStringCurve {
364
364
}
365
365
366
366
fn bbox ( & self ) -> Rect {
367
- let bounding_rect = self . geom . bounding_rect ( ) . unwrap ( ) ;
367
+ let min_point = geo:: Point ( self . geom . bounding_rect ( ) . unwrap ( ) . min ( ) ) ;
368
+ let max_point = geo:: Point ( self . geom . bounding_rect ( ) . unwrap ( ) . max ( ) ) ;
369
+
370
+ // add max_extend distance in South and then West direction
371
+ let min_point_extended = min_point
372
+ . haversine_destination ( 180. , self . max_extent )
373
+ . haversine_destination ( 270. , self . max_extent ) ;
374
+
375
+ // add max_extend distance in North and then East direction
376
+ let max_point_extended = max_point
377
+ . haversine_destination ( 0. , self . max_extent )
378
+ . haversine_destination ( 90. , self . max_extent ) ;
379
+
368
380
Rect :: new (
369
381
coord ! {
370
- x: bounding_rect . min ( ) . x - self . max_extent ,
371
- y: bounding_rect . min ( ) . y - self . max_extent ,
382
+ x: min_point_extended . x ( ) ,
383
+ y: min_point_extended . y ( ) ,
372
384
} ,
373
385
coord ! {
374
- x: bounding_rect . max ( ) . x + self . max_extent ,
375
- y: bounding_rect . max ( ) . y + self . max_extent ,
386
+ x: max_point_extended . x ( ) ,
387
+ y: max_point_extended . y ( ) ,
376
388
} ,
377
389
)
378
390
}
@@ -634,7 +646,7 @@ mod tests {
634
646
#[ test]
635
647
fn spherical_projection ( ) {
636
648
let mut paris_to_new_york =
637
- SphericalLineStringCurve :: new ( line_string ! [ PARIS , NEW_YORK ] , 1. , ) ;
649
+ SphericalLineStringCurve :: new ( line_string ! [ PARIS , NEW_YORK ] , 1. ) ;
638
650
639
651
// Point is located on the right (north) of the curve
640
652
let projected = paris_to_new_york
@@ -730,11 +742,26 @@ mod tests {
730
742
731
743
#[ test]
732
744
fn spherical_bbox ( ) {
733
- let paris_to_new_york = SphericalLineStringCurve :: new ( line_string ! [ PARIS , NEW_YORK ] , 1. ) ;
745
+ let paris_to_new_york = SphericalLineStringCurve :: new (
746
+ line_string ! [
747
+ coord! { x: -7.65 , y: 51.79 } ,
748
+ coord! { x: -7.31 , y: 51.94 } ,
749
+ coord! { x: -7.31 , y: 51.54 } ,
750
+ coord! { x: -6.84 , y: 51.69 } ,
751
+ coord! { x: -6.39 , y: 51.55 } ,
752
+ ] ,
753
+ 100. ,
754
+ ) ;
734
755
let bbox = paris_to_new_york. bbox ( ) ;
735
756
736
- assert_eq ! ( bbox. min( ) , coord! { x: -75.01 , y: 39.71 } ) ;
737
- assert_eq ! ( bbox. max( ) , coord! { x: 3.35 , y: 49.86 } ) ;
757
+ assert_eq ! (
758
+ bbox. min( ) ,
759
+ coord! { x: -7.651445898208635 , y: 51.53910067075082 }
760
+ ) ;
761
+ assert_eq ! (
762
+ bbox. max( ) ,
763
+ coord! { x: -6.388541186830253 , y: 51.9408993113492 }
764
+ ) ;
738
765
}
739
766
740
767
#[ test]
0 commit comments