addDataSet.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <!-- <link rel="stylesheet" href="./ol.css" type="text/css"> -->
  5. <link rel="stylesheet" href="../style.css" type="text/css">
  6. <!-- <script src="./ol.js"></script> -->
  7. <style>
  8. [v-cloak] {
  9. display: none;
  10. }
  11. #editor {
  12. height: 200px;
  13. }
  14. </style>
  15. <!-- <script src="./ol.js"></script> -->
  16. <title>定位</title>
  17. </head>
  18. <body>
  19. <div id="app" v-cloak>
  20. <div class="content">
  21. <!-- <div class="rightBox">
  22. <div class="map-layer">
  23. <div id="map" class="map"></div>
  24. <image-tranform :map-ol="map" v-if="map && showImageTranform" v-show="showImageTranform1" ref="imageTranform" />
  25. </div>
  26. </div> -->
  27. <div id="plane">
  28. <div class="main" v-if="showType==0">
  29. <!-- <div class="title">定位</div> -->
  30. <p class="desc">提示:当前控制点坐标为系统提供的默认值,请将控制点坐标调整为真实的地理坐标。</p>
  31. <div class="editBtn" @click="openEdit">修改控制点</div>
  32. <div class="editBtn pointClound" @click="showType=2">
  33. 添加数据集
  34. </div>
  35. <!-- <div class="editBtn pointClound" @click="showType=3">
  36. 平面图
  37. </div> -->
  38. </div>
  39. <div class="control_box" v-if="showType==1">
  40. <div class="headerBack">
  41. <div class="topBox">
  42. <i class="backIcon" @click="showType=0"></i>
  43. <p class="headerTitle">修改控制点</p>
  44. </div>
  45. <p style="padding-left: 32px;" class="desc">通过两个控制点坐标确定点云在地图上的位置</p>
  46. </div>
  47. <div class="scrollBox">
  48. <!-- <h4>修改控制点 </h4>
  49. <p class="desc">通过两个控制点坐标确定点云在地图上的位置</p> -->
  50. <p class="itemTitle">EPSG 坐标系 </p>
  51. <div class="formItem">
  52. <div class="allIpt">
  53. <input type="text" disabled v-model="EPSG" name="EPSG" id="EPSG" />
  54. </div>
  55. </div>
  56. <form>
  57. <div class="tag">
  58. <P class="formTitle">控制点1</P>
  59. <!-- <div class="localIcon" @click="set_location(1)"></div> -->
  60. </div>
  61. <div class="formItem">
  62. <p class="itemTitle">本地坐标:</p>
  63. <div class="inputItem">
  64. <div class="name"> X</div>
  65. <div class="ipt">
  66. <input @input="limtInput('ax')" type="text" v-model="ax" name="ax" id="ax" />
  67. </div>
  68. <span class="unit">m</span>
  69. </div>
  70. <div class="inputItem">
  71. <div class="name"> Y</div>
  72. <div class="ipt">
  73. <input @input="limtInput('ay')" type="text" v-model="ay" name="ay" id="ay" />
  74. </div>
  75. <span class="unit">m</span>
  76. </div>
  77. </div>
  78. <div class="formItem">
  79. <p class="itemTitle">地理坐标:</p>
  80. <div class="inputItem">
  81. <div class="name">经度</div>
  82. <div class="ipt">
  83. <input type="text" @input="limtInput('alon')" v-model="alon" name="alon" id="alon" value="120" />
  84. </div>
  85. </div>
  86. <div class="inputItem">
  87. <div class="name">纬度</div>
  88. <div class="ipt">
  89. <input type="text" @input="limtInput('alat')" v-model="alat" name="alat" id="alat" value="22" />
  90. </div>
  91. </div>
  92. </div>
  93. <div class="tag">
  94. <P class="formTitle">控制点2</P>
  95. <!-- <div class="localIcon" @click="set_location(2)"></div> -->
  96. </div>
  97. <div class="formItem">
  98. <p class="itemTitle">本地坐标:</p>
  99. <div class="inputItem">
  100. <div class="name"> X</div>
  101. <div class="ipt">
  102. <input type="text" @input="limtInput('bx')" v-model="bx" name="bx" id="bx" />
  103. </div>
  104. <span class="unit">m</span>
  105. </div>
  106. <div class="inputItem">
  107. <div class="name"> Y</div>
  108. <div class="ipt">
  109. <input type="text" @input="limtInput('by')" v-model="by" name="by" id="by" />
  110. </div>
  111. <span class="unit">m</span>
  112. </div>
  113. <!-- <div class="inputItem">
  114. <div class="name"> Z</div>
  115. <div class="ipt">
  116. <input type="text" v-model="bz" name="bz" id="bz" />
  117. </div>
  118. <span class="unit">m</span>
  119. </div> -->
  120. </div>
  121. <div class="formItem">
  122. <p class="itemTitle">地理坐标:</p>
  123. <div class="inputItem">
  124. <div class="name">经度</div>
  125. <div class="ipt">
  126. <input type="text" @input="limtInput('blon')" v-model="blon" name="blon" id="blon" value="123" />
  127. </div>
  128. </div>
  129. <div class="inputItem">
  130. <div class="name">纬度</div>
  131. <div class="ipt">
  132. <input type="text" @input="limtInput('blat')" v-model="blat" name="blat" id="blat" value="22" />
  133. </div>
  134. </div>
  135. <!-- <div class="inputItem">
  136. <div class="name">高程</div>
  137. <div class="ipt">
  138. <input type="text" v-model="balt" name="balt" id="balt" value="0" />
  139. </div>
  140. </div> -->
  141. </div>
  142. </form>
  143. </div>
  144. <div class="bottom">
  145. <div class="style"></div>
  146. <!-- <input type="submit" class="submitBtn" value="提交" />
  147. <button id="clear">取消</button> -->
  148. <!-- <div id="clear" @click="getImageTransform">提交地图信息</div> -->
  149. <!-- <div id="clear" @click="clearMap">取消</div> -->
  150. <div id="clear" @click="showType=0">取消</div>
  151. <div class="submitBtn" @click="commit()">
  152. 保存
  153. </div>
  154. </div>
  155. </div>
  156. <upload-pointClound v-if="showType==2" />
  157. <div id="planePic" v-if="showType==3">
  158. <div class="headerBack">
  159. <div class="topBox">
  160. <i class="backIcon" @click="showType =0"></i>
  161. <p class="headerTitle">平面图</p>
  162. </div>
  163. </div>
  164. <div class="defaultPic itemBox active">
  165. <div class="ctrlBox">
  166. <div class="ctrlTitle">
  167. 默认平面图
  168. <div class="tipBox" title="修改点云或数据集后,请更新平面图"></div>
  169. </div>
  170. <!-- <p>默认平面图</p> -->
  171. <el-popconfirm placement="top" title="系统将创建新的平面图,您上传的平面图将被清除,是否继续?" :hide-icon="true" @confirm="refreshConfirm">
  172. <el-button slot="reference">
  173. <div class="ctrlBtn">
  174. <i class="ctrlIcon refreshIcon"></i>
  175. <p class="ctrlText">更新</p>
  176. </div>
  177. </el-button>
  178. </el-popconfirm>
  179. </div>
  180. </div>
  181. <div class="diyPic itemBox ">
  182. <div class="ctrlBox">
  183. <p class="ctrlTitle">自定义平面图</p>
  184. <div class="btnBox">
  185. <el-popconfirm placement="top" title="确认删除?" :hide-icon="true" @confirm="delConfirm">
  186. <el-button slot="reference">
  187. <div class="ctrlBtn">
  188. <i class="ctrlIcon disableIcon "></i>
  189. <p class="ctrlText">删除</p>
  190. </div>
  191. </el-button>
  192. </el-popconfirm>
  193. <div class="ctrlBtn">
  194. <i class="ctrlIcon downloadIcon"></i>
  195. <p class="ctrlText">下载</p>
  196. </div>
  197. <div class="ctrlBtn" lable="files">
  198. <i class="ctrlIcon uploadIcon"></i>
  199. <p class="ctrlText">上传</p>
  200. </div>
  201. <input type="file" id="files" @change="uploadPic">
  202. </div>
  203. </div>
  204. </div>
  205. <div class="tipText">
  206. 操作说明<br/> 1. 下载默认平面图,支持.png文件下载;<br /> 2. 解压下载的压缩包,替换压缩包中的图片文件;<br /> (文件名,图片大小、格式需与原图保持一致)
  207. <br /> 3. 上传平面图<br />
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. <script src="./js/vue.js"></script>
  214. <script src="./js/element.js"></script>
  215. <script src="./js/axios.min.js"></script>
  216. <!-- <script src="./js/proj4.js"></script>
  217. <script src="./js/three.js"></script> -->
  218. <!-- <script src="./components/image-transform/index.js"></script> -->
  219. <script src="./components/upload-pointClound/index.js"></script>
  220. <script type="text/javascript">
  221. //输入经纬度就可以定位
  222. </script>
  223. <script>
  224. // //坐标转换定义 部分 定义一个 cgc_2000的38度带投影坐标系
  225. // proj4.defs("EPSG:99999",
  226. // "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
  227. // proj4.defs("EPSG:99999", "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
  228. // proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
  229. // var projection = new ol.proj.Projection({
  230. // code: "EPSG:99999",
  231. // extent: [334238.8538694997, 425861.702215328, 599418.034383447, 5936877.5664797],
  232. // units: 'm',
  233. // axisOrientation: 'neu',
  234. // global: false
  235. // });
  236. // //结合proj4在ol中自定义坐标系
  237. // ol.proj.addProjection(projection);
  238. // ol.proj.addCoordinateTransforms("EPSG:4326", "EPSG:99999",
  239. // function(coordinate) {
  240. // return proj4("EPSG:4326", "EPSG:99999", coordinate);
  241. // },
  242. // function(coordinate) {
  243. // return proj4("EPSG:99999", "EPSG:4326", coordinate);
  244. // }
  245. // );
  246. new Vue({
  247. el: '#app',
  248. data() {
  249. return {
  250. status: 0,
  251. showImageTranform: true,
  252. showImageTranform1: true,
  253. showType: 0,
  254. pointLayerArray: [],
  255. map: null,
  256. gaodeMapLayer: {},
  257. ax: '',
  258. ay: '',
  259. az: '',
  260. alon: '120',
  261. alat: '22',
  262. aalt: '',
  263. bx: '',
  264. by: '',
  265. bz: '',
  266. blon: '123',
  267. blat: '22',
  268. balt: '',
  269. EPSG: 'EPSG:4490',
  270. ageControlLocation1: [],
  271. ageControlLocation2: [],
  272. gpsControlCoordinate1: [],
  273. gpsControlCoordinate2: [],
  274. sceneNum: '',
  275. canvas: null,
  276. ctx: null,
  277. imageCanvas: null,
  278. imageCanvasLayer: null,
  279. img: null,
  280. drugObj: null,
  281. rotateObj: null,
  282. imgSrc: null,
  283. file: null,
  284. isRotate: false,
  285. isDraw: false,
  286. size: 512,
  287. limitSize: 512,
  288. uploadData: {
  289. file: null,
  290. lon: '113.59963069739054',
  291. lat: '22.364821730960752',
  292. direction: '0',
  293. size: '256'
  294. },
  295. // 优化
  296. showData: {
  297. ax: '',
  298. ay: '',
  299. az: '',
  300. alon: '120',
  301. alat: '22',
  302. aalt: '',
  303. bx: '',
  304. by: '',
  305. bz: '',
  306. blon: '123',
  307. blat: '22',
  308. balt: ''
  309. },
  310. token: null
  311. }
  312. },
  313. created() {
  314. },
  315. mounted() {
  316. const origin = window.location.origin + window.location.pathname
  317. const tokenKry = 'ls.' + origin + '#JWT'
  318. this.token = localStorage.getItem(tokenKry)
  319. axios.defaults.headers.common['X-Authorization'] = this.token;
  320. // alert(sceneNum)
  321. this.getContorlPoint()
  322. // this.sceneNum = window.location.pathname.split('/')[2]
  323. // this.$nextTick(() => {
  324. // let t = setTimeout(() => {
  325. // this.map = this.initMap('map');
  326. // }, 100)
  327. // })
  328. },
  329. methods: {
  330. readyUpload() {
  331. // console.log(this.$refs.imageTranform)
  332. this.$refs.imageTranform.readyUpload()
  333. },
  334. getImageTransform() {
  335. // 地图数据上传 如果用户没有选择数据直接返回true 如果有数据要上传返回promise
  336. Promise.all([
  337. this.$refs.imageTranform.uploadData(),
  338. this.$refs.imageTranform.uploadTiled()
  339. ])
  340. .then(res => {
  341. alert('成功')
  342. this.showImageTranform = false
  343. this.$nextTick(() => {
  344. this.showImageTranform = true
  345. })
  346. })
  347. .catch(() => {
  348. alert('失败')
  349. })
  350. },
  351. getImageTiled() {
  352. this.$refs.imageTranform.uploadTiled()
  353. .then(() => alert('成功'))
  354. .catch(() => {
  355. alert('失败')
  356. })
  357. },
  358. initMap(divid) {
  359. this.pointLayerArray = [];
  360. this.gaodeMapLayer = new ol.layer.Tile({
  361. source: new ol.source.XYZ({
  362. url: 'http://wprd03.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}' //高德地图切片访问路径
  363. })
  364. });
  365. return new ol.Map({
  366. layers: [this.gaodeMapLayer],
  367. target: divid,
  368. view: new ol.View({
  369. center: ol.proj.fromLonLat([113.59569403794666,
  370. 22.36656052911783
  371. ]), //最初定位的位置
  372. zoom: 4 //地图层级
  373. })
  374. });
  375. },
  376. clearMap() {
  377. this.pointLayerArray.map(each => {
  378. if (each.type == "con_point") {
  379. this.map.removeLayer(each)
  380. }
  381. });
  382. this.pointLayerArray = [];
  383. },
  384. addPoint(lon, lat, text, index) {
  385. let vector = new ol.source.Vector();
  386. let vLayer = new ol.layer.Vector({
  387. source: vector
  388. })
  389. vLayer.type = "con_point";
  390. vLayer.index = index;
  391. this.map.addLayer(vLayer)
  392. this.pointLayerArray.push(vLayer);
  393. let labelCoords = ol.proj.transform([lon, lat], "EPSG:4326", "EPSG:3857");
  394. let feature = new ol.Feature({
  395. geometry: new ol.geom.Point(labelCoords)
  396. });
  397. vector.addFeature(feature);
  398. vLayer.setStyle(new ol.style.Style({
  399. image: new ol.style.Circle({ //点样式
  400. radius: 7,
  401. fill: new ol.style.Fill({
  402. color: '#00c033'
  403. })
  404. }),
  405. text: new ol.style.Text({
  406. text: text,
  407. font: '15px sans-serif',
  408. offsetX: 5,
  409. offsetY: -10,
  410. fill: new ol.style.Fill({
  411. color: "#b9391f"
  412. }),
  413. stroke: new ol.style.Stroke({
  414. color: "#b9391f"
  415. })
  416. })
  417. }))
  418. this.map.getView().setCenter(labelCoords)
  419. },
  420. set_location(index) {
  421. let alon
  422. let alat
  423. let str = ''
  424. if (index == 1) {
  425. alon = this.alon;
  426. alat = this.alat;
  427. str = '锚点1'
  428. } else {
  429. alon = this.blon;
  430. alat = this.blat;
  431. str = '锚点2'
  432. }
  433. this.removePoint(index)
  434. this.addPoint(+alon, +alat, str, index)
  435. },
  436. removePoint(index) {
  437. let num = this.pointLayerArray.filter((item, i) => {
  438. if (index == item.index) {
  439. this.pointLayerArray.splice(i, 1)
  440. }
  441. })
  442. },
  443. commit() {
  444. this.handleData()
  445. this.showLoading('请稍后...')
  446. axios.post('/indoor/' + sceneNum + '/api/controlPoint/save', {
  447. ageControlLocation1: this.ageControlLocation1,
  448. ageControlLocation2: this.ageControlLocation2,
  449. gpsControlCoordinate1: this.gpsControlCoordinate1,
  450. gpsControlCoordinate2: this.gpsControlCoordinate2,
  451. }).then((res) => {
  452. if (res.data.code == 0) {
  453. IV.api.AuthenticationService.sendAuthenticationChanged()
  454. this.getContorlPoint()
  455. this.hideLoading()
  456. this.$message({
  457. message: '控制点上传成功',
  458. type: 'success',
  459. duration: 2000,
  460. });
  461. }
  462. }).catch(function(error) {
  463. this.hideLoading()
  464. this.$message({
  465. message: '控制点上传失败',
  466. type: 'error',
  467. duration: 2000,
  468. });
  469. })
  470. },
  471. handleData() {
  472. //重置数组
  473. this.ageControlLocation1 = []
  474. this.ageControlLocation2 = []
  475. this.gpsControlCoordinate1 = []
  476. this.gpsControlCoordinate2 = []
  477. //
  478. this.ageControlLocation1.push(this.ax - 0)
  479. this.ageControlLocation1.push(this.ay - 0)
  480. this.ageControlLocation1.push(this.az - 0)
  481. this.gpsControlCoordinate1.push(this.alon - 0)
  482. this.gpsControlCoordinate1.push(this.alat - 0)
  483. this.gpsControlCoordinate1.push(this.aalt - 0)
  484. this.ageControlLocation2.push(this.bx - 0)
  485. this.ageControlLocation2.push(this.by - 0)
  486. this.ageControlLocation2.push(this.bz - 0)
  487. this.gpsControlCoordinate2.push(this.blon - 0)
  488. this.gpsControlCoordinate2.push(this.blat - 0)
  489. this.gpsControlCoordinate2.push(this.balt - 0)
  490. },
  491. //获取控制点
  492. getContorlPoint() {
  493. // /indoor/{sceneCode}/api/controlPoint/detail
  494. // const sceneName = window.location.pathname.split('/')[2]
  495. // const isDev = !sceneName || sceneName === 'addDataSet.html'
  496. // const sceneCode = isDev ? 't-kJ2PEjZ' : sceneName
  497. axios.get(`/indoor/${sceneNum}/api/controlPoint/detail`).then(res => {
  498. this.status = res.data.data.status
  499. this.initContorlPoint(res.data.data)
  500. this.set_location(1)
  501. this.set_location(2)
  502. }).catch(err => {
  503. })
  504. },
  505. initContorlPoint(data) {
  506. this.ax = data.ageControlLocation1[0]
  507. this.ay = data.ageControlLocation1[1]
  508. this.bx = data.ageControlLocation2[0]
  509. this.by = data.ageControlLocation2[1]
  510. this.alon = data.gpsControlCoordinate1[0]
  511. this.alat = data.gpsControlCoordinate1[1]
  512. this.blon = data.gpsControlCoordinate2[0]
  513. this.blat = data.gpsControlCoordinate2[1]
  514. this.showData.ax = data.ageControlLocation1[0]
  515. this.showData.ay = data.ageControlLocation1[1]
  516. this.showData.bx = data.ageControlLocation2[0]
  517. this.showData.by = data.ageControlLocation2[1]
  518. this.showData.alon = data.gpsControlCoordinate1[0]
  519. this.showData.alat = data.gpsControlCoordinate1[1]
  520. this.showData.blon = data.gpsControlCoordinate2[0]
  521. this.showData.blat = data.gpsControlCoordinate2[1]
  522. },
  523. openEdit() {
  524. this.showType = 1
  525. this.ax = this.showData.ax
  526. this.ay = this.showData.ay
  527. this.bx = this.showData.bx
  528. this.by = this.showData.by
  529. this.alon = this.showData.alon
  530. this.alat = this.showData.alat
  531. this.blon = this.showData.blon
  532. this.blat = this.showData.blat
  533. },
  534. showLoading(str) {
  535. $('body').append(' <div id="upload-loading"><img class="icon" src="../img/icon/loading.png" alt=""><span class="text">' + str + '</span></div>');
  536. },
  537. hideLoading() {
  538. $('#upload-loading').remove()
  539. },
  540. limtInput(value) {
  541. this[value] = this[value].replace(/[^\-?\d.]/g, '')
  542. },
  543. moveEnd(e) {
  544. let obj = e.currentTarget
  545. obj.focus();
  546. var len = obj.value.length;
  547. if (document.selection) {
  548. var sel = obj.createTextRange();
  549. sel.moveStart('character', len);
  550. sel.collapse();
  551. sel.select();
  552. } else if (typeof obj.selectionStart == 'number' &&
  553. typeof obj.selectionEnd == 'number') {
  554. obj.selectionStart = obj.selectionEnd = len;
  555. }
  556. },
  557. refreshConfirm() {
  558. console.log('refreshConfirm')
  559. },
  560. delConfirm() {
  561. console.log('delConfirm')
  562. },
  563. uploadPic(e) {
  564. let file = e.target.files[0]
  565. let params = new FormData()
  566. params.append('file', file)
  567. axios.post(`/api/${sceneNum}/uploadPic`, params).then(res => {
  568. }).catch(err => {
  569. this.$message({
  570. message: '上传失败',
  571. type: 'error',
  572. duration: 2000,
  573. });
  574. })
  575. }
  576. }
  577. })
  578. </script>
  579. </body>
  580. </html>