Use union type instead of enum for extent corner
This commit is contained in:
committed by
Andreas Hocevar
parent
3a061ed576
commit
9c1b55e09c
+10
-6
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/extent
|
||||
*/
|
||||
import Corner from './extent/Corner.js';
|
||||
import Relationship from './extent/Relationship.js';
|
||||
import {assert} from './asserts.js';
|
||||
|
||||
@@ -11,6 +10,11 @@ import {assert} from './asserts.js';
|
||||
* @api
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extent corner.
|
||||
* @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build an extent that includes all given coordinates.
|
||||
*
|
||||
@@ -484,18 +488,18 @@ export function getCenter(extent) {
|
||||
/**
|
||||
* Get a corner coordinate of an extent.
|
||||
* @param {Extent} extent Extent.
|
||||
* @param {import("./extent/Corner.js").default} corner Corner.
|
||||
* @param {Corner} corner Corner.
|
||||
* @return {import("./coordinate.js").Coordinate} Corner coordinate.
|
||||
*/
|
||||
export function getCorner(extent, corner) {
|
||||
let coordinate;
|
||||
if (corner === Corner.BOTTOM_LEFT) {
|
||||
if (corner === 'bottom-left') {
|
||||
coordinate = getBottomLeft(extent);
|
||||
} else if (corner === Corner.BOTTOM_RIGHT) {
|
||||
} else if (corner === 'bottom-right') {
|
||||
coordinate = getBottomRight(extent);
|
||||
} else if (corner === Corner.TOP_LEFT) {
|
||||
} else if (corner === 'top-left') {
|
||||
coordinate = getTopLeft(extent);
|
||||
} else if (corner === Corner.TOP_RIGHT) {
|
||||
} else if (corner === 'top-right') {
|
||||
coordinate = getTopRight(extent);
|
||||
} else {
|
||||
assert(false, 13); // Invalid corner
|
||||
|
||||
Reference in New Issue
Block a user