影像-跟新周图层组的缩略图

dianlixunjian
滕嵩 2024-12-07 16:55:37 +08:00
parent b106c00f0f
commit 6a959e0e72
7 changed files with 109 additions and 27 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 KiB

View File

@ -115,6 +115,8 @@ enum Api {
GeoTiffManagerGet = '/api/GeoTiffManager/Get', GeoTiffManagerGet = '/api/GeoTiffManager/Get',
// 删除tiff影像 // 删除tiff影像
DeleteTifStore = '/api/GeoTiffManager/DeleteTifStore', DeleteTifStore = '/api/GeoTiffManager/DeleteTifStore',
// 更新tiff周的影像缩略图
UpdateLayerGroupThumb = '/api/GeoTiffManager/UpdateLayerGroupThumb',
// 成果管理-航飞图片 // 成果管理-航飞图片
// 添加成果 // 添加成果
AchievementManageAddImageexif = '/api/AchievementManage/AddImageexif', AchievementManageAddImageexif = '/api/AchievementManage/AddImageexif',
@ -490,6 +492,9 @@ export const GeoTiffManagerGet = (params) =>
// 删除tiff影像 // 删除tiff影像
export const GeoTiffManagerDeleteTifStore = (params) => export const GeoTiffManagerDeleteTifStore = (params) =>
defHttp.post({ url: Api.DeleteTifStore + '?stores=' + params.stores }); defHttp.post({ url: Api.DeleteTifStore + '?stores=' + params.stores });
// 删除tiff影像
export const GeoTiffManagerUpdateLayerGroupThumb = (params) =>
defHttp.post({ url: Api.UpdateLayerGroupThumb + '?layerGroups=' + params.layerGroups });
// 成果管理-航飞图片 // 成果管理-航飞图片
// 添加成果 // 添加成果

View File

@ -5,6 +5,7 @@
<BasicTable @register="registerTable" @row-click="handRowClick"> <BasicTable @register="registerTable" @row-click="handRowClick">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="updateGeoTiff"></a-button> <a-button type="primary" @click="updateGeoTiff"></a-button>
<a-button type="success" @click="updateYearWeekThumbnail"></a-button>
<a-button type="error" @click="deleteGeoTiff"></a-button> <a-button type="error" @click="deleteGeoTiff"></a-button>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -28,7 +29,7 @@
</template> </template>
<template v-if="column.key === 'accessUrl'"> <template v-if="column.key === 'accessUrl'">
<a-image <a-image
:src="getUrl(record)" :src="getUrl(record.accessUrl, record.layerName)"
:style="{ marginRight: '10px' }" :style="{ marginRight: '10px' }"
:width="100" :width="100"
:height="100" :height="100"
@ -78,6 +79,7 @@
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { Modal } from 'ant-design-vue'; import { Modal } from 'ant-design-vue';
import proj4 from 'proj4'; import proj4 from 'proj4';
import dayjs from 'dayjs';
import { getAppEnvConfig } from '@/utils/env'; import { getAppEnvConfig } from '@/utils/env';
import { BasicTable, useTable } from '@/components/Table'; import { BasicTable, useTable } from '@/components/Table';
import { columns, searchFormSchema } from './util'; import { columns, searchFormSchema } from './util';
@ -89,6 +91,7 @@
GeoTiffManagerLoadPage, GeoTiffManagerLoadPage,
GeoTiffManagerGet, GeoTiffManagerGet,
GeoTiffManagerDeleteTifStore, GeoTiffManagerDeleteTifStore,
GeoTiffManagerUpdateLayerGroupThumb,
} from '@/api/demo/system'; } from '@/api/demo/system';
// //
@ -102,7 +105,7 @@
'+proj=tmerc +lat_0=37.56666666666666 +lon_0=126.93333333333333 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +towgs84=-119.819,-78.445,-112.283,0,0,0,0 +units=m +no_defs', '+proj=tmerc +lat_0=37.56666666666666 +lon_0=126.93333333333333 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +towgs84=-119.819,-78.445,-112.283,0,0,0,0 +units=m +no_defs',
); );
// // -----------------------------------------------------------------------------------------------
const [registerTable, { reload, getSelectRows }] = useTable({ const [registerTable, { reload, getSelectRows }] = useTable({
title: '影像管理', title: '影像管理',
api: GeoTiffManagerLoadPage, api: GeoTiffManagerLoadPage,
@ -124,7 +127,7 @@
immediate: false, immediate: false,
}); });
// // -----------------------------------------------------------------------------------------
const failOpen = ref(false); const failOpen = ref(false);
const failYingxiangData: any = ref(); const failYingxiangData: any = ref();
// //
@ -137,10 +140,11 @@
GeoTiffManagerUpdateGeoTiff() GeoTiffManagerUpdateGeoTiff()
.then((res) => { .then((res) => {
if (res.length == 0) { if (res.length == 0) {
createMessage.success('影像更新成功');
reload(); reload();
} else { } else {
failYingxiangData.value = getFailYingxiangData(res); failYingxiangData.value = getFailYingxiangData(res);
console.log(failYingxiangData.value); // console.log(failYingxiangData.value);
failOpen.value = true; failOpen.value = true;
reload(); reload();
} }
@ -165,14 +169,14 @@
return result; return result;
} }
// tiff // tiff---------------------------------------------------------------------------------------
const deleteGeoTiff = () => { const deleteGeoTiff = () => {
let rows = getSelectRows(); let rows = getSelectRows();
if (rows.length == 0) { if (rows.length == 0) {
return createMessage.warn('请勾选一条数据进行删除'); return createMessage.warn('请勾选一条数据进行删除');
} }
const record = rows[0]; const record = rows[0];
isPngImageUrl(getUrl(record)) isPngImageUrl(getUrl(record.accessUrl, record.layerName))
.then((isPng) => { .then((isPng) => {
if (isPng) { if (isPng) {
createMessage.warn('所选影像完好,不能删除!'); createMessage.warn('所选影像完好,不能删除!');
@ -214,7 +218,69 @@
} }
} }
// // -------------------------------------------------------------------------------
async function updateYearWeekThumbnail() {
GeoTiffManagerLoadPage({
page: 1,
limit: 1000000,
}).then((res) => {
//
let uniqueKeysArray = [...new Set(res.items.map((item) => item.dateDir))];
// (-)
uniqueKeysArray = [...new Set(uniqueKeysArray.map(convertToYearWeek))];
// -
let layerNames: any = '';
uniqueKeysArray.forEach((item, index) => {
if (index == 0) {
layerNames = item;
} else {
layerNames = layerNames.concat(',' + item);
}
});
//
// res.items.forEach((item, index) => {
// if (layerNames === '') {
// layerNames = item.layerName;
// } else {
// layerNames = layerNames.concat(',' + item.layerName);
// }
// });
//
generateThumbnail(layerNames);
});
}
//
async function generateThumbnail(layerNames) {
GeoTiffManagerUpdateLayerGroupThumb({ layerGroups: layerNames }).then((res) => {
if (res) {
createMessage.success('生成新的缩略图成功!');
} else {
createMessage.error('生成新的缩略图失败!');
}
});
}
// -
function convertToYearWeek(dateStr) {
const date = dayjs(dateStr, 'YYYYMMDD');
//
return `${date.year()}-${getWeekOfYear(date)}`;
}
//
function getWeekOfYear(date) {
const firstDayOfYear = dayjs(date).startOf('year');
const firstMondayOfYear =
firstDayOfYear.day() === 1
? firstDayOfYear
: firstDayOfYear.add(1 - firstDayOfYear.day(), 'day');
const diffInDays = date.diff(firstMondayOfYear, 'days');
const weekNumber = Math.floor(diffInDays / 7) + 1;
return weekNumber;
}
// -----------------------------------------------------------------------------------------
const mapboxComponentRef = ref(); const mapboxComponentRef = ref();
function handRowClick(record) { function handRowClick(record) {
allDataForClearMap.forEach((data) => { allDataForClearMap.forEach((data) => {
@ -231,6 +297,7 @@
let chooseRows: any = []; let chooseRows: any = [];
chooseRows.push(record); chooseRows.push(record);
mapboxComponentRef.value.GeoTiffManagerRaster(chooseRows, lngLat, 11, true); mapboxComponentRef.value.GeoTiffManagerRaster(chooseRows, lngLat, 11, true);
return lngLat;
} }
function isProjectedCoordinates(x, y) { function isProjectedCoordinates(x, y) {
@ -276,29 +343,24 @@
return [centerLon, centerLat]; return [centerLon, centerLat];
} }
// // 使----------------------------------------------------------------------------
let allDataForClearMap: any = [];
function forClearMap() {
GeoTiffManagerLoadPage({
page: 1,
limit: 10000,
}).then((res) => {
allDataForClearMap = res.items;
});
}
// 使
const visible = ref<boolean>(false); const visible = ref<boolean>(false);
const setVisible = (value): void => { const setVisible = (value): void => {
visible.value = false; visible.value = false;
}; };
// geoserver // geoserver
function getUrl(record) { function getUrl(accessUrl, name) {
let bbox: any = getBboxFromUrl(record.accessUrl); let r1 = [117.34046403513817, 34.331716698906675];
let r2 = [119.27763051149853, 36.263686454243626];
let size = 4096;
if (accessUrl) {
let bbox: any = getBboxFromUrl(accessUrl);
const coords = bbox.split(',').map((coord) => parseFloat(coord)); const coords = bbox.split(',').map((coord) => parseFloat(coord));
let r1 = proj4('EPSG:4326', 'EPSG:3857', [coords[0], coords[1]]); r1 = [coords[0], coords[1]];
let r2 = proj4('EPSG:4326', 'EPSG:3857', [coords[2], coords[3]]); r2 = [coords[2], coords[3]];
size = 256;
}
let titeUrl: any = null; let titeUrl: any = null;
if (new URL(VITE_GLOB_API_URL).hostname == 'localhost') { if (new URL(VITE_GLOB_API_URL).hostname == 'localhost') {
titeUrl = titeUrl =
@ -309,7 +371,7 @@
} }
let url = let url =
titeUrl + titeUrl +
record.layerName + name +
'&styles=&bbox=' + '&styles=&bbox=' +
r1[0] + r1[0] +
',' + ',' +
@ -318,10 +380,25 @@
r2[0] + r2[0] +
',' + ',' +
r2[1] + r2[1] +
'&width=256&height=256&srs=EPSG:3857&format=image/png&TRANSPARENT=TRUE'; '&width=' +
size +
'&height=' +
size +
'&srs=EPSG:4326&format=image/png&TRANSPARENT=TRUE';
return url; return url;
} }
// --------------------------------------------------------------
let allDataForClearMap: any = [];
function forClearMap() {
GeoTiffManagerLoadPage({
page: 1,
limit: 100000,
}).then((res) => {
allDataForClearMap = res.items;
});
}
onMounted(() => { onMounted(() => {
reload(); reload();
// //

View File

@ -354,7 +354,7 @@
]; ];
map.addSource(chooseRow.layerName + '-image', { map.addSource(chooseRow.layerName + '-image', {
type: 'image', type: 'image',
url: '/geoserver/group/my_workspace-' + chooseRow.layerName + '.png', url: '/geoserver/group/' + chooseRow.layerName + '.png',
coordinates: fourpoint, coordinates: fourpoint,
}); });
map.addLayer({ map.addLayer({