addDataSet.html 26 KB

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