最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue中使用Cesium加載shp文件、wms服務(wù)、WMTS服務(wù)問題

 更新時間:2023年05月19日 10:25:26   作者:愿為浪漫渡此劫  
這篇文章主要介紹了vue中使用Cesium加載shp文件、wms服務(wù)、WMTS服務(wù)問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

如何在vue中使用Cesium加載shp文件或者說是wms服務(wù)

背景:企業(yè)項目在管理界面可以上傳shp數(shù)據(jù)文件集合,需要在用戶界面可視化展示

注意: Cesium是不能直接加載shp數(shù)文件的

所以需要后端將上傳的shp數(shù)據(jù)轉(zhuǎn)成WMS服務(wù),這樣Cesium就可以加載WMS服務(wù)來可視化shp數(shù)據(jù)了

注意后端接口必須返回以下關(guān)于WMS服務(wù)的參數(shù)

  1. 工作空間 share:xxxx,用于Cesium加載wms服務(wù)的圖層
  2. srs : 用于Cesium加載wms服務(wù)的srs屬性
  3. wms服務(wù)地址 : 類似 http://localhost:8080/geoServer/wms
  4. 四個坐標xmin,ymin和xmax,ymax : 用于定位WMS地圖的位置

Vue初始化Cesium

前提: Vue使用Cesium處理npm,還需要在Webpack文件配置,詳情可看上期文章

基于Vue的Cesium配置

