Select to view content in your preferred language

WmtsService not working for airbusds

1377
10
Jump to solution
05-09-2022 10:09 AM
George
by
Occasional Contributor

I am using the following 

private val wmtsService: WmtsService by lazy { WmtsService("https://view.geoapi-airbusds.com/api/v1/map/imagery.wmts") }
val configuration = RequestConfiguration()
configuration.headers = mapOf(Pair("Authorization","Bearer $Bearer_Token"))

wmtsService.requestConfiguration = configuration
ArcGISRuntimeEnvironment.setLicense(getString(R.string.arcgis_licence_key))

wmtsService.customParameters["service"] = "WMTS"
wmtsService.customParameters["request"] = "GetTile"
wmtsService.customParameters["version"] = "1.0.0"
wmtsService.customParameters["style"] = "default"
wmtsService.customParameters["tilematrixset"] = "3857"
wmtsService.customParameters["Format"] = "image/jpeg"
wmtsService.customParameters["TileMatrix"] = "9"
wmtsService.customParameters["TileRow"] = "296"
wmtsService.customParameters["TileCol"] = "292"

// create a Map
val map = ArcGISMap()
// set the map to be displayed in this view
mapView.map = map


// display wmts data on the map
wmtsService.addDoneLoadingListener {
if (wmtsService.loadStatus == LoadStatus.LOADED) {
// get service info
val wmtsServiceInfo = wmtsService.serviceInfo
// get the first layers id
val layerInfos = wmtsServiceInfo.layerInfos
// create WMTS layer from layer info
val wmtsLayer = WmtsLayer(layerInfos[0])
// set the basemap of the map with WMTS layer
map.basemap = Basemap(wmtsLayer)
}
if (wmtsService.loadStatus == LoadStatus.FAILED_TO_LOAD){
Log.e("ARCGIS", "Load failed: ${wmtsService.loadError.cause}")
}
}

wmtsService.loadAsync()

 

But I cannot seem to load the satellite imagery from the service. I get a grid of grey squares from the interactive map view.

 

 

 

Not sure what I am doing wrong.  

 

 

0 Kudos
1 Solution

Accepted Solutions
George
by
Occasional Contributor

The to set requestConfiguration on the wmtsLayer

wmtsLayer.requestConfiguration = wmtsService.requestConfiguration

if (wmtsService.loadStatus == LoadStatus.LOADED) {
// get service info
val wmtsServiceInfo = wmtsService.serviceInfo
// get the first layers id
val layerInfos = wmtsServiceInfo.layerInfos
// create WMTS layer from layer info
val wmtsLayer = WmtsLayer(layerInfos[0])
// set the basemap of the map with WMTS layer
wmtsLayer.requestConfiguration = wmtsService.requestConfiguration
map.basemap = Basemap(wmtsLayer)
mapView.map = map
}

 Thanks @Nicholas-Furness  for the assistance

View solution in original post

0 Kudos
10 Replies
Nicholas-Furness
Esri Regular Contributor

One thought. Setting the map on the map view will proceed to load the map. Once its loaded, its spatial reference is fixed and I wonder, because you haven't set a basemap or a spatial reference, whether it's set to something that isn't the same as the WMTS layer. Tiled layers are not reprojected in Runtime so that could lead to you not being able to display the layer.

Can you try calling mapView.map = map right after you set map.basemap = Basemap(wmtsLayer)?

Or you could create the ArcGISMap with a spatial reference if you know what it should be: https://developers.arcgis.com/android/api-reference/reference/com/esri/arcgisruntime/mapping/ArcGISM...

Do either of those suggestions help?

0 Kudos
George
by
Occasional Contributor

This does not seem to work, is there a way to schedule a call, been at this for a couple of hours and have tried almost everything that the API allows. 

These parameters seem to be returning nulls 

val wmtsServiceInfo = wmtsService.serviceInfo
// get the first layers id
val layerInfos = wmtsServiceInfo.layerInfos
// create WMTS layer from layer info
val wmtsLayer = WmtsLayer(layerInfos[0])

 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

I assume that the wmtsService.loadStatus is LOADED and that there is no error reported?

If you would like to schedule a call, you should contact Esri Technical Support.

0 Kudos
George
by
Occasional Contributor

wmtsService.loadStatus is LOADED but on debugging the lines below they are all null 

val wmtsServiceInfo = wmtsService.serviceInfo
// get the first layers id
val layerInfos = wmtsServiceInfo.layerInfos
// create WMTS layer from layer info
val wmtsLayer = WmtsLayer(layerInfos[0])
// set the basemap of the map with WMTS layer
map.basemap = Basemap(wmtsLayer)
mapView.map = map
0 Kudos
PriyankaRupani
Esri Contributor

Hello,

The code you have looks okay, we have a similar sample here https://github.com/Esri/arcgis-runtime-samples-android/tree/main/java/wmts-layer 
which is using the WMTSService. The Wmts layer handles tile requests when rendering the layer.

I discussed this with a senior engineer and sharing her thoughts here:

"I think we need get more info from the user on the WMTS service.

Question1:
The user is setting 
configuration.headers = mapOf(Pair("Authorization","Bearer $Bearer_Token")) in the header. Seems like it is a secured service and the user is trying to authenticate through the header. We need to know what kind of authentication approach is configured on the service. And whether the setting of the header works..?

Question 2:
I think we also need to understand why the user sets the custom parameters. Any specific reason you need them to be set?"


0 Kudos
George
by
Occasional Contributor

@PriyankaRupani 

The service I am trying to get the satellite imagery from is the one below :

https://airbusgeo.github.io/geoapi-viewer/?url=https://airbusgeo.github.io/api-docs/view.yaml#!/Maps... 

The reason for adding the custom parameters is because of how the request needs to be structured.

The call would be Get call below :

/api/v1/map/imagery.wmts?layer={layer}&tilematrixset={tileSet}&Service=WMTS&Request=GetTile&Version=... 

Hope this clarifies some of the questions?

0 Kudos
MatveiStefarov
Esri Contributor

@George Have you tried HTTP Basic authentication instead of Bearer? The documentation of AirBus OneAtlas mentions that it is supported, with "APIKEY" for username and your key for the password.

Although I don't have access to the exact service you are using, I was able to access their trial data (at access.foundation.api.oneatlas.airbus.com) using ArcGIS Runtime and HTTP Basic authentication:

2022-05-10_101943.png

 

0 Kudos
George
by
Occasional Contributor

@MatveiStefarov 

is this airbus service compatible with the 

com.esri.arcgisruntime:arcgis-android

 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Matvei shows using an Airbus service with the Runtime SDKs above. We would need a suitable API Key to test the actual service you're using. That's not a key that's available through the Airbus OneAtlas Developer Portal, but if you could share one with me via DM we can try to test the specific service you are trying to access.

Two other suggestions:

1. Remove your headerConfiguration and all other customParameters and just try this one:

 

wmtsService.customParameters["APIKEY"] = "<Your OneAtlas Basemap API Key>"

 

2. Airbus publishes ArcGIS Services for the OneAtlas Basemap service. You could consider using one of those instead of the WMTS service, but of course you'd still need to authenticate.

0 Kudos