Use union instead of enum for geometry type
This commit is contained in:
committed by
Andreas Hocevar
parent
04ad0e0c5a
commit
9a6f8493fb
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/Circle
|
||||
*/
|
||||
import GeometryType from './GeometryType.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {createOrUpdate, forEachCorner, intersects} from '../extent.js';
|
||||
import {deflateCoordinate} from './flat/deflate.js';
|
||||
@@ -137,11 +136,11 @@ class Circle extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.CIRCLE;
|
||||
return 'Circle';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,13 @@ import {get as getProjection, getTransform} from '../proj.js';
|
||||
import {memoizeOne} from '../functions.js';
|
||||
import {transform2D} from './flat/transform.js';
|
||||
|
||||
/**
|
||||
* @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type
|
||||
* The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,
|
||||
* `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,
|
||||
* `'GeometryCollection'`, or `'Circle'`.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {import("../transform.js").Transform}
|
||||
*/
|
||||
@@ -237,7 +244,7 @@ class Geometry extends BaseObject {
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @abstract
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {Type} Geometry type.
|
||||
*/
|
||||
getType() {
|
||||
return abstract();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
import EventType from '../events/EventType.js';
|
||||
import Geometry from './Geometry.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import {
|
||||
closestSquaredDistanceXY,
|
||||
createOrUpdateEmpty,
|
||||
@@ -204,11 +203,11 @@ class GeometryCollection extends Geometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.GEOMETRY_COLLECTION;
|
||||
return 'GeometryCollection';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* @module ol/geom/GeometryType
|
||||
*/
|
||||
|
||||
/**
|
||||
* The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,
|
||||
* `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,
|
||||
* `'GeometryCollection'`, `'Circle'`.
|
||||
* @enum {string}
|
||||
*/
|
||||
export default {
|
||||
POINT: 'Point',
|
||||
LINE_STRING: 'LineString',
|
||||
LINEAR_RING: 'LinearRing',
|
||||
POLYGON: 'Polygon',
|
||||
MULTI_POINT: 'MultiPoint',
|
||||
MULTI_LINE_STRING: 'MultiLineString',
|
||||
MULTI_POLYGON: 'MultiPolygon',
|
||||
GEOMETRY_COLLECTION: 'GeometryCollection',
|
||||
CIRCLE: 'Circle',
|
||||
};
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/LineString
|
||||
*/
|
||||
import GeometryLayout from './GeometryLayout.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
@@ -269,11 +268,11 @@ class LineString extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.LINE_STRING;
|
||||
return 'LineString';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/LinearRing
|
||||
*/
|
||||
import GeometryLayout from './GeometryLayout.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
@@ -149,11 +148,11 @@ class LinearRing extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.LINEAR_RING;
|
||||
return 'LinearRing';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/MultiLineString
|
||||
*/
|
||||
import GeometryLayout from './GeometryLayout.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import LineString from './LineString.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';
|
||||
@@ -308,11 +307,11 @@ class MultiLineString extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.MULTI_LINE_STRING;
|
||||
return 'MultiLineString';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/MultiPoint
|
||||
*/
|
||||
import GeometryType from './GeometryType.js';
|
||||
import Point from './Point.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {closestSquaredDistanceXY, containsXY} from '../extent.js';
|
||||
@@ -154,11 +153,11 @@ class MultiPoint extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.MULTI_POINT;
|
||||
return 'MultiPoint';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/MultiPolygon
|
||||
*/
|
||||
import GeometryLayout from './GeometryLayout.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import MultiPoint from './MultiPoint.js';
|
||||
import Polygon from './Polygon.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
@@ -425,11 +424,11 @@ class MultiPolygon extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.MULTI_POLYGON;
|
||||
return 'MultiPolygon';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/Point
|
||||
*/
|
||||
import GeometryType from './GeometryType.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
import {containsXY, createOrUpdateFromCoordinate} from '../extent.js';
|
||||
import {deflateCoordinate} from './flat/deflate.js';
|
||||
@@ -81,11 +80,11 @@ class Point extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.POINT;
|
||||
return 'Point';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/Polygon
|
||||
*/
|
||||
import GeometryLayout from './GeometryLayout.js';
|
||||
import GeometryType from './GeometryType.js';
|
||||
import LinearRing from './LinearRing.js';
|
||||
import Point from './Point.js';
|
||||
import SimpleGeometry from './SimpleGeometry.js';
|
||||
@@ -363,11 +362,11 @@ class Polygon extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* Get the type of this geometry.
|
||||
* @return {import("./GeometryType.js").default} Geometry type.
|
||||
* @return {import("./Geometry.js").Type} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
getType() {
|
||||
return GeometryType.POLYGON;
|
||||
return 'Polygon';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user