diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx index 1b7d192b12c312eb5e4bb8d6d4fb7ce80fbd5e30..1c7da28931cbf759afa8276f6c4502cdbcb382d6 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ExportCompound.component.tsx @@ -83,6 +83,7 @@ export const Export = ({ children }: ExportProps): JSX.Element => { handler: imageFormats?.[FIRST_ARRAY_ELEMENT]?.id, zoom: getModelExportZoom(imageSize.width, model), overlayIds: overlays.map(overlayId => `${overlayId}`), + currentView: currentView.value, }); if (url) { diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useScreenAspectRatios.ts b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useScreenAspectRatios.ts index e586afcbfa2e4004fbd3ae4533f49bfaf5d96fee..ee1bec83ec0db6998535a0849c8c8c3382de4318 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useScreenAspectRatios.ts +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageSize/utils/useScreenAspectRatios.ts @@ -1,5 +1,4 @@ import { getBounds } from '@/services/pluginsManager/map/data/getBounds'; -import { ZERO } from '@/constants/common'; import { DEFAULT_IMAGE_SIZE, DEFAULT_MODEL_ASPECT_RATIOS } from '../ImageSize.constants'; import { ImageSize, ModelAspectRatios } from '../ImageSize.types'; @@ -8,14 +7,7 @@ export const getScreenAspectRatios = (): ModelAspectRatios => { if (!bounds) { return DEFAULT_MODEL_ASPECT_RATIOS; } - let { x1, y1 } = bounds; - const { x2, y2 } = bounds; - if (x1 > x2) { - x1 = ZERO; - } - if (y1 > y2) { - y1 = ZERO; - } + const { x1, x2, y1, y2 } = bounds; const width = x2 - x1; const height = y2 - y1; @@ -30,14 +22,7 @@ export const getScreenDimension = (): ImageSize => { if (!bounds) { return DEFAULT_IMAGE_SIZE; } - let { x1, y1 } = bounds; - const { x2, y2 } = bounds; - if (x1 > x2) { - x1 = ZERO; - } - if (y1 > y2) { - y1 = ZERO; - } + const { x1, x2, y1, y2 } = bounds; const width = x2 - x1; const height = y2 - y1; diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/utils/getGraphicsDownloadUrl.ts b/src/components/Map/Drawer/ExportDrawer/ExportCompound/utils/getGraphicsDownloadUrl.ts index 169265eacb16fa65f80698c2768ebb4f359018a8..2844899535138beda38a96fc209db517bb13c12e 100644 --- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/utils/getGraphicsDownloadUrl.ts +++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/utils/getGraphicsDownloadUrl.ts @@ -1,4 +1,5 @@ import { BASE_API_URL, PROJECT_ID } from '@/constants'; +import { getBounds } from '@/services/pluginsManager/map/data/getBounds'; export interface GetGraphicsDownloadUrlProps { backgroundId?: number; @@ -6,6 +7,7 @@ export interface GetGraphicsDownloadUrlProps { handler?: string; zoom?: number; overlayIds: string[]; + currentView?: boolean; } export const getGraphicsDownloadUrl = ({ @@ -14,6 +16,7 @@ export const getGraphicsDownloadUrl = ({ handler, zoom, overlayIds, + currentView, }: GetGraphicsDownloadUrlProps): string | undefined => { const isAllElementsTruthy = [backgroundId, modelId, handler, zoom].reduce( (a, b) => Boolean(a) && Boolean(b), @@ -26,5 +29,14 @@ export const getGraphicsDownloadUrl = ({ const overlays = overlayIds.join(','); - return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${modelId}:downloadImage?backgroundOverlayId=${backgroundId}&handlerClass=${handler}&zoomLevel=${zoom}&overlayIds=${overlays}`; + let polygonSuffix = ''; + if (currentView) { + const bounds = getBounds(); + if (bounds) { + const { x1, y1, x2, y2 } = bounds; + polygonSuffix = `&polygonString=${x1},${y1};${x1},${y2};${x2},${y2};${x2},${y1}`; + } + } + + return `${BASE_API_URL}/projects/${PROJECT_ID}/models/${modelId}:downloadImage?backgroundOverlayId=${backgroundId}&handlerClass=${handler}&zoomLevel=${zoom}&overlayIds=${overlays}${polygonSuffix}`; }; diff --git a/src/services/pluginsManager/map/data/getBounds.ts b/src/services/pluginsManager/map/data/getBounds.ts index 626e13f705c08dcf163ed1a1017e99d857a7723b..a905228e9996f3f447dc301c67d7eb2a1fa3e56c 100644 --- a/src/services/pluginsManager/map/data/getBounds.ts +++ b/src/services/pluginsManager/map/data/getBounds.ts @@ -2,6 +2,7 @@ import { mapDataSizeSelector } from '@/redux/map/map.selectors'; import { store } from '@/redux/store'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; import { toLonLat } from 'ol/proj'; +import { ZERO } from '@/constants/common'; import { MapManager } from '../mapManager'; type GetBoundsReturnType = @@ -29,8 +30,8 @@ export const getBounds = (): GetBoundsReturnType => { const { x: x2, y: y2 } = latLngToPoint([latY2, lngX2], mapSize, { rounded: true }); return { - x1, - y1, + x1: x1 > x2 ? ZERO : x1, // handle lat,lng overflow + y1: y1 > y2 ? ZERO : y1, // handle lat,lng overflow x2, y2, };