成果管理、展示-影像按照鼠标拖动缩放;针对todesk的环境加速加载geoserver影像图层

dianlixunjian
滕嵩 2024-12-18 13:33:44 +08:00
parent 52a44f42bb
commit 7e1c870f83
4 changed files with 312 additions and 72 deletions

View File

@ -493,8 +493,13 @@ export const GeoTiffManagerGet = (params) =>
export const GeoTiffManagerDeleteTifStore = (params) =>
defHttp.post({ url: Api.DeleteTifStore + '?stores=' + params.stores });
// 删除tiff影像
export const GeoTiffManagerUpdateLayerGroupThumb = (params) =>
defHttp.post({ url: Api.UpdateLayerGroupThumb + '?layerGroups=' + params.layerGroups + "&bbox=" + params.bbox + "&num=" + params.num + "&width=" + params.width + "&height=" + params.height });
export const GeoTiffManagerUpdateLayerGroupThumb = ((params) => {
if (params.bbox) {
return defHttp.post({ url: Api.UpdateLayerGroupThumb + '?layerGroups=' + params.layerGroups + "&num=" + params.num + "&width=" + params.width + "&height=" + params.height + "&bbox=" + params.bbox });
} else {
return defHttp.post({ url: Api.UpdateLayerGroupThumb + '?layerGroups=' + params.layerGroups + "&num=" + params.num + "&width=" + params.width + "&height=" + params.height });
}
});
// 成果管理-航飞图片
// 添加成果

View File

