|
@ -346,22 +346,20 @@ export const fixedAspectRatioBox: GeometryFunction = ( |
|
|
coordinates: SketchCoordType, |
|
|
coordinates: SketchCoordType, |
|
|
geometry: SimpleGeometry | undefined, |
|
|
geometry: SimpleGeometry | undefined, |
|
|
): SimpleGeometry => { |
|
|
): SimpleGeometry => { |
|
|
// Ensure coordinates is an array of at least two points
|
|
|
|
|
|
if (!Array.isArray(coordinates) || coordinates.length < 2) { |
|
|
if (!Array.isArray(coordinates) || coordinates.length < 2) { |
|
|
return geometry ?? new Polygon([]); |
|
|
return geometry ?? new Polygon([]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const [start, end] = coordinates as Coordinate[]; // Ensure it's a Coordinate array
|
|
|
|
|
|
|
|
|
const [start, end] = coordinates as Coordinate[]; |
|
|
const minX = start[0]; |
|
|
const minX = start[0]; |
|
|
const minY = start[1]; |
|
|
const minY = start[1]; |
|
|
const maxX = end[0]; |
|
|
const maxX = end[0]; |
|
|
let maxY = end[1]; |
|
|
|
|
|
|
|
|
|
|
|
const width = maxX - minX; |
|
|
const width = maxX - minX; |
|
|
const height = width / 2; // Enforce 2:1 aspect ratio
|
|
|
|
|
|
maxY = minY + height; |
|
|
|
|
|
|
|
|
const height = Math.abs(width / 2) |
|
|
|
|
|
|
|
|
|
|
|
const maxY = end[1] > minY ? minY + height : minY - height; |
|
|
|
|
|
|
|
|
// Define the rectangle's coordinates
|
|
|
|
|
|
const boxCoords: Coordinate[][] = [[ |
|
|
const boxCoords: Coordinate[][] = [[ |
|
|
[minX, minY], |
|
|
[minX, minY], |
|
|
[maxX, minY], |
|
|
[maxX, minY], |
|
@ -378,7 +376,6 @@ export const fixedAspectRatioBox: GeometryFunction = ( |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const addInteractions = ( |
|
|
export const addInteractions = ( |
|
|
map_id: string |
|
|
map_id: string |
|
|
) => { |
|
|
) => { |
|
|