addDataSet.html 24 KB

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