addDataSet.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. // this.getContorlPoint()
  333. // this.sceneNum = window.location.pathname.split('/')[2]
  334. // this.$nextTick(() => {
  335. // let t = setTimeout(() => {
  336. // this.map = this.initMap('map');
  337. // }, 100)
  338. // })
  339. },
  340. methods: {
  341. readyUpload() {
  342. // console.log(this.$refs.imageTranform)
  343. this.$refs.imageTranform.readyUpload()
  344. },
  345. getImageTransform() {
  346. // 地图数据上传 如果用户没有选择数据直接返回true 如果有数据要上传返回promise
  347. Promise.all([
  348. this.$refs.imageTranform.uploadData(),
  349. this.$refs.imageTranform.uploadTiled()
  350. ])
  351. .then(res => {
  352. alert('成功')
  353. this.showImageTranform = false
  354. this.$nextTick(() => {
  355. this.showImageTranform = true
  356. })
  357. })
  358. .catch(() => {
  359. alert('失败')
  360. })
  361. },
  362. getImageTiled() {
  363. this.$refs.imageTranform.uploadTiled()
  364. .then(() => alert('成功'))
  365. .catch(() => {
  366. alert('失败')
  367. })
  368. },
  369. initMap(divid) {
  370. this.pointLayerArray = [];
  371. this.gaodeMapLayer = new ol.layer.Tile({
  372. source: new ol.source.XYZ({
  373. url: 'http://wprd03.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}' //高德地图切片访问路径
  374. })
  375. });
  376. return new ol.Map({
  377. layers: [this.gaodeMapLayer],
  378. target: divid,
  379. view: new ol.View({
  380. center: ol.proj.fromLonLat([113.59569403794666,
  381. 22.36656052911783
  382. ]), //最初定位的位置
  383. zoom: 4 //地图层级
  384. })
  385. });
  386. },
  387. clearMap() {
  388. this.pointLayerArray.map(each => {
  389. if (each.type == "con_point") {
  390. this.map.removeLayer(each)
  391. }
  392. });
  393. this.pointLayerArray = [];
  394. },
  395. addPoint(lon, lat, text, index) {
  396. let vector = new ol.source.Vector();
  397. let vLayer = new ol.layer.Vector({
  398. source: vector
  399. })
  400. vLayer.type = "con_point";
  401. vLayer.index = index;
  402. this.map.addLayer(vLayer)
  403. this.pointLayerArray.push(vLayer);
  404. let labelCoords = ol.proj.transform([lon, lat], "EPSG:4326", "EPSG:3857");
  405. let feature = new ol.Feature({
  406. geometry: new ol.geom.Point(labelCoords)
  407. });
  408. vector.addFeature(feature);
  409. vLayer.setStyle(new ol.style.Style({
  410. image: new ol.style.Circle({ //点样式
  411. radius: 7,
  412. fill: new ol.style.Fill({
  413. color: '#00c033'
  414. })
  415. }),
  416. text: new ol.style.Text({
  417. text: text,
  418. font: '15px sans-serif',
  419. offsetX: 5,
  420. offsetY: -10,
  421. fill: new ol.style.Fill({
  422. color: "#b9391f"
  423. }),
  424. stroke: new ol.style.Stroke({
  425. color: "#b9391f"
  426. })
  427. })
  428. }))
  429. this.map.getView().setCenter(labelCoords)
  430. },
  431. set_location(index) {
  432. let alon
  433. let alat
  434. let str = ''
  435. if (index == 1) {
  436. alon = this.alon;
  437. alat = this.alat;
  438. str = '锚点1'
  439. } else {
  440. alon = this.blon;
  441. alat = this.blat;
  442. str = '锚点2'
  443. }
  444. this.removePoint(index)
  445. this.addPoint(+alon, +alat, str, index)
  446. },
  447. removePoint(index) {
  448. let num = this.pointLayerArray.filter((item, i) => {
  449. if (index == item.index) {
  450. this.pointLayerArray.splice(i, 1)
  451. }
  452. })
  453. },
  454. commit() {
  455. this.handleData()
  456. Promise.all([
  457. axios.post('/indoor/' + this.sceneNum + '/api/controlPoint/save', {
  458. ageControlLocation1: this.ageControlLocation1,
  459. ageControlLocation2: this.ageControlLocation2,
  460. gpsControlCoordinate1: this.gpsControlCoordinate1,
  461. gpsControlCoordinate2: this.gpsControlCoordinate2,
  462. sceneNum: this.sceneNum,
  463. // id: 1
  464. })
  465. .catch(function(error) {
  466. alert('数据集位置上传失败')
  467. }),
  468. // this.getImageTransform()
  469. // .catch(_ => {
  470. // alert('地图数据上传失败')
  471. // })
  472. ]).then(() => {
  473. this.getContorlPoint()
  474. alert('成功')
  475. })
  476. },
  477. handleData() {
  478. //重置数组
  479. this.ageControlLocation1 = []
  480. this.ageControlLocation2 = []
  481. this.gpsControlCoordinate1 = []
  482. this.gpsControlCoordinate2 = []
  483. //
  484. this.ageControlLocation1.push(this.ax - 0)
  485. this.ageControlLocation1.push(this.ay - 0)
  486. this.ageControlLocation1.push(this.az - 0)
  487. this.gpsControlCoordinate1.push(this.alon - 0)
  488. this.gpsControlCoordinate1.push(this.alat - 0)
  489. this.gpsControlCoordinate1.push(this.aalt - 0)
  490. this.ageControlLocation2.push(this.bx - 0)
  491. this.ageControlLocation2.push(this.by - 0)
  492. this.ageControlLocation2.push(this.bz - 0)
  493. this.gpsControlCoordinate2.push(this.blon - 0)
  494. this.gpsControlCoordinate2.push(this.blat - 0)
  495. this.gpsControlCoordinate2.push(this.balt - 0)
  496. },
  497. //获取控制点
  498. getContorlPoint() {
  499. // /indoor/{sceneCode}/api/controlPoint/detail
  500. const sceneName = window.location.pathname.split('/')[2]
  501. const isDev = !sceneName || sceneName === 'addDataSet.html'
  502. const sceneCode = isDev ? 't-kJ2PEjZ' : sceneName
  503. axios.get(`/indoor/${sceneCode}/api/controlPoint/detail`).then(res => {
  504. this.status = res.data.data.status
  505. this.initContorlPoint(res.data.data)
  506. this.set_location(1)
  507. this.set_location(2)
  508. }).catch(err => {
  509. })
  510. },
  511. initContorlPoint(data) {
  512. this.ax = data.ageControlLocation1[0]
  513. this.ay = data.ageControlLocation1[1]
  514. this.bx = data.ageControlLocation2[0]
  515. this.by = data.ageControlLocation2[1]
  516. this.alon = data.gpsControlCoordinate1[0]
  517. this.alat = data.gpsControlCoordinate1[1]
  518. this.blon = data.gpsControlCoordinate2[0]
  519. this.blat = data.gpsControlCoordinate2[1]
  520. this.showData.ax = data.ageControlLocation1[0]
  521. this.showData.ay = data.ageControlLocation1[1]
  522. this.showData.bx = data.ageControlLocation2[0]
  523. this.showData.by = data.ageControlLocation2[1]
  524. this.showData.alon = data.gpsControlCoordinate1[0]
  525. this.showData.alat = data.gpsControlCoordinate1[1]
  526. this.showData.blon = data.gpsControlCoordinate2[0]
  527. this.showData.blat = data.gpsControlCoordinate2[1]
  528. },
  529. openEdit() {
  530. this.isEdit = true
  531. this.ax = this.showData.ax
  532. this.ay = this.showData.ay
  533. this.bx = this.showData.bx
  534. this.by = this.showData.by
  535. this.alon = this.showData.alon
  536. this.alat = this.showData.alat
  537. this.blon = this.showData.blon
  538. this.blat = this.showData.blat
  539. }
  540. }
  541. })
  542. </script>
  543. </body>
  544. </html>