Select to view content in your preferred language

ArcGis corrupts URLs

1249
11
07-29-2022 03:25 AM
Karrok
by
Emerging Contributor
0 Kudos
11 Replies
TimDietz
Occasional Contributor

Is there a way you can start with a partial URL and then programmatically set the color_formula?

0 Kudos
Karrok
by
Emerging Contributor

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

0 Kudos
TimDietz
Occasional Contributor

Yes.  Try https://planetarycomputer.microsoft.com/api/data/v1/mosaic/tiles/7557a0b9c1e010154c6c34b5616ce374/We...

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.

0 Kudos
Karrok
by
Emerging Contributor

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

0 Kudos
TimDietz
Occasional Contributor

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."

0 Kudos
Karrok
by
Emerging Contributor

ok, but I'm sending a request not to "ArcGIS Online", right?

0 Kudos
TimDietz
Occasional Contributor

Yes, and that's why I said you might have to get the help from someone who does know this API.

0 Kudos
JohnGrayson
Esri Regular Contributor

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.

0 Kudos
JohnGrayson
Esri Regular Contributor

...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

0 Kudos