【问题标题】:Opening file geodatabase using ESRI android API使用 ESRI android API 打开文件地理数据库
【发布时间】:2014-02-25 22:05:33
【问题描述】:

一段时间以来,我试图在 10.2 版中使用 ESRI api 在 android 上打开文件 godatabase。

我有一个使用 Arccatalog 10.1 制作的文件 godatabase。它包含一层。我可以在 Arcmap 中打开它,所以这里的一切看起来都很好。 地理数据库位于名为 android.gdb 的文件夹中 我将它复制到 microSD 卡并尝试使用以下代码打开它:

new com.esri.core.gdb.Geodatabase("/mnt/sdcard2/android.gdb");

“/mnt/sdcard2/android.gdb”文件存在,是一个文件夹,我有读写权限。

我收到一个 RuntimeException 并显示无法打开 goeddatabase 文件的消息。

有人有类似的问题吗?

【问题讨论】:

    标签: java android gis esri


    【解决方案1】:

    Android 的 ESRI 运行时 api 将无法打开那种数据库。它使用 SQLLite 中内置的专有版本的地理数据库。您需要在 ArcGisOnline 或 ArcServer 10.2 中发布服务并调用 GeodatabaseSyncTask 对象,以便在设备上以正确的格式获取数据库版本。在您发布的要素服务上,您需要确保同步已启用。然后,您可以利用此代码调用您的要素服务并将其存储在本地。此代码基于此 ESRI 示例 -- https://developers.arcgis.com/android/sample-code/offline-editor/

    public void LoadGdb(UserCredentials credentials, Polygon extent, SpatialReference spatRef){
    
        mapExtent = extent;
        mapSpatialRef = spatRef;
        String replicaUrl = callingActivity.getResources().getString(R.string.feature_service_url);
        gdbTask = new GeodatabaseSyncTask(replicaUrl, credentials);
    
        gdbTask.fetchFeatureServiceInfo(new CallbackListener<FeatureServiceInfo>() {
    
            @Override
            public void onError(Throwable e) {
              Log.e(TAG, "", e);
            }
    
            @Override
            public void onCallback(FeatureServiceInfo objs) {
              if (objs.isSyncEnabled()) {
                requestGdbInOneMethod(gdbTask, mapExtent, mapSpatialRef);
              }
            }
          });
    }
    
    protected void requestGdbInOneMethod(GeodatabaseSyncTask geodatabaseSyncTask, Polygon extent, SpatialReference spatRef) {
    
         GenerateGeodatabaseParameters params = new GenerateGeodatabaseParameters({0, 1}, extent,
                 spatRef, true, SyncModel.LAYER, spatRef);
    
        CallbackListener<String> gdbResponseCallback = new CallbackListener<String>() {
    
            @Override
            public void onCallback(String obj) {
    
              try {
                       // This onCallback gets called after the generateGeodatabase
                       // function on the GeodatabaseSyncTask is called.
                       // You can store a reference to this database or you can load it
                       // with your code and point it to the gdbFileName location
                       Geodatabase myGeodatabase = (Geodatabase)obj;
    
              } catch (FileNotFoundException e) {
                e.printStackTrace();
              }
            }
    
            @Override
            public void onError(Throwable e) {
              Log.e(TAG, "", e);
            }
          };
    
          GeodatabaseStatusCallback statusCallback = new GeodatabaseStatusCallback() {
    
              @Override
              public void statusUpdated(GeodatabaseStatusInfo status) {
                showMessage(callingActivity, status.getStatus().toString());
              }
            };
    
                //  !!   THE gdbFileName is a string of the path and filename
                // where the geodatabse will be stored.
            geodatabaseSyncTask.generateGeodatabase(params, gdbFileName, false, statusCallback, gdbResponseCallback);
    }
    

    【讨论】:

      【解决方案2】:

      要加载本地文件,您需要使用 ArcGIS Desktop 10.2.1 或更高版本来生成具有 *.geodatabase 文件扩展名的运行时地理数据库文件。请参阅此处的说明:http://resources.arcgis.com/en/help/main/10.2/index.html#//00660000045q000000

      【讨论】:

        猜你喜欢
        • 2016-10-08
        • 2019-09-18
        • 2019-05-22
        • 1970-01-01
        • 2014-03-09
        • 2019-01-08
        • 1970-01-01
        • 1970-01-01
        • 2012-07-11
        相关资源
        最近更新 更多