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