22// Distributed under the terms of the Modified BSD License.
33
44const L = require ( '../leaflet.js' ) ;
5- const imageoverlay = require ( './ImageOverlay .js' ) ;
5+ const rasterlayer = require ( './RasterLayer .js' ) ;
66const proj = require ( '../projections.js' ) ;
77
8- export class LeafletImageServiceLayerModel extends imageoverlay . LeafletImageOverlayModel {
8+ export class LeafletImageServiceLayerModel extends rasterlayer . LeafletRasterLayerModel {
99 defaults ( ) {
1010 return {
1111 ...super . defaults ( ) ,
@@ -19,21 +19,21 @@ export class LeafletImageServiceLayerModel extends imageoverlay.LeafletImageOver
1919 // data type of the raster image
2020 pixel_type : 'F32' ,
2121 // pixel value or list of pixel values representing no data
22- no_data : null ,
22+ no_data : [ ] ,
2323 // how to interpret no data values
2424 no_data_interpretation : '' ,
2525 // resampling process for interpolating the pixel values
2626 interpolation : '' ,
2727 // lossy quality for image compression
2828 compression_quality : '' ,
2929 // order of bands to export for multiple band images
30- band_ids : null ,
30+ band_ids : [ ] ,
3131 // time instance or extent for image
32- time : null ,
32+ time : [ ] ,
3333 // rules for rendering
34- rendering_rule : null ,
34+ rendering_rule : { } ,
3535 // rules for mosaicking
36- mosaic_rule : null ,
36+ mosaic_rule : { } ,
3737 // image transparency
3838 transparent : false ,
3939 // coordinate reference system
@@ -44,10 +44,10 @@ export class LeafletImageServiceLayerModel extends imageoverlay.LeafletImageOver
4444 }
4545}
4646
47- export class LeafletImageServiceLayerView extends imageoverlay . LeafletImageOverlayView {
47+ export class LeafletImageServiceLayerView extends rasterlayer . LeafletRasterLayerView {
4848 create_obj ( ) {
4949 this . model . _url = this . model . get ( 'url' ) + '/exportImage' + this . buildParams ( )
50- this . model . _bounds = this . _map . getBounds ( )
50+ this . model . _bounds = this . get_bounds ( )
5151 this . obj = L . ImageOverlay ( this . model . _url , this . model . _bounds )
5252 }
5353
@@ -56,13 +56,38 @@ export class LeafletImageServiceLayerView extends imageoverlay.LeafletImageOverl
5656 for ( var option in this . get_options ( ) ) {
5757 this . _map . on ( 'change:' + option , ( ) => {
5858 this . model . _url = this . model . get ( 'url' ) + '/exportImage' + this . buildParams ( )
59- this . model . _bounds = this . _map . getBounds ( )
59+ this . model . _bounds = this . get_bounds ( )
60+ this . obj . setUrl ( this . model . _url ) ;
61+ this . obj . setBounds ( this . model . _bounds ) ;
6062 this . refresh ( ) ;
6163 } ) ;
62- }
64+ } ;
65+ this . _map . on ( 'moveend' , ( ) => {
66+ this . model . _url = this . model . get ( 'url' ) + '/exportImage' + this . buildParams ( )
67+ this . model . _bounds = this . get_bounds ( )
68+ this . obj . setUrl ( this . model . _url ) ;
69+ this . obj . setBounds ( this . model . _bounds ) ;
70+ this . refresh ( ) ;
71+ } )
72+ }
73+
74+ get_bbox ( ) {
75+ return [ this . _map . getBounds ( ) . getWest ( ) ,
76+ this . _map . getBounds ( ) . getSouth ( ) ,
77+ this . _map . getBounds ( ) . getEast ( ) ,
78+ this . _map . getBounds ( ) . getNorth ( ) ]
79+ }
80+
81+ get_bounds ( ) {
82+ return [ [ map . getBounds ( ) . getSouth ( ) , map . getBounds ( ) . getWest ( ) ] ,
83+ [ map . getBounds ( ) . getNorth ( ) , map . getBounds ( ) . getEast ( ) ] ]
84+ }
85+
86+ get_size ( ) {
87+ return [ this . _map . getSize ( ) . x , this . _map . getSize ( ) . y ]
6388 }
6489
65- model_epsg ( ) {
90+ get_epsg ( ) {
6691 // get the EPSG code of the current map
6792 var crs = proj . getProjection ( this . model . get ( 'crs' ) )
6893 var spatial_reference = parseInt ( crs . code . split ( ':' ) [ 1 ] , 10 ) ;
@@ -72,10 +97,10 @@ export class LeafletImageServiceLayerView extends imageoverlay.LeafletImageOverl
7297 buildParams ( ) {
7398 // parameters for image server query
7499 var params = {
75- bbox : this . _map . getBounds ( ) ,
76- size : this . _map . getSize ( ) ,
100+ bbox : this . get_bbox ( ) ,
101+ size : this . get_size ( ) ,
77102 bboxSR : 4326 ,
78- imageSR : this . model_epsg ( ) ,
103+ imageSR : this . get_epsg ( ) ,
79104 ...this . get_options ( )
80105 } ;
81106 // merge list parameters
0 commit comments