Hi guys…
I’m in trouble trying to call a request using VERSION 3 of a evalscript in a multipart-formdata POST
Bellow, follow my inputs and the response from Service. Could you help me with this issue?
request:
{“input”:{“bounds”:{“bbox”:[-53.4124684384803,-19.0388663330172,-53.4122684384803,-19.0386663330172]},“data”:[{“type”:“S2L2A”,“dataFilter”:{“timeRange”:{“from”:“2018-11-01T00:00:00Z”,“to”:“2018-11-28T00:00:00Z”}}}]},“output”:{“width”:10,“height”:10,“responses”:[{“identifier”:“idx0”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx1”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx2”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx3”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx4”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx5”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx6”,“format”:{“type”:“image/tiff”}},{“identifier”:“idx7”,“format”:{“type”:“image/tiff”}},{“identifier”:“userdata”,“format”:{“type”:“application/json”}}]}}
evalscript:
//VERSION=3
function setup() {return { input: [{ bands: [“B02”, “B03”, “B04”, “B08”], units: “DN” }],
output: [
{ id: “idx0”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx1”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx2”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx3”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx4”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx5”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx6”, bands: 4, sampleType: SampleType.UINT16 },
{ id: “idx7”, bands: 4, sampleType: SampleType.UINT16 }],
mosaicking: Mosaicking.ORBIT } }
function updateOutputMetadata(scenes, inputMetadata, outputMetadata) { outputMetadata.userData = { “metadata”: JSON.stringify(scenes) } }
function evaluatePixel (sample) {return {
idx0: [sample[0].B02, sample[0].B03, sample[0].B04, sample[0].B08],
idx1: [sample[1].B02, sample[1].B03, sample[1].B04, sample[1].B08],
idx2: [sample[2].B02, sample[2].B03, sample[2].B04, sample[2].B08],
idx3: [sample[3].B02, sample[3].B03, sample[3].B04, sample[3].B08],
idx4: [sample[4].B02, sample[4].B03, sample[4].B04, sample[4].B08],
idx5: [sample[5].B02, sample[5].B03, sample[5].B04, sample[5].B08],
idx6: [sample[6].B02, sample[6].B03, sample[6].B04, sample[6].B08],
idx7: [sample[7].B02, sample[7].B03, sample[7].B04, sample[7].B08] } }
response:
“error”: {
"status": 400,
"reason": "Bad Request",
"message": "Failed to evaluate script!\nevalscript.js:24: TypeError: Cannot read property 'B02' of undefined\nidx6: [sample[6].B02, sample[6].B03, sample[6].B04, sample[6].B08],\n ^\nTypeError: Cannot read property 'B02' of undefined\n at evaluatePixel (evalscript.js:24:17)\n at executeForMultipleScenes (<anonymous>:1004:14)\n",
"code": "RENDERER_EXCEPTION"
}