ArcGisMapServerImageryProvider format doesn't appear to be configurable

1. A concise explanation of the problem you're experiencing.
I need to use an ArcGisMapServerImageryProvider where the format query parameter is png32.

The hard coded format in the code seems to be png. See: https://github.com/AnalyticalGraphicsInc/cesium/blob/1.59/Source/Scene/ArcGisMapServerImageryProvider.js#L265

If I add format to the resource queryParameters it is ignored due to the above code. I would have expected you could override the 'default' queryparam values with queryparams in resource?

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
Try changing the format used here: https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=ArcGIS%20MapServer.html

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
The png data for this MapServer (non-public, or I'd link it) is not valid, but the png32 data works perfectly.

4. The Cesium version you're using, your operating system and browser.
1.59

Thanks for reporting this! I can see that there’s a call to resource.getDerivedResource (https://cesiumjs.org/Cesium/Build/Documentation/Resource.html?classFilter=Resour#getDerivedResource) which has a “preserveQueryParameters” that defaults to false. I wonder if this should be true instead here.

If that works, it’d be awesome to make a pull request to contribute this to CesiumJS! See the contributing guide here for tips on that https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md#opening-a-pull-request

Hi Omar,

Thanks for your response. It doesn’t appear that changing preserveQueryParameters between true and false does anything.

Either way, the queryParameters specified in the above linked LOC are merged over the top of the queryParameters in the resource.

If I add ‘&format=test’ to the url string, and add {format: “some_other_value”} to the queryParameters arg on the Resource object, then I end up with an array of both listed for ‘format’ on the resource as expected.

Once “resource = imageryProvider._resource.getDerivedResource()” is run however, the format arg is replaced with “png” only, regardless of whether preserveQueryParameters is true or false.

It looks like ‘preserveQueryParameters’ doesn’t work properly if queryParameters are passed through to the getDerivedResource() function, unless I’m missing something…

Could this be an issue with preserveQueryParameters?

Kind Regards,

Scott

I think I see what you mean here. The preserve parameter seems to only work as expected if the query parameters are in the URL, and not when it’s passed as a queryParameters object. So this code example works as expected I think:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var resource = new Cesium.Resource({

url: 'https://example.com',

queryParameters: {'key': 'value'}

});

var derivedResource = resource.getDerivedResource({

url: 'https://example.com?key=newValue',

preserveQueryParameters: true

});

console.log(resource.url);//https://example.com?key=value

console.log(derivedResource.url);//https://example.com?key=newValue&key=value

``

You can see the derived resource has the original value at the end of the list. As opposed to this example where it is replaced:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var resource = new Cesium.Resource({

url: 'https://example.com',

queryParameters: {'key': 'value'}

});

var derivedResource = resource.getDerivedResource({

url: 'https://example.com',

queryParameters: {'key': 'newValue'},

preserveQueryParameters: true

});

console.log(resource.url);//https://example.com?key=value

console.log(derivedResource.url);//https://example.com?key=newValue

``

So we’d need to fix both this bug, and then set preserveQueryParameters to true in the ArcGIS imagery provider. To confirm that would fix this issue you could set preserve to true and add the format parameter to the url in the getDerivedResource call.