addDataSet.html 27 KB

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