首页 / 浏览问题 / 移动GIS / 问题详情
imobile如何重新导入shp
82EXP 2022年07月29日
各位大佬,我需要在矢量图层加载后,在某一时刻重新替换原始shp文件,请问,如何将已加载的数据集和图层删除后重新导入shp文件并加载至图层中?目前,我在DataConversion.importSHP之前判断工作空间是否有数据集和图层存在,如果有就将对应的数据集和图层删掉后导入,导入是在一个线程中导入shp并添加到图层,但是程序一直崩溃,崩溃日志如下:

2022-07-29 14:32:27.179 30490-30490/? A/DEBUG: pid: 30243, tid: 30487, name: Thread-177  >>> com.xtkj.LpWydc <<<
2022-07-29 14:32:27.179 30490-30490/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2022-07-29 14:32:27.179 30490-30490/? A/DEBUG:     r0  00000000  r1  00007717  r2  00000006  r3  00000008
2022-07-29 14:32:27.179 30490-30490/? A/DEBUG:     r4  00007623  r5  00007717  r6  c98fe9fc  r7  0000010c
2022-07-29 14:32:27.179 30490-30490/? A/DEBUG:     r8  c865cfac  r9  00000001  r10 c98feb20  r11 c98fea34
2022-07-29 14:32:27.179 30490-30490/? A/DEBUG:     ip  00000041  sp  c98fe9e8  lr  f2a6ae55  pc  f2a62b7a
2022-07-29 14:32:27.247 30490-30490/? A/DEBUG: backtrace:
2022-07-29 14:32:27.247 30490-30490/? A/DEBUG:     #00 pc 0001db7a  /system/lib/libc.so (abort+58)
2022-07-29 14:32:27.247 30490-30490/? A/DEBUG:     #01 pc 01699104  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (__gnu_cxx::__verbose_terminate_handler()+312)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #02 pc 01695210  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (__cxxabiv1::__terminate(void (*)())+8)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #03 pc 01695254  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (std::terminate()+20)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #04 pc 016958b4  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (__cxa_pure_virtual+24)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #05 pc 00eedc29  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (UGC::UGLayer::IsWebRasterLayer()+16)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #06 pc 00efbf0d  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (UGC::UGLayers::RemoveAt(int, int, unsigned char)+92)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #07 pc 00f7c1b5  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (UGC::UGMobileMap::Remove(UGC::UGLayers*, UGC::UGLayer*)+48)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #08 pc 009dab73  /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/lib/arm/libimb_v1012.so (Java_com_supermap_mapping_LayersNative_jni_1Remove+30)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #09 pc 00442479  /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #10 pc 0043df75  /system/lib/libart.so (art_quick_invoke_stub_internal+68)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #11 pc 00410793  /system/lib/libart.so (art_quick_invoke_static_stub+222)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #12 pc 000a82bf  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+154)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #13 pc 001f4717  /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+230)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #14 pc 001ef389  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+784)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #15 pc 0021854d  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE0ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+96)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #16 pc 00215541  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+51296)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #17 pc 00442e55  /system/lib/libart.so (ExecuteSwitchImplAsm+4)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #18 pc 0046bae8  /dev/ashmem/dalvik-classes.dex extracted in memory from /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/base.apk (deleted) (com.supermap.mapping.Layers.removeLayer)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #19 pc 001d3d01  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2377676604+292)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #20 pc 001d8677  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+146)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #21 pc 001ef373  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+762)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #22 pc 002163db  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+438)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #23 pc 00214913  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+48178)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #24 pc 00442e55  /system/lib/libart.so (ExecuteSwitchImplAsm+4)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #25 pc 0046b7dc  /dev/ashmem/dalvik-classes.dex extracted in memory from /data/app/com.xtkj.LpWydc-GM8WO8U_2yZxmvFBt25EeQ==/base.apk (deleted) (com.supermap.mapping.Layers.remove)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #26 pc 001d3d01  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2377676604+292)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #27 pc 001d8677  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+146)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #28 pc 001ef373  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+762)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #29 pc 002163db  /system/lib/libart.so (_ZN3art11interpreterL8DoInvokeILNS_10InvokeTypeE2ELb0ELb0EEEbPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+438)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #30 pc 00214913  /system/lib/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+48178)
2022-07-29 14:32:27.248 30490-30490/? A/DEBUG:     #31 pc 00442e55  /system/lib/libart.so (ExecuteSwitchImplAsm+4)
问题关闭原因: 解决

1个回答

您好,1.请问您的意思是删除数据集就会引起上述崩溃是吗,

2.“但是这种在获取图斑属性时,有可能得不到最新的数据”指的是“得不到最新的信息”这种情况不是必现的吗

3.请问您有没有尝试过只移除数据集呢,如果有的话,在移除数据集的时候有没有关闭数据集再移除呢,还是数据集在没有打开的情况下移除出现了上述的崩溃问题呢
3,745EXP 2022年08月01日

针对第1点和第三点,测试发现删除数据集会造成崩溃,且关闭数据集后再移除同样会出现崩溃。针对第二点,如果不删除数据集,重新导入得不到最新的是必现的啊,所以才问如何重新导的嘛,另外你说的有可能是因为我没关闭数据集造成的崩溃,个人觉得这个有点不太合理吧?如果没有关闭数据集就删除数据集也不应该会导致程序崩溃。另外附上删除数据集和删除图层的代码:

