首页 / 浏览问题 / 移动GIS / 问题详情
Datasource打开失败
27EXP 2018年08月07日
版本9D supermap-imobile-9.0.1-103-android-zip-chs

使用下列方法打开数据服务失败 得到mDataSource=null的结果
DatasourceConnectionInfo dsInfo = new DatasourceConnectionInfo();
dsInfo.setEngineType(EngineType.Rest);
dsInfo.setServer(datasourceLink);
dsInfo.setAlias(alias);
mDataSource = mWorkspace.getDatasources().open(dsInfo);
其中datasourceLink = http://xxx/iserver/services/data-hdhj/rest/data/datasources/ORCL

求解

2 个回答

最后解决了 因为手机端能下载的数据服务数据集类型 目前只支持点、线、面,换成这三种类型的数据服务链接,就能下载成功了
27EXP 2018年08月10日
您好,不好意思,之前给你回答错了,数据服务不能直接打开。根据你的需求,你可以将数据服务下载到本地进行操作,可以参考一下我们的范例代码-数据服务。
9,127EXP 2018年08月07日
这个传得是FieldInfo,你传得是FieldInfos,所以会报这个错误。传得参数错误

我只是调用了

downloadService.downloadDataset("http://xxx/iserver/services/data-hdhj/rest/data/datasources/ORCL/datasets/shorelineArea", mDataSource);


这个错不知道什么原因导致的requestFailed java.lang.UnsupportedOperationException: add(FieldInfo fieldInfo)
    The operation is not supported by FieldInfos.
你把你代码发出来看一下,还有知道是哪一句报这个错误吗
if (addDatasource(DATA_SOURCE_SHORELINE, "DATA_SOURCE_SHORELINE")) {
    downloadService();
}

对应方法在下面


// 添加数据服务
public boolean addDatasource(String datasourceLink, String alias) {
    LogUtil.e(TAG, "addDatasource called  " + alias);

    DatasourceConnectionInfo connectionInfo = new DatasourceConnectionInfo();
    connectionInfo.setEngineType(EngineType.UDB);
    connectionInfo.setServer(filepath);

    mDataSource2 = mWorkspace.getDatasources().open(connectionInfo);

    if(mDataSource2 != null)
        return true;

    return true;
}


//下载数据集
public void downloadService() {
    LogUtil.e(TAG, "downloadService ");
    if (mDataSource2 == null) {
        LogUtil.e(TAG, "mDataSource2 == null ");
        return;
    }

    String urlServer = "http://xxx";
    DataDownloadService downloadService = new DataDownloadService(urlServer);
    downloadService.setResponseCallback(new ResponseCallback() {

        @Override
        public void requestFailed(String errorMsg) {
            LogUtil.e(TAG, "requestFailed " + errorMsg);

            ToastUtil.showShort(getContext(), "下载失败 " + errorMsg);
            if (errorMsg.contains("shorelineArea_Table already") && mMapControl != null) {
                mMapControl.getMap().refresh();
            }
        }

        @Override
        public void requestSuccess() {
            LogUtil.i(TAG, "requestSuccess");
        }

        @Override
        public void receiveResponse(FeatureSet result) {
            LogUtil.i(TAG, "receiveResponse " + result.toString());

        }

        @Override
        public void dataServiceFinished(String arg0) {
            LogUtil.i(TAG, "dataServiceFinished " + arg0);

            ToastUtil.showShort(getContext(), "下载成功 " + arg0);

            mMapControl.getMap().refresh();
        }

        @Override
        public void addFeatureSuccess(int arg0) {
            LogUtil.i(TAG, "addFeatureSuccess " + arg0);

        }

    });

    downloadService.downloadDataset(DATA_SOURCE_SHORELINE, mDataSource2);
}

报错处:supermap-imobile-9.0.1-103-android-zip-chs


08-08 17:06:33.690 8765-9015/com.gzsl.riversmanager W/System.err: java.lang.UnsupportedOperationException: add(FieldInfo fieldInfo)
    The operation is not supported by FieldInfos.
        at com.supermap.data.FieldInfos.add(FieldInfos.java:106)
        at com.supermap.services.DataDownloadService.a(DataDownloadService.java:617)

你加我一个qq:2889751134
...