How can I send a request "as is" without additional URL encoding?
Example:
Correct request -
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
Corrupted request - 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%2BRGB%2B2.7%2C%2Bsaturation%2B1.5%2C%2Bsigmoidal%2BRGB%2B15%2B0.55
CodePen:
https://codepen.io/karrok/pen/bGvYKrg
I would recommend against the use of the interceptor for this use case. Just make sure you specify the parameters correctly and you can just extend the BaseTileLayer, which will help a lot as you try to use other parameters and options from these services. Using the interceptor to ignore improperly formatted URL parameters might lead to other issues as you try other settings.
I used a different solution - https://codepen.io/karrok/pen/OJvzeEx
I used
esriConfig.request.interceptors
and fetched tiles on my own
...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
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.
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
Yes. Try 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
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.
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
Is there a way you can start with a partial URL and then programmatically set the color_formula?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.