MapPrint: fixedAspectRatioBox direction fix
This commit is contained in:
@ -346,22 +346,20 @@ export const fixedAspectRatioBox: GeometryFunction = (
|
||||
coordinates: SketchCoordType,
|
||||
geometry: SimpleGeometry | undefined,
|
||||
): SimpleGeometry => {
|
||||
// Ensure coordinates is an array of at least two points
|
||||
if (!Array.isArray(coordinates) || coordinates.length < 2) {
|
||||
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 minY = start[1];
|
||||
const maxX = end[0];
|
||||
let maxY = end[1];
|
||||
|
||||
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[][] = [[
|
||||
[minX, minY],
|
||||
[maxX, minY],
|
||||
@ -378,7 +376,6 @@ export const fixedAspectRatioBox: GeometryFunction = (
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const addInteractions = (
|
||||
map_id: string
|
||||
) => {
|
||||
|
Reference in New Issue
Block a user