newlayers.forEach {
    val existDataset = mapActivity.udbDatasource!!.datasets.get(it.datasetName)
    if (existDataset != null) {
        if(existDataset.isOpen){
            existDataset.close()
        }

        mapActivity.udbDatasource!!.datasets.delete(it.datasetName)
        var layer = mMap!!.layers.getByCaption("${it.datasetName}@Layer")
        if (layer != null) {
            mMap!!.layers.remove(layer)
        }

        var l1 = mMap!!.layers.getByCaption("${it.datasetName}@themLabelLayer")
        if (l1 != null) {
            mMap!!.layers.remove(l1)
        }
    }
}
就不管关不关数据集,删除数据集都会崩

您好,我这边测试删除没问题的,不会崩溃,删除也可用成功,您可以看下我的代码,这里先移除图层再关闭数据集最后删除数据集

private void delete(){
   Datasets datasets = mWorkspace.getDatasources().get(0).getDatasets();
   for (int i = 0; i < datasets.getCount(); i++) {
      String name = datasets.get(i).getName();
       if (name.equals("shpImport")){
         Dataset dataset = datasets.get(i);
         mMapControl.getMap().getLayers().remove(dataset.getName()+"@World");
         dataset.close();
         datasets.delete(name);
         mMapControl.getMap().refresh();
      }
   }
}

希望可用帮助到您。

看了下代码,然后将逻辑改成先删图层再删数据集后,发现还是会崩,然后检查下代码和崩溃信息在重新导入shp结束后使用 mMap!!.refresh()时,也会导致程序崩溃。也不知道是啥原因,但是根据你提供的思路,崩溃没那么频繁了,算是解决了吧,另外,附上经常遇到的崩溃信息:

2022-08-03 10:00:58.144 19002-19002/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1f
2022-08-03 10:00:58.144 19002-19002/? A/DEBUG: Cause: null pointer dereference
2022-08-03 10:00:58.144 19002-19002/? A/DEBUG:     r0  00000000  r1  c048d6c0  r2  40000000  r3  00000001
2022-08-03 10:00:58.144 19002-19002/? A/DEBUG:     r4  c3e947d8  r5  c048d6c0  r6  00000000  r7  cb7d3000
2022-08-03 10:00:58.144 19002-19002/? A/DEBUG:     r8  c05bbea0  r9  e4a2e428  r10 c3e94930  r11 bfee8400
2022-08-03 10:00:58.145 19002-19002/? A/DEBUG:     ip  ef46fd08  sp  c3e946b8  lr  c56dbc49  pc  c56d9ef0
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG: backtrace:
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #00 pc 01647ef0  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (icu_50::UnicodeString::getTerminatedBuffer()+4)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #01 pc 01649c45  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (OGDC::OgdcUnicodeString::OgdcUnicodeString(OGDC::OgdcUnicodeString const&)+8)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #02 pc 00f2fbad  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGPainterLabel::DrawLabelElement(UGC::UGRecordset*, UGC::UGGeometry*&, UGC::UGThemeLabel::UGLabelStyleInfo*, UGC::UGThemeLabel::UGLabelElementResult*, UGC::UGGeometry*)+1004)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #03 pc 00f2ffe7  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGPainterLabel::DrawLabel(UGC::UGRecordset*)+918)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #04 pc 00f303eb  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGPainterLabel::DoDraw()+210)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #05 pc 00f04e3b  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGLayerVector::DoLayerDraw(UGC::UGGraphics*, UGC::UGDrawing*, UGC::UGProgress*)+994)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #06 pc 00ef2d21  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGLayer::OnDraw(UGC::UGGraphics*, UGC::UGDrawing*, UGC::UGProgress*)+1272)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #07 pc 00efd809  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGLayers::DrawEachLayerInCollection(UGC::UGLayerCollection*, UGC::UGDrawing*, UGC::UGGraphics*, UGC::UGProgress*, UGC::UGRgn*, UGC::UGRgn*, unsigned char&, unsigned char*&, OGDC::OgdcUnicodeString&)+2376)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #08 pc 00eff95b  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGLayers::OnDraw(UGC::UGGraphics*, UGC::UGDrawing*, unsigned char*, UGC::UGProgress*)+222)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #09 pc 00f16ee5  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGMap::OnDraw(UGC::UGGraphics*, OGDC::OgdcRect, OGDC::OgdcRect, unsigned char*, unsigned char, unsigned char, unsigned char, UGC::UGProgress*, unsigned char)+1516)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #10 pc 00f17c9d  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGMap::OutputMap(UGC::UGGraphics*, OGDC::OgdcRect, unsigned char*, unsigned char, unsigned char, unsigned char, unsigned char, UGC::UGProgress*)+672)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #11 pc 00c470db  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGCacheGLES10Touch::ProcessTask(UGC::UGTaskBase*)+2362)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #12 pc 0162e4d3  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGTaskMessageLoop::Run()+58)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #13 pc 0162e513  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGTaskWorkThread::run()+10)
2022-08-03 10:00:58.165 19002-19002/? A/DEBUG:     #14 pc 01624d99  /data/app/com.xtkj.LpWydc-Bf14UUe3jDOCQdmdMm4Ozw==/lib/arm/libimb_v1012.so (UGC::UGThread::execute(void*)+28)
另外说句不知道该不该说的,之前有做过arcgis的开发,觉得用imobile经常会遇到崩溃,而且不太好排查,有可能是因为代码逻辑原因哈。
...