Skip to content

Commit

Permalink
fix: update params for snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutterley committed Mar 3, 2022
1 parent 337705e commit 74e40a3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 62 deletions.
32 changes: 17 additions & 15 deletions ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,25 +769,27 @@ class ImageServiceLayer(ImageOverlay):
----------
url: string, default ""
Url to the image service.
f: string, default "image"
response format (use `'image'` to stream as bytes)
format: string, default "png"
format of exported image (use `'png'` for layers with transparency)
pixelType: string, default "F32"
pixel_type: string, default "F32"
data type of the raster image
noData: list, default []
no_data: list, default []
pixel value or comma-delimited list of pixel values representing no data
noDataInterpretation: string, default ""
no_data_interpretation: string, default ""
how to interpret no data values
interpolation: string, default ""
resampling process for interpolating the pixel values
compressionQuality: int, default 100
compression_quality: int, default 100
lossy quality for image compression
bandIds: string, default ""
band_ids: List, default []
Order of bands to export for multiple band images
time: List, default None
time: List, default []
time instance or extent for image
renderingRule: dict, default {}
rendering_rule: dict, default {}
rules for rendering
mosaicRule: dict, default {}
mosaic_rule: dict, default {}
rules for mosaicking
transparent: boolean, default False
If true, the image service will return images with transparency
Expand All @@ -801,15 +803,15 @@ class ImageServiceLayer(ImageOverlay):
url = Unicode().tag(sync=True)
f = Unicode('image').tag(sync=True, o=True)
format = Unicode('png').tag(sync=True, o=True)
pixelType = Unicode(default_value="F32", allow_none=True).tag(sync=True, o=True)
noData = List(allow_none=True).tag(sync=True, o=True)
noDataInterpretation = Unicode().tag(sync=True, o=True)
pixel_type = Unicode(default_value="F32", allow_none=True).tag(sync=True, o=True)
no_data = List(allow_none=True).tag(sync=True, o=True)
no_data_interpretation = Unicode().tag(sync=True, o=True)
interpolation = Unicode().tag(sync=True, o=True)
compressionQuality = Unicode().tag(sync=True, o=True)
bandIds = Unicode().tag(sync=True, o=True)
compression_quality = Unicode().tag(sync=True, o=True)
band_ids = List(allow_none=True).tag(sync=True, o=True)
time = List(allow_none=True).tag(sync=True, o=True)
renderingRule = Dict({}).tag(sync=True, o=True)
mosaicRule = Dict({}).tag(sync=True, o=True)
rendering_rule = Dict({}).tag(sync=True, o=True)
mosaic_rule = Dict({}).tag(sync=True, o=True)
transparent = Bool(False).tag(sync=True, o=True)
crs = Dict(default_value=projections.EPSG3857).tag(sync=True)
_url = Unicode().tag(sync=True)
Expand Down
82 changes: 35 additions & 47 deletions js/src/layers/ImageServiceLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,31 @@ export class LeafletImageServiceLayerModel extends imageoverlay.LeafletImageOver
_view_name: 'LeafletImageServiceLayerView',
_model_name: 'LeafletImageServiceLayerModel',
url: '',
// response format
f: 'image',
// output image format
format: 'png',
pixelType: 'F32',
noData: null,
noDataInterpretation: '',
// data type of the raster image
pixel_type: 'F32',
// pixel value or list of pixel values representing no data
no_data: null,
// how to interpret no data values
no_data_interpretation: '',
// resampling process for interpolating the pixel values
interpolation: '',
compressionQuality: '',
bandIds: null,
// lossy quality for image compression
compression_quality: '',
// order of bands to export for multiple band images
band_ids: null,
// time instance or extent for image
time: null,
renderingRule: null,
mosaicRule: null,
// rules for rendering
rendering_rule: null,
// rules for mosaicking
mosaic_rule: null,
// image transparency
transparent: false,
// coordinate reference system
crs: null,
_url: '',
_bounds: null,
Expand Down Expand Up @@ -57,55 +70,30 @@ export class LeafletImageServiceLayerView extends imageoverlay.LeafletImageOverl
}

buildParams () {
// required parmeters for query
// parameters for image server query
var params = {
f: this.model.get('f'),
format: this.model.get('format'),
bbox: this._map.getBounds(),
size: this._map.getSize(),
bboxSR: 4326,
imageSR: this.model_epsg()
imageSR: this.model_epsg(),
...this.get_options()
};
// append optional parameters
// image transparency
if (this.model.get('transparent')) {
params.transparent = this.model.get('transparent');
// merge list parameters
if (params['noData']) {
params['noData'] = params['noData'].join(',');
}
// data type of the raster image
if (this.model.get('pixelType')) {
params.pixelType = this.model.get('pixelType');
if (params['bandIds']) {
params['bandIds'] = params['bandIds'].join(',');
}
// pixel value or list of pixel values representing no data
if (this.model.get('noData')) {
params.noData = this.model.get('noData').join(',');
if (params['time']) {
params['time'] = params['time'].join(',');
}
// how to interpret no data values
if (this.model.get('noDataInterpretation')) {
params.noDataInterpretation = this.model.get('noDataInterpretation');
// convert dictionary parameters to JSON
if (params['renderingRule']) {
params['renderingRule'] = JSON.stringify(params['renderingRule']);
}
// resampling process for interpolating the pixel values
if (this.model.get('interpolation')) {
params.interpolation = this.model.get('interpolation');
}
// lossy quality for image compression
if (this.model.get('compressionQuality')) {
params.compressionQuality = this.model.get('compressionQuality');
}
// order of bands to export for multiple band images
if (this.model.get('bandIds')) {
params.bandIds = this.model.get('bandIds').join(',');
}
// time instance or extent for image
if (this.model.get('time')) {
params.time = this.model.get('time').join(',');
}
// rules for rendering
if (this.model.get('renderingRule')) {
params.renderingRule = JSON.stringify(this.model.get('renderingRule'));
}
// rules for mosaicking
if (this.model.get('mosaicRule')) {
params.mosaicRule = JSON.stringify(this.model.get('mosaicRule'));
if (params['mosaicRule']) {
params['mosaicRule'] = JSON.stringify(params['mosaicRule']);
}
// return the formatted query string
return L.Util.getParamString(params);
Expand Down

0 comments on commit 74e40a3

Please sign in to comment.