Select to view content in your preferred language

How to use dynamic workspaces correctly?

6153
8
Jump to solution
08-03-2012 11:10 AM
Jan-Tschada
Esri Contributor
I modified the "Dynamic Layers - Simple Renderer Sample" by using a LocalMapService and added a new WorkspaceInfo instance as dynamic workspace. After modifying the data source by using DynamicLayerInfo::setLayerSource and refreshing the layer by ArcGISDynamicMapServiceLayer::refresh, an EsriServiceException "Requested an image but received content type text. Either the token used to access this server has expired or the parameters of this request are invalid." occurs. The workspace is a copy of the unpacked usa.gdb from the package folder.

It would be nice to have a sample showing how to use dynamic workspaces.
Thanks in advance.



Modifed code:

private WorkspaceInfo workspaceInfo;  private JMap createMap() {         ...                  // Add a new workspace         LocalMapService mapService = new LocalMapService(getPathSampleData() + "MPKs/USCitiesStates.mpk");         mapService.setEnableDynamicLayers(true);         WorkspaceInfoSet dynamicWorkspaces = mapService.getDynamicWorkspaces();         workspaceInfo = new WorkspaceInfo("WORKSPACE", WorkspaceInfo.WorkspaceFactoryType.FILE_GDB, "DATABASE=C:/data/arcgis/USA/usa.gdb");         dynamicWorkspaces.add(workspaceInfo);         mapService.start();          dynamicLayer = new ArcGISDynamicMapServiceLayer(mapService.getUrlMapService());          ... }  private void render(Renderer<Graphic> renderer, int layerId) {         // Create new drawing info from our renderer, with set transparency         DrawingInfo drawingInfo = new DrawingInfo(renderer, TRANSPARENCY);          // Get the layerInfo from the dynamic layer and set the drawing info         DynamicLayerInfoCollection layerInfos = dynamicLayer.getDynamicLayerInfos();         DynamicLayerInfo layerInfo = layerInfos.get(layerId);         layerInfo.setDrawingInfo(drawingInfo);                   TableDataSource tableDataSource = new TableDataSource();         tableDataSource.setWorkspaceId(workspaceInfo.getId());         tableDataSource.setDataSourceName("Cities");          LayerDataSource layerDataSource = new LayerDataSource();         layerDataSource.setDataSource(tableDataSource);         layerInfo.setLayerSource(layerDataSource);          // Refresh the layer         dynamicLayer.refresh();     }
Product Manager
Developers and Location Services
Germany and Switzerland
0 Kudos
1 Solution

Accepted Solutions
EricBader
Honored Contributor
Hello Jan.

This is something the team is still working on at the moment. So your approach will not work with Java + accerated display at 1.0 Final.
Please stay tuned, the team is working on fixing it.

View solution in original post

0 Kudos
8 Replies
EricBader
Honored Contributor
Hello Jan.

This is something the team is still working on at the moment. So your approach will not work with Java + accerated display at 1.0 Final.
Please stay tuned, the team is working on fixing it.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
What is the status of this functionality? Has it being implemented in 10.1.1?
0 Kudos
EliseAcheson1
Deactivated User
Hi,

Yes this works at 10.1.1. The samples showing a simple dynamic workspace functionality workflow are in the sample app under 'Datasources' called 'Add Raster' and 'Add Shapefile'.

Note I've also just given Jan's code above a spin, i.e. modifying the Dynamic Layers 'Simple Renderer' sample, and that workflow works nicely as well. By switching one of the mpk layers to point to a local shp file instead, the 'render' button displayed/udpated my local shapefile's renderer, in my case instead of the 'states' layer. (Note that I used WorkspaceInfo.CreateShapefileFolderConnection("WORKSPACE", "c:/data/shapefile") to create the workspaceInfo in my test code, and I put my actual shp file name in tableDataSource.setDataSourceName("MyShapefile").)

~elise
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
Thanks for responding, Elise.

This works at 10.1.1. The samples showing a simple dynamic workspace functionality workflow are in the sample app under 'Datasources' called 'Add Raster' and 'Add Shapefile'.


I am aware of those two sample code source files, but neither use a geodatabase as data source for workspace, as shown on the desired code that J.T. posted.

I've also just given Jan's code above a spin, i.e. modifying the Dynamic Layers 'Simple Renderer' sample, and that workflow works nicely as well. By switching one of the mpk layers to point to a local shp file instead, the 'render' button displayed/udpated my local shapefile's renderer, in my case instead of the 'states' layer. (Note that I used WorkspaceInfo.CreateShapefileFolderConnection("WORKSPACE", "c:/data/shapefile") to create the workspaceInfo in my test code, and I put my actual shp file name in tableDataSource.setDataSourceName("MyShapefile").)


Your modifications to J.T.'s code shy away from using geodatabase connection, which makes it similar to the code on the examples. The examples make mention of geodatabase connection capability for obtaining data source for work-spaces, but I can't find any sample code to demonstrate this.
0 Kudos
EliseAcheson1
Deactivated User
Hi Carlos,

Apologies for not being more specific. We didn't quite get this right at 1.0 so I assumed the post was about the dynamic workspaces in general.

Just to confirm that yes this workflow works with a file geodatabase and the other workspace factory types (see the static WorkspaceInfo creation methods and also WorkspaceFactoryType enum).

The change in code in this case would be one line:

workspaceInfo = WorkspaceInfo.CreateFileGeoDatabaseConnection("WORKSPACE", "c:/data/ArcObjectsData/portland/portland.gdb");


(where I have the portland.gdb file gdb at the location in the code, and "WORKSPACE" is an arbitrary String since when I create the TableDataSource I retrieve this name programatically).

Plus you also need to make sure that the data source name is correct/exists in the gdb. In my case for example:

tableDataSource.setDataSourceName("Zones");


cheers,

~elise
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
After further investigation and Esri support, I've learned that using work spaces to connect to geodatabases for adding rasters to mosaic data sets is not currently supported. Using work spaces to add data for display is temporary only for the current session, and persistence can only be achieved by continually loading the data per session which is not efficient. I've attempted to use a geoprocessing package containing the "AddRastersToMosaicDataset" tool with package scheme only and ArcGIS Runtime support, only to find that the tool "is not licensed for use in an ArcGIS Runtime package."

The given explanation was that ArcGIS Runtime's workflow was primarily designed to "consume" services rather maintaining its own locally. While I agree with its primary functions in support of other ArcGIS software and services, I believe that, as part of its disconnected capabilities, this capability will support the need of many existing customers, primarily in the defense and intelligence community, as well as bring more customers to Esri's door steps.

I recommend that the "AddRastersToMosaicDataset" and "RemoveRastersFromMosaicDataset" tools be licensed for use in an ArcGIS Runtime package at minimum.
0 Kudos
GeneLege
Deactivated User
I can add that while we do not support this capability in our current software, it is one that is highly requested, and on our roadmap.

True, initially, we will primarily focus on adding support for consuming mosaic datasets, but our users will want the ability to add to an existing mosaic as well, and we will need to be able to leverage geoprocessing, or some more direct api, to do so.

In general, I must agree with Carlos that limiting the capabilities of local gpk packages is a particularly pain point in moving to Runtime sdk from Engine.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
In general, I must agree with Carlos that limiting the capabilities of local gpk packages is a particularly pain point in moving to Runtime sdk from Engine.


Thanks, Gene. If you and any user supports this idea, please go to the Esri ArcGIS Ideas site and promote my suggestion here.
0 Kudos