// 初始化
<template>
? ?// 地圖容器?
? <div class="img-box" id="cesiumContainer"></div>
</template>
<script>
export default {
? props: ["fileUrl","srs","workspace","zb"],
? data() {
? ? return {
? ? ? viewer: {},
? ? ? Cesium: {},
? ? ? highlightColor: null,
? ? ? normalColor: null,
? ? ? wmsLayer : null // wms 地圖服務(wù)圖層
? ? };
? },
? methods: {
? ? // init : 初始化Cesium
? ? init() {
? ? ? const Cesium = this.cesium;
? ? ? this.highlightColor = Cesium.Color.GREEN.withAlpha(0.6);
? ? ? this.normalColor = Cesium.Color.YELLOW.withAlpha(0.6);
? ? ? this.viewer = new Cesium.Viewer("cesiumContainer", {
? ? ? ? //先行禁止infoBox彈出
? ? ? ? selectionIndicator: false,
? ? ? ? infoBox: false,
? ? ? ? //baseLayerPicker : false,
? ? ? ? geocoder: false,
? ? ? ? homeButton: false,
? ? ? ? sceneModePicker: false,
? ? ? ? fullscreenButton: false,
? ? ? ? navigationHelpButton: false,
? ? ? ? animation: false,
? ? ? ? timeline: false,
? ? ? ? fulllscreenButtond: false,
? ? ? ? vrButton: false,
?? ??? ?// getImageryProviderArr和getTerrainProviderViewModelsArr ?可根據(jù)項目需求進行實現(xiàn)
? ? ? ? //獲取或設(shè)置可用于圖像選擇的ProviderViewModel實例數(shù)組。
? ? ? ? imageryProviderViewModels: this.getImageryProviderArr(),
? ? ? ? // //獲取或設(shè)置可用于地形選擇的ProviderViewModel實例數(shù)組。
? ? ? ? terrainProviderViewModels: this.getTerrainProviderViewModelsArr(),
? ? ? });
? ? ? this.viewer._cesiumWidget._creditContainer.style.display = "none"; // 隱藏版權(quán)
? ? },
? ? getImageryProviderArr() {
? ? ? const Cesium = this.cesium;
? ? ? return [
? ? ? ? new Cesium.ProviderViewModel({
? ? ? ? ? //圖層的名稱。
? ? ? ? ? name: "影像底圖",
? ? ? ? ? //顯示項目被隱藏的工具提示
? ? ? ? ? tooltip: "影像底圖",
? ? ? ? ? //代表圖層的圖標
? ? ? ? ? iconUrl: require("@/assets/img/yxdt.png"),
? ? ? ? ? //一個函數(shù)或命令,用于創(chuàng)建一個或多個提供程序,這些提供程序?qū)⒃谶x擇此項目時添加到地球儀中。
? ? ? ? ? creationFunction: function () {
? ? ? ? ? ? return new Cesium.ArcGisMapServerImageryProvider({
? ? ? ? ? ? ? url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
? ? ? ? ? ? });
? ? ? ? ? },
? ? ? ? }),
? ? ? ? new Cesium.ProviderViewModel({
? ? ? ? ? //圖層的名稱
? ? ? ? ? name: "電子地圖",
? ? ? ? ? //顯示項目被隱藏的工具提示
? ? ? ? ? tooltip: "電子地圖",
? ? ? ? ? //代表圖層的圖標
? ? ? ? ? iconUrl: require("@/assets/img/sldt.png"),
? ? ? ? ? //一個函數(shù)或命令,用于創(chuàng)建一個或多個提供程序,這些提供程序?qū)⒃谶x擇此項目時添加到地球儀中
? ? ? ? ? creationFunction: function () {
? ? ? ? ? ? return new Cesium.ArcGisMapServerImageryProvider({
? ? ? ? ? ? ? url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
? ? ? ? ? ? });
? ? ? ? ? },
? ? ? ? }),
? ? ? ];
? ? },
? ? getTerrainProviderViewModelsArr() {
? ? ? const Cesium = this.cesium;
? ? ? return [
? ? ? ? new Cesium.ProviderViewModel({
? ? ? ? ? //圖層的名稱
? ? ? ? ? name: "無地形",
? ? ? ? ? //顯示項目被隱藏的工具提示
? ? ? ? ? tooltip: "WGS84標準球體",
? ? ? ? ? //代表圖層的圖標
? ? ? ? ? iconUrl: require("@/assets/img/WGS84.png"),
? ? ? ? ? //一個函數(shù)或命令,用于創(chuàng)建一個或多個提供程序,這些提供程序?qū)⒃谶x擇此項目時添加到地球儀中
? ? ? ? ? creationFunction: function () {
? ? ? ? ? ? return new Cesium.EllipsoidTerrainProvider({
? ? ? ? ? ? ? ellipsoid: Cesium.Ellipsoid.WGS84,
? ? ? ? ? ? });
? ? ? ? ? },
? ? ? ? }),
? ? ? ? new Cesium.ProviderViewModel({
? ? ? ? ? //圖層的名稱
? ? ? ? ? name: "地形",
? ? ? ? ? //顯示項目被隱藏的工具提示
? ? ? ? ? tooltip: "STK在線地形",
? ? ? ? ? //代表圖層的圖標
? ? ? ? ? iconUrl: require("@/assets/img/STK在線地形.png"),
? ? ? ? ? //一個函數(shù)或命令,用于創(chuàng)建一個或多個提供程序,這些提供程序?qū)⒃谶x擇此項目時添加到地球儀中
? ? ? ? ? creationFunction: function () {
? ? ? ? ? ? return new Cesium.CesiumTerrainProvider({
? ? ? ? ? ? ? url: Cesium.IonResource.fromAssetId(1),
? ? ? ? ? ? ? requestWaterMask: !0,
? ? ? ? ? ? ? requestVertexNormals: !0,
? ? ? ? ? ? });
? ? ? ? ? },
? ? ? ? }),
? ? ? ];
? ? },
? },
};
</script>

加載WMS服務(wù)

