@@ -222,5 +222,45 @@ describe('leaflet_ImageMapLayer', () => {
222222 expect ( hillshadeParameter . azimuth ) . toBe ( 200 ) ;
223223 expect ( hillshadeParameter . zFactor ) . toBe ( 1 ) ;
224224 } ) ;
225+ it ( "getImageUrl, clipRegion_grojson" , ( ) => {
226+ const tempOptions = {
227+ clipRegion :{ "type" :"Feature" , "properties" :{ } , "geometry" :{ "type" :"Polygon" , "coordinates" :[ [ [ 20 , - 20 ] , [ 20 , 0 ] , [ 40 , 0 ] , [ 40 , - 20 ] , [ 20 , - 20 ] ] ] } } ,
228+ clipRegionEnabled :true
229+ } ;
230+ const imageMapLayerObject = imageMapLayer ( url , tempOptions ) . addTo ( map ) ;
231+ expect ( imageMapLayerObject ) . not . toBeNull ( ) ;
232+ const tileUrl = imageMapLayerObject . getImageUrl ( L . point ( 1 , 4 ) ) ;
233+ const clipRegionEnabledValue = getQueryValue ( tileUrl , 'clipRegionEnabled' ) ;
234+ expect ( clipRegionEnabledValue ) . toBeTruthy ( ) ;
235+ const clipRegionValue = getQueryValue ( tileUrl , 'clipRegion' ) ;
236+ expect ( clipRegionValue ) . not . toBeNull ;
237+ const clipRegionParameter = JSON . parse ( decodeURIComponent ( clipRegionValue ) ) ;
238+ expect ( clipRegionParameter . parts [ 0 ] ) . toBe ( 5 ) ;
239+ expect ( clipRegionParameter . points . length ) . toBe ( 5 ) ;
240+ expect ( clipRegionParameter . points [ 0 ] . x ) . toBe ( 20 ) ;
241+ expect ( clipRegionParameter . points [ 0 ] . y ) . toBe ( - 20 ) ;
242+ expect ( clipRegionParameter . points [ 4 ] . x ) . toBe ( 20 ) ;
243+ expect ( clipRegionParameter . points [ 4 ] . y ) . toBe ( - 20 ) ;
244+ } ) ;
245+ it ( "getImageUrl, clipRegion_polygon" , ( ) => {
246+ const tempOptions = {
247+ clipRegion :L . polygon ( [ [ - 20 , 20 ] , [ 0 , 20 ] , [ 0 , 40 ] , [ - 20 , 40 ] , [ - 20 , 20 ] ] , { color : 'red' } ) ,
248+ clipRegionEnabled :true
249+ } ;
250+ const imageMapLayerObject = imageMapLayer ( url , tempOptions ) . addTo ( map ) ;
251+ expect ( imageMapLayerObject ) . not . toBeNull ( ) ;
252+ const tileUrl = imageMapLayerObject . getImageUrl ( L . point ( 1 , 4 ) ) ;
253+ const clipRegionEnabledValue = getQueryValue ( tileUrl , 'clipRegionEnabled' ) ;
254+ expect ( clipRegionEnabledValue ) . toBeTruthy ( ) ;
255+ const clipRegionValue = getQueryValue ( tileUrl , 'clipRegion' ) ;
256+ expect ( clipRegionValue ) . not . toBeNull ;
257+ const clipRegionParameter = JSON . parse ( decodeURIComponent ( clipRegionValue ) ) ;
258+ expect ( clipRegionParameter . parts [ 0 ] ) . toBe ( 5 ) ;
259+ expect ( clipRegionParameter . points . length ) . toBe ( 5 ) ;
260+ expect ( clipRegionParameter . points [ 0 ] . x ) . toBe ( 20 ) ;
261+ expect ( clipRegionParameter . points [ 0 ] . y ) . toBe ( - 20 ) ;
262+ expect ( clipRegionParameter . points [ 4 ] . x ) . toBe ( 20 ) ;
263+ expect ( clipRegionParameter . points [ 4 ] . y ) . toBe ( - 20 ) ;
264+ } ) ;
225265
226266} ) ;
0 commit comments