@ -19,6 +19,33 @@
<div :style="{ width: '10px' }" />
</template>
<template #rightExtra>
<a-select
v-if="activeKey == '1'"
v-model:value="numValue"
:options="NumOptions"
style="width: 80px; margin-right: 10px"
allowClear
placeholder="份数"
/>
<a-popover title="提示">
<template #content>
<p>是否只展示当前无缩略图的影像图层</p>
</template>
<a-switch
v-if="activeKey == '2'"
v-model:checked="switchYingxiang"
style="margin-right: 15px; margin-bottom: 4px"
checked-children="是"
un-checked-children="否"
/>
</a-popover>
<a-select
v-model:value="widthAndHeightValue"
:options="widthAndHeightOptions"
style="width: 80px; margin-right: 10px"
allowClear
placeholder="长宽"
/>
<a-button type="success" @click="updateGeoTiff" :style="{ marginRight: '10px' }">
更新缩略图
</a-button>
@ -44,8 +71,52 @@
const emit = defineEmits(['generateThumbnail']);
const activeKey = ref('1');
//
const widthAndHeightValue = ref(1024);
const widthAndHeightOptions = ref([
{
value: '4096',
label: '4096',
},
{
value: '2048',
label: '2048',
},
{
value: '1024',
label: '1024',
},
{
value: '512',
label: '512',
},
{
value: '256',
label: '256',
},
]);
//
const numValue = ref(1);
const NumOptions = ref([
{
value: '30',
label: '900',
},
{
value: '20',
label: '400',
},
{
value: '5',
label: '25',
},
{
value: '1',
label: '1',
},
]);
// -
// -----------------------------------------------------------------------------
const [
chooseUpdateRegisterTable_yearweeks,
{
@ -68,7 +139,7 @@
maxHeight: 585,
});
// -
// -----------------------------------------------------------------------------
const serachInfoData = ref(props.chooseUpdateData_layernames);
const [
chooseUpdateRegisterTable_layernames,
@ -107,7 +178,47 @@
maxHeight: 471,
});
//
// or----------------------------------------------------------------------------
const switchYingxiang = ref(false);
watch(
() => switchYingxiang.value,
async () => {
if (switchYingxiang.value) {
serachInfoData.value = await filterLayersWithImages(props.chooseUpdateData_layernames);
} else {
serachInfoData.value = props.chooseUpdateData_layernames;
}
},
);
async function filterLayersWithImages(layerNames) {
// Promise
const checkPromises = layerNames.map(async (item) => {
const exists = await checkImageExists(
`/geoserver/group/1/${item.rowname}/${item.rowname}.png`,
);
return { item, exists };
});
// Promise
const results = await Promise.all(checkPromises);
//
return results.filter((result) => !result.exists).map((result) => result.item);
}
async function checkImageExists(url) {
try {
const response = await fetch(url, { method: 'HEAD' });
if (response.ok) {
return true;
} else {
return false;
}
} catch (error) {
return false;
}
}
// ----------------------------------------------------------------------------
const updateGeoTiff = () => {
if (activeKey.value == '1') {
//
@ -155,17 +266,26 @@
}
};
//
// -------------------------------------------------------------------------------------------
//
const loading_yearweeks = ref(false);
const loading_layernames = ref(false);
function updateThumbnail_yearweeks(layerNames) {
loading_yearweeks.value = true;
emit('generateThumbnail', layerNames, null, null, null);
emit(
'generateThumbnail',
layerNames,
null,
null,
null,
widthAndHeightValue.value,
numValue.value,
);
}
//
function updateThumbnail_layernames(rowname, bbox, length, num) {
function updateThumbnail_layernames(rowname, bbox, length, index) {
loading_layernames.value = true;
emit('generateThumbnail', rowname, bbox, length, num);
emit('generateThumbnail', rowname, bbox, length, index, widthAndHeightValue.value, 1);
}
//

View File

@ -29,7 +29,7 @@
</template>
<template v-if="column.key === 'accessUrl'">
<a-image
:src="'/geoserver/group/' + record.layerName + '.png'"
:src="'/geoserver/group/1/' + record.layerName + '/' + record.layerName + '.png'"
:fallback="getUrl(record.accessUrl, record.layerName)"
:style="{ marginRight: '10px' }"
:width="100"
@ -276,27 +276,34 @@
}
//
async function generateThumbnail(layerNames, bbox, length, num) {
async function generateThumbnail(
layerNames,
bbox,
length,
index,
widthAndHeightValue = 1024,
numValue = 1,
) {
if (bbox) {
GeoTiffManagerUpdateLayerGroupThumb({
layerGroups: layerNames,
bbox: bbox,
num: 1,
width: 1024,
height: 1024,
width: widthAndHeightValue,
height: widthAndHeightValue,
})
.then((res) => {
if (res && length == num) {
if (res && length == index) {
createMessage.success('生成新的缩略图成功!');
chooseUpdateRef.value.clearSelect_layernames();
chooseUpdateRef.value.loading_layernames = false;
} else if (length == num) {
} else if (length == index) {
createMessage.error('生成新的缩略图失败!');
chooseUpdateRef.value.loading_layernames = false;
}
})
.catch((error) => {
if (length == num) {
if (length == index) {
createMessage.error('生成新的缩略图失败!');
chooseUpdateRef.value.loading_layernames = false;
}
@ -305,24 +312,24 @@
//
GeoTiffManagerUpdateLayerGroupThumb({
layerGroups: layerNames,
bbox: null,
num: 5,
width: 4096,
height: 4096,
num: numValue,
width: widthAndHeightValue,
height: widthAndHeightValue,
})
.then((res) => {
if (res) {
createMessage.success('生成新的缩略图成功!');
chooseUpdateRef.value.loading_yearweeks = false;
chooseUpdateRef.value.clearSelect_yearweeks();
//
GeoTiffManagerUpdateLayerGroupThumb({
layerGroups: layerNames,
bbox: null,
num: 1,
width: 1024,
height: 1024,
});
if (numValue != 1) {
//
GeoTiffManagerUpdateLayerGroupThumb({
layerGroups: layerNames,
num: 1,
width: widthAndHeightValue,
height: widthAndHeightValue,
});
}
} else {
createMessage.error('生成新的缩略图失败!');
chooseUpdateRef.value.loading_yearweeks = false;

View File

@ -333,12 +333,14 @@
// -
const splitNum = 5;
let chooseNowRowLayerName = '';
function GeoTiffManagerRaster(chooseRows, lngLat, zoom, isMove, fillOpacity = 1) {
//
if (isMove) {
handlerLocation(lngLat, zoom);
}
chooseRows?.forEach((chooseRow, index) => {
chooseNowRowLayerName = chooseRows[chooseRows.length - 1].layerName;
if (
6 <= chooseRow.layerName.length &&
chooseRow.layerName.length <= 7 &&
@ -353,7 +355,7 @@
];
map.addSource(chooseRow.layerName + '-image', {
type: 'image',
url: '/geoserver/group/' + chooseRow.layerName + '.png',
url: '/geoserver/group/1/' + chooseRow.layerName + '/' + chooseRow.layerName + '.png',
coordinates: fourpoint,
});
map.addLayer({
@ -361,44 +363,43 @@
type: 'raster',
source: chooseRow.layerName + '-image',
minzoom: 0,
maxzoom: 10,
maxzoom: 14,
});
if (map.getLayer('streetLayer')) {
map.moveLayer(chooseRow.layerName + '-image', 'streetLayer');
}
//
//
const LNG = (119.27763051149853 - 117.34046403513817) / splitNum;
const LAT = (36.263686454243626 - 34.331716698906675) / splitNum;
for (let x = 0; x < splitNum; x++) {
for (let y = 0; y < splitNum; y++) {
let fourpoint = [
[Number(117.34046403513817 + x * LNG), Number(34.331716698906675 + (y + 1) * LAT)],
[
Number(117.34046403513817 + (x + 1) * LNG),
Number(34.331716698906675 + (y + 1) * LAT),
],
[Number(117.34046403513817 + (x + 1) * LNG), Number(34.331716698906675 + y * LAT)],
[Number(117.34046403513817 + x * LNG), Number(34.331716698906675 + y * LAT)],
];
map.addSource(chooseRow.layerName + '-image-' + x + '-' + y, {
type: 'image',
url: '/geoserver/group/' + chooseRow.layerName + '-' + x + '-' + y + '.png',
coordinates: fourpoint,
});
map.addLayer({
id: chooseRow.layerName + '-image-' + x + '-' + y,
type: 'raster',
source: chooseRow.layerName + '-image-' + x + '-' + y,
minzoom: 10,
maxzoom: 16,
});
if (map.getLayer('streetLayer')) {
map.moveLayer(chooseRow.layerName + '-image-' + x + '-' + y, 'streetLayer');
}
}
}
// //
// //
// const LNG = (119.27763051149853 - 117.34046403513817) / splitNum;
// const LAT = (36.263686454243626 - 34.331716698906675) / splitNum;
// for (let x = 0; x < splitNum; x++) {
// for (let y = 0; y < splitNum; y++) {
// let fourpoint = [
// [Number(117.34046403513817 + x * LNG), Number(34.331716698906675 + (y + 1) * LAT)],
// [
// Number(117.34046403513817 + (x + 1) * LNG),
// Number(34.331716698906675 + (y + 1) * LAT),
// ],
// [Number(117.34046403513817 + (x + 1) * LNG), Number(34.331716698906675 + y * LAT)],
// [Number(117.34046403513817 + x * LNG), Number(34.331716698906675 + y * LAT)],
// ];
// map.addSource(chooseRow.layerName + '-image-' + x + '-' + y, {
// type: 'image',
// url: '/geoserver/group/5/' + chooseRow.layerName + '-' + x + '-' + y + '.png',
// coordinates: fourpoint,
// });
// map.addLayer({
// id: chooseRow.layerName + '-image-' + x + '-' + y,
// type: 'raster',
// source: chooseRow.layerName + '-image-' + x + '-' + y,
// minzoom: 10,
// maxzoom: 14,
// });
// if (map.getLayer('streetLayer')) {
// map.moveLayer(chooseRow.layerName + '-image-' + x + '-' + y, 'streetLayer');
// }
// }
// }
} else {
const [minLon, minLat, maxLon, maxLat] = chooseRow.bbox
.split(',')
@ -411,7 +412,7 @@
];
map.addSource(chooseRow.layerName + '-image', {
type: 'image',
url: '/geoserver/group/' + chooseRow.layerName + '.png',
url: '/geoserver/group/1/' + chooseRow.layerName + '/' + chooseRow.layerName + '.png',
coordinates: fourpoint,
});
map.addLayer({
@ -599,13 +600,14 @@
//
map.removeImage('diagonal-stripe');
}
//
//
if (map.getLayer(layerName + '-image')) {
map.removeLayer(layerName + '-image');
}
if (map.getSource(layerName + '-image')) {
map.removeSource(layerName + '-image');
}
//
for (let x = 0; x < splitNum; x++) {
for (let y = 0; y < splitNum; y++) {
if (map.getLayer(layerName + '-image-' + x + '-' + y)) {
@ -616,6 +618,18 @@
}
}
}
//
if (layerName == chooseNowRowLayerName) {
chooseNowRowLayerName = '';
alldata.forEach((data) => {
if (map.getLayer('moveend' + data.number)) {
map.removeLayer('moveend' + data.number);
}
if (map.getSource('moveend' + data.number)) {
map.removeSource('moveend' + data.number);
}
});
}
}
//
@ -659,10 +673,30 @@
}
}
let alldata: any = [];
function getAllData() {
const splitnum = 20;
const LNG = (119.27763051149853 - 117.34046403513817) / splitnum;
const LAT = (36.263686454243626 - 34.331716698906675) / splitnum;
for (let x = 0; x < splitnum; x++) {
for (let y = 0; y < splitnum; y++) {
alldata.push({
number: '-' + x + '-' + y,
point: [
Number(117.34046403513817 + x * LNG),
Number(34.331716698906675 + y * LAT),
Number(117.34046403513817 + (x + 1) * LNG),
Number(34.331716698906675 + (y + 1) * LAT),
],
});
}
}
}
onMounted(() => {
getAllData();
mapboxgl.accessToken = MAPBOX_TOKEN;
map = initMap();
// handlerLocation([118.30207505530701, 35.30123435040745], 7.848587811931849);
map.on('load', () => {
//
@ -676,13 +710,87 @@
handlerDealCountry(null);
// map.on('click', function (e) {
// const zoom = map.getZoom();
// alert(':' + zoom);
// console.log(':', zoom);
// alert(':' + e.lngLat.lng + ',' + e.lngLat.lat);
// console.log(':', e.lngLat.lng, e.lngLat.lat);
// const zoom = map.getZoom();
// const bounds = map.getBounds();
// const sw = bounds.getSouthWest(); // 西
// const ne = bounds.getNorthEast(); //
// console.log('zoom:', zoom);
// console.log('bounds:', bounds);
// console.log('西:', sw);
// console.log(':', ne);
// console.log(':', e.lngLat.lng, e.lngLat.lat);
// });
//
map.on('moveend', function (e) {
const zoom = map.getZoom();
if (zoom > 12.5 && chooseNowRowLayerName != '') {
const bounds = map.getBounds();
const sw = bounds.getSouthWest(); // 西
const ne = bounds.getNorthEast(); //
if (
6 <= chooseNowRowLayerName.length &&
chooseNowRowLayerName.length <= 7 &&
chooseNowRowLayerName.charAt(4) == '-'
) {
let addLayers: any = [];
//
alldata.forEach((data) => {
if (
(((sw.lng <= data.point[0] && data.point[0] <= ne.lng) ||
(sw.lng <= data.point[2] && data.point[2] <= ne.lng)) &&
((sw.lat <= data.point[1] && data.point[1] <= ne.lat) ||
(sw.lat <= data.point[3] && data.point[3] <= ne.lat))) ||
(((data.point[0] <= sw.lng && sw.lng <= data.point[2]) ||
(data.point[0] <= ne.lng && ne.lng <= data.point[2])) &&
((data.point[1] <= sw.lat && sw.lat <= data.point[3]) ||
(data.point[1] <= ne.lat && ne.lat <= data.point[3])))
) {
addLayers.push(data);
}
});
//
addLayers?.forEach((add) => {
let fourpoint = [
[add.point[0], add.point[3]],
[add.point[2], add.point[3]],
[add.point[2], add.point[1]],
[add.point[0], add.point[1]],
];
if (!map.getSource('moveend' + add.number)) {
map.addSource('moveend' + add.number, {
type: 'image',
url:
'/geoserver/group/30/' +
chooseNowRowLayerName +
+'/' +
chooseNowRowLayerName +
add.number +
'.png',
coordinates: fourpoint,
});
}
if (!map.getLayer('moveend' + add.number)) {
map.addLayer({
id: 'moveend' + add.number,
type: 'raster',
source: 'moveend' + add.number,
});
if (map.getLayer('streetLayer')) {
map.moveLayer('moveend' + add.number, 'streetLayer');
}
if (map.getLayer('streetLayer')) {
map.moveLayer('moveend' + add.number, chooseNowRowLayerName);
}
}
});
}
}
});
});
});