// 加載geoserver wms服務(wù)
addWMS(fileUrl) {
? ? // 刪除之前的wms 圖層?
? ? // 這塊移除圖層 需要指出圖層變量名
? ?this.viewer.imageryLayers.remove(this.wmsLayer);
? ?this.wmsLayer = null;
? const Cesium = this.cesium;
? if(this.zb.xmin) {
? ? var provider = new Cesium.WebMapServiceImageryProvider({
? ? ? ? url : fileUrl, // wms服務(wù)地址
? ? ? ? // layers 必須參數(shù),不寫會報錯;
? ? ? ? // layers寫的不對會報如下錯誤: An error occered in "WebMapServiceImageryProvider":
? ? ? ? // Failed to obtain image tile X : 425y ? ?(有的博客說這是跨域????)
?? ??? ?// 后端API接口返回
? ? ? ? layers: this.workspace, ?
? ? ? ? // 必須參數(shù)rectangle : 用來定位加載的WMS位置 ?后端API接口返回
? ? ? ? rectangle: Cesium.Rectangle.fromDegrees(
? ? ? ? ? +this.zb.xmin, +this.zb.ymin, +this.zb.xmax, +this.zb.ymax), ? // 必須有
? ? ? ? parameters: {
? ? ? ? ? ? service : 'WMS',
? ? ? ? ? ? format: 'image/png',
? ? ? ? ? ? transparent: true,
? ? ? ? ? ? // 后端API接口返回的
? ? ? ? ? ? srs: this.srs,
? ? ? ? } ?
? ? });
? ? // 加載WMS服務(wù)到viewer
? ? this.wmsLayer = this.viewer.imageryLayers.addImageryProvider(provider);
? ? // 飛入動畫
? ? this.viewer.flyTo(this.wmsLayer, {
? ? ? ? duration: 2
? ? });
? } else {
? ? this.$message.warning('該地圖服務(wù)沒有坐標可以定位')
? }

加載WMTS服務(wù)

對與url 屬性: 很多博客都說要進行 如下拼接:

后端返回的wmts/rest/{layer}/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format=image/png

其實不用拼接 只需要后端返回的/wtms路徑即可

// 加載geoserver wmts服務(wù)
addWMTS(fileUrl) {
? ? ? const Cesium = this.cesium;
? ? ? let provider = new Cesium.WebMapTileServiceImageryProvider({
? ? ? ? // ?對與url ?很多博客都說要進行 如下拼接
? ? ? ? // 后端返回的wmts/rest/{layer}/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format=image/png
?? ??? ?// 其實不用拼接 ?只需要后端返回的/wtms路徑即可
? ? ? ? url: fileUrl, //服務(wù)地址 服務(wù)地址只需要后端返回的 /WMTS ? 不需要給后面拼接任何東西, ?
? ? ? ? layer: this.workspace, //圖層名稱 : "pucheng:satellite"
? ? ? ? style: '',
? ? ? ? format: 'image/png',
? ? ? ? tileMatrixSetID: this.srs, ?// "EPSG:900913"
? ? ? ? // 地圖飛入 ?定位的坐標 ?后端返回的數(shù)據(jù)
? ? ? ? rectangle: Cesium.Rectangle.fromDegrees(
? ? ? ? ? ? +this.zb.xmin, +this.zb.ymin, +this.zb.xmax, +this.zb.ymax),
? ? ? ? // 必須加 ?不然地圖出不來
?? ??? ?//之所以要在這里提出這個tileMatrixLabels參數(shù),是因為GeoServer在緩沖切分瓦片時對每一個縮放級別的存儲目錄沒有使用相應(yīng)的數(shù)字,而使用了網(wǎng)格+級別的方式來命名,如“EPSG:9100913:10”表示的是使用“EPSG:9100913”網(wǎng)格切分的第10級瓦片。
? ? ? ? tileMatrixLabels : [`${this.srs}:0`,`${this.srs}:1`, `${this.srs}:2`,`${this.srs}:3`,`${this.srs}:4`,`${this.srs}:5`,`${this.srs}:6`,
? ? ? ? `${this.srs}:7`,`${this.srs}:8`,`${this.srs}:9`,`${this.srs}:10`,`${this.srs}:11`,`${this.srs}:12`,`${this.srs}:13`,`${this.srs}:14`,
? ? ? ? `${this.srs}:15`,`${this.srs}:16`,`${this.srs}:17`,`${this.srs}:18`,
? ? ? ? ],
? ? ? ? // 必須加 ?不然地圖出不來
? ? ? ? tilingScheme: new Cesium.GeographicTilingScheme({//此處很重要,很重要。。。
? ? ? ? ? numberOfLevelZeroTilesX: 2,
? ? ? ? ? numberOfLevelZeroTilesY: 1
? ? ? ? }),
? ? ? ? // tilematrixset: this.srs,
? ? ? ? // maximumLevel: 18,
? ? ? });
? ? ? let layer = this.viewer.imageryLayers.addImageryProvider(provider);
? ? ? //控制圖層顯示
? ? ? this.viewer.flyTo(layer, {
? ? ? ? ? duration: 2
? ? ? ? });
? ? },

cesium加載shp格式的白模建筑

ceisum加載shp格式的建筑。有兩種思路,目前推薦第二種。

方法一

將shp格式轉(zhuǎn)換為geojson格式,然后采用cesium提供的接口加載到ceisum中。

嚴重缺陷:在面對大場景問題,即數(shù)據(jù)量較大時,非常容易卡死、崩潰

方法二

將shp轉(zhuǎn)換為3dtiles,然后加載到ceiusm中。

3dtiles是ceisum解決大場景問題專門提供的一種數(shù)據(jù)格式。

關(guān)鍵:轉(zhuǎn)換工具,我使用的是cesiumLab,比較好用,工具中需要加載dem,目測是用來與地形貼合的。

推薦方法:方法二。

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue?3中defineProps與defineEmits用法深度解析

    Vue?3中defineProps與defineEmits用法深度解析

    defineProps 和 defineEmits 這兩個是Vue3中<script setup>語法糖特有的編譯宏,專門用于組件通信,這篇文章主要介紹了Vue3中defineProps與defineEmits用法的相關(guān)資料,需要的朋友可以參考下
    2026-02-02
  • Vue多層數(shù)據(jù)結(jié)構(gòu)響應(yīng)式失效,視圖更新失敗問題

    Vue多層數(shù)據(jù)結(jié)構(gòu)響應(yīng)式失效,視圖更新失敗問題

    這篇文章主要介紹了Vue多層數(shù)據(jù)結(jié)構(gòu)響應(yīng)式失效,視圖更新失敗問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • vue組件之全局注冊和局部注冊方式

    vue組件之全局注冊和局部注冊方式

    這篇文章主要介紹了vue組件之全局注冊和局部注冊方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • vue實現(xiàn)分頁欄效果

    vue實現(xiàn)分頁欄效果

    這篇文章主要為大家詳細介紹了vue實現(xiàn)分頁欄效果,分頁欄設(shè)計的步驟與實現(xiàn)方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-06-06
  • vue?serve及其與vue-cli-service?serve之間的關(guān)系解讀

    vue?serve及其與vue-cli-service?serve之間的關(guān)系解讀

    這篇文章主要介紹了vue?serve及其與vue-cli-service?serve之間的關(guān)系,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • Vue 路由 過渡動效 數(shù)據(jù)獲取方法

    Vue 路由 過渡動效 數(shù)據(jù)獲取方法

    這篇文章主要介紹了Vue 路由 過渡動效 數(shù)據(jù)獲取方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-07-07
  • element plus tree拖動節(jié)點交換位置和改變層級問題(解決方案)

    element plus tree拖動節(jié)點交換位置和改變層級問題(解決方案)

    圖層list里有各種組件,用element plus的tree來渲染,可以把圖片等組件到面板里,面板是容器,非容器組件,比如圖片、文本等,就不能讓其他組件拖進來,這篇文章主要介紹了element plus tree拖動節(jié)點交換位置和改變層級問題(解決方案),需要的朋友可以參考下
    2024-04-04
  • vue3使用localStorage實現(xiàn)登錄注冊功能實例

    vue3使用localStorage實現(xiàn)登錄注冊功能實例

    這篇文章主要給大家介紹了關(guān)于vue3使用localStorage實現(xiàn)登錄注冊功能的相關(guān)資料, localStorage這個特性主要是用來作為本地存儲來使用的,解決了cookie存儲空間不足的問題,需要的朋友可以參考下
    2023-06-06
  • Vue中的ESLint配置方式

    Vue中的ESLint配置方式

    這篇文章主要介紹了Vue中的ESLint配置方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • vue與axios上傳視頻并顯示上傳進度情況

    vue與axios上傳視頻并顯示上傳進度情況

    本文講述了項目中實現(xiàn)上傳視頻并顯示上傳進度的功能,首先使用axios庫進行單文件引入,未進行封裝,通過element組件庫實現(xiàn)選擇文件上傳,并打印選擇文件的信息,上傳完成后,可以在展示區(qū)域顯示上傳的視頻,鼠標移入播放區(qū)域時會有相應(yīng)的效果
    2026-02-02

最新評論

高陵县| 泸州市| 来凤县| 天峻县| 洛隆县| 华阴市| 临泽县| 岚皋县| 铜陵市| 布拖县| 大姚县| 广元市| 民权县| 林西县| 崇阳县| 金华市| 筠连县| 蒙阴县| 越西县| 高清| 郯城县| 同心县| 大港区| 江西省| 河源市| 盘锦市| 瑞金市| 固始县| 治县。| 剑河县| 贵德县| 阳高县| 客服| 赤峰市| 临西县| 科技| 禄劝| 阿克苏市| 七台河市| 东宁县| 赤峰市|