@@ -3,7 +3,11 @@ import proj4 from 'proj4'
3
3
import { describe , it } from 'vitest'
4
4
5
5
import { LV03 , LV95 , WEBMERCATOR , WGS84 } from '@/utils/coordinates/coordinateSystems'
6
- import { reprojectUnknownSrsCoordsToWGS84 } from '@/utils/coordinates/coordinateUtils'
6
+ import {
7
+ flattenExtent ,
8
+ normalizeExtent ,
9
+ reprojectUnknownSrsCoordsToWGS84 ,
10
+ } from '@/utils/coordinates/coordinateUtils'
7
11
8
12
describe ( 'Unit test functions from coordinateUtils.js' , ( ) => {
9
13
describe ( 'reprojectUnknownSrsCoordsToWGS84(x,y)' , ( ) => {
@@ -74,5 +78,29 @@ describe('Unit test functions from coordinateUtils.js', () => {
74
78
coordinatesWGS84
75
79
)
76
80
} )
81
+ it ( 'normalize an extent' , ( ) => {
82
+ const flatExtent = [ 1 , 2 , 3 , 4 ]
83
+ const result = normalizeExtent ( flatExtent )
84
+ expect ( result ) . to . have . length ( 2 )
85
+ expect ( result [ 0 ] ) . to . have . length ( 2 )
86
+ expect ( result [ 1 ] ) . to . have . length ( 2 )
87
+ expect ( result [ 0 ] [ 0 ] ) . to . equal ( 1 )
88
+ expect ( result [ 0 ] [ 1 ] ) . to . equal ( 2 )
89
+ expect ( result [ 1 ] [ 0 ] ) . to . equal ( 3 )
90
+ expect ( result [ 1 ] [ 1 ] ) . to . equal ( 4 )
91
+
92
+ expect ( normalizeExtent ( result ) ) . to . deep . equal ( result )
93
+ } )
94
+ it ( 'flattern an extent' , ( ) => {
95
+ const normalizedExtent = [
96
+ [ 1 , 2 ] ,
97
+ [ 3 , 4 ] ,
98
+ ]
99
+ const flatExtent = flattenExtent ( normalizedExtent )
100
+ expect ( flatExtent ) . to . have . length ( 4 )
101
+ expect ( flatExtent ) . to . deep . equal ( [ 1 , 2 , 3 , 4 ] )
102
+
103
+ expect ( flattenExtent ( flatExtent ) ) . to . deep . equal ( [ 1 , 2 , 3 , 4 ] )
104
+ } )
77
105
} )
78
106
} )
0 commit comments