geometalab / ArcGISConnector-QGIS-Plugin

"ArcGIS REST API Connector" (beta) - a QGIS-Plugin which reads "Feature Service" and "Map Service" - aka WFS- and WMTS-alike services - from ArcGIS Online or ArcGIS Server.
http://giswiki.hsr.ch/QGIS_ArcGIS_REST_API_Connector_Plugin
27 stars 7 forks source link

Adding an ArcGIS Dynamic Map services does not preserve styling #8

Open mhogeweg opened 9 years ago

mhogeweg commented 9 years ago

In an ArcGIS Dynamic Map service, the author chooses cartography, scale-dependent rendering of layers, labeling etc. When adding an ArcGIS Dynamic Map service using the plugin, the styling is lost. This may be verified with: http://geoss.esri.com/arcgis/rest/services/WorldBackGroundGrey/MapServer

sfkeller commented 9 years ago

I don't understand the issue: This plugin does not support styling based client requests. But to my understanding ArcGIS Dynamic Map services always have a default styling attached since the raster map response needs to be generated anyhow. Pls. clarify.

mhogeweg commented 9 years ago

the example service above is not a raster map service with precooked tiles. it is dynamic in the sense that client applications can show/hide layers, do identify operations, and (depending on how the publisher configured the service) even allow modifying styling. all this handled through basic REST call to the service like this example:

http://geoss.esri.com/arcgis/rest/services/WorldBackGroundGrey/MapServer/export?bbox=-201.94247790675956,-94.83849562389014,194.05752264644622,97.46681437927066

notice I'm not submitting any layer ids or such and the service still draws all of them with the styling I defined in this particular service. as you zoom in you'll notice the major rivers disappear at some point:

compare: http://geoss.esri.com/arcgis/rest/services/WorldBackGroundGrey/MapServer/export?dpi=96&transparent=true&format=png8&bbox=-3.4050263481304324%2C45.20685937488983%2C17.287878217291983%2C59.837389555911145&bboxSR=4326&imageSR=4326&size=768%2C543&f=image

with: http://geoss.esri.com/arcgis/rest/services/WorldBackGroundGrey/MapServer/export?dpi=96&transparent=true&format=png8&bbox=0.25934216866311655%2C48.88469983475983%2C10.605794451374333%2C56.19996492527049&bboxSR=4326&imageSR=4326&size=768%2C543&f=image

same request, only different is the bounding extent (and resulting from that the map scale).

sfkeller commented 9 years ago

I understand that there are no precooked tiles; to me it's like an OGC WMS. But I still can't follow what you expect from the plugin, which styling is "lost" and which of the parameters of the examples above are styling parameters.

mhogeweg commented 9 years ago

more illustrated example using my local SampleWorldCities service.

this is how it shows in a browser using the ArcGIS JS API (all just making the simple REST calls illustrated above):

sampleworldcities js api

Adding this service to ArcMap gives the same styling:

sampleworldcities arcmap

but adding this service to QGIS results in improper layer order (backward, see #7) and with incorrect styling:

sampleworldcities qgis

sfkeller commented 9 years ago

I see. What is then the difference to issue #7 ?

mhogeweg commented 9 years ago

7 is just about the layer order (they're upside down, in the above, the cities should be on top, not on the bottom). #8 (this issue) is about the styling. I see them as separate issues.

sfkeller commented 9 years ago

Ok. But where is the styling parameter in the URL examples you gave? What should the plugin do?

mhogeweg commented 9 years ago

that's the beauty of Dynamic Map Services: you don't have to provide the styling since that is already defined in the service itself.

I was playing with adding a dynamic map service in QGIS myself. This works except for capturing the signal to redraw when the map extent changes. I'll send you the full code, but here's a snippet (note the server is my laptop, so replace that with a public service URL):

    fileName = 'http://hogeweg.esri.com/arcgis/rest/services/SampleWorldCities/MapServer/export?dpi=96&transparent=true&format=png8&bboxSR=4326&imageSR=4326&f=image'
    fileInfo = QFileInfo(fileName)
    baseName = fileInfo.baseName()
    canvasSize = qgis.utils.iface.mapCanvas().size()
    canvasWidth = canvasSize.width()
    canvasHeight = canvasSize.height()
    canvasExtent = qgis.utils.iface.mapCanvas().extent()

    agsbbox = str('&bbox=%d,%d,%d,%d' % (canvasExtent.xMinimum(), canvasExtent.yMinimum(),canvasExtent.xMaximum(),canvasExtent.yMaximum()))
    agssize = str('&size=%s,%s' % (canvasWidth,canvasHeight))
    fileName += agsbbox
    fileName += agssize

    rlayer = qgis.core.QgsRasterLayer(fileName, baseName)
    rlayer.setCrs(qgis.core.QgsCoordinateReferenceSystem(4326, qgis.core.QgsCoordinateReferenceSystem.EpsgCrsId) )
    qgis.core.QgsMapLayerRegistry.instance().addMapLayer(rlayer)
ajturner commented 9 years ago

This should support both the predefined styling in the service as well as user defined styling at query time.