Select to view content in your preferred language

How to get Feature Classes name of File Geodatabase

4046
3
Jump to solution
03-07-2013 06:56 AM
JeremieJoalland1
Deactivated User
From ArcGIS Runtime for Java samples "Add Raster" and "Add Shapefile", I have developed a "Add Feature Class" method base on File Geodatabase (user can select the .gdb folder).

for now, I have to give the name of Feature Class I want to add in my code, but I would like to get all Feature Classes name from my File Geodatabase, so the user can select the Feature Class he wants.
after some researches, I don't see how to do that from my WorkspaceInfo or WorkspaceInfoSet !!

need some help !

my code below :
private void addFileGdbBrowsed(final String folderPath) {     final String workspaceId = "" + count++; // an arbitrary unique string      // create a local map service and enable dynamic layers     LocalMapService localMapService = new LocalMapService(ConstantesExample.URL_BLANK_MPK);     localMapService.setEnableDynamicLayers(true);      // get dynamic workspaces from service     WorkspaceInfoSet workspaceInfoSet = localMapService.getDynamicWorkspaces();      // create a workspace info via the static method according to data type     // e.g. file geodatabase folder connection     WorkspaceInfo workspaceInfo = WorkspaceInfo.CreateFileGeoDatabaseConnection(workspaceId, folderPath);          // set dynamic workspaces for our local map service     workspaceInfoSet.add(workspaceInfo);     localMapService.setDynamicWorkspaces(workspaceInfoSet);      // now start service...     localMapService.start();      // set up a local dynamic layer     final ArcGISDynamicMapServiceLayer localDynamicLayer = new ArcGISDynamicMapServiceLayer(             localMapService.getUrlMapService());      // add the layer to the map     localDynamicLayer.setName("File Geodatabase");     jMap.getLayers().add(localDynamicLayer);      localDynamicLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener()     {         @Override         public void layerInitializeComplete(LayerInitializeCompleteEvent arg0)         {             DynamicLayerInfoCollection layerInfos = localDynamicLayer.getDynamicLayerInfos();             DynamicLayerInfo layerInfo = layerInfos.get(0);                          /* 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 simpleRenderer = new SimpleRenderer(new SimpleLineSymbol(Color.ORANGE, 2f, SimpleLineSymbol.Style.SOLID));             DrawingInfo drawingInfo = new DrawingInfo(simpleRenderer, 0); // Transparency = 0%             layerInfo.setDrawingInfo(drawingInfo);              // Create the Feature Class data source             TableDataSource dataSource = new TableDataSource();             dataSource.setWorkspaceId(workspaceId);             dataSource.setDataSourceName("polbndl"); // <-- HERE IS MY FEATURE CLASS NAME, BUT WOULD LIKE THE USER TO SELECT IT !!                          // Set the data source             LayerDataSource layerDataSource = new LayerDataSource();             layerDataSource.setDataSource(dataSource);             layerInfo.setLayerSource(layerDataSource);              localDynamicLayer.refresh();         }     }); }
0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor
The API doesn't contain methods to query the contents of a file-geodatabase. 

The workflow we intended for use in all Runtime APIs for disconnected use is centred around the use of "packages" which you can generate from ArcMap...  however I'm always been asked about the ArcGIS Engine way of adding layers to a runtime application.

The code you have shown makes it possible to add these layers, but I'll be the first to admit this isn't particularly easy and has it's limitations (like not being able to list feature classes in a geo-database).

As I've said before I'm always intersted to hear about how developers use the API and if there are improvements we can make.

Mark

View solution in original post

0 Kudos
3 Replies
MarkBaird
Esri Regular Contributor
The API doesn't contain methods to query the contents of a file-geodatabase. 

The workflow we intended for use in all Runtime APIs for disconnected use is centred around the use of "packages" which you can generate from ArcMap...  however I'm always been asked about the ArcGIS Engine way of adding layers to a runtime application.

The code you have shown makes it possible to add these layers, but I'll be the first to admit this isn't particularly easy and has it's limitations (like not being able to list feature classes in a geo-database).

As I've said before I'm always intersted to hear about how developers use the API and if there are improvements we can make.

Mark
0 Kudos
MarkBaird
Esri Regular Contributor
However if you are feeling like a challenge, the you could check out this:

http://www.esri.com/news/releases/11-2qtr/esri-file-geodatabase-api-is-now-available.html

You could write your methods in C++ using the geodatabase API and expose it to your Java App using JNI...

Mark
0 Kudos
JeremieJoalland1
Deactivated User
Thanks for the ideas, but I'm not C++ profil... si I will not test the File Geodatabase API. but you've answered my question, as I mainly needed to define the Runtime possibilities.

From what you said about the disconnected scenario with Pacakges, I understand the ESRI point of view, but we will always have customers who wants to add their own data (geotiff, shapefiles, but sometimes .kml, VMap, Geodatabase), and it's sometimes an important constraint for Runtime to be too Packages and Desktop oriented !

Sometimes we are ready to accept lower performances on display and execution, to be able to work with diffrent data format added on the fly... just because data will change for each customer, and we can't prepare all basemap and data with ArcGIS Desktop... or maybe sometimes there is no Desktop competences !
0 Kudos