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