1+ import { extentToResolutions } from '../../../src/common/iServer/InitMapServiceBase' ;
2+
3+ describe ( 'extentToResolutions' , ( ) => {
4+ it ( 'should calculate resolutions for a given bounding box' , ( ) => {
5+ const bounds = { left : - 180 , right : 180 } ;
6+ const resolutions = extentToResolutions ( bounds ) ;
7+ expect ( resolutions . length ) . toBe ( 22 ) ;
8+ expect ( resolutions [ 0 ] ) . toBeCloseTo ( 0.703125 ) ;
9+ expect ( resolutions [ 21 ] ) . toBeCloseTo ( 0.00000686328125 ) ;
10+ } ) ;
11+
12+ it ( 'should handle array bounds input' , ( ) => {
13+ const bounds = [ - 180 , - 90 , 180 , 90 ] ;
14+ const resolutions = extentToResolutions ( bounds ) ;
15+ expect ( resolutions . length ) . toBe ( 22 ) ;
16+ expect ( resolutions [ 0 ] ) . toBeCloseTo ( 0.703125 ) ;
17+ expect ( resolutions [ 21 ] ) . toBeCloseTo ( 0.00000686328125 ) ;
18+ } ) ;
19+
20+ it ( 'should handle custom maxZoom and tileSize' , ( ) => {
21+ const bounds = { left : - 180 , right : 180 } ;
22+ const resolutions = extentToResolutions ( bounds , 10 , 256 ) ;
23+ expect ( resolutions . length ) . toBe ( 10 ) ;
24+ expect ( resolutions [ 0 ] ) . toBeCloseTo ( 1.40625 ) ;
25+ expect ( resolutions [ 9 ] ) . toBeCloseTo ( 0.00146484375 ) ;
26+ } ) ;
27+
28+ it ( 'should handle zero width bounds' , ( ) => {
29+ const bounds = { left : 0 , right : 0 } ;
30+ const resolutions = extentToResolutions ( bounds ) ;
31+ expect ( resolutions . length ) . toBe ( 22 ) ;
32+ expect ( resolutions [ 0 ] ) . toBe ( 0 ) ;
33+ } ) ;
34+
35+ it ( 'should handle negative width bounds' , ( ) => {
36+ const bounds = { left : 180 , right : - 180 } ;
37+ const resolutions = extentToResolutions ( bounds ) ;
38+ expect ( resolutions . length ) . toBe ( 22 ) ;
39+ expect ( resolutions [ 0 ] ) . toBeCloseTo ( 0.703125 ) ;
40+ expect ( resolutions [ 21 ] ) . toBeCloseTo ( 0.00000686328125 ) ;
41+ } ) ;
42+ } ) ;
0 commit comments