|
232 | 232 | */ |
233 | 233 |
|
234 | 234 | // Raise an alert in case of non-native output-CRS applied for referenceable data-sets. |
235 | | - |
236 | 235 | var cbx_list = this.$("#download-list").find('input[type="checkbox"]') ; |
237 | | - |
238 | 236 | if (options.outputCRS) { |
239 | 237 | var refds_count = 0; |
240 | 238 | cbx_list.each(_.bind(function(index) { |
|
250 | 248 | } |
251 | 249 | } |
252 | 250 |
|
| 251 | + // raise an alert in case of JP2000 requests |
| 252 | + if (options.format == 'image/jp2') |
| 253 | + { |
| 254 | + window.alert("JP2000 download is limited to 8bit Grayscale or RGB imagery. The number of bands is therefore "+ |
| 255 | + "reduced to 1 or 3. 12 or 16bits output is not supported. \nThe current draft of the WCS JP2000 encoding specification "+ |
| 256 | + "does not define a way how to pass any encoding parameters (e.g., quality factor). The imagery is encoded using the "+ |
| 257 | + "server default values."); |
| 258 | + } |
| 259 | + |
| 260 | + // JP2000 RGB range subsetting |
| 261 | + var _jp2_rgb = function(rtlist){ |
| 262 | + if (!rtlist.length) { return rtlist; } |
| 263 | + if (rtlist.length < 3) { return [rtlist[0]]; } |
| 264 | + |
| 265 | + //Try to interpret the range-type. |
| 266 | + var idx_red = rtlist.indexOf('Red'); |
| 267 | + var idx_green = rtlist.indexOf('Green'); |
| 268 | + var idx_blue = rtlist.indexOf('Blue'); |
| 269 | + var idx_nir = rtlist.indexOf('NIR'); |
| 270 | + |
| 271 | + if ((idx_blue >= 0) && (idx_green >= 0) && (idx_red >= 0)) { |
| 272 | + return ['Red', 'Green', 'Blue'] ; |
| 273 | + } |
| 274 | + |
| 275 | + if ((idx_nir >= 0) && (idx_green >= 0) && (idx_red >= 0)) { |
| 276 | + return ['NIR', 'Red', 'Green']; |
| 277 | + } |
| 278 | + |
| 279 | + // Fallback to the firts 3 bands. |
| 280 | + return [rtlist[0],rtlist[1],rtlist[2]]; |
| 281 | + } |
| 282 | + |
| 283 | + options.format = this.$("#select-output-format").val(); |
| 284 | + |
253 | 285 | cbx_list.each(_.bind(function(index) { |
254 | 286 | if (cbx_list[index].checked){ |
255 | 287 | var model = this.coverages.models[index]; |
256 | 288 | options.coverageSubtype = model.get('coverageSubtype'); |
| 289 | + if (options.format == 'image/jp2') |
| 290 | + options.rangeSubset = _jp2_rgb(_.map(model.get('rangeType'), function(rt) { return rt.name } )); |
| 291 | + else { |
| 292 | + options.rangeSubset = null ; |
| 293 | + } |
257 | 294 | var xml = getCoverageXML(model.get('coverageId'), options); |
258 | 295 | var owsUrl = model.get('url').split('?')[0]; |
259 | 296 | var $form = $(CoverageDownloadPostTmpl({url: owsUrl, xml: xml})); |
|
0 commit comments