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

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',
// 删除tiff影像
DeleteTifStore = '/api/GeoTiffManager/DeleteTifStore',
// 更新tiff周的影像缩略图
UpdateLayerGroupThumb = '/api/GeoTiffManager/UpdateLayerGroupThumb',
// 成果管理-航飞图片
// 添加成果
AchievementManageAddImageexif = '/api/AchievementManage/AddImageexif',
@ -490,6 +492,9 @@ export const GeoTiffManagerGet = (params) =>
// 删除tiff影像
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 });
// 成果管理-航飞图片
// 添加成果

View File

@ -5,6 +5,7 @@
<BasicTable @register="registerTable" @row-click="handRowClick">
<template #toolbar>
<a-button type="primary" @click="updateGeoTiff"></a-button>
<a-button type="success" @click="updateYearWeekThumbnail"></a-button>
<a-button type="error" @click="deleteGeoTiff"></a-button>
</template>
<template #bodyCell="{ column, record }">
@ -28,7 +29,7 @@
</template>
<template v-if="column.key === 'accessUrl'">
<a-image
:src="getUrl(record)"
:src="getUrl(record.accessUrl, record.layerName)"
:style="{ marginRight: '10px' }"
:width="100"
:height="100"
@ -78,6 +79,7 @@
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { Modal } from 'ant-design-vue';
import proj4 from 'proj4';
import dayjs from 'dayjs';
import { getAppEnvConfig } from '@/utils/env';
import { BasicTable, useTable } from '@/components/Table';
import { columns, searchFormSchema } from './util';
@ -89,6 +91,7 @@
GeoTiffManagerLoadPage,
GeoTiffManagerGet,
GeoTiffManagerDeleteTifStore,
GeoTiffManagerUpdateLayerGroupThumb,
} 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',
);
//
// -----------------------------------------------------------------------------------------------
const [registerTable, { reload, getSelectRows }] = useTable({
title: '影像管理',
api: GeoTiffManagerLoadPage,
@ -124,7 +127,7 @@
immediate: false,
});
//
// -----------------------------------------------------------------------------------------
const failOpen = ref(false);
const failYingxiangData: any = ref();
//
@ -137,10 +140,11 @@
GeoTiffManagerUpdateGeoTiff()
.then((res) => {
if (res.length == 0) {
createMessage.success('影像更新成功');
reload();
} else {
failYingxiangData.value = getFailYingxiangData(res);
console.log(failYingxiangData.value);
// console.log(failYingxiangData.value);
failOpen.value = true;
reload();
}
@ -165,14 +169,14 @@
return result;
}
// tiff
// tiff---------------------------------------------------------------------------------------
const deleteGeoTiff = () => {
let rows = getSelectRows();
if (rows.length == 0) {
return createMessage.warn('请勾选一条数据进行删除');
}
const record = rows[0];
isPngImageUrl(getUrl(record))
isPngImageUrl(getUrl(record.accessUrl, record.layerName))
.then((isPng) => {
if (isPng) {
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();
function handRowClick(record) {
allDataForClearMap.forEach((data) => {
@ -231,6 +297,7 @@
let chooseRows: any = [];
chooseRows.push(record);
mapboxComponentRef.value.GeoTiffManagerRaster(chooseRows, lngLat, 11, true);
return lngLat;
}
function isProjectedCoordinates(x, y) {
@ -276,29 +343,24 @@
return [centerLon, centerLat];
}
//
let allDataForClearMap: any = [];
function forClearMap() {
GeoTiffManagerLoadPage({
page: 1,
limit: 10000,
}).then((res) => {
allDataForClearMap = res.items;
});
}
// 使
// 使----------------------------------------------------------------------------
const visible = ref<boolean>(false);
const setVisible = (value): void => {
visible.value = false;
};
// geoserver
function getUrl(record) {
let bbox: any = getBboxFromUrl(record.accessUrl);
const coords = bbox.split(',').map((coord) => parseFloat(coord));
let r1 = proj4('EPSG:4326', 'EPSG:3857', [coords[0], coords[1]]);
let r2 = proj4('EPSG:4326', 'EPSG:3857', [coords[2], coords[3]]);
function getUrl(accessUrl, name) {
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));
r1 = [coords[0], coords[1]];
r2 = [coords[2], coords[3]];
size = 256;
}
let titeUrl: any = null;
if (new URL(VITE_GLOB_API_URL).hostname == 'localhost') {
titeUrl =
@ -309,7 +371,7 @@
}
let url =
titeUrl +
record.layerName +
name +
'&styles=&bbox=' +
r1[0] +
',' +
@ -318,10 +380,25 @@
r2[0] +
',' +
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;
}
// --------------------------------------------------------------
let allDataForClearMap: any = [];
function forClearMap() {
GeoTiffManagerLoadPage({
page: 1,
limit: 100000,
}).then((res) => {
allDataForClearMap = res.items;
});
}
onMounted(() => {
reload();
//

View File

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