addDataSet.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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. <p class="ctrlTitle">默认平面图</p>
  167. <div class="ctrlBtn">
  168. <i class="ctrlIcon refreshIcon"></i>
  169. <p class="ctrlText">更新</p>
  170. <div class="tipBox" title="修改点云或数据集后,请更新平面图"></div>
  171. </div>
  172. </div>
  173. </div>
  174. <div class="diyPic itemBox ">
  175. <div class="ctrlBox">
  176. <p class="ctrlTitle">自定义平面图</p>
  177. <div class="btnBox">
  178. <div class="ctrlBtn">
  179. <i class="ctrlIcon disableIcon "></i>
  180. <p class="ctrlText">删除</p>
  181. </div>
  182. <div class="ctrlBtn">
  183. <i class="ctrlIcon downloadIcon"></i>
  184. <p class="ctrlText">下载</p>
  185. </div>
  186. <div class="ctrlBtn">
  187. <i class="ctrlIcon uploadIcon"></i>
  188. <p class="ctrlText">上传</p>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="tipText">
  194. 操作说明<br/> 1. 下载默认平面图,支持.png文件下载;<br /> 2. 解压下载的压缩包,替换压缩包中的图片文件;<br /> (文件名,图片大小、格式需与原图保持一致)
  195. <br /> 3. 上传平面图<br />
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. <script src="./js/vue.js"></script>
  202. <script src="./js/element.js"></script>
  203. <script src="./js/axios.min.js"></script>
  204. <!-- <script src="./js/proj4.js"></script>
  205. <script src="./js/three.js"></script> -->
  206. <!-- <script src="./components/image-transform/index.js"></script> -->
  207. <script src="./components/upload-pointClound/index.js"></script>
  208. <script type="text/javascript">
  209. //输入经纬度就可以定位
  210. </script>
  211. <script>
  212. // //坐标转换定义 部分 定义一个 cgc_2000的38度带投影坐标系
  213. // proj4.defs("EPSG:99999",
  214. // "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
  215. // 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");
  216. // proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
  217. // var projection = new ol.proj.Projection({
  218. // code: "EPSG:99999",
  219. // extent: [334238.8538694997, 425861.702215328, 599418.034383447, 5936877.5664797],
  220. // units: 'm',
  221. // axisOrientation: 'neu',
  222. // global: false
  223. // });
  224. // //结合proj4在ol中自定义坐标系
  225. // ol.proj.addProjection(projection);
  226. // ol.proj.addCoordinateTransforms("EPSG:4326", "EPSG:99999",
  227. // function(coordinate) {
  228. // return proj4("EPSG:4326", "EPSG:99999", coordinate);
  229. // },
  230. // function(coordinate) {
  231. // return proj4("EPSG:99999", "EPSG:4326", coordinate);
  232. // }
  233. // );
  234. new Vue({
  235. el: '#app',
  236. data() {
  237. return {
  238. status: 0,
  239. showImageTranform: true,
  240. showImageTranform1: true,
  241. showType: 0,
  242. pointLayerArray: [],
  243. map: null,
  244. gaodeMapLayer: {},
  245. ax: '',
  246. ay: '',
  247. az: '',
  248. alon: '120',
  249. alat: '22',
  250. aalt: '',
  251. bx: '',
  252. by: '',
  253. bz: '',
  254. blon: '123',
  255. blat: '22',
  256. balt: '',
  257. EPSG: 'EPSG:4490',
  258. ageControlLocation1: [],
  259. ageControlLocation2: [],
  260. gpsControlCoordinate1: [],
  261. gpsControlCoordinate2: [],
  262. sceneNum: '',
  263. canvas: null,
  264. ctx: null,
  265. imageCanvas: null,
  266. imageCanvasLayer: null,
  267. img: null,
  268. drugObj: null,
  269. rotateObj: null,
  270. imgSrc: null,
  271. file: null,
  272. isRotate: false,
  273. isDraw: false,
  274. size: 512,
  275. limitSize: 512,
  276. uploadData: {
  277. file: null,
  278. lon: '113.59963069739054',
  279. lat: '22.364821730960752',
  280. direction: '0',
  281. size: '256'
  282. },
  283. // 优化
  284. showData: {
  285. ax: '',
  286. ay: '',
  287. az: '',
  288. alon: '120',
  289. alat: '22',
  290. aalt: '',
  291. bx: '',
  292. by: '',
  293. bz: '',
  294. blon: '123',
  295. blat: '22',
  296. balt: ''
  297. },
  298. token: null
  299. }
  300. },
  301. created() {
  302. },
  303. mounted() {
  304. const origin = window.location.origin + window.location.pathname
  305. const tokenKry = 'ls.' + origin + '#JWT'
  306. this.token = localStorage.getItem(tokenKry)
  307. // alert(sceneNum)
  308. this.getContorlPoint()
  309. // this.sceneNum = window.location.pathname.split('/')[2]
  310. // this.$nextTick(() => {
  311. // let t = setTimeout(() => {
  312. // this.map = this.initMap('map');
  313. // }, 100)
  314. // })
  315. },
  316. methods: {
  317. readyUpload() {
  318. // console.log(this.$refs.imageTranform)
  319. this.$refs.imageTranform.readyUpload()
  320. },
  321. getImageTransform() {
  322. // 地图数据上传 如果用户没有选择数据直接返回true 如果有数据要上传返回promise
  323. Promise.all([
  324. this.$refs.imageTranform.uploadData(),
  325. this.$refs.imageTranform.uploadTiled()
  326. ])
  327. .then(res => {
  328. alert('成功')
  329. this.showImageTranform = false
  330. this.$nextTick(() => {
  331. this.showImageTranform = true
  332. })
  333. })
  334. .catch(() => {
  335. alert('失败')
  336. })
  337. },
  338. getImageTiled() {
  339. this.$refs.imageTranform.uploadTiled()
  340. .then(() => alert('成功'))
  341. .catch(() => {
  342. alert('失败')
  343. })
  344. },
  345. initMap(divid) {
  346. this.pointLayerArray = [];
  347. this.gaodeMapLayer = new ol.layer.Tile({
  348. source: new ol.source.XYZ({
  349. url: 'http://wprd03.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}' //高德地图切片访问路径
  350. })
  351. });
  352. return new ol.Map({
  353. layers: [this.gaodeMapLayer],
  354. target: divid,
  355. view: new ol.View({
  356. center: ol.proj.fromLonLat([113.59569403794666,
  357. 22.36656052911783
  358. ]), //最初定位的位置
  359. zoom: 4 //地图层级
  360. })
  361. });
  362. },
  363. clearMap() {
  364. this.pointLayerArray.map(each => {
  365. if (each.type == "con_point") {
  366. this.map.removeLayer(each)
  367. }
  368. });
  369. this.pointLayerArray = [];
  370. },
  371. addPoint(lon, lat, text, index) {
  372. let vector = new ol.source.Vector();
  373. let vLayer = new ol.layer.Vector({
  374. source: vector
  375. })
  376. vLayer.type = "con_point";
  377. vLayer.index = index;
  378. this.map.addLayer(vLayer)
  379. this.pointLayerArray.push(vLayer);
  380. let labelCoords = ol.proj.transform([lon, lat], "EPSG:4326", "EPSG:3857");
  381. let feature = new ol.Feature({
  382. geometry: new ol.geom.Point(labelCoords)
  383. });
  384. vector.addFeature(feature);
  385. vLayer.setStyle(new ol.style.Style({
  386. image: new ol.style.Circle({ //点样式
  387. radius: 7,
  388. fill: new ol.style.Fill({
  389. color: '#00c033'
  390. })
  391. }),
  392. text: new ol.style.Text({
  393. text: text,
  394. font: '15px sans-serif',
  395. offsetX: 5,
  396. offsetY: -10,
  397. fill: new ol.style.Fill({
  398. color: "#b9391f"
  399. }),
  400. stroke: new ol.style.Stroke({
  401. color: "#b9391f"
  402. })
  403. })
  404. }))
  405. this.map.getView().setCenter(labelCoords)
  406. },
  407. set_location(index) {
  408. let alon
  409. let alat
  410. let str = ''
  411. if (index == 1) {
  412. alon = this.alon;
  413. alat = this.alat;
  414. str = '锚点1'
  415. } else {
  416. alon = this.blon;
  417. alat = this.blat;
  418. str = '锚点2'
  419. }
  420. this.removePoint(index)
  421. this.addPoint(+alon, +alat, str, index)
  422. },
  423. removePoint(index) {
  424. let num = this.pointLayerArray.filter((item, i) => {
  425. if (index == item.index) {
  426. this.pointLayerArray.splice(i, 1)
  427. }
  428. })
  429. },
  430. commit() {
  431. this.handleData()
  432. Promise.all([
  433. axios.post('/indoor/' + sceneNum + '/api/controlPoint/save', {
  434. ageControlLocation1: this.ageControlLocation1,
  435. ageControlLocation2: this.ageControlLocation2,
  436. gpsControlCoordinate1: this.gpsControlCoordinate1,
  437. gpsControlCoordinate2: this.gpsControlCoordinate2,
  438. sceneNum: sceneNum,
  439. // id: 1
  440. })
  441. .catch(function(error) {
  442. this.$message({
  443. message: '控制点上传失败',
  444. type: 'error',
  445. duration: 2000,
  446. });
  447. }),
  448. // this.getImageTransform()
  449. // .catch(_ => {
  450. // alert('地图数据上传失败')
  451. // })
  452. ]).then(() => {
  453. this.getContorlPoint()
  454. this.$message({
  455. message: '控制点上传成功',
  456. type: 'success',
  457. duration: 2000,
  458. });
  459. // alert('控制点上传成功')
  460. })
  461. },
  462. handleData() {
  463. //重置数组
  464. this.ageControlLocation1 = []
  465. this.ageControlLocation2 = []
  466. this.gpsControlCoordinate1 = []
  467. this.gpsControlCoordinate2 = []
  468. //
  469. this.ageControlLocation1.push(this.ax - 0)
  470. this.ageControlLocation1.push(this.ay - 0)
  471. this.ageControlLocation1.push(this.az - 0)
  472. this.gpsControlCoordinate1.push(this.alon - 0)
  473. this.gpsControlCoordinate1.push(this.alat - 0)
  474. this.gpsControlCoordinate1.push(this.aalt - 0)
  475. this.ageControlLocation2.push(this.bx - 0)
  476. this.ageControlLocation2.push(this.by - 0)
  477. this.ageControlLocation2.push(this.bz - 0)
  478. this.gpsControlCoordinate2.push(this.blon - 0)
  479. this.gpsControlCoordinate2.push(this.blat - 0)
  480. this.gpsControlCoordinate2.push(this.balt - 0)
  481. },
  482. //获取控制点
  483. getContorlPoint() {
  484. // /indoor/{sceneCode}/api/controlPoint/detail
  485. // const sceneName = window.location.pathname.split('/')[2]
  486. // const isDev = !sceneName || sceneName === 'addDataSet.html'
  487. // const sceneCode = isDev ? 't-kJ2PEjZ' : sceneName
  488. axios.get(`/indoor/${sceneNum}/api/controlPoint/detail`).then(res => {
  489. this.status = res.data.data.status
  490. this.initContorlPoint(res.data.data)
  491. this.set_location(1)
  492. this.set_location(2)
  493. }).catch(err => {
  494. })
  495. },
  496. initContorlPoint(data) {
  497. this.ax = data.ageControlLocation1[0]
  498. this.ay = data.ageControlLocation1[1]
  499. this.bx = data.ageControlLocation2[0]
  500. this.by = data.ageControlLocation2[1]
  501. this.alon = data.gpsControlCoordinate1[0]
  502. this.alat = data.gpsControlCoordinate1[1]
  503. this.blon = data.gpsControlCoordinate2[0]
  504. this.blat = data.gpsControlCoordinate2[1]
  505. this.showData.ax = data.ageControlLocation1[0]
  506. this.showData.ay = data.ageControlLocation1[1]
  507. this.showData.bx = data.ageControlLocation2[0]
  508. this.showData.by = data.ageControlLocation2[1]
  509. this.showData.alon = data.gpsControlCoordinate1[0]
  510. this.showData.alat = data.gpsControlCoordinate1[1]
  511. this.showData.blon = data.gpsControlCoordinate2[0]
  512. this.showData.blat = data.gpsControlCoordinate2[1]
  513. },
  514. openEdit() {
  515. this.showType = 1
  516. this.ax = this.showData.ax
  517. this.ay = this.showData.ay
  518. this.bx = this.showData.bx
  519. this.by = this.showData.by
  520. this.alon = this.showData.alon
  521. this.alat = this.showData.alat
  522. this.blon = this.showData.blon
  523. this.blat = this.showData.blat
  524. },
  525. showLoading(str) {
  526. $('body').append(' <div id="upload-loading"><img class="icon" src="../img/icon/loading.png" alt=""><span class="text">' + str + '</span></div>');
  527. },
  528. hideLoading() {
  529. $('#upload-loading').remove()
  530. },
  531. limtInput(value) {
  532. this[value] = this[value].replace(/[^\-?\d.]/g, '')
  533. },
  534. moveEnd(e) {
  535. let obj = e.currentTarget
  536. obj.focus();
  537. var len = obj.value.length;
  538. if (document.selection) {
  539. var sel = obj.createTextRange();
  540. sel.moveStart('character', len);
  541. sel.collapse();
  542. sel.select();
  543. } else if (typeof obj.selectionStart == 'number' &&
  544. typeof obj.selectionEnd == 'number') {
  545. obj.selectionStart = obj.selectionEnd = len;
  546. }
  547. },
  548. }
  549. })
  550. </script>
  551. </body>
  552. </html>