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.
Thanks,
Luke
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.
Thanks,Bhargav
Bhargav, I have a couple of questions for you:
Thank 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.
WRT
> 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..
try
{
// You can't modify the dynamic workspaces on a running local map service.
m_localMapService.stopAndWait();
// 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");
workspaceInfo.setEditable(true);
// set dynamic workspaces for our local map service
workspaceInfoSet.add(workspaceInfo);
m_localMapService.start();
}
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)
{
Q_UNUSED(url);
Q_UNUSED(name);
// // create the ArcGISDynamicMapServiceLayer using the LocalMapService's url
// m_dynamicLocalServiceLayer = new EsriRuntimeQt::ArcGISDynamicMapServiceLayer(m_localMapService.urlMapService(), this);
// m_map->addLayer(m_dynamicLocalServiceLayer);
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)));
m_map->addLayer(m_dynamicLayer);
}
on dynamic layer creation onLayerCreateComplete() slot called.
void ShapeFile::onLayerCreateComplete()
{
m_dynamicLayer->setVisible(true);
EsriRuntimeQt::DynamicLayerInfoCollection& layerInfos = m_dynamicLayer->dynamicLayerInfos();
EsriRuntimeQt::DynamicLayerInfo* layerInfo = layerInfos[0];
if (!layerInfo)
return;
/* 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.
*/
EsriRuntimeQt::SimpleRenderer* simpleRenderer;
//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);
layerInfo->setDrawingInfo(drawingInfo);
// Create the table data source
EsriRuntimeQt::TableDataSource* dataSource = new EsriRuntimeQt::TableDataSource(this);
dataSource->setWorkspaceId(m_workspaceId);
dataSource->setDataSourceName("Cities");
qDebug() << "DataSource JSON" << dataSource->toJson();
// Set the data source
EsriRuntimeQt::LayerDataSource* layerDataSource = new EsriRuntimeQt::LayerDataSource(this);
layerDataSource->setDataSource(dataSource);
layerInfo->setLayerSource(layerDataSource);
m_dynamicLayer->refresh();
}
Bhargav,
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?
Regards,
Bhargav