sentinel-hub/custom-scripts

Issues using EvalScript Parameter

moussmo opened this issue · 3 comments

Hello,

I am currently working on a project in which I am using Sentinel Hub 2 WMS URLs. I need to point out that I am very noob in web development.

In my project, I use I have a small interface allowing the user to choose 3 bands to allocate to the RGB Bands (juste like in the Sentinel Hub Playground custom tool). Using HTML and JavaScript, I collect the data from the interface and create a variable for the custom Eval Script according to the basic script style (return [ 2.5*B01...).

I then set this variable as the parameter 'EVALSCRIPT' of the URL:
_source.getParams()['EVALSCRIPT']=_customScript;

This doesn't seem to work.

On the other hand, using the parameter EVALSCRIPTURL seems to work if I give it the URL to a JS file containing the script:
_source.getParams()['EVALSCRIPTURL']='https://geobretagne.fr/apps/sentinel/customcontrols/evalscript.js';

For various reasons, I need to use the EVALSCRIPT parameter and not the EVALSCRIPTURL one. Do you have an idea why isn't it working ? Or is my understanding of the EVALSCRIPT parameter wrong ?

Thank you.

EVALSCRIPT parameter has to be BASE64 encoded before you pass it to the service.
Try first doing it manually, e.g. by using this app:
https://www.base64encode.org/
Once you see the concept, you should be able to find a base64 encoder function in more or less any programming language you use.

I just tried it, it worked !
That information was nowhere to be found on Sentinel Hub Website.
Thanks a lot for your help.

Hi.
May I just add that evalscript, evalscripturl and some other parameters are custom URL parameters, so they are not included in the documentation for WMS requests, but in a separate "chapter" - https://www.sentinel-hub.com/develop/documentation/api/custom-url-parameters

Wish you well.