Use union type instead of enum for extent corner
This commit is contained in:
committed by
Andreas Hocevar
parent
3a061ed576
commit
9c1b55e09c
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/extent
|
* @module ol/extent
|
||||||
*/
|
*/
|
||||||
import Corner from './extent/Corner.js';
|
|
||||||
import Relationship from './extent/Relationship.js';
|
import Relationship from './extent/Relationship.js';
|
||||||
import {assert} from './asserts.js';
|
import {assert} from './asserts.js';
|
||||||
|
|
||||||
@@ -11,6 +10,11 @@ import {assert} from './asserts.js';
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extent corner.
|
||||||
|
* @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an extent that includes all given coordinates.
|
* Build an extent that includes all given coordinates.
|
||||||
*
|
*
|
||||||
@@ -484,18 +488,18 @@ export function getCenter(extent) {
|
|||||||
/**
|
/**
|
||||||
* Get a corner coordinate of an extent.
|
* Get a corner coordinate of an extent.
|
||||||
* @param {Extent} extent Extent.
|
* @param {Extent} extent Extent.
|
||||||
* @param {import("./extent/Corner.js").default} corner Corner.
|
* @param {Corner} corner Corner.
|
||||||
* @return {import("./coordinate.js").Coordinate} Corner coordinate.
|
* @return {import("./coordinate.js").Coordinate} Corner coordinate.
|
||||||
*/
|
*/
|
||||||
export function getCorner(extent, corner) {
|
export function getCorner(extent, corner) {
|
||||||
let coordinate;
|
let coordinate;
|
||||||
if (corner === Corner.BOTTOM_LEFT) {
|
if (corner === 'bottom-left') {
|
||||||
coordinate = getBottomLeft(extent);
|
coordinate = getBottomLeft(extent);
|
||||||
} else if (corner === Corner.BOTTOM_RIGHT) {
|
} else if (corner === 'bottom-right') {
|
||||||
coordinate = getBottomRight(extent);
|
coordinate = getBottomRight(extent);
|
||||||
} else if (corner === Corner.TOP_LEFT) {
|
} else if (corner === 'top-left') {
|
||||||
coordinate = getTopLeft(extent);
|
coordinate = getTopLeft(extent);
|
||||||
} else if (corner === Corner.TOP_RIGHT) {
|
} else if (corner === 'top-right') {
|
||||||
coordinate = getTopRight(extent);
|
coordinate = getTopRight(extent);
|
||||||
} else {
|
} else {
|
||||||
assert(false, 13); // Invalid corner
|
assert(false, 13); // Invalid corner
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/extent/Corner
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extent corner.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
BOTTOM_LEFT: 'bottom-left',
|
|
||||||
BOTTOM_RIGHT: 'bottom-right',
|
|
||||||
TOP_LEFT: 'top-left',
|
|
||||||
TOP_RIGHT: 'top-right',
|
|
||||||
};
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/tilegrid
|
* @module ol/tilegrid
|
||||||
*/
|
*/
|
||||||
import Corner from './extent/Corner.js';
|
|
||||||
import TileGrid from './tilegrid/TileGrid.js';
|
import TileGrid from './tilegrid/TileGrid.js';
|
||||||
import Units from './proj/Units.js';
|
import Units from './proj/Units.js';
|
||||||
import {DEFAULT_MAX_ZOOM, DEFAULT_TILE_SIZE} from './tilegrid/common.js';
|
import {DEFAULT_MAX_ZOOM, DEFAULT_TILE_SIZE} from './tilegrid/common.js';
|
||||||
@@ -57,11 +56,11 @@ export function wrapX(tileGrid, tileCoord, projection) {
|
|||||||
* DEFAULT_MAX_ZOOM).
|
* DEFAULT_MAX_ZOOM).
|
||||||
* @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
|
* @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
|
||||||
* DEFAULT_TILE_SIZE).
|
* DEFAULT_TILE_SIZE).
|
||||||
* @param {import("./extent/Corner.js").default} [opt_corner] Extent corner (default is `'top-left'`).
|
* @param {import("./extent.js").Corner} [opt_corner] Extent corner (default is `'top-left'`).
|
||||||
* @return {!TileGrid} TileGrid instance.
|
* @return {!TileGrid} TileGrid instance.
|
||||||
*/
|
*/
|
||||||
export function createForExtent(extent, opt_maxZoom, opt_tileSize, opt_corner) {
|
export function createForExtent(extent, opt_maxZoom, opt_tileSize, opt_corner) {
|
||||||
const corner = opt_corner !== undefined ? opt_corner : Corner.TOP_LEFT;
|
const corner = opt_corner !== undefined ? opt_corner : 'top-left';
|
||||||
|
|
||||||
const resolutions = resolutionsFromExtent(extent, opt_maxZoom, opt_tileSize);
|
const resolutions = resolutionsFromExtent(extent, opt_maxZoom, opt_tileSize);
|
||||||
|
|
||||||
@@ -153,7 +152,7 @@ function resolutionsFromExtent(
|
|||||||
* DEFAULT_MAX_ZOOM).
|
* DEFAULT_MAX_ZOOM).
|
||||||
* @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
|
* @param {number|import("./size.js").Size} [opt_tileSize] Tile size (default uses
|
||||||
* DEFAULT_TILE_SIZE).
|
* DEFAULT_TILE_SIZE).
|
||||||
* @param {import("./extent/Corner.js").default} [opt_corner] Extent corner (default is `'top-left'`).
|
* @param {import("./extent.js").Corner} [opt_corner] Extent corner (default is `'top-left'`).
|
||||||
* @return {!TileGrid} TileGrid instance.
|
* @return {!TileGrid} TileGrid instance.
|
||||||
*/
|
*/
|
||||||
export function createForProjection(
|
export function createForProjection(
|
||||||
|
|||||||
Reference in New Issue
Block a user