How can I send a request "as is" without additional URL encoding?
Example:
Correct request -
Corrupted request - https://planetarycomputer.microsoft.com/api/data/v1/mosaic/tiles/7557a0b9c1e010154c6c34b5616ce374/We...
CodePen:
Is there a way you can start with a partial URL and then programmatically set the color_formula?
What do you mean by "start with partial"? Did you try to open the correct link with and without color_formula?
If it's possible to apply the coloring setting "on the fly" somewhere in fetchTile, please show me how to do it.
Also, I assume that applying such changes for each tile will have poor performance
I do not work with this API so I can't show you. I am just throwing out possibilities. You might have to get the help from someone who does know this API.
As for me with and without color_formula tile looks totally different.
The question is why arcgis request performs url encoding, I need to skip it, try to run a simple plain JS -
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'https://planetarycomputer.microsoft.com/api/data/v1/mosaic/tiles/7557a0b9c1e010154c6c34b5616ce374/WebMercatorQuad/10/174/408@1x.png?pixel_selection=first&assets=red&assets=green&assets=blue&collection=landsat-c2-l2&color_formula=gamma+RGB+2.7%2C+saturation+1.5%2C+sigmoidal+RGB+15+0.55');
httpRequest.send();
correct tile will be loaded, no errors, no url encoding
From https://doc.arcgis.com/en/arcgis-online/reference/use-url-parameters.htm
"All query parameters must be encoded. URL encoding ensures that valid characters are sent to ArcGIS Online. Encoding replaces invalid characters with % followed by their hex equivalent."
ok, but I'm sending a request not to "ArcGIS Online", right?
Yes, and that's why I said you might have to get the help from someone who does know this API.
I believe the issue is that the color_formula you're trying to use is already encoded. Using decodeURIComponents produces the following parameter:
gamma+RGB+2.7,+saturation+1.5,+sigmoidal+RGB+15+0.55
As shown in the previous example I would recommend you try to configure the base part of the url (before the ? char) and all the parameters separately so you have better control of the URL being requested.
...but that doesn't quite give us the final solution as those parameters still have undesired encoding of the '+' sign for spaces. Here's a code pen showing how to configure the parameters correctly:
https://codepen.io/john-grayson/pen/ExEozep