Browse Source

Merge branch 'release-sy-v1.0.0' of ssh://gitlab.datameta.com:2224/project/water/shuili-vue into release-sy-v1.0.0

sy-water-data-board-ui
panyuyi 1 month ago
parent
commit
8e0da012be
  1. 32824
      public/lib/SuperMap3D/SuperMap3D.js
  2. 169
      src/views/aiSupervision/waterSetting/runScene/layerTree/index.js
  3. 4
      vue.config.js

32824
public/lib/SuperMap3D/SuperMap3D.js

File diff suppressed because one or more lines are too long

169
src/views/aiSupervision/waterSetting/runScene/layerTree/index.js

@ -2,64 +2,64 @@
const createXyzLayer = (data) => const createXyzLayer = (data) =>
new sycim.XyzLayer(data.id, { new sycim.XyzLayer(data.id, {
...data, ...data,
maximumLevel: data.maximumLevel || 22 maximumLevel: data.maximumLevel || 22,
}); });
const layerTypeEnum = { const layerTypeEnum = {
'011100': 'BAIDU', "011100": "BAIDU",
'012000': 'PRIMITIVE', "012000": "PRIMITIVE",
'013000': 'TILESET', "013000": "TILESET",
'014000': 'XYZ', "014000": "XYZ",
'021102': 'ARCGIS_DYNAMIC', "021102": "ARCGIS_DYNAMIC",
'030100': 'WMTS', "030100": "WMTS",
'030200': 'WMS', "030200": "WMS",
'030300': 'WFS', "030300": "WFS",
'030400': 'GEOJSON', "030400": "GEOJSON",
'040003': 'WFS', "040003": "WFS",
'050100': 'TDTWMTS', "050100": "TDTWMTS",
'060100': 'XYZ', "060100": "XYZ",
'070100': 'BINGMAP', "070100": "BINGMAP",
'080100': 'S3M', "080100": "S3M",
'081100': 'SUPERMAP_REST' "081100": "SUPERMAP_REST",
}; };
// 图层响应动作 // 图层响应动作
const layerActions = { const layerActions = {
'011100': (data) => "011100": (data) =>
new sycim.BaiduLayer(data.id, { new sycim.BaiduLayer(data.id, {
...data, ...data,
style: data.layerTable, style: data.layerTable,
crs: 'WGS84' crs: "WGS84",
}), }),
'012000': (data) => new sycim.PrimitiveLayer(data.id), "012000": (data) => new sycim.PrimitiveLayer(data.id),
'013000': (data) => new sycim.TilesetLayer(data.id), "013000": (data) => new sycim.TilesetLayer(data.id),
'014000': createXyzLayer, "014000": createXyzLayer,
'021102': (data) => "021102": (data) =>
new sycim.ArcgisDynamicLayer(data.id, { new sycim.ArcgisDynamicLayer(data.id, {
url: data.url url: data.url,
}), }),
'030100': (data) => "030100": (data) =>
new sycim.WmtsLayer(data.id, { new sycim.WmtsLayer(data.id, {
...data, ...data,
url: data.url, url: data.url,
layer: data.layerTable, layer: data.layerTable,
tileMatrixSetID: data.tileMatrixSet, tileMatrixSetID: data.tileMatrixSet,
style: data.style || '' style: data.style || "",
}), }),
'030200': (data) => "030200": (data) =>
new sycim.WmsLayer(data.id, { new sycim.WmsLayer(data.id, {
...data, ...data,
url: data.url, url: data.url,
layer: data.layerTable, layer: data.layerTable,
parameters: { parameters: {
version: '1.3.0' version: "1.3.0",
} },
}), }),
'030300': async (data) => { "030300": async (data) => {
const options = { const options = {
version: '2.0.0', version: "2.0.0",
TYPENAMES: data.layerTable, TYPENAMES: data.layerTable,
outputFormat: 'json' outputFormat: "json",
}; };
// if (data.relationStyleId) { // if (data.relationStyleId) {
// const res = await getLayerStyle(data.relationStyleId); // const res = await getLayerStyle(data.relationStyleId);
@ -67,7 +67,7 @@ const layerActions = {
// } // }
return new sycim.WfsLayer(data.id, data.url, data.layerTable, options); return new sycim.WfsLayer(data.id, data.url, data.layerTable, options);
}, },
'030400': async (data) => { "030400": async (data) => {
const options = {}; const options = {};
// if (data.relationStyleId) { // if (data.relationStyleId) {
// const res = await getLayerStyle(data.relationStyleId); // const res = await getLayerStyle(data.relationStyleId);
@ -75,14 +75,14 @@ const layerActions = {
// } // }
return new sycim.GeoJsonLayer(data.id, data.url, options); return new sycim.GeoJsonLayer(data.id, data.url, options);
}, },
'040003': (data) => "040003": (data) =>
new sycim.WfsLayer(data.id, data.url, data.layerTable, { new sycim.WfsLayer(data.id, data.url, data.layerTable, {
cql_filter: data.filter, cql_filter: data.filter,
propertyName: '*' propertyName: "*",
}), }),
'050100': (data) => { "050100": (data) => {
let url = `${data.proxyUrl}${data.url}`; let url = `${data.proxyUrl}${data.url}`;
if (!url.includes('?tk=') && data.serviceToken) { if (!url.includes("?tk=") && data.serviceToken) {
url = `${url}?tk=${data.serviceToken}`; url = `${url}?tk=${data.serviceToken}`;
} }
return new sycim.TdtWmtsLayer(data.id, { return new sycim.TdtWmtsLayer(data.id, {
@ -91,27 +91,30 @@ const layerActions = {
layer: data.layerTable, layer: data.layerTable,
tileMatrixSetID: data.tileMatrixSet, tileMatrixSetID: data.tileMatrixSet,
spatialReference: { spatialReference: {
wkid: data.epsg wkid: data.epsg,
} },
}); });
}, },
'060100': createXyzLayer, "060100": createXyzLayer,
'070100': (data) => "070100": (data) =>
new sycim.BingMapLayer(data.id, { new sycim.BingMapLayer(data.id, {
...data ...data,
}), }),
'081100': (data) => "081100": (data) =>
// new sycim.SuperMapRestLayer(data.id, { // new sycim.SuperMapRestLayer(data.id, {
// ...data // ...data
// }) // })
new sycim.SuperMapRestLayer(data.id, { url: data.url, k: data.serviceToken }) new sycim.SuperMapRestLayer(data.id, {
url: data.url,
k: data.serviceToken,
}),
}; };
//图层缩放 //图层缩放
function defaultZoomToLayer(data) { function defaultZoomToLayer(data) {
const { mapParam } = data; const { mapParam } = data;
if (!mapParam?.tileCenter) return; if (!mapParam?.tileCenter) return;
const p = mapParam.tileCenter.split(','); const p = mapParam.tileCenter.split(",");
window.viewer.flyToPosition(new sycim.Position(+p[0], +p[1], 500, 0, -90, 0)); window.viewer.flyToPosition(new sycim.Position(+p[0], +p[1], 500, 0, -90, 0));
} }
@ -131,9 +134,18 @@ const supermapLayer = {};
// 超图s3m图层定位 // 超图s3m图层定位
function zoomToS3MLayer(data) { function zoomToS3MLayer(data) {
if (supermapLayer[data.id]) { if (supermapLayer[data.id]) {
Cesium.Resource.fetchJson(data.url + '/scenes.json').then(function (scenes) { let requestScenesUrl = data.url + "/scenes.json";
if (data.serviceToken) {
requestScenesUrl = data.url + "/scenes.json?k=" + data.serviceToken;
}
Cesium.Resource.fetchJson(requestScenesUrl).then(function (scenes) {
let sname = scenes && scenes[0].name; let sname = scenes && scenes[0].name;
Cesium.Resource.fetchJson(data.url + '/scenes/' + sname + '.json').then(function (jsonData) { let requestSceneUrl = data.url + "/scenes/" + sname + ".json";
if (data.serviceToken) {
requestSceneUrl =
data.url + "/scenes/" + sname + ".json?k=" + data.serviceToken;
}
Cesium.Resource.fetchJson(requestSceneUrl).then(function (jsonData) {
var cameraPosition = jsonData.camera; var cameraPosition = jsonData.camera;
var tilt = Cesium.Math.toRadians(cameraPosition.tilt - 90); var tilt = Cesium.Math.toRadians(cameraPosition.tilt - 90);
//设置相机位置、视角,便于观察场景 //设置相机位置、视角,便于观察场景
@ -146,53 +158,59 @@ function zoomToS3MLayer(data) {
orientation: { orientation: {
heading: cameraPosition.heading, heading: cameraPosition.heading,
pitch: tilt, pitch: tilt,
roll: 0 roll: 0,
} },
}); });
}); });
}); });
} else { } else {
alert('请先加载s3m图层'); alert("请先加载s3m图层");
} }
} }
// 图层缩放响应动作 // 图层缩放响应动作
const zoomToLayerActions = { const zoomToLayerActions = {
'011100': zoomToLayerByType, "011100": zoomToLayerByType,
'012000': (data) => { "012000": (data) => {
// modal // modal
const { modelInitPosition } = data; const { modelInitPosition } = data;
if (!modelInitPosition) return; if (!modelInitPosition) return;
const p = JSON.parse(modelInitPosition); const p = JSON.parse(modelInitPosition);
window.viewer.flyToPosition(new sycim.Position(p.lng, p.lat, p.alt + 500, 0, -90, 0)); window.viewer.flyToPosition(
new sycim.Position(p.lng, p.lat, p.alt + 500, 0, -90, 0)
);
}, },
'013000': zoomToLayerByType, "013000": zoomToLayerByType,
'014000': zoomToLayerByType, "014000": zoomToLayerByType,
'021102': zoomToLayerByType, "021102": zoomToLayerByType,
'030200': zoomToLayerByType, "030200": zoomToLayerByType,
'030300': zoomToLayerByType, "030300": zoomToLayerByType,
'030100': zoomToLayerByType, "030100": zoomToLayerByType,
'030400': zoomToLayerByType, "030400": zoomToLayerByType,
'040003': zoomToLayerByType, "040003": zoomToLayerByType,
'050100': zoomToLayerByType, "050100": zoomToLayerByType,
'060100': zoomToLayerByType, "060100": zoomToLayerByType,
'070100': zoomToLayerByType, "070100": zoomToLayerByType,
'080100': zoomToS3MLayer, "080100": zoomToS3MLayer,
'081100': zoomToLayerByType "081100": zoomToLayerByType,
}; };
// 添加图层 // 添加图层
export async function addLayer(layerData) { export async function addLayer(layerData) {
console.log('addLayer-layerData >>>>> ', layerData) console.log("addLayer-layerData >>>>> ", layerData);
const { layerType, url, id } = layerData; const { layerType, url, id } = layerData;
let action = null; let action = null;
// 超图 S3M图层 // 超图 S3M图层
if (layerType === '080100') { if (layerType === "080100") {
if (supermapLayer[id]) { if (supermapLayer[id]) {
supermapLayer[id].show = true; supermapLayer[id].show = true;
} else { } else {
const layerPromise = window.viewer.scene.open(url, { let requestUrl = url;
autoSetView: false //不自动定位 if (layerData.serviceToken) {
requestUrl = url + "?k=" + layerData.serviceToken;
}
const layerPromise = window.viewer.scene.open(requestUrl, {
autoSetView: false, //不自动定位
}); });
layerPromise.then((layer) => { layerPromise.then((layer) => {
supermapLayer[id] = layer?.[0]; supermapLayer[id] = layer?.[0];
@ -203,16 +221,19 @@ export async function addLayer(layerData) {
if (!layerType || !(action = layerActions[layerType])) return; if (!layerType || !(action = layerActions[layerType])) return;
const layer = await action(layerData); const layer = await action(layerData);
layer && window.viewer.addLayer(layer); layer && window.viewer.addLayer(layer);
if (['013000'].includes(layerType)) { if (["013000"].includes(layerType)) {
// 3d tiles // 3d tiles
const tileset = new sycim.Tileset(url); const tileset = new sycim.Tileset(url);
tileset.id = layerData.id; tileset.id = layerData.id;
layer.addGraphic(tileset); layer.addGraphic(tileset);
} else if (['012000'].includes(layerType)) { } else if (["012000"].includes(layerType)) {
// modal // modal
if (!layerData.modelInitPosition) return; if (!layerData.modelInitPosition) return;
const p = JSON.parse(layerData.modelInitPosition); const p = JSON.parse(layerData.modelInitPosition);
const model = new sycim.ModelPrimitive(new sycim.Position(p.lng, p.lat, p.alt, p.heading, p.pitch, p.roll), url); const model = new sycim.ModelPrimitive(
new sycim.Position(p.lng, p.lat, p.alt, p.heading, p.pitch, p.roll),
url
);
model.id = layerData.id; model.id = layerData.id;
layer.addGraphic(model); layer.addGraphic(model);
} }
@ -222,14 +243,14 @@ export function removeLayer(layerData) {
const { id, layerType } = layerData; const { id, layerType } = layerData;
if (!layerType) return; if (!layerType) return;
const type = layerTypeEnum[layerType]; const type = layerTypeEnum[layerType];
if (layerType === '080100') { if (layerType === "080100") {
if (supermapLayer[id]) { if (supermapLayer[id]) {
supermapLayer[id].show = false; supermapLayer[id].show = false;
} }
} else { } else {
window.viewer.removeLayer({ window.viewer.removeLayer({
id, id,
type: sycim.LayerType[type] type: sycim.LayerType[type],
}); });
} }
} }

4
vue.config.js

@ -52,7 +52,7 @@ module.exports = {
// } // }
// }, // },
// [ '/profile/']: { // [ '/profile/']: {
// target: 'http://shuili-admin.product.dev.com:30115', // target: 'http://shuili.product.dev.com:30115/',
// changeOrigin: true, // changeOrigin: true,
// // logLevel: 'debug', // // logLevel: 'debug',
// pathRewrite: { // pathRewrite: {
@ -68,7 +68,7 @@ module.exports = {
// } // }
// }, // },
["profile"]: { ["profile"]: {
target: "http://shuili-admin.product.dev.com:30115", target: "http://shuili.product.dev.com:30115",
changeOrigin: true, changeOrigin: true,
}, },
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {

Loading…
Cancel
Save