Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DA-Platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
文档服务地址:
http://47.92.0.57:3000/
周报索引地址:
http://47.92.0.57:3000/s/NruNXRYmV
Open sidebar
Berlin
DA-Platform
Commits
8cac7d6a
Commit
8cac7d6a
authored
Nov 10, 2020
by
ren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改上传文件的bug
parent
e89de876
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
253 additions
and
145 deletions
+253
-145
package-lock.json
DAPlatform-front/package-lock.json
+51
-2
package.json
DAPlatform-front/package.json
+1
-0
layerAnnotation.vue
...-front/src/components/imageAnnotation/layerAnnotation.vue
+142
-120
1605014565.shp
DAPlatform/upload/1605014565.shp
+0
-0
imageAnnotation.py
DAPlatform/views/imageAnnotation.py
+59
-23
No files found.
DAPlatform-front/package-lock.json
View file @
8cac7d6a
...
...
@@ -376,6 +376,11 @@
"is-string"
:
"^1.0.5"
}
},
"array-source"
:
{
"version"
:
"0.0.4"
,
"resolved"
:
"https://registry.npm.taobao.org/array-source/download/array-source-0.0.4.tgz"
,
"integrity"
:
"sha1-pSXfSoSxN20nxnfNQmqXw4gviso="
},
"array-union"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz"
,
...
...
@@ -2211,8 +2216,7 @@
"commander"
:
{
"version"
:
"2.17.1"
,
"resolved"
:
"https://registry.npmjs.org/commander/-/commander-2.17.1.tgz"
,
"integrity"
:
"sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg=="
,
"dev"
:
true
"integrity"
:
"sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg=="
},
"commondir"
:
{
"version"
:
"1.0.1"
,
...
...
@@ -4843,6 +4847,14 @@
"resolved"
:
"https://registry.npmjs.org/file-saver/-/file-saver-2.0.2.tgz"
,
"integrity"
:
"sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw=="
},
"file-source"
:
{
"version"
:
"0.6.1"
,
"resolved"
:
"https://registry.npm.taobao.org/file-source/download/file-source-0.6.1.tgz"
,
"integrity"
:
"sha1-rhidSZN2a4Zad/g63Pm5pQTNN9w="
,
"requires"
:
{
"stream-source"
:
"0.3"
}
},
"file-uri-to-path"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz"
,
...
...
@@ -8145,6 +8157,15 @@
"resolved"
:
"https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz"
,
"integrity"
:
"sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
},
"path-source"
:
{
"version"
:
"0.1.3"
,
"resolved"
:
"https://registry.npm.taobao.org/path-source/download/path-source-0.1.3.tgz"
,
"integrity"
:
"sha1-A5B8WVSAqiWWoVqQHET3RXNuenM="
,
"requires"
:
{
"array-source"
:
"0.0"
,
"file-source"
:
"0.6"
}
},
"path-to-regexp"
:
{
"version"
:
"0.1.7"
,
"resolved"
:
"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz"
,
...
...
@@ -11590,6 +11611,19 @@
}
}
},
"shapefile"
:
{
"version"
:
"0.6.6"
,
"resolved"
:
"https://registry.npm.taobao.org/shapefile/download/shapefile-0.6.6.tgz"
,
"integrity"
:
"sha1-b+4VK5+yschfaQKFtpL7aMlaX08="
,
"requires"
:
{
"array-source"
:
"0.0"
,
"commander"
:
"2"
,
"path-source"
:
"0.1"
,
"slice-source"
:
"0.4"
,
"stream-source"
:
"0.3"
,
"text-encoding"
:
"^0.6.4"
}
},
"shebang-command"
:
{
"version"
:
"1.2.0"
,
"resolved"
:
"https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz"
,
...
...
@@ -11664,6 +11698,11 @@
"is-fullwidth-code-point"
:
"^2.0.0"
}
},
"slice-source"
:
{
"version"
:
"0.4.1"
,
"resolved"
:
"https://registry.npm.taobao.org/slice-source/download/slice-source-0.4.1.tgz"
,
"integrity"
:
"sha1-QKV6wDxmaLXaIA4FN44AC/KmHXk="
},
"snapdragon"
:
{
"version"
:
"0.8.2"
,
"resolved"
:
"https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz"
,
...
...
@@ -12090,6 +12129,11 @@
"integrity"
:
"sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ=="
,
"dev"
:
true
},
"stream-source"
:
{
"version"
:
"0.3.5"
,
"resolved"
:
"https://registry.npm.taobao.org/stream-source/download/stream-source-0.3.5.tgz"
,
"integrity"
:
"sha1-uX9S0PjqVm2wcdtnm5hUA6MeA0A="
},
"strict-uri-encode"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz"
,
...
...
@@ -12326,6 +12370,11 @@
"inherits"
:
"2"
}
},
"text-encoding"
:
{
"version"
:
"0.6.4"
,
"resolved"
:
"https://registry.npm.taobao.org/text-encoding/download/text-encoding-0.6.4.tgz"
,
"integrity"
:
"sha1-45mpgiV6J22uQou5KEXLcb3CbRk="
},
"text-table"
:
{
"version"
:
"0.2.0"
,
"resolved"
:
"https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz"
,
...
...
DAPlatform-front/package.json
View file @
8cac7d6a
...
...
@@ -20,6 +20,7 @@
"mathjs"
:
"^7.0.2"
,
"node-sass"
:
"^4.14.1"
,
"qs"
:
"^6.9.4"
,
"shapefile"
:
"^0.6.6"
,
"vue"
:
"^2.5.2"
,
"vue-router"
:
"^3.0.1"
,
"vuex"
:
"^3.4.0"
,
...
...
DAPlatform-front/src/components/imageAnnotation/layerAnnotation.vue
View file @
8cac7d6a
...
...
@@ -148,7 +148,7 @@
label=
"显示"
width=
"50"
>
<template
slot-scope=
"scope"
>
<input
type=
"checkbox"
@
click=
"handleShowClick(scope.$index)"
checked
/>
<input
type=
"checkbox"
@
click=
"handleShowClick(scope.$index)"
/>
</
template
>
</el-table-column>
</el-table>
...
...
@@ -160,7 +160,8 @@
<!-- <div class="sidebar" style="border-radius:0px;position: absolute;margin-top: 264px;height: 1px;width: 300px;background-color: #409eff">-->
<!-- </div>-->
<div
class=
"sidebar"
style=
"position: absolute;margin-top: 445px;width:300px;height: calc(100vh - 71px - 345px - 150px);"
>
<div
class=
"sidebar"
style=
"position: absolute;margin-top: 445px;width:300px;height: calc(100vh - 71px - 345px - 150px);"
>
<div
class=
"sidebar-box"
>
<el-tabs
v-model=
"activeName"
type=
"card"
@
tab-click=
"handleClick"
>
<el-tab-pane
label=
"地标列表"
name=
"first"
>
...
...
@@ -220,11 +221,11 @@
</template>
<
script
>
import
gcoord
from
'gcoord'
import
gcoord
from
'gcoord'
export
default
{
export
default
{
name
:
'layerAnnotation'
,
data
()
{
data
()
{
return
{
activeName
:
'first'
,
isPoint
:
true
,
...
...
@@ -254,15 +255,16 @@
},
tableData
:
[],
layerEventMap
:
[],
layerNum
:
0
,
layerList
:
[],
colorList
:
[
'blue'
,
'pink'
,
'purple'
,
'red'
,
'salmon'
,
'orchid'
,
'darkblue'
,
'orange'
,
colorList
:
[
'blue'
,
'pink'
,
'purple'
,
'red'
,
'salmon'
,
'orchid'
,
'darkblue'
,
'orange'
,
'green'
,
'gray'
,
'darkred'
,
'darkgreen'
,
'cadetblue'
,
'black'
,
'white'
,
'lightblue'
,
'beige'
],
colorIndex
:
0
,
colorIndex
:
0
}
},
async
mounted
()
{
async
mounted
()
{
/**
* 在整个项目中X都是经度,Y都是纬度
*/
...
...
@@ -289,65 +291,81 @@
}
else
{
this
.
landmarkData
=
[]
}
// console.log(this.landmarkData)
if
(
res
.
geoJSON
!=
null
)
{
//不能直接加载,因为map此时还是Null
this
.
axios
({
method
:
'get'
,
url
:
'https://a.amap.com/jsapi_demos/static/geojson/chongqing.json'
,
}).
then
(
geoJSON
=>
{
console
.
log
(
res
.
geoJSON
)
for
(
var
index
=
0
;
index
<
res
.
geoJSON
.
length
;
index
++
){
var
resItem
=
res
.
geoJSON
[
index
]
var
name
=
resItem
.
name
var
geoItem
=
resItem
.
geojson
console
.
log
(
geoItem
)
this
.
tableData
.
push
({
id
:
index
,
name
:
name
})
// console.log(geoItem.features[0].geometry.coordinates[0][0]);
//分析geojson结构
this
.
get_height
()
var
_this
=
this
window
.
onresize
=
function
()
{
// alert("??");
_this
.
height_res
=
document
.
body
.
clientHeight
-
61
}
this
.
init
()
if
(
res
.
geoNames
!=
null
)
{
this
.
layerNum
=
res
.
geoNames
.
length
for
(
var
index
=
0
;
index
<
this
.
layerNum
;
index
++
)
{
this
.
tableData
.
push
({
id
:
index
,
name
:
res
.
geoNames
[
index
]})
}
}
// 叠加图层
for
(
let
index
=
0
;
index
<
this
.
layerNum
;
index
++
)
{
const
geojsonList
=
await
this
.
getGeoList
(
index
)
if
(
geojsonList
!=
null
)
{
const
blob
=
new
Blob
([
geojsonList
])
const
fileReader
=
new
FileReader
()
fileReader
.
readAsArrayBuffer
(
blob
)
fileReader
.
onload
=
function
()
{
const
shapefile
=
require
(
'shapefile'
)
shapefile
.
read
(
this
.
result
)
.
then
(
geoJson
=>
{
let
i
let
lnglats
let
x
const
geoItem
=
geoJson
// 分析geojson结构
if
((
typeof
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
])
===
'number'
)
{
//
一般为点
//
一般为点
// console.log("1");
//
判断是否是墨卡托坐标系,如果是转化为经纬度
//
判断是否是墨卡托坐标系,如果是转化为经纬度
if
(
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
]
>
180
)
{
gcoord
.
transform
(
geoItem
,
gcoord
.
WebMercator
,
gcoord
.
AMap
);
gcoord
.
transform
(
geoItem
,
gcoord
.
WebMercator
,
gcoord
.
AMap
)
}
//
判断经度是否已经小于我国的最小经度,如果是,就将经度+105(中央经线),纬度+4(有问题,为解决)
//
判断经度是否已经小于我国的最小经度,如果是,就将经度+105(中央经线),纬度+4(有问题,为解决)
if
(
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
]
<
73
)
{
for
(
var
x
=
0
;
x
<
geoItem
.
features
.
length
;
x
++
)
{
var
lnglats
=
geoItem
.
features
[
x
].
geometry
.
coordinates
;
for
(
x
=
0
;
x
<
geoItem
.
features
.
length
;
x
++
)
{
lnglats
=
geoItem
.
features
[
x
].
geometry
.
coordinates
;
lnglats
[
0
]
+=
105
lnglats
[
1
]
+=
4
}
}
}
else
if
((
typeof
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
][
0
])
===
'number'
)
{
//
一般为线
//
一般为线
// console.log("2");
if
(
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
][
0
]
>
180
)
{
gcoord
.
transform
(
geoItem
,
gcoord
.
WebMercator
,
gcoord
.
AMap
);
gcoord
.
transform
(
geoItem
,
gcoord
.
WebMercator
,
gcoord
.
AMap
)
}
if
(
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
][
0
]
<
73
)
{
for
(
var
x
=
0
;
x
<
geoItem
.
features
.
length
;
x
++
)
{
var
lnglats
=
geoItem
.
features
[
x
].
geometry
.
coordinates
;
for
(
var
i
=
0
;
i
<
lnglats
.
length
;
i
++
)
{
for
(
x
=
0
;
x
<
geoItem
.
features
.
length
;
x
++
)
{
lnglats
=
geoItem
.
features
[
x
].
geometry
.
coordinates
;
for
(
i
=
0
;
i
<
lnglats
.
length
;
i
++
)
{
lnglats
[
i
][
0
]
+=
105
lnglats
[
i
][
1
]
+=
4
}
}
}
}
else
if
((
typeof
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
][
0
][
0
])
===
'number'
)
{
//
一般为多边形
//
一般为多边形
// console.log("3");
if
(
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
][
0
][
0
]
>
180
)
{
gcoord
.
transform
(
geoItem
,
gcoord
.
WebMercator
,
gcoord
.
AMap
);
gcoord
.
transform
(
geoItem
,
gcoord
.
WebMercator
,
gcoord
.
AMap
)
}
if
(
geoItem
.
features
[
0
].
geometry
.
coordinates
[
0
][
0
][
0
]
<
73
)
{
for
(
var
x
=
0
;
x
<
geoItem
.
features
.
length
;
x
++
)
{
var
lnglats
=
geoItem
.
features
[
x
].
geometry
.
coordinates
;
for
(
var
i
=
0
;
i
<
lnglats
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
lnglats
[
i
].
length
;
j
++
)
{
for
(
x
=
0
;
x
<
geoItem
.
features
.
length
;
x
++
)
{
lnglats
=
geoItem
.
features
[
x
].
geometry
.
coordinates
;
for
(
i
=
0
;
i
<
lnglats
.
length
;
i
++
)
{
for
(
let
j
=
0
;
j
<
lnglats
[
i
].
length
;
j
++
)
{
lnglats
[
i
][
j
][
0
]
+=
105
lnglats
[
i
][
j
][
1
]
+=
4
}
...
...
@@ -356,74 +374,60 @@
}
}
// Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon、GeometryCollection
var
type
=
geoItem
.
features
[
0
].
geometry
.
type
var
geojson
;
if
(
type
===
"Point"
||
type
===
"MultiPoint"
)
{
geojson
=
new
AMap
.
GeoJSON
({
const
type
=
geoItem
.
features
[
0
].
geometry
.
type
let
geoLayer
if
(
type
===
'Point'
||
type
===
'MultiPoint'
)
{
geoLayer
=
new
AMap
.
GeoJSON
({
geoJSON
:
geoItem
,
getMarker
:
function
(
geojson
,
lnglats
)
{
getMarker
:
function
(
geojson
,
lnglats
)
{
return
new
AMap
.
CircleMarker
({
center
:
lnglats
,
//
圆心位置
radius
:
6
,
//
半径
center
:
lnglats
,
//
圆心位置
radius
:
6
,
//
半径
strokeColor
:
'white'
,
fillColor
:
_this
.
colorList
[
_this
.
colorIndex
],
});
}
fillColor
:
_this
.
colorList
[
_this
.
colorIndex
]
})
//colorList中有17个颜色
this
.
colorIndex
=
(
this
.
colorIndex
+
1
)
%
17
;
}
else
if
(
type
===
"LineString"
||
type
===
"MultiLineString"
){
geojson
=
new
AMap
.
GeoJSON
({
})
// colorList中有17个颜色
_this
.
colorIndex
=
(
_this
.
colorIndex
+
1
)
%
17
}
else
if
(
type
===
'LineString'
||
type
===
'MultiLineString'
)
{
geoLayer
=
new
AMap
.
GeoJSON
({
geoJSON
:
geoItem
,
getPolyline
:
function
(
geojson
,
lnglats
)
{
getPolyline
:
function
(
geojson
,
lnglats
)
{
return
new
AMap
.
Polyline
({
path
:
lnglats
,
strokeColor
:
_this
.
colorList
[
_this
.
colorIndex
],
});
}
strokeColor
:
_this
.
colorList
[
_this
.
colorIndex
]
})
this
.
colorIndex
=
(
this
.
colorIndex
+
1
)
%
17
;
}
else
if
(
type
===
"Polygon"
||
type
===
"MultiPolygon"
){
geojson
=
new
AMap
.
GeoJSON
({
})
_this
.
colorIndex
=
(
_this
.
colorIndex
+
1
)
%
17
}
else
if
(
type
===
'Polygon'
||
type
===
'MultiPolygon'
)
{
geoLayer
=
new
AMap
.
GeoJSON
({
geoJSON
:
geoItem
,
// 还可以自定义getMarker和getPolyline
getPolygon
:
function
(
geojson
,
lnglats
)
{
getPolygon
:
function
(
geojson
,
lnglats
)
{
return
new
AMap
.
Polygon
({
path
:
lnglats
,
strokeColor
:
'white'
,
fillColor
:
_this
.
colorList
[
_this
.
colorIndex
],
});
}
fillColor
:
_this
.
colorList
[
_this
.
colorIndex
]
})
this
.
colorIndex
=
(
this
.
colorIndex
+
1
)
%
17
;
}
else
{
geojson
=
new
AMap
.
GeoJSON
({
geoJSON
:
geoItem
,
})
_this
.
colorIndex
=
(
_this
.
colorIndex
+
1
)
%
17
}
else
{
geoLayer
=
new
AMap
.
GeoJSON
({
geoJSON
:
geoItem
})
}
this
.
map
.
add
(
geojson
)
this
.
layerEventMap
.
push
(
0
)
this
.
layerList
.
push
(
geojson
)
}
}).
catch
(
e
=>
{
console
.
log
(
e
.
toString
())
_this
.
layerEventMap
.
push
(
0
)
_this
.
layerList
.
push
(
geoLayer
)
})
}
this
.
get_height
()
var
_this
=
this
window
.
onresize
=
function
()
{
// alert("??");
_this
.
height_res
=
document
.
body
.
clientHeight
-
61
}
this
.
init
()
}
this
.
restore
()
},
beforeRouteLeave
:
function
(
to
,
from
,
next
)
{
if
(
!
this
.
hasSaved
)
{
let
i
=
0
...
...
@@ -448,10 +452,9 @@
// next()
// }
// },500)
},
watch
:
{
radio1
:
function
f
()
{
radio1
:
function
f
()
{
if
(
this
.
radio1
==
'地标'
)
{
this
.
mouseTool
.
close
()
}
else
if
(
this
.
radio1
==
'矩形'
)
{
...
...
@@ -466,7 +469,7 @@
}
},
methods
:
{
init
()
{
init
()
{
this
.
map
=
new
AMap
.
Map
(
'container'
,
{
center
:
[
116.397428
,
39.90923
],
// 中心点坐标
resizeEnable
:
true
,
...
...
@@ -528,21 +531,23 @@
}
})
},
handleShowClick
(
index
)
{
handleShowClick
(
index
)
{
if
(
this
.
layerEventMap
[
index
]
===
0
)
{
this
.
map
.
add
(
this
.
layerList
[
index
])
}
this
.
layerEventMap
[
index
]
++
this
.
layerHide
=
index
if
(
this
.
layerEventMap
[
index
]
%
2
===
1
)
{
this
.
layerList
[
index
].
hide
()
}
else
{
this
.
layerList
[
index
].
show
()
}
else
{
this
.
layerList
[
index
].
hide
()
}
},
// 点标注&区域标注跳转
handleClick
(
tab
,
event
)
{
handleClick
(
tab
,
event
)
{
// console.log(tab, event)
},
// 删除标注
deleteLabelInList
()
{
deleteLabelInList
()
{
if
(
this
.
isMark
)
{
this
.
landmarkData
.
splice
(
this
.
labelNow
,
1
)
}
else
{
...
...
@@ -554,7 +559,7 @@
this
.
hasSaved
=
false
},
// 双击显示详细信息
markInfo
(
index
)
{
markInfo
(
index
)
{
// 改变中心位置
this
.
setCenter
(
'mark'
,
this
.
landmarkData
[
index
])
...
...
@@ -565,7 +570,7 @@
this
.
labelName
=
this
.
landmarkData
[
index
].
landmarkName
this
.
labelPosition
=
'经度:'
+
this
.
landmarkData
[
index
].
X
+
'
\
n纬度:'
+
this
.
landmarkData
[
index
].
Y
},
areaInfo
(
index
)
{
areaInfo
(
index
)
{
// 改变中心位置
this
.
setCenter
(
'polygon'
,
this
.
layerData
[
index
].
pointList
)
...
...
@@ -580,7 +585,7 @@
})
},
// 鼠标移入高亮
areaEnter
(
index
)
{
areaEnter
(
index
)
{
// 还原地标
this
.
map
.
clearMap
()
this
.
landmarkData
.
forEach
(
element
=>
{
...
...
@@ -618,7 +623,7 @@
})
},
// 计算多边形几何中心, 没有使用的函数
findCenter
(
pointList
)
{
findCenter
(
pointList
)
{
var
minX
=
1000
var
minY
=
1000
var
maxX
=
-
1000
...
...
@@ -642,7 +647,7 @@
this
.
jumpByPosition
(
midX
,
midY
)
},
markEnter
(
index
)
{
markEnter
(
index
)
{
// 还原地标
this
.
map
.
clearMap
()
this
.
landmarkData
.
forEach
((
element
,
i
)
=>
{
...
...
@@ -679,7 +684,7 @@
this
.
map
.
add
(
polygon
)
})
},
setCenter
(
type
,
pointList
)
{
setCenter
(
type
,
pointList
)
{
if
(
type
==
'mark'
)
{
var
tmp
=
new
AMap
.
Marker
({
position
:
new
AMap
.
LngLat
(
pointList
.
X
,
pointList
.
Y
),
// 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
...
...
@@ -702,7 +707,7 @@
/**
* 还原数据中的地标、标注区域
*/
restore
()
{
restore
()
{
// 还原地标
this
.
map
.
clearMap
()
this
.
landmarkData
.
forEach
(
element
=>
{
...
...
@@ -732,7 +737,7 @@
/**
获取标注任务的relationID
*/
getRelationId
()
{
getRelationId
()
{
// 由于获取方法还没有确定,所以这里先使用桩
let
res
=
{
'relationId'
:
this
.
relationId
...
...
@@ -742,7 +747,24 @@
/**
前端接口——获取图层数据
*/
async
getLayerList
()
{
async
getGeoList
(
index
)
{
this
.
data
=
[]
let
relationId
=
this
.
relationId
try
{
return
await
this
.
axios
({
method
:
'post'
,
url
:
'/layer/getGeojson'
,
data
:
{
'relationId'
:
relationId
,
'index'
:
index
},
responseType
:
'blob'
})
}
catch
(
err
)
{
self
.
$store
.
commit
(
'clearLayerData'
)
console
.
log
(
err
)
alert
(
'请求出错!'
)
}
},
async
getLayerList
()
{
this
.
data
=
[]
let
params
=
this
.
getRelationId
()
try
{
...
...
@@ -756,12 +778,12 @@
if
(
res
.
code
===
1
)
{
let
layerInfo
=
res
.
data
.
layerInfo
let
landmarkList
=
res
.
data
.
landmarkList
let
geoJSON
=
res
.
data
.
geojson
let
geoNames
=
res
.
data
.
geoNames
// console.log(res.data)
return
{
layerInfo
:
layerInfo
,
landmarkList
:
landmarkList
,
geoJSON
:
geoJSON
geoNames
:
geoNames
}
}
else
{
self
.
$store
.
commit
(
'clearLayerData'
)
...
...
@@ -776,14 +798,14 @@
/**
* 坐标跳转
*/
jumpByPosition
(
X
,
Y
)
{
jumpByPosition
(
X
,
Y
)
{
var
position
=
new
AMap
.
LngLat
(
X
,
Y
)
this
.
map
.
setCenter
(
position
)
},
/**
* 添加地标
*/
addlandmark
(
position
)
{
addlandmark
(
position
)
{
var
landmarkName
this
.
$prompt
(
'请输入地标名称'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
...
...
@@ -802,7 +824,7 @@
/**
* 创建地标数据
*/
makelandmark
(
landmarkName
,
position
)
{
makelandmark
(
landmarkName
,
position
)
{
let
currentId
=
this
.
landmarkData
.
length
let
newlandmark
=
{
...
...
@@ -827,7 +849,7 @@
/**
* 画矩形,这是高德地图的样例代码
*/
drawRectangle
()
{
drawRectangle
()
{
if
(
this
.
radio1
==
'矩形'
)
{
this
.
mouseTool
.
rectangle
({
strokeColor
:
'red'
,
...
...
@@ -843,7 +865,7 @@
})
}
},
addRectangle
(
northEast
,
southWest
)
{
addRectangle
(
northEast
,
southWest
)
{
var
name
this
.
$prompt
(
'请输入标注名称'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
...
...
@@ -863,7 +885,7 @@
/**
* 创建矩形区域数据
*/
makeRectangle
(
labelName
,
northEast
,
southWest
)
{
makeRectangle
(
labelName
,
northEast
,
southWest
)
{
// X是经度,Y是纬度,应该是没错的,当初就不该叫XY的
// 右上
let
p0
=
{
...
...
@@ -911,7 +933,7 @@
/**
* 画多边形,高德地图的样例代码
*/
drawPolygon
()
{
drawPolygon
()
{
this
.
mouseTool
.
polygon
({
strokeColor
:
'red'
,
strokeOpacity
:
1
,
...
...
@@ -928,7 +950,7 @@
/**
* 创建多边形标签
*/
addPolygon
(
path
)
{
addPolygon
(
path
)
{
var
name
this
.
$prompt
(
'请输入标注名称'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
...
...
@@ -948,7 +970,7 @@
/**
* 创建多边形数据
*/
makePolygon
(
labelName
,
path
)
{
makePolygon
(
labelName
,
path
)
{
// console.log(path)
var
pointList
=
[]
var
i
=
0
...
...
@@ -975,7 +997,7 @@
this
.
hasSaved
=
false
},
// 保存数据用的接口
save
()
{
save
()
{
let
outputLayerInfo
=
{
relationId
:
this
.
relationId
,
labelList
:
this
.
layerData
...
...
@@ -1032,10 +1054,10 @@
})
})
},
get_height
()
{
get_height
()
{
this
.
height_res
=
document
.
body
.
clientHeight
-
61
},
changeToolBar
(
val
)
{
changeToolBar
(
val
)
{
this
.
activeIndex1
=
val
},
/**
...
...
@@ -1059,7 +1081,7 @@
})
}
}
}
}
</
script
>
<
style
scoped
>
...
...
DAPlatform/upload/1605014565.shp
0 → 100644
View file @
8cac7d6a
File added
DAPlatform/views/imageAnnotation.py
View file @
8cac7d6a
...
...
@@ -5,7 +5,7 @@ import zipfile
import
os
import
shapefile
from
support
import
basedir
from
flask
import
Blueprint
,
request
,
make_response
,
send_file
from
flask
import
Blueprint
,
request
,
make_response
,
send_file
,
jsonify
from
dao
import
Image
,
Relation
...
...
@@ -61,16 +61,16 @@ def save_image():
# 获取图层中的每一个shp文件
def
retGeo
Json
(
relationId
):
def
retGeo
Names
(
relationId
):
urlList
=
Image
.
retURLList
(
relationId
)
geo
List
=
[]
name
List
=
[]
defaultList
=
[
{
"name"
:
"河流水系1-2级"
,
"url"
:
'1604321976.shp'
},
# 河1-2
{
"name"
:
"河流水系3级"
,
"url"
:
'1604321548.shp'
},
# 河3
#
{"name": "河流水系4级", "url": '1604321993.shp'}, # 河4
{
"name"
:
"河流水系4级"
,
"url"
:
'1604321993.shp'
},
# 河4
# {"name": "河流水系5级", "url": '1604322005.shp'}, #河5,文件太大,全部叠加后前端无法显示
{
"name"
:
"活动断裂分布"
,
"url"
:
'1604042749.shp'
},
# 活动断裂
{
"name"
:
"全国降雨量站降雨数据"
,
"url"
:
'1604042339.shp'
},
# 降雨量
#
{"name": "活动断裂分布", "url": '1604042749.shp'}, # 活动断裂
#
{"name": "全国降雨量站降雨数据", "url": '1604042339.shp'}, # 降雨量
]
allList
=
[]
isExtended
=
False
...
...
@@ -78,29 +78,65 @@ def retGeoJson(relationId):
url
=
item
[
'url'
]
if
url
==
"默认"
:
isExtended
=
True
urlList
.
remove
(
item
)
if
isExtended
:
allList
.
extend
(
defaultList
)
allList
.
extend
(
urlList
)
for
item
in
allList
:
nameList
.
append
(
item
[
'name'
])
return
nameList
# 获取图层中的每一个shp文件
def
retGeoJson
(
all_list
,
index
):
item
=
all_list
[
index
]
url
=
item
[
'url'
]
if
url
==
"默认"
:
if
isExtended
==
False
:
defaultList
.
extend
(
urlList
)
isExtended
=
True
else
:
continue
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
))
geoList
.
append
({
"name"
:
item
[
'name'
],
"geojson"
:
{
"type"
:
"FeatureCollection"
,
"features"
:
buffer
}})
shp
=
open
(
file_dir
,
'rb'
)
name
=
item
[
'name'
]
.
encode
(
"utf-8"
)
.
decode
(
"latin1"
)
geoList
=
shp
.
read
()
return
geoList
# 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))
# geoList.append({"name": item['name'], "geojson": {"type": "FeatureCollection", "features": buffer}})
# 获取图层
@image.route
(
"/layer/getGeojson"
,
methods
=
[
"POST"
])
def
get_geo_list
():
print
(
"get_geo_list"
)
data
=
json
.
loads
(
request
.
data
.
decode
(
'utf-8'
))
relation_list
=
data
[
'relationId'
]
index
=
data
[
'index'
]
print
(
relation_list
,
index
)
urlList
=
Image
.
retURLList
(
relation_list
)
geoList
=
None
defaultList
=
[
{
"name"
:
"河流水系1-2级"
,
"url"
:
'1604321976.shp'
},
# 河1-2
{
"name"
:
"河流水系3级"
,
"url"
:
'1604321548.shp'
},
# 河3
{
"name"
:
"河流水系4级"
,
"url"
:
'1604321993.shp'
},
# 河4
# {"name": "河流水系5级", "url": '1604322005.shp'}, #河5,文件太大,全部叠加后前端无法显示
# {"name": "活动断裂分布", "url": '1604042749.shp'}, # 活动断裂
# {"name": "全国降雨量站降雨数据", "url": '1604042339.shp'}, # 降雨量
]
allList
=
[]
isExtended
=
False
for
item
in
urlList
:
url
=
item
[
'url'
]
if
url
==
"默认"
:
isExtended
=
True
urlList
.
remove
(
item
)
if
isExtended
:
allList
.
extend
(
defaultList
)
allList
.
extend
(
urlList
)
geojson
=
retGeoJson
(
allList
,
index
)
print
(
"geojson"
)
return
geojson
# 获取图层
...
...
@@ -109,10 +145,10 @@ def get_layer():
data
=
json
.
loads
(
request
.
data
.
decode
(
'utf-8'
))
relation_list
=
data
[
'relationId'
]
resLayer
=
Image
.
getLayer
(
relation_list
)
geo
json
=
retGeoJson
(
relation_list
)
geo
Names
=
retGeoNames
(
relation_list
)
layer
=
resLayer
.
data
resdata
=
{
'geo
json'
:
geojson
,
'geo
Names'
:
geoNames
,
'layerInfo'
:
layer
[
'layerInfo'
],
'landmarkList'
:
layer
[
'landmarkList'
],
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment