spatiallite空间数据库转换到leaflet.js的GeoJson格式
来源:互联网 发布:网络教育笔试考试 编辑:程序博客网 时间:2024/05/19 19:57
spatiallite是一个轻量型的空间数据库,可以将GIS的点线面数据以GeoJson的格式读取出来,但是这个GeoJson的格式与Leaflet的GeoJson格式不同,具体的格式大家可以去网上看。这里公布一下,转换的代码:
public void queryGeometry(String tableName) { net.sf.json.JSONObject jsonObject=new net.sf.json.JSONObject(); jsonObject.put("type","FeatureCollection"); List list = new ArrayList(); String query = "SELECT ROWID, AsGeoJSON(Geometry) from "+tableName+";"; try { Stmt stmt = db.prepare(query); while (stmt.step()) { String rowID = stmt.column_string(0); JSONObject geoJson=JSONObject.fromObject(stmt.column_string(1)); Map map = new HashMap(); map.put("ROWID",rowID); map.put("tableName",tableName); net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(map); Map mapParent=new HashMap(); mapParent.put("type","Feature"); mapParent.put("geometry",geoJson); mapParent.put("properties",json); net.sf.json.JSONObject jsonParent = net.sf.json.JSONObject.fromObject(mapParent); list.add(jsonParent); Log.e(TAG,json.toString()); Log.e(TAG,jsonParent.toString()); } jsonObject.put("features", JSONArray.fromObject(list)); Log.e(TAG,jsonObject.toString()); stmt.close(); }catch (Exception e){ Log.e(TAG,"查询数据库错误"+e.toString()); } }
这里转换json使用了特定的jar包,可以去网上找。
阅读全文
0 0
- spatiallite空间数据库转换到leaflet.js的GeoJson格式
- spatiallite空间数据库在Android平台的两种数据查询方式
- geotools中shp和geojson格式的相互转换
- GeoJson格式与转换(shapefile)Geotools
- Spring Boot(MVC)下空间字段(Geometry)与geojson的自动转换
- R语言在线地图神器:Leaflet for R包(五) GeoJson文件的使用
- leaflet学习笔记一(初识GeoJSON)
- GeoJSON格式规范说明
- 有关Leaflet.js的相关操作
- MapInfo格式到ArcInfo格式的转换
- MapInfo格式到ArcInfo格式的转换
- YUV格式到RGB格式的转换
- YUYV格式到RGB格式的转换
- js时间格式的转换
- js 时间格式的转换
- JS日期格式的转换
- 数据库的日期格式转换
- Geotools中Geometry对象与GeoJson的相互转换
- 并行计算奇异值分解--Jacobi旋转(转)
- Viewpager+选项卡
- 51nod 1615 跳跃的杰克
- eclipse添加服务器时没有server选项怎么办
- C# WindowsForm程序同时启动多个窗口类
- spatiallite空间数据库转换到leaflet.js的GeoJson格式
- 怎么做共享充电宝方案
- 【第1088期】webpack & HTTP/2
- @SuppressWarnings(unused) 、serial与rawtypes
- 12期 11月期刊自荐
- 普元 EOS Platform 7.5 default和sso集成后,如何配置不登录拦截
- Banner+DrawerLayout+Tablayout+PullTofresh+Fragment(Viewpage)
- 大数据早报:三江航天与数澜科技达成人工智能合作 谷歌推出 AVA 数据库(10.24)
- 项目一阶段问题汇总