文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 85e00be9 by ren

点线面的shp显示(单一图层)

parent 67f0f965
......@@ -10,4 +10,4 @@
<!-- built files will be auto injected -->
</body>
</html>
<script src="//webapi.amap.com/maps?v=2.0&key=fd28dc34eb931d82a25869cd127005d5&plugin=AMap.MouseTool,AMap.ToolBar"></script>
<script src="//webapi.amap.com/maps?v=2.0&key=fd28dc34eb931d82a25869cd127005d5&plugin=AMap.MouseTool,AMap.ToolBar,AMap.GeoJSON"></script>
......@@ -5688,6 +5688,11 @@
"globule": "^1.0.0"
}
},
"gcoord": {
"version": "0.2.3",
"resolved": "https://registry.npm.taobao.org/gcoord/download/gcoord-0.2.3.tgz",
"integrity": "sha1-vfjUjtGZeFF36ylyfvOrFrKdiV4="
},
"get-caller-file": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
......
......@@ -15,6 +15,7 @@
"default-passive-events": "^2.0.0",
"element-ui": "^2.13.1",
"file-saver": "^2.0.2",
"gcoord": "^0.2.3",
"jszip": "^3.5.0",
"mathjs": "^7.0.2",
"node-sass": "^4.14.1",
......
......@@ -213,11 +213,10 @@
:http-request="uploadFileL"
:data="'3:'+(index)"
:limit="7"
disabled
:on-exceed="handleExceed"
:file-list="dynamicValidateForm.layerDomains[index].fileList">
<!-- <el-button size="small" type="primary" @click="setIndex(index)">点击上传图层文件</el-button>-->
<!-- <div slot="tip" class="el-upload__tip">上传要求:kml格式文件</div>-->
<el-button size="small" type="primary" @click="setIndex(index)">点击上传图层文件</el-button>
<div slot="tip" class="el-upload__tip">上传要求:shp、kml格式文件</div>
</el-upload>
</el-col>
<el-col offset="4" span="12">
......@@ -964,7 +963,7 @@
//添加图层分片
else if(ptype == 3){
this.dynamicValidateForm.layerDomains.push({
fileList:[{name:"默认文件",url:"默认路径",size:2333}],
fileList:new Array(),
description:'',
key: Date.now()
});
......
......@@ -9,6 +9,8 @@ import PIL.Image
import PIL.ImageDraw
from flask_mongoengine import MongoEngine
import dao.Data as Data
import dao.Relation as Relation
import views.uploadDownload as fileDownload
db = MongoEngine()
......@@ -474,6 +476,15 @@ def saveImage(image_list):
traceback.print_exc()
return Result(0, repr(e), {})
#获取每一个图层分片下的所有shp文件的URL
#参数暂且有问题
def retURLList(relation_id):
slice_id = Relation.find_slice_by_id(relation_id)
datalist = Data.find_data_by_slice(slice_id).data
urlList = []
for data in datalist:
urlList.append(data['url'])
return urlList
# 获取图层
def getLayer(relation_id):
......
......@@ -30,6 +30,15 @@ class Relation(Model):
database = mysql
def find_slice_by_id(relation_id):
try:
slice_id = Relation.get(Relation.relation_id == relation_id).slice_id
except:
return False
else:
return slice_id
# 创建标注关系
def create_relation(slice_id, user_id, data_id):
try:
......
......@@ -2,13 +2,23 @@ import json
import io
import traceback
import zipfile
import os
import shapefile
from support import basedir
from flask import Blueprint, request, make_response, send_file
from dao import Image, Relation
UPLOAD_FOLDER = 'upload' # 用于保存上传文件的文件夹名称
image = Blueprint("image", __name__, url_prefix="/api")
class Result:
def __init__(self, code, message, data):
self.code = code
self.message = message
self.data = data
def handle_except(result):
res = {
'code': result.code,
......@@ -48,14 +58,37 @@ def save_image():
return json.dumps(res, ensure_ascii=False)
# 获取图层中的每一个shp文件
def retGeoJson(relationId):
urlList = Image.retURLList(relationId)
for url in urlList:
file_dir = os.path.join(basedir, UPLOAD_FOLDER, url)
print(file_dir)
shp = shapefile.Reader(file_dir)
fields = shp.fields[1:]
field_names = [field[0] for field in fields]
buffer = []
for sr in shp.shapeRecords():
atr = dict(zip(field_names, sr.record))
geom = sr.shape.__geo_interface__
buffer.append(dict(type="Feature", geometry=geom, properties=atr))
return {"type": "FeatureCollection", "features": buffer}
# 获取图层
@image.route("/layer/getLayer", methods=["POST"])
def get_layer():
data = json.loads(request.data.decode('utf-8'))
relation_list = data['relationId']
layer = Image.getLayer(relation_list)
return handle_except(layer)
resLayer = Image.getLayer(relation_list)
geojson = retGeoJson(relation_list)
layer = resLayer.data
resdata = {
'geojson': geojson,
'layerInfo': layer['layerInfo'],
'landmarkList': layer['landmarkList'],
}
res = Result(resLayer.code, resLayer.message, resdata)
return handle_except(res)
# 保存图层标注结果
......
......@@ -22,7 +22,7 @@ from views.textAnnotation import collectionTest
uploadDownload = Blueprint("uploadDownload", __name__, url_prefix="/api/files")
UPLOAD_FOLDER = 'upload' # 用于保存上传文件的文件夹名称
ZIP_FOLDER = 'zip' # 用于保存zip文件的文件夹名称
ALLOWED_EXTENSIONS = {'txt', 'json', 'xlsx', 'png', 'jpg', 'jpeg', 'kml', 'gif'} # 允许上传的文件格式
ALLOWED_EXTENSIONS = {'txt', 'json', 'xlsx', 'png', 'jpg', 'jpeg', 'kml', 'gif', 'shp', 'dbf'} # 允许上传的文件格式
# 用于判断文件后缀
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment