package Ġcom . s feather stone . ge ode sy . model . spher ical . vectors čĊč Ċ import Ġcom . s feather stone . ge ode sy .* č Ċ import Ġorg . junit . Test č Ċ import Ġorg . junit . Assert .* čĊč Ċ /* Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ Ġ*/ č Ċ /* Ġ ĠGe ode sy ĠTest ĠH arness Ġ- Ġlat lon - vectors ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ( c ) ĠChris ĠV eness Ġ 2 0 1 4 - 2 0 1 7 Ġ Ġ*/ č Ċ /* ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ( c ) ĠSimon ĠFr ather stone Ġ 2 0 1 8 Ġ*/ č Ċ /* Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ- Ġ Ġ*/ čĊč Ċ class ĠVector s Test Ġ{ čĊĠĠĠ Ġval ĠR Ġ= Ġ 6 3 7 1 e 3 čĊĠĠĠ Ġval ĠÏĢ Ġ= ĠMath . PI čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġformat ing Test () Ġ{ čĊĠĠĠĠĠĠĠ ĠassertEquals (" toString Ġd ", Ġ" 5 1 . 5 2 1 4 7 0 Â° N , Ġ 0 0 0 . 1 3 8 8 3 3 Â° W ", ĠLat Lon ( 5 1 . 5 2 1 4 7 0 , Ġ- 0 . 1 3 8 8 3 3 ). toString (" d ", Ġ 6 )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" toString Ġd ms ", Ġ" 5 1 Â° 3 1 âĢ² 1 7 . 2 9 âĢ ³ N , Ġ 0 0 0 Â° 0 8 âĢ² 1 9 . 8 0 âĢ ³ W ", ĠLat Lon ( 5 1 . 5 2 1 4 7 0 , Ġ- 0 . 1 3 8 8 3 3 ). toString (" d ms ", Ġ 2 )) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġge odes ics Test () Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġcamb g Ġ= ĠLat Lon ( 5 2 . 2 0 5 , Ġ 0 . 1 1 9 ) čĊĠĠĠĠĠĠĠ Ġval Ġpar is Ġ= ĠLat Lon ( 4 8 . 8 5 7 , Ġ 2 . 3 5 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" distance ", Ġ 4 . 0 4 3 e + 5 , Ġcamb g . distance To ( par is ). to Precision ( 4 ), Ġ 0 . 0 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" distance Ġ( m iles )", Ġ 2 5 1 . 2 , Ġcamb g . distance To ( par is , Ġ 3 9 5 9 . 0 ). to Precision ( 4 ), Ġ 0 . 0 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" initial Ġbe aring ", Ġ 1 5 6 . 2 , Ġcamb g . be aring To ( par is ). toFixed ( 1 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" mid point ", Ġ" 5 0 . 5 3 6 3 Â° N , Ġ 0 0 1 . 2 7 4 6 Â° E ", Ġcamb g . mid point To ( par is ). toString (" d ")) čĊĠĠĠĠĠĠĠ ĠassertEquals (" int . point ", Ġ" 5 1 . 3 7 2 1 Â° N , Ġ 0 0 0 . 7 0 7 3 Â° E ", Ġcamb g . intermediate Point To ( par is , Ġ 0 . 2 5 ). toString (" d ")) čĊĠĠĠĠĠĠĠ ĠassertEquals (" int . point - ch ord ", Ġ" 5 1 . 3 7 2 3 Â° N , Ġ 0 0 0 . 7 0 7 2 Â° E ", Ġcamb g . intermediate Point On Ch ord To ( par is , Ġ 0 . 2 5 ). toString (" d ")) čĊčĊĠĠĠĠĠĠĠ Ġvar Ġgreen wich Ġ= ĠLat Lon ( 5 1 . 4 7 7 8 , Ġ- 0 . 0 0 1 5 ) čĊĠĠĠĠĠĠĠ Ġval Ġdist Ġ= Ġ 7 7 9 4 . 0 čĊĠĠĠĠĠĠĠ Ġval Ġbr ng Ġ= Ġ 3 0 0 . 7 čĊĠĠĠĠĠĠĠ ĠassertEquals (" dest âĢĻ n ", Ġ" 5 1 . 5 1 3 5 Â° N , Ġ 0 0 0 . 0 9 8 3 Â° W ", Ġgreen wich . destination Point ( dist , Ġbr ng ). toString (" d ")) čĊĠĠĠĠĠĠĠ ĠassertEquals (" dest âĢĻ n Ġinc Ġr ", Ġ" 5 1 . 5 1 3 5 Â° N , Ġ 0 0 0 . 0 9 8 3 Â° W ", Ġgreen wich . destination Point ( dist , Ġbr ng , Ġ 6 3 7 1 e 3 ). toString (" d ")) čĊčĊĠĠĠĠĠĠĠ Ġvar Ġb rad well Ġ= ĠLat Lon ( 5 3 . 3 2 0 6 , Ġ- 1 . 7 2 9 7 ) č Ċ /* ĠĠĠĠĠĠĠ ĠassertEquals (" cross - track ", ĠĠĠĠĠĠ Ġ- 3 0 7 . 5 , ĠLat Lon ( 5 3 . 2 6 1 1 , Ġ- 0 . 7 9 7 2 ). cross Track Distance To ( br ad well , ĠLat Lon ( 5 3 . 1 8 8 7 , ĠĠ 0 . 1 3 3 4 )). to Precision ( 4 ), Ġ 0 . 0 0 1 ); čĊĠĠĠĠĠĠĠ ĠassertEquals (" along - track ", ĠĠĠĠĠĠĠ 6 . 2 3 3 e + 4 , ĠLat Lon ( 5 3 . 2 6 1 1 , Ġ- 0 . 7 9 7 2 ). along Track Distance To ( br ad well , ĠLat Lon ( 5 3 . 1 8 8 7 , ĠĠ 0 . 1 3 3 4 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ); čĊčĊĠĠĠĠĠĠĠ ĠassertEquals (" cross - track ĠNE ", ĠĠĠ Ġ- 1 . 1 1 2 e + 5 , ĠLat Lon ( 1 . 0 , Ġ 1 . 0 ). cross Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" cross - track ĠSE ", ĠĠĠĠ 1 . 1 1 2 e + 5 , ĠLat Lon (- 1 . 0 , ĠĠ 1 . 0 ). cross Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" cross - track ĠSW ?", ĠĠĠ 1 . 1 1 2 e + 5 , ĠLat Lon (- 1 . 0 , Ġ- 1 . 0 ). cross Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" cross - track ĠN W ?", ĠĠ Ġ- 1 . 1 1 2 e + 5 , ĠLat Lon ( Ġ 1 . 0 , Ġ- 1 . 0 ). cross Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊčĊĠĠĠĠĠĠĠ ĠassertEquals (" along - track ĠNE ", ĠĠĠĠ 1 . 1 1 2 e + 5 , ĠLat Lon ( Ġ 1 . 0 , ĠĠ 1 . 0 ). along Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" along - track ĠSE ", ĠĠĠĠ 1 . 1 1 2 e + 5 , ĠLat Lon (- 1 . 0 , ĠĠ 1 . 0 ). along Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" along - track ĠSW ", ĠĠĠ Ġ- 1 . 1 1 2 e + 5 , ĠLat Lon (- 1 . 0 , Ġ- 1 . 0 ). along Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" along - track ĠN W ", ĠĠĠ Ġ- 1 . 1 1 2 e + 5 , ĠLat Lon ( Ġ 1 . 0 , Ġ- 1 . 0 ). along Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 2 . 0 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊčĊĠĠĠĠĠĠĠ ĠassertEquals (" cross - track Ġbr ng Ġw - e ", Ġ Ġ- 1 . 1 1 2 e + 5 , ĠLat Lon ( 1 . 0 , Ġ 0 . 0 ). cross Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), Ġ 9 0 . 0 ). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" cross - track Ġbr ng Ġe - w ", ĠĠ 1 . 1 1 2 e + 5 , ĠLat Lon ( 1 . 0 , Ġ 0 . 0 ). cross Track Distance To ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), Ġ 2 7 0 . 0 ). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) č Ċ */ čĊĠĠĠĠĠĠĠ ĠassertEquals (" nearest Ġpoint Ġon Ġsegment Ġ 1 ", Ġ" 5 1 . 0 0 0 4 Â° N , Ġ 0 0 1 . 9 0 0 0 Â° E ", ĠLat Lon ( 5 1 . 0 , Ġ 1 . 9 ). nearest Point On Segment ( Lat Lon ( 5 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 5 1 . 0 , Ġ 2 . 0 )). toString (" d ")) čĊĠĠĠĠĠĠĠ ĠassertEquals (" nearest Ġpoint Ġon Ġsegment Ġ 1 d ", Ġ 4 2 . 7 1 , ĠLat Lon ( 5 1 . 0 , Ġ 1 . 9 ). nearest Point On Segment ( Lat Lon ( 5 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 5 1 . 0 , Ġ 2 . 0 )). distance To ( Lat Lon ( 5 1 . 0 , Ġ 1 . 9 )). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" nearest Ġpoint Ġon Ġsegment Ġ 2 ", Ġ" 5 1 . 0 0 0 0 Â° N , Ġ 0 0 2 . 0 0 0 0 Â° E ", ĠLat Lon ( 5 1 . 0 , Ġ 2 . 1 ). nearest Point On Segment ( Lat Lon ( 5 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 5 1 . 0 , Ġ 2 . 0 )). toString (" d ")) čĊĠĠĠĠĠĠĠ ĠassertEquals (" nearest Ġpoint Ġon Ġsegment ĠJ B ", Ġ" 0 0 . 0 0 0 0 Â° N , Ġ 0 2 0 . 0 0 0 0 Â° E ", ĠLat Lon ( 1 0 . 0 , Ġ- 1 4 0 . 0 ). nearest Point On Segment ( Lat Lon ( 0 . 0 , Ġ 2 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 4 0 . 0 )). toString (" d ")) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun ĠEd W illi ams Test () Ġ{ čĊĠĠĠĠĠĠĠ Ġvar Ġl ax Ġ= ĠLat Lon (" 3 3 Â° Ġ 5 7 âĢ² N ". parse Degrees Minutes Seconds (), Ġ" 1 1 8 Â° Ġ 2 4 âĢ² W ". parse Degrees Minutes Seconds ()) čĊĠĠĠĠĠĠĠ Ġvar Ġj fk Ġ= ĠLat Lon (" 4 0 Â° Ġ 3 8 âĢ² N ". parse Degrees Minutes Seconds (), Ġ" 0 7 3 Â° Ġ 4 7 âĢ² W ". parse Degrees Minutes Seconds ()) čĊĠĠĠĠĠĠĠ ĠassertEquals (" distance Ġnm ", Ġ 2 1 4 4 . 0 , Ġl ax . distance To ( j fk , Ġ 1 8 0 Ġ* Ġ 6 0 Ġ/ ĠÏĢ ). to Precision ( 4 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" be aring ", Ġ 6 6 . 0 , Ġl ax . be aring To ( j fk ). to Precision ( 2 ), Ġ 0 . 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" intermediate ", Ġ" 3 4 Â° 3 7 âĢ² N , Ġ 1 1 6 Â° 3 3 âĢ² W ", Ġl ax . intermediate Point To ( j fk , Ġ 1 0 0 . 0 Ġ/ Ġ 2 1 4 4 . 0 ). toString (" dm ", Ġ 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġd Ġ= ĠLat Lon (" 3 4 : 3 0 N ". parse Degrees Minutes Seconds (), Ġ" 1 1 6 : 3 0 W ". parse Degrees Minutes Seconds ()) čĊĠĠĠĠĠĠĠ Ġ// assertEquals (" cross - track ", ĠĠĠ Ġd . cross Track Distance To ( l ax , Ġj fk , Ġ 1 8 0 * 6 0 / ÏĢ ). to Precision ( 5 ). should . equal (" 7 . 4 5 2 3 ")); čĊĠĠĠĠĠĠĠ ĠassertEquals (" intermediate ", Ġ" 3 8 Â° 4 0 . 1 6 7 âĢ² N , Ġ 1 0 1 Â° 3 7 . 5 7 0 âĢ² W ", Ġl ax . intermediate Point To ( j fk , Ġ 0 . 4 ). toString (" dm ", Ġ 3 )) čĊĠĠĠĠĠĠĠ Ġvar Ġre o Ġ= ĠLat Lon (" 4 2 . 6 0 0 N ". parse Degrees Minutes Seconds (), Ġ" 1 1 7 . 8 6 6 W ". parse Degrees Minutes Seconds ()) čĊĠĠĠĠĠĠĠ Ġvar Ġb ke Ġ= ĠLat Lon (" 4 4 . 8 4 0 N ". parse Degrees Minutes Seconds (), Ġ" 1 1 7 . 8 0 6 W ". parse Degrees Minutes Seconds ()) čĊĠĠĠĠĠĠĠ Ġ// assertEquals (" intersection ", ĠĠ Ġ" 4 3 . 5 7 2 Â° N , Ġ 1 1 6 . 1 8 9 Â° W ", ĠLat Lon . intersection ( re o , Ġ 5 1 , Ġb ke , Ġ 1 3 7 ). toString (" d ", Ġ 3 )) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun ĠInter sections Test () Ġ{ čĊĠĠĠĠĠĠĠ Ġvar ĠN Ġ= Ġ 0 . 0 čĊĠĠĠĠĠĠĠ Ġval ĠE Ġ= Ġ 9 0 . 0 čĊĠĠĠĠĠĠĠ Ġval ĠS Ġ= Ġ 1 8 0 . 0 čĊĠĠĠĠĠĠĠ Ġval ĠW Ġ= Ġ 2 7 0 . 0 čĊĠĠĠĠĠĠĠ Ġ/* ĠĠ ĠassertEquals (" tow ard Ġ 1 , 1 ĠN , E Ġnearest ", ĠĠĠĠĠĠĠĠ Ġ" 0 0 . 9 9 9 8 Â° N , Ġ 0 0 1 . 0 0 0 0 Â° E ", ĠLat Lon . intersection ( Lat Lon ( 0 , Ġ 1 ), ĠN , ĠLat Lon ( 1 , Ġ 0 ), ĠE ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" tow ard Ġ 1 , 1 ĠE , N Ġnearest ", ĠĠĠĠĠĠĠĠ Ġ" 0 0 . 9 9 9 8 Â° N , Ġ 0 0 1 . 0 0 0 0 Â° E ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 0 ), ĠE , ĠLat Lon ( 0 , Ġ 1 ), ĠN ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" tow ard Ġ 1 , 1 ĠN , E Ġan tip od al ", ĠĠĠĠĠĠ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 2 , Ġ 1 ), ĠN , ĠLat Lon ( 1 , Ġ 0 ), ĠE ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" tow ard / away Ġ 1 , 1 ĠN , W Ġan tip od al ", Ġ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 0 , Ġ 1 ), ĠN , ĠLat Lon ( 1 , Ġ 0 ), ĠW ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" tow ard / away Ġ 1 , 1 ĠW , N Ġan tip od al ", Ġ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 0 ), ĠW , ĠLat Lon ( 0 , Ġ 1 ), ĠN ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" tow ard / away Ġ 1 , 1 ĠS , E Ġan tip od al ", Ġ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 0 , Ġ 1 ), ĠS , ĠLat Lon ( 1 , Ġ 0 ), ĠE ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" tow ard / away Ġ 1 , 1 ĠE , S Ġan tip od al ", Ġ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 0 ), ĠE , ĠLat Lon ( 0 , Ġ 1 ), ĠS ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" away Ġ 1 , 1 ĠS , W Ġan tip od al ", ĠĠĠĠĠĠĠĠ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 0 , Ġ 1 ), ĠS , ĠLat Lon ( 1 , Ġ 0 ), ĠW ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" away Ġ 1 , 1 ĠW , S Ġan tip od al ", ĠĠĠĠĠĠĠĠ Ġ" 0 0 . 9 9 9 8 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 0 ), ĠW , ĠLat Lon ( 0 , Ġ 1 ), ĠS ). toString (" d ")); čĊč ĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" 1 E / 9 0 E ĠN , E Ġan tip od al ", ĠĠĠĠĠĠĠĠĠĠ Ġ" 0 0 . 0 1 7 5 Â° S , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 0 , Ġ 1 ), ĠN , ĠLat Lon ( 1 , Ġ 9 0 ), ĠE ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" 1 E / 9 0 E ĠN , E Ġnearest ", ĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 0 . 0 1 7 5 Â° N , Ġ 1 7 9 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 0 , Ġ 1 ), ĠN , ĠLat Lon ( 1 , Ġ 9 2 ), ĠE ). toString (" d ")); čĊč ĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" br ng + end Ġ 1 a ", ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 1 . 0 0 0 3 Â° N , Ġ 0 0 2 . 0 0 0 0 Â° E ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 0 ), ĠLat Lon ( 1 , Ġ 3 ), ĠLat Lon ( 2 , Ġ 2 ), ĠS ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" br ng + end Ġ 1 b ", ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 1 . 0 0 0 3 Â° N , Ġ 0 0 2 . 0 0 0 0 Â° E ", ĠLat Lon . intersection ( Lat Lon ( 2 , Ġ 2 ), ĠS , ĠLat Lon ( 1 , Ġ 0 ), ĠLat Lon ( 1 , Ġ 3 )). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" br ng + end Ġ 2 a ", ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 1 . 0 0 0 3 Â° S , Ġ 1 7 8 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 0 ), ĠLat Lon ( 1 , Ġ 3 ), ĠLat Lon ( 2 , Ġ 2 ), ĠN ). toString (" d ")); čĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" br ng + end Ġ 2 b ", ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 1 . 0 0 0 3 Â° S , Ġ 1 7 8 . 0 0 0 0 Â° W ", ĠLat Lon . intersection ( Lat Lon ( 2 , Ġ 2 ), ĠN , ĠLat Lon ( 1 , Ġ 0 ), ĠLat Lon ( 1 , Ġ 3 )). toString (" d ")); čĊč ĊĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" end + end ", ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 0 2 . 4 9 9 4 Â° N , Ġ 0 0 2 . 5 0 0 0 Â° E ", ĠLat Lon . intersection ( Lat Lon ( 1 , Ġ 1 ), ĠLat Lon ( 2 , Ġ 2 ), ĠLat Lon ( 1 , Ġ 4 ), ĠLat Lon ( 2 , Ġ 3 )). toString (" d ")); čĊĠĠĠĠĠĠ Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġst n Ġ= ĠLat Lon ( 5 1 . 8 8 5 3 , Ġ 0 . 2 5 4 5 ) čĊĠĠĠĠĠĠĠ Ġval Ġcd g Ġ= ĠLat Lon ( 4 9 . 0 0 3 4 , Ġ 2 . 5 7 3 5 ) čĊĠĠĠĠĠĠĠ Ġ// Ġ ĠassertEquals (" st n - cd g - b xl ", ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" 5 0 . 9 0 7 8 Â° N , Ġ 0 0 4 . 5 0 8 4 Â° E ", ĠLat Lon . intersection ( st n , Ġ 1 0 8 . 5 4 7 , Ġcd g , Ġ 3 2 . 4 3 5 ). toString (" d ")); čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun ĠPolygon al Test () Ġ{ čĊĠĠĠĠĠĠĠ Ġvar Ġpoly Triangle Ġ= ĠarrayOf ( Lat Lon ( 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 2 . 0 , Ġ 1 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 1 . 0 , Ġ 2 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly Square Cw Ġ= ĠarrayOf ( Lat Lon ( 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 2 . 0 , Ġ 1 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 2 . 0 , Ġ 2 . 0 ), ĠLat Lon ( 1 . 0 , Ġ 2 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly Square C cw Ġ= ĠarrayOf ( Lat Lon ( 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 1 . 0 , Ġ 2 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 2 . 0 , Ġ 2 . 0 ), ĠLat Lon ( 2 . 0 , Ġ 1 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly Quadr ant Ġ= ĠarrayOf ( Lat Lon ( 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 9 0 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 9 0 . 0 , Ġ 0 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly H emi Ġ= ĠarrayOf ( Lat Lon ( 0 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 4 5 . 0 , Ġ 0 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 8 9 . 0 , Ġ 9 0 . 0 ), ĠLat Lon ( 4 5 . 0 , Ġ 1 8 0 . 0 ), ĠLat Lon ( 0 . 0 , Ġ 1 7 9 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon (- 4 5 . 0 , Ġ 1 8 0 . 0 ), ĠLat Lon (- 8 9 . 0 , Ġ 9 0 . 0 ), ĠLat Lon (- 4 5 . 0 , Ġ 0 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly Gc Ġ= ĠarrayOf ( Lat Lon ( 1 0 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 1 0 . 0 , Ġ 9 0 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 0 . 0 , Ġ 4 5 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly P ole Ġ= ĠarrayOf ( Lat Lon ( 8 9 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 8 9 . 0 , Ġ 1 2 0 . 0 ), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLat Lon ( 8 9 . 0 , Ġ- 1 2 0 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly P ole Edge Ġ= ĠarrayOf ( Lat Lon ( 8 5 . 0 , Ġ 9 0 . 0 ), ĠLat Lon ( 8 5 . 0 , Ġ 0 . 0 ), ĠLat Lon ( 8 5 . 0 , Ġ- 9 0 . 0 )) čĊĠĠĠĠĠĠĠ Ġvar Ġpoly Con c ave Ġ= ĠarrayOf ( Lat Lon ( 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 5 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 5 . 0 , Ġ 3 . 0 ), ĠLat Lon ( 1 . 0 , Ġ 3 . 0 ), ĠLat Lon ( 3 . 0 , Ġ 2 . 0 )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" triangle Ġarea ", Ġ 6 1 8 1 5 2 7 8 8 8 . 0 , Ġarea Of ( poly Triangle ). toFixed ( 0 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" square Ġcw Ġarea ", Ġ 1 2 3 6 0 2 3 0 9 8 7 . 0 , Ġarea Of ( poly Square Cw ). toFixed ( 0 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" square Ġcc w Ġarea ", Ġ 1 2 3 6 0 2 3 0 9 8 7 . 0 , Ġarea Of ( poly Square C cw ). toFixed ( 0 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" quadr ant Ġarea ", Ġ( ÏĢ Ġ* ĠR Ġ* ĠR Ġ/ Ġ 2 . 0 ). toFixed ( 1 ), Ġarea Of ( poly Quadr ant ). toFixed ( 1 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" he mis phere Ġarea ", Ġ 2 5 2 1 9 8 9 7 5 9 4 1 6 0 6 . 0 , Ġarea Of ( poly H emi ). toFixed ( 0 ), Ġ 0 . 0 0 0 1 ) Ġ// ĠTODO : Ġs pherical Ġgives Ġ 2 5 2 6 8 4 6 7 9 6 7 6 4 5 9 Ġ( 0 . 2 % Ġerror ) Ġ- Ġwhich Ġis Ġrig h , Ġ 0 . 0 0 0 1 t ? čĊĠĠĠĠĠĠĠ ĠassertEquals (" pole Ġarea ", Ġ 1 6 0 6 3 1 3 9 1 9 2 . 0 , Ġarea Of ( poly P ole ). toFixed ( 0 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" conc ave Ġarea ", Ġ 7 4 0 4 2 6 9 9 2 3 6 . 0 , Ġarea Of ( poly Con c ave ). toFixed ( 0 ), Ġ 0 . 0 0 0 1 ) čĊĠĠĠĠĠĠĠ ĠassertEquals (" he mis phere Ġen closed Ġy ", Ġtrue , ĠLat Lon ( 2 2 . 5 , Ġ 0 . 5 9 ). enc losed By ( poly H emi )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" he mis phere Ġen closed Ġn ", Ġfalse , ĠLat Lon ( 2 2 . 5 , Ġ 0 . 5 8 ). enc losed By ( poly H emi )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" gc Ġen closed Ġy ", Ġtrue , ĠLat Lon ( 1 4 . 0 , Ġ 4 5 . 0 ). enc losed By ( poly Gc )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" gc Ġen closed Ġn ", Ġfalse , ĠLat Lon ( 1 5 . 0 , Ġ 4 5 . 0 ). enc losed By ( poly Gc )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" pole Ġen closed ", Ġtrue , ĠLat Lon ( 9 0 . 0 , Ġ 0 . 0 ). enc losed By ( poly P ole )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" polar Ġedge Ġen closed ", Ġtrue , ĠLat Lon ( 9 0 . 0 , Ġ 0 . 0 ). enc losed By ( poly P ole Edge )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" conc ave Ġen closed Ġy ", Ġtrue , ĠLat Lon ( 4 . 0 , Ġ 2 . 0 ). enc losed By ( poly Con c ave )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" conc ave Ġen closed Ġn ", Ġfalse , ĠLat Lon ( 2 . 0 , Ġ 2 . 0 ). enc losed By ( poly Con c ave )) čĊĠĠĠ Ġ} čĊčĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun ĠMean Test () Ġ{ čĊĠĠĠĠĠĠĠ Ġvar Ġpoints Ġ= ĠarrayOf ( Lat Lon ( 1 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 2 . 0 , Ġ 1 . 0 ), ĠLat Lon ( 2 . 0 , Ġ 2 . 0 ), ĠLat Lon ( 1 . 0 , Ġ 2 . 0 )) čĊĠĠĠĠĠĠĠ ĠassertEquals (" mean ", Ġ" 0 1 Â° 3 0 âĢ² 0 0 âĢ ³ N , Ġ 0 0 1 Â° 3 0 âĢ² 0 0 âĢ ³ E ", Ġmean Of ( points ). toString ()) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun ĠMisc Test () Ġ{ čĊĠĠĠĠĠĠĠ ĠassertEquals (" equals Ġtrue ", Ġtrue , ĠLat Lon ( 5 2 . 2 0 5 , Ġ 0 . 1 1 9 ). equals ( Lat Lon ( 5 2 . 2 0 5 , Ġ 0 . 1 1 9 ))) čĊĠĠĠĠĠĠĠ ĠassertEquals (" equals Ġfalse ", Ġfalse , ĠLat Lon ( 5 2 . 2 0 6 , Ġ 0 . 1 1 9 ). equals ( Lat Lon ( 5 2 . 2 0 5 , Ġ 0 . 1 1 9 ))) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun ĠVector s Test () Ġ{ čĊĠĠĠĠĠĠĠ ĠassertEquals (" ll Ġto Ġv ", Ġ"[ 0 . 5 0 0 , 0 . 5 0 0 , 0 . 7 0 7 ]", ĠLat Lon ( 4 5 . 0 , Ġ 4 5 . 0 ). to Vector (). toString ()) čĊĠĠĠĠĠĠĠ ĠassertEquals (" v Ġto Ġll ", Ġ" 4 5 . 0 0 0 0 Â° N , Ġ 0 4 5 . 0 0 0 0 Â° E ", ĠVector 3 d ( 0 . 5 0 0 , Ġ 0 . 5 0 0 , Ġ 0 . 7 0 7 1 0 7 ). to Lat Lon S (). toString (" d ")) čĊĠĠĠĠĠĠĠ ĠassertEquals (" great Ġcircle ", Ġ" [- 0 . 7 9 4 , 0 . 1 2 9 , 0 . 5 9 4 ]", ĠLat Lon ( 5 3 . 3 2 0 6 , Ġ- 1 . 7 2 9 7 ). great Circle ( 9 6 . 0 ). toString ()) čĊĠĠĠĠĠĠĠ ĠassertEquals (" gc Ġfrom Ġvector ", Ġ" [- 0 . 7 9 4 , 0 . 1 2 9 , 0 . 5 9 4 ]", ĠLat Lon ( 5 3 . 3 2 0 6 , Ġ- 1 . 7 2 9 7 ). to Vector (). great Circle ( 9 6 . 0 ). toString ()) čĊĠĠĠĠĠĠĠ ĠassertEquals (" div ided ", Ġ"[ 0 . 2 5 0 , 0 . 2 5 0 , 0 . 3 5 4 ]", ĠVector 3 d ( 0 . 5 0 0 , Ġ 0 . 5 0 0 , Ġ 0 . 7 0 7 1 0 7 ). div ( 2 . 0 ). toString ()) čĊĠĠĠĠĠĠĠ ĠassertEquals (" neg ate ", Ġ" [- 0 . 5 0 0 ,- 0 . 5 0 0 ,- 0 . 7 0 7 ]", ĠVector 3 d ( 0 . 5 0 0 , Ġ 0 . 5 0 0 , Ġ 0 . 7 0 7 1 0 7 ). neg ate . toString ()) čĊĠĠĠĠĠĠĠ ĠassertEquals (" rotate Ġaround ", Ġ"[ 0 . 5 0 0 ,- 0 . 1 4 6 , 0 . 8 5 4 ]", ĠVector 3 d ( 0 . 5 0 0 , Ġ 0 . 5 0 0 , Ġ 0 . 7 0 7 1 0 7 ). rotate Around ( Vector 3 d ( 1 . 0 , Ġ 0 . 0 , Ġ 0 . 0 ), ĠÏĢ Ġ/ Ġ 4 ). toString ()) čĊĠĠĠ Ġ} čĊč Ċ }