I created file geodatabase in Arc Map consisting of feature classes. These feature classes I want to access in ArcGIS Qt Runtime and see in application.
There is function EsriRuntimeQt::WorkspaceInfo::CreateFileGeoDatabaseConnection in ArcGis Qt Runtime, is this related to file geodatabase?
Yes, that static method should allow you to connect to a file geodatabase. You will need to use this in conjunction with Local Server in C++. I recommend you take a look at the Local Server > Shapefile sample and base your code off that.
I tried using this static method but not able to access layers present in file geodatabase(*.gdb). Can you please give more insight on how to achieve this in Qt SDK and also if possible any code snippets.
Bhargav, I have a couple of questions for you:
1. I am planning to read only file geodatabase, editing is not required.
2. When I tried using EsriRuntimeQt::WorkspaceInfo::CreateFileGeoDatabaseConnection, where to give layers name to load.
> 2. When I tried using EsriRuntimeQt::WorkspaceInfo::CreateFileGeoDatabaseConnection, where to give layers name to load.
What messages did you receive?
I used like this in my code..
// You can't modify the dynamic workspaces on a running local map service.
// get dynamic workspaces from service
EsriRuntimeQt::WorkspaceInfoSet& workspaceInfoSet = m_localMapService.dynamicWorkspaces();
// create a workspace info via the static method according to data type
// e.g. shapefile folder connection
//EsriRuntimeQt::WorkspaceInfo workspaceInfo = EsriRuntimeQt::WorkspaceInfo::CreateShapefileFolderConnection(m_workspaceId, fileDir);//shapefile
EsriRuntimeQt::WorkspaceInfo workspaceInfo = EsriRuntimeQt::WorkspaceInfo::CreateFileGeoDatabaseConnection(m_workspaceId, "/home/sau/Downloads/Sample.gdb");
// set dynamic workspaces for our local map service
catch (EsriRuntimeQt::Exception ex)
QMessageBox::warning(this, "Error", ex.what(), QMessageBox::Ok);
I am not getting messages for this part of code. When m_localMapService.start() is called onLocalServiceCreationSuccess() slot is called.
void ShapeFile::onLocalServiceCreationSuccess(const QString& url, const QString& name)
// // create the ArcGISDynamicMapServiceLayer using the LocalMapService's url
// m_dynamicLocalServiceLayer = new EsriRuntimeQt::ArcGISDynamicMapServiceLayer(m_localMapService.urlMapService(), this);
m_dynamicLayer = new EsriRuntimeQt::ArcGISDynamicMapServiceLayer(m_localMapService.urlMapService(), this);
connect(m_dynamicLayer, SIGNAL(layerCreateComplete()), this, SLOT(onLayerCreateComplete()));
connect(m_dynamicLayer, SIGNAL(layerCreateError(QString)), this, SLOT(onLayerCreateError(QString)));
on dynamic layer creation onLayerCreateComplete() slot called.
EsriRuntimeQt::DynamicLayerInfoCollection& layerInfos = m_dynamicLayer->dynamicLayerInfos();
EsriRuntimeQt::DynamicLayerInfo* layerInfo = layerInfos;
/* Apply a renderer for vector layers.
* Note: It is always necessary to provide a renderer, but the renderer provided does
* not need to be valid with regard to the actual layer and geometry type, it simply
* needs to be a valid renderer. If the renderer specified here is not appropriate for
* the geometry type of the layer the symbology will fall back to a default
* SimpleMarkerSymbol, SimpleLineSymbol or SimpleFillSymbol.
//simpleRenderer = new EsriRuntimeQt::SimpleRenderer(EsriRuntimeQt::SimpleLineSymbol(QColor(1, 1, 1), 6.0), this);//0, 100, 250
simpleRenderer = new EsriRuntimeQt::SimpleRenderer(EsriRuntimeQt::SimpleMarkerSymbol(Qt::blue, 16, EsriRuntimeQt::SimpleMarkerSymbolStyle::Diamond));
EsriRuntimeQt::DrawingInfo* drawingInfo = new EsriRuntimeQt::DrawingInfo(simpleRenderer, 20, this);
// Create the table data source
EsriRuntimeQt::TableDataSource* dataSource = new EsriRuntimeQt::TableDataSource(this);
qDebug() << "DataSource JSON" << dataSource->toJson();
// Set the data source
EsriRuntimeQt::LayerDataSource* layerDataSource = new EsriRuntimeQt::LayerDataSource(this);
To access a file geodatabase, you must use local server. As an alternative, you can move your to a Runtime geodatabase authored in ArcMap. There are many advantages of Runtime geodatabases over file geodatabases in the context of a Runtime SDK app. Here are a few.
To access a Runtime geodatabase with the SDK:
Where does the Runtime geodatabase come from?
Thank you. I have idea of accessing runtime geodatabase from Qt Application. How to access a file geodatabase( *.gdb) using local server, can you give some more idea how to achieve this?
It will be more straightforward to use a map package that already references your data rather than modifying the data sources of a running service as your code and the shapefile sample do. I tested using a pre-authored map package today and that works with a file geodatabase as a data source. Doing it this way avoids the signal problem that you encountered.
Author a map package with ArcMap, with a map referencing the layers in the file geodatabase. Be sure to specify that the data should support Runtime and the the data should be referenced and not embedded in the map package. Then, create a local service with that map package. Later, you can modify the data in the file geodatabase without changing the map package.
I found that this works well using ArcMap 10.2.2 to author the map package. I found that there is a problem in 10.3 that only allows you to embed the data in the map package. This problem is fixed for 10.4. Embedded data could be viable if you write a GP script to refresh your map package at desired intervals.
Retrieving data ...