3

CAD 在openlayers 中实现思路

 1 year ago
source link: https://blog.51cto.com/tp101/5753774
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CAD 在openlayers 中实现思路

精选 原创

CAD DWG文件属于加密文件没有过多的去研究

CAD DXF文件属于文本型文件

OPENLAYERS 可以加载GEOJSON文件

DXF -- GEOJSON (文件过大时加载浏览器崩溃)--  导入数据库-- 根据zoom级别抽稀压缩传输 -- 浏览器端还原 GEOJSON 

DXF 2 GEOJSON

import os
from osgeo import osr, ogr, gdal


def dxf_to_geojson(dxf):
basename = os.path.split(dxf)[0]
filename = os.path.basename(dxf).split('.')[0]
outfile = "{}.json".format(basename + filename)
print(outfile)
ogr.RegisterAll()
gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES")
gdal.SetConfigOption("SHAPE_ENCODING", "")
gdal.SetConfigOption("DXF_ENCODING", "ASCII") # 设置DXF缺省编码
poDS = ogr.Open(dxf, False,)
poDriver = ogr.GetDriverByName("GeoJson")
# 保存文件 COORDINATE_PRECISION 坐标保留小数位数
options = ["WRITE_NAME=NO","COORDINATE_PRECISION=3","ID_GENERATE=NO"];
res = poDriver.CopyDataSource(poDS, outfile,options)

if __name__ == '__main__':
dxf_to_geojson('test.dxf')

GEOJSON 导入数据库

使用ijson 读取GEOJSON 入库  进行中。。。

  • 打赏
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK