addDataSet.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. </div>
  46. <div class="scrollBox">
  47. <p class="desc">通过两个控制点坐标确定点云在地图上的位置</p>
  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"
  84. id="alon" value="120" />
  85. </div>
  86. </div>
  87. <div class="inputItem">
  88. <div class="name">纬度</div>
  89. <div class="ipt">
  90. <input type="text" @input="limtInput('alat')" v-model="alat" name="alat"
  91. id="alat" value="22" />
  92. </div>
  93. </div>
  94. </div>
  95. <div class="tag">
  96. <P class="formTitle">控制点2</P>
  97. <!-- <div class="localIcon" @click="set_location(2)"></div> -->
  98. </div>
  99. <div class="formItem">
  100. <p class="itemTitle">本地坐标:</p>
  101. <div class="inputItem">
  102. <div class="name"> X</div>
  103. <div class="ipt">
  104. <input type="text" @input="limtInput('bx')" v-model="bx" name="bx" id="bx" />
  105. </div>
  106. <span class="unit">m</span>
  107. </div>
  108. <div class="inputItem">
  109. <div class="name"> Y</div>
  110. <div class="ipt">
  111. <input type="text" @input="limtInput('by')" v-model="by" name="by" id="by" />
  112. </div>
  113. <span class="unit">m</span>
  114. </div>
  115. <!-- <div class="inputItem">
  116. <div class="name"> Z</div>
  117. <div class="ipt">
  118. <input type="text" v-model="bz" name="bz" id="bz" />
  119. </div>
  120. <span class="unit">m</span>
  121. </div> -->
  122. </div>
  123. <div class="formItem">
  124. <p class="itemTitle">地理坐标:</p>
  125. <div class="inputItem">
  126. <div class="name">经度</div>
  127. <div class="ipt">
  128. <input type="text" @input="limtInput('blon')" v-model="blon" name="blon"
  129. id="blon" value="123" />
  130. </div>
  131. </div>
  132. <div class="inputItem">
  133. <div class="name">纬度</div>
  134. <div class="ipt">
  135. <input type="text" @input="limtInput('blat')" v-model="blat" name="blat"
  136. id="blat" value="22" />
  137. </div>
  138. </div>
  139. <!-- <div class="inputItem">
  140. <div class="name">高程</div>
  141. <div class="ipt">
  142. <input type="text" v-model="balt" name="balt" id="balt" value="0" />
  143. </div>
  144. </div> -->
  145. </div>
  146. </form>
  147. </div>
  148. <div class="bottom">
  149. <div class="style"></div>
  150. <!-- <input type="submit" class="submitBtn" value="提交" />
  151. <button id="clear">取消</button> -->
  152. <!-- <div id="clear" @click="getImageTransform">提交地图信息</div> -->
  153. <!-- <div id="clear" @click="clearMap">取消</div> -->
  154. <div id="clear" @click="showType=0">取消</div>
  155. <div class="submitBtn" @click="commit()">
  156. 保存
  157. </div>
  158. </div>
  159. </div>
  160. <upload-pointClound v-if="showType==2" />
  161. <upload-titlemap v-if="showType==3" />
  162. </div>
  163. </div>
  164. </div>
  165. <script src="./js/vue.js"></script>
  166. <script src="./js/element.js"></script>
  167. <script src="./js/axios.min.js"></script>
  168. <!-- <script src="./js/proj4.js"></script>
  169. <script src="./js/three.js"></script> -->
  170. <!-- <script src="./components/image-transform/index.js"></script> -->
  171. <script src="../components/upload-pointClound/index.js"></script>
  172. <script src="../components/upload-titleMap/index.js"></script>
  173. <script type="text/javascript">
  174. //输入经纬度就可以定位
  175. </script>
  176. <script>
  177. // //坐标转换定义 部分 定义一个 cgc_2000的38度带投影坐标系
  178. // proj4.defs("EPSG:99999",
  179. // "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
  180. // 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");
  181. // proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
  182. // var projection = new ol.proj.Projection({
  183. // code: "EPSG:99999",
  184. // extent: [334238.8538694997, 425861.702215328, 599418.034383447, 5936877.5664797],
  185. // units: 'm',
  186. // axisOrientation: 'neu',
  187. // global: false
  188. // });
  189. // //结合proj4在ol中自定义坐标系
  190. // ol.proj.addProjection(projection);
  191. // ol.proj.addCoordinateTransforms("EPSG:4326", "EPSG:99999",
  192. // function(coordinate) {
  193. // return proj4("EPSG:4326", "EPSG:99999", coordinate);
  194. // },
  195. // function(coordinate) {
  196. // return proj4("EPSG:99999", "EPSG:4326", coordinate);
  197. // }
  198. // );
  199. new Vue({
  200. el: '#app',
  201. data() {
  202. return {
  203. status: 0,
  204. showImageTranform: true,
  205. showImageTranform1: true,
  206. showType: 0,
  207. pointLayerArray: [],
  208. map: null,
  209. gaodeMapLayer: {},
  210. ax: '',
  211. ay: '',
  212. az: '',
  213. alon: '120',
  214. alat: '22',
  215. aalt: '',
  216. bx: '',
  217. by: '',
  218. bz: '',
  219. blon: '123',
  220. blat: '22',
  221. balt: '',
  222. EPSG: 'EPSG:4490',
  223. ageControlLocation1: [],
  224. ageControlLocation2: [],
  225. gpsControlCoordinate1: [],
  226. gpsControlCoordinate2: [],
  227. sceneNum: '',
  228. canvas: null,
  229. ctx: null,
  230. imageCanvas: null,
  231. imageCanvasLayer: null,
  232. img: null,
  233. drugObj: null,
  234. rotateObj: null,
  235. imgSrc: null,
  236. file: null,
  237. isRotate: false,
  238. isDraw: false,
  239. size: 512,
  240. limitSize: 512,
  241. uploadData: {
  242. file: null,
  243. lon: '113.59963069739054',
  244. lat: '22.364821730960752',
  245. direction: '0',
  246. size: '256'
  247. },
  248. // 优化
  249. showData: {
  250. ax: '',
  251. ay: '',
  252. az: '',
  253. alon: '120',
  254. alat: '22',
  255. aalt: '',
  256. bx: '',
  257. by: '',
  258. bz: '',
  259. blon: '123',
  260. blat: '22',
  261. balt: ''
  262. },
  263. token: null,
  264. }
  265. },
  266. created() {
  267. window.eventBus.off('closeMenu', closeMenu);
  268. window.eventBus.on('closeMenu', closeMenu);
  269. function closeMenu() {
  270. if (IV.SidebarMenuService.navigationStack[0].title == '设置') {
  271. if (IV.getMainView().ViewService.primaryView == 'map') {
  272. IV.swapScenes()
  273. }
  274. }
  275. }
  276. },
  277. destroyed() {
  278. },
  279. mounted() {
  280. const origin = window.location.origin + window.location.pathname
  281. const tokenKry = 'ls.' + origin + '#JWT'
  282. this.token = localStorage.getItem(tokenKry)
  283. axios.defaults.headers.common['X-Authorization'] = this.token;
  284. // alert(sceneNum)
  285. this.getContorlPoint()
  286. // this.sceneNum = window.location.pathname.split('/')[2]
  287. // this.$nextTick(() => {
  288. // let t = setTimeout(() => {
  289. // this.map = this.initMap('map');
  290. // }, 100)
  291. // })
  292. },
  293. methods: {
  294. readyUpload() {
  295. // console.log(this.$refs.imageTranform)
  296. this.$refs.imageTranform.readyUpload()
  297. },
  298. getImageTransform() {
  299. // 地图数据上传 如果用户没有选择数据直接返回true 如果有数据要上传返回promise
  300. Promise.all([
  301. this.$refs.imageTranform.uploadData(),
  302. this.$refs.imageTranform.uploadTiled()
  303. ])
  304. .then(res => {
  305. alert('成功')
  306. this.showImageTranform = false
  307. this.$nextTick(() => {
  308. this.showImageTranform = true
  309. })
  310. })
  311. .catch(() => {
  312. alert('失败')
  313. })
  314. },
  315. getImageTiled() {
  316. this.$refs.imageTranform.uploadTiled()
  317. .then(() => alert('成功'))
  318. .catch(() => {
  319. alert('失败')
  320. })
  321. },
  322. initMap(divid) {
  323. this.pointLayerArray = [];
  324. this.gaodeMapLayer = new ol.layer.Tile({
  325. source: new ol.source.XYZ({
  326. url: 'http://wprd03.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}' //高德地图切片访问路径
  327. })
  328. });
  329. return new ol.Map({
  330. layers: [this.gaodeMapLayer],
  331. target: divid,
  332. view: new ol.View({
  333. center: ol.proj.fromLonLat([113.59569403794666,
  334. 22.36656052911783
  335. ]), //最初定位的位置
  336. zoom: 4 //地图层级
  337. })
  338. });
  339. },
  340. clearMap() {
  341. this.pointLayerArray.map(each => {
  342. if (each.type == "con_point") {
  343. this.map.removeLayer(each)
  344. }
  345. });
  346. this.pointLayerArray = [];
  347. },
  348. addPoint(lon, lat, text, index) {
  349. let vector = new ol.source.Vector();
  350. let vLayer = new ol.layer.Vector({
  351. source: vector
  352. })
  353. vLayer.type = "con_point";
  354. vLayer.index = index;
  355. this.map.addLayer(vLayer)
  356. this.pointLayerArray.push(vLayer);
  357. let labelCoords = ol.proj.transform([lon, lat], "EPSG:4326", "EPSG:3857");
  358. let feature = new ol.Feature({
  359. geometry: new ol.geom.Point(labelCoords)
  360. });
  361. vector.addFeature(feature);
  362. vLayer.setStyle(new ol.style.Style({
  363. image: new ol.style.Circle({ //点样式
  364. radius: 7,
  365. fill: new ol.style.Fill({
  366. color: '#00c033'
  367. })
  368. }),
  369. text: new ol.style.Text({
  370. text: text,
  371. font: '15px sans-serif',
  372. offsetX: 5,
  373. offsetY: -10,
  374. fill: new ol.style.Fill({
  375. color: "#b9391f"
  376. }),
  377. stroke: new ol.style.Stroke({
  378. color: "#b9391f"
  379. })
  380. })
  381. }))
  382. this.map.getView().setCenter(labelCoords)
  383. },
  384. set_location(index) {
  385. let alon
  386. let alat
  387. let str = ''
  388. if (index == 1) {
  389. alon = this.alon;
  390. alat = this.alat;
  391. str = '锚点1'
  392. } else {
  393. alon = this.blon;
  394. alat = this.blat;
  395. str = '锚点2'
  396. }
  397. this.removePoint(index)
  398. this.addPoint(+alon, +alat, str, index)
  399. },
  400. removePoint(index) {
  401. let num = this.pointLayerArray.filter((item, i) => {
  402. if (index == item.index) {
  403. this.pointLayerArray.splice(i, 1)
  404. }
  405. })
  406. },
  407. commit() {
  408. this.handleData()
  409. this.showLoading('请稍后...')
  410. axios.post('/indoor/' + sceneNum + '/api/controlPoint/save', {
  411. ageControlLocation1: this.ageControlLocation1,
  412. ageControlLocation2: this.ageControlLocation2,
  413. gpsControlCoordinate1: this.gpsControlCoordinate1,
  414. gpsControlCoordinate2: this.gpsControlCoordinate2,
  415. }).then((res) => {
  416. if (res.data.code == 0) {
  417. IV.api.AuthenticationService.sendAuthenticationChanged()
  418. this.getContorlPoint()
  419. this.hideLoading()
  420. this.$message({
  421. message: '控制点上传成功',
  422. type: 'success',
  423. duration: 2000,
  424. });
  425. }
  426. }).catch(function (error) {
  427. this.hideLoading()
  428. this.$message({
  429. message: '控制点上传失败',
  430. type: 'error',
  431. duration: 2000,
  432. });
  433. })
  434. },
  435. handleData() {
  436. //重置数组
  437. this.ageControlLocation1 = []
  438. this.ageControlLocation2 = []
  439. this.gpsControlCoordinate1 = []
  440. this.gpsControlCoordinate2 = []
  441. //
  442. this.ageControlLocation1.push(this.ax - 0)
  443. this.ageControlLocation1.push(this.ay - 0)
  444. this.ageControlLocation1.push(this.az - 0)
  445. this.gpsControlCoordinate1.push(this.alon - 0)
  446. this.gpsControlCoordinate1.push(this.alat - 0)
  447. this.gpsControlCoordinate1.push(this.aalt - 0)
  448. this.ageControlLocation2.push(this.bx - 0)
  449. this.ageControlLocation2.push(this.by - 0)
  450. this.ageControlLocation2.push(this.bz - 0)
  451. this.gpsControlCoordinate2.push(this.blon - 0)
  452. this.gpsControlCoordinate2.push(this.blat - 0)
  453. this.gpsControlCoordinate2.push(this.balt - 0)
  454. },
  455. //获取控制点
  456. getContorlPoint() {
  457. // /indoor/{sceneCode}/api/controlPoint/detail
  458. // const sceneName = window.location.pathname.split('/')[2]
  459. // const isDev = !sceneName || sceneName === 'addDataSet.html'
  460. // const sceneCode = isDev ? 't-kJ2PEjZ' : sceneName
  461. axios.get(`/indoor/${sceneNum}/api/controlPoint/detail`).then(res => {
  462. this.status = res.data.data.status
  463. this.initContorlPoint(res.data.data)
  464. this.set_location(1)
  465. this.set_location(2)
  466. }).catch(err => {
  467. })
  468. },
  469. initContorlPoint(data) {
  470. this.ax = data.ageControlLocation1[0]
  471. this.ay = data.ageControlLocation1[1]
  472. this.bx = data.ageControlLocation2[0]
  473. this.by = data.ageControlLocation2[1]
  474. this.alon = data.gpsControlCoordinate1[0]
  475. this.alat = data.gpsControlCoordinate1[1]
  476. this.blon = data.gpsControlCoordinate2[0]
  477. this.blat = data.gpsControlCoordinate2[1]
  478. this.showData.ax = data.ageControlLocation1[0]
  479. this.showData.ay = data.ageControlLocation1[1]
  480. this.showData.bx = data.ageControlLocation2[0]
  481. this.showData.by = data.ageControlLocation2[1]
  482. this.showData.alon = data.gpsControlCoordinate1[0]
  483. this.showData.alat = data.gpsControlCoordinate1[1]
  484. this.showData.blon = data.gpsControlCoordinate2[0]
  485. this.showData.blat = data.gpsControlCoordinate2[1]
  486. },
  487. openEdit() {
  488. this.showType = 1
  489. this.ax = this.showData.ax
  490. this.ay = this.showData.ay
  491. this.bx = this.showData.bx
  492. this.by = this.showData.by
  493. this.alon = this.showData.alon
  494. this.alat = this.showData.alat
  495. this.blon = this.showData.blon
  496. this.blat = this.showData.blat
  497. },
  498. showLoading(str) {
  499. $('body').append(
  500. ' <div id="upload-loading"><img class="icon" src="../img/icon/loading.png" alt=""><span class="text">' +
  501. str + '</span></div>');
  502. },
  503. hideLoading() {
  504. $('#upload-loading').remove()
  505. },
  506. limtInput(value) {
  507. this[value] = this[value].replace(/[^\-?\d.]/g, '')
  508. },
  509. moveEnd(e) {
  510. let obj = e.currentTarget
  511. obj.focus();
  512. var len = obj.value.length;
  513. if (document.selection) {
  514. var sel = obj.createTextRange();
  515. sel.moveStart('character', len);
  516. sel.collapse();
  517. sel.select();
  518. } else if (typeof obj.selectionStart == 'number' &&
  519. typeof obj.selectionEnd == 'number') {
  520. obj.selectionStart = obj.selectionEnd = len;
  521. }
  522. },
  523. }
  524. })
  525. </script>
  526. </body>
  527. </html>