addDataSet.html 23 KB

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