diff --git a/package.json b/package.json index 08316c8..bf170d8 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "ezuikit-js": "^8.1.10", "file-saver": "2.0.5", "fuse.js": "7.0.0", + "geotiff": "^2.1.4-beta.0", "highlight.js": "11.9.0", "image-conversion": "2.1.1", "js-cookie": "3.0.5", diff --git a/src/assets/images/orthophoto.jpg b/src/assets/images/orthophoto.jpg new file mode 100644 index 0000000..b468004 Binary files /dev/null and b/src/assets/images/orthophoto.jpg differ diff --git a/src/assets/images/orthophoto.tif b/src/assets/images/orthophoto.tif new file mode 100644 index 0000000..7976c73 Binary files /dev/null and b/src/assets/images/orthophoto.tif differ diff --git a/src/router/index.ts b/src/router/index.ts index 9da0283..5eb2888 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -109,6 +109,11 @@ export const constantRoutes: RouteRecordRaw[] = [ component: () => import('@/views/progress/progressPaper/index.vue'), hidden: true }, + { + path: '/gis2D1', + component: () => import('@/views/gis2D/index.vue'), + hidden: true + } ]; // 动态路由,基于用户权限动态去加载 diff --git a/src/views/gis2D/index.vue b/src/views/gis2D/index.vue new file mode 100644 index 0000000..e8b9f35 --- /dev/null +++ b/src/views/gis2D/index.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/src/views/gis2D/js/center.js b/src/views/gis2D/js/center.js new file mode 100644 index 0000000..7112050 --- /dev/null +++ b/src/views/gis2D/js/center.js @@ -0,0 +1,137 @@ +import { polygon, centerOfMass } from '@turf/turf'; +export function CenterHeight(list) { + + let arr = [] + let arr2 = [] + list.forEach(ele => { + let point = CenterPoint(ele) + let point2 = sampleHeight(ele) + arr.push(point) + arr2.push(point2) + }) + return { + Cartographic: sampleHeightMostDetailed(arr), + center: arr, + arr2: arr2, + Height: sampleHeightMostDetailed2 + } +} + + +// list:[ +// { +// positionList:[] +// } +// ] +// center[0] == [106,23] +// Cartographic[0] == { +// longitude:106, +// latitude:23, +// height:100, +// } +// Height[0] == [ +// { +// longitude:106, +// latitude:23, +// height:100, +// }, +// { +// longitude:106, +// latitude:23, +// height:100, +// }, +// { +// longitude:106, +// latitude:23, +// height:100, +// }, +// { +// longitude:106, +// latitude:23, +// height:100, +// }, +// { +// longitude:106, +// latitude:23, +// height:100, +// }, +// ] + +function CenterPoint(item) { + const { positionList } = item + let arr = [] + positionList.forEach(ele => { + let itemdata =[Number(ele[0]),Number(ele[1])] + arr.push(itemdata) + }) + let polygondata = polygon([arr]); + let point = centerOfMass(polygondata).geometry.coordinates + return point +} +// 计算所有的点的高程 +function sampleHeight(item) { + const { positionList } = item + let arr = [] + positionList.forEach(item => { + let a = [Number(item[0]),Number(item[1])] + arr.push(a) + }) + return arr +} + +function sampleHeightMostDetailed(cartesians) { + let positionList = [] + let viewer = window.sdk.viewer + // console.log('cartesianscartesians', cartesians); + cartesians.forEach(cartesian => { + positionList.push(new Cesium.Cartographic.fromDegrees(cartesian[0], cartesian[1])) + }) + return new Promise(async resolve => { + try { + // 当前场景中没有使用地形 + const promise = viewer.scene.sampleHeightMostDetailed(positionList) + promise.then(updatedPositions => { + let resultCartesians = [] + updatedPositions.forEach(position => { + if (position) { + // 采集成功,转为笛卡尔坐标 + // resultCartesians.push(this.cartographicToCartesian(position)) + resultCartesians.push(position) + } else { + // postion为undefined时,说明该位置采集失败 + // resultCartesians.push(position) + } + }) + resolve(resultCartesians) + }) + } catch (e) { + resolve(false) + } + }) +} +function sampleHeightMostDetailed2(cartesians, onResult) { + cartesians.forEach(cartesianGroup => { + const positionList = cartesianGroup.map(c => + Cesium.Cartographic.fromDegrees(c[0], c[1]) + ); + getHeight(positionList).then(res => { + if (typeof onResult === 'function') { + onResult(res); + } + }); + }); +} + +function getHeight(positionList) { + const viewer = window.sdk.viewer; + return new Promise(resolve => { + try { + viewer.scene.sampleHeightMostDetailed(positionList).then(updatedPositions => { + const resultCartesians = updatedPositions.filter(Boolean); + resolve(resultCartesians); + }); + } catch (e) { + resolve([]); + } + }); +} diff --git a/src/views/gisHome/component/map.vue b/src/views/gisHome/component/map.vue index d5ae124..69d5ed9 100644 --- a/src/views/gisHome/component/map.vue +++ b/src/views/gisHome/component/map.vue @@ -5,7 +5,8 @@ diff --git a/src/views/progress/progressPaper/index.vue b/src/views/progress/progressPaper/index.vue index 327d238..370de03 100644 --- a/src/views/progress/progressPaper/index.vue +++ b/src/views/progress/progressPaper/index.vue @@ -53,8 +53,8 @@