Use union instead of enum for geometry type

This commit is contained in:
Tim Schaub
2021-09-04 17:39:54 -06:00
committed by Andreas Hocevar
parent 04ad0e0c5a
commit 9a6f8493fb
35 changed files with 296 additions and 378 deletions

View File

@@ -2,7 +2,6 @@
* @module ol/View * @module ol/View
*/ */
import BaseObject from './Object.js'; import BaseObject from './Object.js';
import GeometryType from './geom/GeometryType.js';
import Units from './proj/Units.js'; import Units from './proj/Units.js';
import ViewHint from './ViewHint.js'; import ViewHint from './ViewHint.js';
import ViewProperty from './ViewProperty.js'; import ViewProperty from './ViewProperty.js';
@@ -1345,7 +1344,7 @@ class View extends BaseObject {
assert(!isEmpty(geometryOrExtent), 25); // Cannot fit empty extent provided as `geometry` assert(!isEmpty(geometryOrExtent), 25); // Cannot fit empty extent provided as `geometry`
const extent = fromUserExtent(geometryOrExtent, this.getProjection()); const extent = fromUserExtent(geometryOrExtent, this.getProjection());
geometry = polygonFromExtent(extent); geometry = polygonFromExtent(extent);
} else if (geometryOrExtent.getType() === GeometryType.CIRCLE) { } else if (geometryOrExtent.getType() === 'Circle') {
const extent = fromUserExtent( const extent = fromUserExtent(
geometryOrExtent.getExtent(), geometryOrExtent.getExtent(),
this.getProjection() this.getProjection()

View File

@@ -3,7 +3,6 @@
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import JSONFeature from './JSONFeature.js'; import JSONFeature from './JSONFeature.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import LinearRing from '../geom/LinearRing.js'; import LinearRing from '../geom/LinearRing.js';
@@ -43,27 +42,29 @@ import {transformGeometryWithOptions} from './Feature.js';
/** /**
* @const * @const
* @type {Object<import("../geom/GeometryType.js").default, function(EsriJSONGeometry): import("../geom/Geometry.js").default>} * @type {Object<import("../geom/Geometry.js").Type, function(EsriJSONGeometry): import("../geom/Geometry.js").default>}
*/ */
const GEOMETRY_READERS = {}; const GEOMETRY_READERS = {
GEOMETRY_READERS[GeometryType.POINT] = readPointGeometry; Point: readPointGeometry,
GEOMETRY_READERS[GeometryType.LINE_STRING] = readLineStringGeometry; LineString: readLineStringGeometry,
GEOMETRY_READERS[GeometryType.POLYGON] = readPolygonGeometry; Polygon: readPolygonGeometry,
GEOMETRY_READERS[GeometryType.MULTI_POINT] = readMultiPointGeometry; MultiPoint: readMultiPointGeometry,
GEOMETRY_READERS[GeometryType.MULTI_LINE_STRING] = readMultiLineStringGeometry; MultiLineString: readMultiLineStringGeometry,
GEOMETRY_READERS[GeometryType.MULTI_POLYGON] = readMultiPolygonGeometry; MultiPolygon: readMultiPolygonGeometry,
};
/** /**
* @const * @const
* @type {Object<string, function(import("../geom/Geometry.js").default, import("./Feature.js").WriteOptions=): (EsriJSONGeometry)>} * @type {Object<import("../geom/Geometry.js").Type, function(import("../geom/Geometry.js").default, import("./Feature.js").WriteOptions=): (EsriJSONGeometry)>}
*/ */
const GEOMETRY_WRITERS = {}; const GEOMETRY_WRITERS = {
GEOMETRY_WRITERS[GeometryType.POINT] = writePointGeometry; Point: writePointGeometry,
GEOMETRY_WRITERS[GeometryType.LINE_STRING] = writeLineStringGeometry; LineString: writeLineStringGeometry,
GEOMETRY_WRITERS[GeometryType.POLYGON] = writePolygonGeometry; Polygon: writePolygonGeometry,
GEOMETRY_WRITERS[GeometryType.MULTI_POINT] = writeMultiPointGeometry; MultiPoint: writeMultiPointGeometry,
GEOMETRY_WRITERS[GeometryType.MULTI_LINE_STRING] = writeMultiLineStringGeometry; MultiLineString: writeMultiLineStringGeometry,
GEOMETRY_WRITERS[GeometryType.MULTI_POLYGON] = writeMultiPolygonGeometry; MultiPolygon: writeMultiPolygonGeometry,
};
/** /**
* @typedef {Object} Options * @typedef {Object} Options
@@ -255,28 +256,28 @@ function readGeometry(object, opt_options) {
if (!object) { if (!object) {
return null; return null;
} }
/** @type {import("../geom/GeometryType.js").default} */ /** @type {import("../geom/Geometry.js").Type} */
let type; let type;
if (typeof object['x'] === 'number' && typeof object['y'] === 'number') { if (typeof object['x'] === 'number' && typeof object['y'] === 'number') {
type = GeometryType.POINT; type = 'Point';
} else if (object['points']) { } else if (object['points']) {
type = GeometryType.MULTI_POINT; type = 'MultiPoint';
} else if (object['paths']) { } else if (object['paths']) {
const esriJSONPolyline = /** @type {EsriJSONPolyline} */ (object); const esriJSONPolyline = /** @type {EsriJSONPolyline} */ (object);
if (esriJSONPolyline.paths.length === 1) { if (esriJSONPolyline.paths.length === 1) {
type = GeometryType.LINE_STRING; type = 'LineString';
} else { } else {
type = GeometryType.MULTI_LINE_STRING; type = 'MultiLineString';
} }
} else if (object['rings']) { } else if (object['rings']) {
const esriJSONPolygon = /** @type {EsriJSONPolygon} */ (object); const esriJSONPolygon = /** @type {EsriJSONPolygon} */ (object);
const layout = getGeometryLayout(esriJSONPolygon); const layout = getGeometryLayout(esriJSONPolygon);
const rings = convertRings(esriJSONPolygon.rings, layout); const rings = convertRings(esriJSONPolygon.rings, layout);
if (rings.length === 1) { if (rings.length === 1) {
type = GeometryType.POLYGON; type = 'Polygon';
object = assign({}, object, {['rings']: rings[0]}); object = assign({}, object, {['rings']: rings[0]});
} else { } else {
type = GeometryType.MULTI_POLYGON; type = 'MultiPolygon';
object = assign({}, object, {['rings']: rings}); object = assign({}, object, {['rings']: rings});
} }
} }

View File

@@ -3,7 +3,6 @@
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
@@ -848,7 +847,7 @@ function writeRte(node, feature, objectStack) {
const context = {node: node}; const context = {node: node};
context['properties'] = properties; context['properties'] = properties;
const geometry = feature.getGeometry(); const geometry = feature.getGeometry();
if (geometry.getType() == GeometryType.LINE_STRING) { if (geometry.getType() == 'LineString') {
const lineString = /** @type {LineString} */ ( const lineString = /** @type {LineString} */ (
transformGeometryWithOptions(geometry, true, options) transformGeometryWithOptions(geometry, true, options)
); );
@@ -882,7 +881,7 @@ function writeTrk(node, feature, objectStack) {
const context = {node: node}; const context = {node: node};
context['properties'] = properties; context['properties'] = properties;
const geometry = feature.getGeometry(); const geometry = feature.getGeometry();
if (geometry.getType() == GeometryType.MULTI_LINE_STRING) { if (geometry.getType() == 'MultiLineString') {
const multiLineString = /** @type {MultiLineString} */ ( const multiLineString = /** @type {MultiLineString} */ (
transformGeometryWithOptions(geometry, true, options) transformGeometryWithOptions(geometry, true, options)
); );
@@ -932,7 +931,7 @@ function writeWpt(node, feature, objectStack) {
const context = objectStack[objectStack.length - 1]; const context = objectStack[objectStack.length - 1];
context['properties'] = feature.getProperties(); context['properties'] = feature.getProperties();
const geometry = feature.getGeometry(); const geometry = feature.getGeometry();
if (geometry.getType() == GeometryType.POINT) { if (geometry.getType() == 'Point') {
const point = /** @type {Point} */ ( const point = /** @type {Point} */ (
transformGeometryWithOptions(geometry, true, options) transformGeometryWithOptions(geometry, true, options)
); );

View File

@@ -4,7 +4,6 @@
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js'; import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryType from '../geom/GeometryType.js';
import JSONFeature from './JSONFeature.js'; import JSONFeature from './JSONFeature.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
@@ -284,46 +283,46 @@ function readGeometry(object, opt_options) {
*/ */
let geometry; let geometry;
switch (object['type']) { switch (object['type']) {
case GeometryType.POINT: { case 'Point': {
geometry = readPointGeometry(/** @type {GeoJSONPoint} */ (object)); geometry = readPointGeometry(/** @type {GeoJSONPoint} */ (object));
break; break;
} }
case GeometryType.LINE_STRING: { case 'LineString': {
geometry = readLineStringGeometry( geometry = readLineStringGeometry(
/** @type {GeoJSONLineString} */ (object) /** @type {GeoJSONLineString} */ (object)
); );
break; break;
} }
case GeometryType.POLYGON: { case 'Polygon': {
geometry = readPolygonGeometry(/** @type {GeoJSONPolygon} */ (object)); geometry = readPolygonGeometry(/** @type {GeoJSONPolygon} */ (object));
break; break;
} }
case GeometryType.MULTI_POINT: { case 'MultiPoint': {
geometry = readMultiPointGeometry( geometry = readMultiPointGeometry(
/** @type {GeoJSONMultiPoint} */ (object) /** @type {GeoJSONMultiPoint} */ (object)
); );
break; break;
} }
case GeometryType.MULTI_LINE_STRING: { case 'MultiLineString': {
geometry = readMultiLineStringGeometry( geometry = readMultiLineStringGeometry(
/** @type {GeoJSONMultiLineString} */ (object) /** @type {GeoJSONMultiLineString} */ (object)
); );
break; break;
} }
case GeometryType.MULTI_POLYGON: { case 'MultiPolygon': {
geometry = readMultiPolygonGeometry( geometry = readMultiPolygonGeometry(
/** @type {GeoJSONMultiPolygon} */ (object) /** @type {GeoJSONMultiPolygon} */ (object)
); );
break; break;
} }
case GeometryType.GEOMETRY_COLLECTION: { case 'GeometryCollection': {
geometry = readGeometryCollectionGeometry( geometry = readGeometryCollectionGeometry(
/** @type {GeoJSONGeometryCollection} */ (object) /** @type {GeoJSONGeometryCollection} */ (object)
); );
break; break;
} }
default: { default: {
throw new Error('Unsupported GeoJSON type: ' + object.type); throw new Error('Unsupported GeoJSON type: ' + object['type']);
} }
} }
return transformGeometryWithOptions(geometry, false, opt_options); return transformGeometryWithOptions(geometry, false, opt_options);
@@ -407,56 +406,56 @@ function writeGeometry(geometry, opt_options) {
/** @type {GeoJSONGeometry} */ /** @type {GeoJSONGeometry} */
let geoJSON; let geoJSON;
switch (type) { switch (type) {
case GeometryType.POINT: { case 'Point': {
geoJSON = writePointGeometry( geoJSON = writePointGeometry(
/** @type {Point} */ (geometry), /** @type {Point} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.LINE_STRING: { case 'LineString': {
geoJSON = writeLineStringGeometry( geoJSON = writeLineStringGeometry(
/** @type {LineString} */ (geometry), /** @type {LineString} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.POLYGON: { case 'Polygon': {
geoJSON = writePolygonGeometry( geoJSON = writePolygonGeometry(
/** @type {Polygon} */ (geometry), /** @type {Polygon} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.MULTI_POINT: { case 'MultiPoint': {
geoJSON = writeMultiPointGeometry( geoJSON = writeMultiPointGeometry(
/** @type {MultiPoint} */ (geometry), /** @type {MultiPoint} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.MULTI_LINE_STRING: { case 'MultiLineString': {
geoJSON = writeMultiLineStringGeometry( geoJSON = writeMultiLineStringGeometry(
/** @type {MultiLineString} */ (geometry), /** @type {MultiLineString} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.MULTI_POLYGON: { case 'MultiPolygon': {
geoJSON = writeMultiPolygonGeometry( geoJSON = writeMultiPolygonGeometry(
/** @type {MultiPolygon} */ (geometry), /** @type {MultiPolygon} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.GEOMETRY_COLLECTION: { case 'GeometryCollection': {
geoJSON = writeGeometryCollectionGeometry( geoJSON = writeGeometryCollectionGeometry(
/** @type {GeometryCollection} */ (geometry), /** @type {GeometryCollection} */ (geometry),
opt_options opt_options
); );
break; break;
} }
case GeometryType.CIRCLE: { case 'Circle': {
geoJSON = { geoJSON = {
type: 'GeometryCollection', type: 'GeometryCollection',
geometries: [], geometries: [],

View File

@@ -5,7 +5,6 @@ import Feature from '../Feature.js';
import Fill from '../style/Fill.js'; import Fill from '../style/Fill.js';
import GeometryCollection from '../geom/GeometryCollection.js'; import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import Icon from '../style/Icon.js'; import Icon from '../style/Icon.js';
import IconAnchorUnits from '../style/IconAnchorUnits.js'; import IconAnchorUnits from '../style/IconAnchorUnits.js';
import IconOrigin from '../style/IconOrigin.js'; import IconOrigin from '../style/IconOrigin.js';
@@ -1012,16 +1011,12 @@ function createFeatureStyleFunction(
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.filter(function (geometry) { .filter(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
return ( return type === 'Point' || type === 'MultiPoint';
type === GeometryType.POINT ||
type === GeometryType.MULTI_POINT
);
}); });
drawName = multiGeometryPoints.length > 0; drawName = multiGeometryPoints.length > 0;
} else { } else {
const type = geometry.getType(); const type = geometry.getType();
drawName = drawName = type === 'Point' || type === 'MultiPoint';
type === GeometryType.POINT || type === GeometryType.MULTI_POINT;
} }
} }
} }
@@ -1759,7 +1754,7 @@ function readMultiGeometry(node, objectStack) {
if (homogeneous) { if (homogeneous) {
let layout; let layout;
let flatCoordinates; let flatCoordinates;
if (type == GeometryType.POINT) { if (type == 'Point') {
const point = geometries[0]; const point = geometries[0];
layout = point.getLayout(); layout = point.getLayout();
flatCoordinates = point.getFlatCoordinates(); flatCoordinates = point.getFlatCoordinates();
@@ -1769,13 +1764,13 @@ function readMultiGeometry(node, objectStack) {
} }
multiGeometry = new MultiPoint(flatCoordinates, layout); multiGeometry = new MultiPoint(flatCoordinates, layout);
setCommonGeometryProperties(multiGeometry, geometries); setCommonGeometryProperties(multiGeometry, geometries);
} else if (type == GeometryType.LINE_STRING) { } else if (type == 'LineString') {
multiGeometry = new MultiLineString(geometries); multiGeometry = new MultiLineString(geometries);
setCommonGeometryProperties(multiGeometry, geometries); setCommonGeometryProperties(multiGeometry, geometries);
} else if (type == GeometryType.POLYGON) { } else if (type == 'Polygon') {
multiGeometry = new MultiPolygon(geometries); multiGeometry = new MultiPolygon(geometries);
setCommonGeometryProperties(multiGeometry, geometries); setCommonGeometryProperties(multiGeometry, geometries);
} else if (type == GeometryType.GEOMETRY_COLLECTION) { } else if (type == 'GeometryCollection') {
multiGeometry = new GeometryCollection(geometries); multiGeometry = new GeometryCollection(geometries);
} else { } else {
assert(false, 37); // Unknown geometry type found assert(false, 37); // Unknown geometry type found
@@ -1919,7 +1914,7 @@ function readStyle(node, objectStack) {
geometry: function (feature) { geometry: function (feature) {
const geometry = feature.getGeometry(); const geometry = feature.getGeometry();
const type = geometry.getType(); const type = geometry.getType();
if (type === GeometryType.GEOMETRY_COLLECTION) { if (type === 'GeometryCollection') {
const collection = const collection =
/** @type {import("../geom/GeometryCollection").default} */ ( /** @type {import("../geom/GeometryCollection").default} */ (
geometry geometry
@@ -1929,16 +1924,10 @@ function readStyle(node, objectStack) {
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.filter(function (geometry) { .filter(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
return ( return type !== 'Polygon' && type !== 'MultiPolygon';
type !== GeometryType.POLYGON &&
type !== GeometryType.MULTI_POLYGON
);
}) })
); );
} else if ( } else if (type !== 'Polygon' && type !== 'MultiPolygon') {
type !== GeometryType.POLYGON &&
type !== GeometryType.MULTI_POLYGON
) {
return geometry; return geometry;
} }
}, },
@@ -1952,7 +1941,7 @@ function readStyle(node, objectStack) {
geometry: function (feature) { geometry: function (feature) {
const geometry = feature.getGeometry(); const geometry = feature.getGeometry();
const type = geometry.getType(); const type = geometry.getType();
if (type === GeometryType.GEOMETRY_COLLECTION) { if (type === 'GeometryCollection') {
const collection = const collection =
/** @type {import("../geom/GeometryCollection").default} */ ( /** @type {import("../geom/GeometryCollection").default} */ (
geometry geometry
@@ -1962,16 +1951,10 @@ function readStyle(node, objectStack) {
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.filter(function (geometry) { .filter(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
return ( return type === 'Polygon' || type === 'MultiPolygon';
type === GeometryType.POLYGON ||
type === GeometryType.MULTI_POLYGON
);
}) })
); );
} else if ( } else if (type === 'Polygon' || type === 'MultiPolygon') {
type === GeometryType.POLYGON ||
type === GeometryType.MULTI_POLYGON
) {
return geometry; return geometry;
} }
}, },
@@ -2868,27 +2851,27 @@ function writeMultiGeometry(node, geometry, objectStack) {
let geometries = []; let geometries = [];
/** @type {function(*, Array<*>, string=): (Node|undefined)} */ /** @type {function(*, Array<*>, string=): (Node|undefined)} */
let factory; let factory;
if (type === GeometryType.GEOMETRY_COLLECTION) { if (type === 'GeometryCollection') {
/** @type {GeometryCollection} */ (geometry) /** @type {GeometryCollection} */ (geometry)
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.forEach(function (geometry) { .forEach(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
if (type === GeometryType.MULTI_POINT) { if (type === 'MultiPoint') {
geometries = geometries.concat( geometries = geometries.concat(
/** @type {MultiPoint} */ (geometry).getPoints() /** @type {MultiPoint} */ (geometry).getPoints()
); );
} else if (type === GeometryType.MULTI_LINE_STRING) { } else if (type === 'MultiLineString') {
geometries = geometries.concat( geometries = geometries.concat(
/** @type {MultiLineString} */ (geometry).getLineStrings() /** @type {MultiLineString} */ (geometry).getLineStrings()
); );
} else if (type === GeometryType.MULTI_POLYGON) { } else if (type === 'MultiPolygon') {
geometries = geometries.concat( geometries = geometries.concat(
/** @type {MultiPolygon} */ (geometry).getPolygons() /** @type {MultiPolygon} */ (geometry).getPolygons()
); );
} else if ( } else if (
type === GeometryType.POINT || type === 'Point' ||
type === GeometryType.LINE_STRING || type === 'LineString' ||
type === GeometryType.POLYGON type === 'Polygon'
) { ) {
geometries.push(geometry); geometries.push(geometry);
} else { } else {
@@ -2896,13 +2879,13 @@ function writeMultiGeometry(node, geometry, objectStack) {
} }
}); });
factory = GEOMETRY_NODE_FACTORY; factory = GEOMETRY_NODE_FACTORY;
} else if (type === GeometryType.MULTI_POINT) { } else if (type === 'MultiPoint') {
geometries = /** @type {MultiPoint} */ (geometry).getPoints(); geometries = /** @type {MultiPoint} */ (geometry).getPoints();
factory = POINT_NODE_FACTORY; factory = POINT_NODE_FACTORY;
} else if (type === GeometryType.MULTI_LINE_STRING) { } else if (type === 'MultiLineString') {
geometries = /** @type {MultiLineString} */ (geometry).getLineStrings(); geometries = /** @type {MultiLineString} */ (geometry).getLineStrings();
factory = LINE_STRING_NODE_FACTORY; factory = LINE_STRING_NODE_FACTORY;
} else if (type === GeometryType.MULTI_POLYGON) { } else if (type === 'MultiPolygon') {
geometries = /** @type {MultiPolygon} */ (geometry).getPolygons(); geometries = /** @type {MultiPolygon} */ (geometry).getPolygons();
factory = POLYGON_NODE_FACTORY; factory = POLYGON_NODE_FACTORY;
} else { } else {
@@ -3036,22 +3019,18 @@ function writePlacemark(node, feature, objectStack) {
const geometry = style.getGeometryFunction()(feature); const geometry = style.getGeometryFunction()(feature);
if (geometry) { if (geometry) {
const type = geometry.getType(); const type = geometry.getType();
if (type === GeometryType.GEOMETRY_COLLECTION) { if (type === 'GeometryCollection') {
return /** @type {GeometryCollection} */ (geometry) return /** @type {GeometryCollection} */ (geometry)
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.filter(function (geometry) { .filter(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
return ( return type === 'Point' || type === 'MultiPoint';
type === GeometryType.POINT ||
type === GeometryType.MULTI_POINT
);
}).length; }).length;
} }
return ( return type === 'Point' || type === 'MultiPoint';
type === GeometryType.POINT || type === GeometryType.MULTI_POINT
);
} }
}); });
('Point');
} }
if (this.writeStyles_) { if (this.writeStyles_) {
let lineStyles = styleArray; let lineStyles = styleArray;
@@ -3061,42 +3040,30 @@ function writePlacemark(node, feature, objectStack) {
const geometry = style.getGeometryFunction()(feature); const geometry = style.getGeometryFunction()(feature);
if (geometry) { if (geometry) {
const type = geometry.getType(); const type = geometry.getType();
if (type === GeometryType.GEOMETRY_COLLECTION) { if (type === 'GeometryCollection') {
return /** @type {GeometryCollection} */ (geometry) return /** @type {GeometryCollection} */ (geometry)
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.filter(function (geometry) { .filter(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
return ( return type === 'LineString' || type === 'MultiLineString';
type === GeometryType.LINE_STRING ||
type === GeometryType.MULTI_LINE_STRING
);
}).length; }).length;
} }
return ( return type === 'LineString' || type === 'MultiLineString';
type === GeometryType.LINE_STRING ||
type === GeometryType.MULTI_LINE_STRING
);
} }
}); });
polyStyles = styleArray.filter(function (style) { polyStyles = styleArray.filter(function (style) {
const geometry = style.getGeometryFunction()(feature); const geometry = style.getGeometryFunction()(feature);
if (geometry) { if (geometry) {
const type = geometry.getType(); const type = geometry.getType();
if (type === GeometryType.GEOMETRY_COLLECTION) { if (type === 'GeometryCollection') {
return /** @type {GeometryCollection} */ (geometry) return /** @type {GeometryCollection} */ (geometry)
.getGeometriesArrayRecursive() .getGeometriesArrayRecursive()
.filter(function (geometry) { .filter(function (geometry) {
const type = geometry.getType(); const type = geometry.getType();
return ( return type === 'Polygon' || type === 'MultiPolygon';
type === GeometryType.POLYGON ||
type === GeometryType.MULTI_POLYGON
);
}).length; }).length;
} }
return ( return type === 'Polygon' || type === 'MultiPolygon';
type === GeometryType.POLYGON ||
type === GeometryType.MULTI_POLYGON
);
} }
}); });
} }

View File

@@ -6,7 +6,6 @@
import FeatureFormat, {transformGeometryWithOptions} from './Feature.js'; import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
import FormatType from './FormatType.js'; import FormatType from './FormatType.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js'; import MultiPoint from '../geom/MultiPoint.js';
@@ -202,7 +201,7 @@ class MVT extends FeatureFormat {
feature.transform(options.dataProjection); feature.transform(options.dataProjection);
} else { } else {
let geom; let geom;
if (geometryType == GeometryType.POLYGON) { if (geometryType == 'Polygon') {
const endss = inflateEnds(flatCoordinates, ends); const endss = inflateEnds(flatCoordinates, ends);
geom = geom =
endss.length > 1 endss.length > 1
@@ -210,15 +209,13 @@ class MVT extends FeatureFormat {
: new Polygon(flatCoordinates, GeometryLayout.XY, ends); : new Polygon(flatCoordinates, GeometryLayout.XY, ends);
} else { } else {
geom = geom =
geometryType === GeometryType.POINT geometryType === 'Point'
? new Point(flatCoordinates, GeometryLayout.XY) ? new Point(flatCoordinates, GeometryLayout.XY)
: geometryType === GeometryType.LINE_STRING : geometryType === 'LineString'
? new LineString(flatCoordinates, GeometryLayout.XY) ? new LineString(flatCoordinates, GeometryLayout.XY)
: geometryType === GeometryType.POLYGON : geometryType === 'MultiPoint'
? new Polygon(flatCoordinates, GeometryLayout.XY, ends)
: geometryType === GeometryType.MULTI_POINT
? new MultiPoint(flatCoordinates, GeometryLayout.XY) ? new MultiPoint(flatCoordinates, GeometryLayout.XY)
: geometryType === GeometryType.MULTI_LINE_STRING : geometryType === 'MultiLineString'
? new MultiLineString(flatCoordinates, GeometryLayout.XY, ends) ? new MultiLineString(flatCoordinates, GeometryLayout.XY, ends)
: null; : null;
} }
@@ -421,19 +418,17 @@ function readRawFeature(pbf, layer, i) {
* @param {number} type The raw feature's geometry type * @param {number} type The raw feature's geometry type
* @param {number} numEnds Number of ends of the flat coordinates of the * @param {number} numEnds Number of ends of the flat coordinates of the
* geometry. * geometry.
* @return {import("../geom/GeometryType.js").default} The geometry type. * @return {import("../geom/Geometry.js").Type} The geometry type.
*/ */
function getGeometryType(type, numEnds) { function getGeometryType(type, numEnds) {
/** @type {import("../geom/GeometryType.js").default} */ /** @type {import("../geom/Geometry.js").Type} */
let geometryType; let geometryType;
if (type === 1) { if (type === 1) {
geometryType = geometryType = numEnds === 1 ? 'Point' : 'MultiPoint';
numEnds === 1 ? GeometryType.POINT : GeometryType.MULTI_POINT;
} else if (type === 2) { } else if (type === 2) {
geometryType = geometryType = numEnds === 1 ? 'LineString' : 'MultiLineString';
numEnds === 1 ? GeometryType.LINE_STRING : GeometryType.MULTI_LINE_STRING;
} else if (type === 3) { } else if (type === 3) {
geometryType = GeometryType.POLYGON; geometryType = 'Polygon';
// MultiPolygon not relevant for rendering - winding order determines // MultiPolygon not relevant for rendering - winding order determines
// outer rings of polygons. // outer rings of polygons.
} }

View File

@@ -6,7 +6,6 @@ import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
import FormatType from './FormatType.js'; import FormatType from './FormatType.js';
import GeometryCollection from '../geom/GeometryCollection.js'; import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js'; import MultiPoint from '../geom/MultiPoint.js';
@@ -579,14 +578,17 @@ class WkbWriter {
* @param {number} [srid] SRID * @param {number} [srid] SRID
*/ */
writeGeometry(geom, srid) { writeGeometry(geom, srid) {
/**
* @type {Object<import("../geom/Geometry.js").Type, WKBGeometryType>}
*/
const wkblut = { const wkblut = {
[GeometryType.POINT]: WKBGeometryType.POINT, Point: WKBGeometryType.POINT,
[GeometryType.LINE_STRING]: WKBGeometryType.LINE_STRING, LineString: WKBGeometryType.LINE_STRING,
[GeometryType.POLYGON]: WKBGeometryType.POLYGON, Polygon: WKBGeometryType.POLYGON,
[GeometryType.MULTI_POINT]: WKBGeometryType.MULTI_POINT, MultiPoint: WKBGeometryType.MULTI_POINT,
[GeometryType.MULTI_LINE_STRING]: WKBGeometryType.MULTI_LINE_STRING, MultiLineString: WKBGeometryType.MULTI_LINE_STRING,
[GeometryType.MULTI_POLYGON]: WKBGeometryType.MULTI_POLYGON, MultiPolygon: WKBGeometryType.MULTI_POLYGON,
[GeometryType.GEOMETRY_COLLECTION]: WKBGeometryType.GEOMETRY_COLLECTION, GeometryCollection: WKBGeometryType.GEOMETRY_COLLECTION,
}; };
const geomType = geom.getType(); const geomType = geom.getType();
const typeId = wkblut[geomType]; const typeId = wkblut[geomType];
@@ -604,12 +606,12 @@ class WkbWriter {
if (geom instanceof SimpleGeometry) { if (geom instanceof SimpleGeometry) {
const writerLUT = { const writerLUT = {
[GeometryType.POINT]: this.writePoint, Point: this.writePoint,
[GeometryType.LINE_STRING]: this.writeLineString, LineString: this.writeLineString,
[GeometryType.POLYGON]: this.writePolygon, Polygon: this.writePolygon,
[GeometryType.MULTI_POINT]: this.writeMultiPoint, MultiPoint: this.writeMultiPoint,
[GeometryType.MULTI_LINE_STRING]: this.writeMultiLineString, MultiLineString: this.writeMultiLineString,
[GeometryType.MULTI_POLYGON]: this.writeMultiPolygon, MultiPolygon: this.writeMultiPolygon,
}; };
writerLUT[geomType].call(this, geom.getCoordinates(), geom.getLayout()); writerLUT[geomType].call(this, geom.getCoordinates(), geom.getLayout());
} else if (geom instanceof GeometryCollection) { } else if (geom instanceof GeometryCollection) {

View File

@@ -4,7 +4,6 @@
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js'; import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js'; import MultiPoint from '../geom/MultiPoint.js';
@@ -79,13 +78,18 @@ const TokenType = {
}; };
/** /**
* @const * @type {Object<import("../geom/Geometry.js").Type, string>}
* @type {Object<string, string>}
*/ */
const WKTGeometryType = {}; const wktTypeLookup = {
for (const type in GeometryType) { Point: 'POINT',
WKTGeometryType[type] = GeometryType[type].toUpperCase(); LineString: 'LINESTRING',
} Polygon: 'POLYGON',
MultiPoint: 'MULTIPOINT',
MultiLineString: 'MULTILINESTRING',
MultiPolygon: 'MULTIPOLYGON',
GeometryCollection: 'GEOMETRYCOLLECTION',
Circle: 'CIRCLE',
};
/** /**
* Class to tokenize a WKT string. * Class to tokenize a WKT string.
@@ -648,10 +652,7 @@ class WKT extends TextFeature {
readFeaturesFromText(text, opt_options) { readFeaturesFromText(text, opt_options) {
let geometries = []; let geometries = [];
const geometry = this.readGeometryFromText(text, opt_options); const geometry = this.readGeometryFromText(text, opt_options);
if ( if (this.splitCollection_ && geometry.getType() == 'GeometryCollection') {
this.splitCollection_ &&
geometry.getType() == GeometryType.GEOMETRY_COLLECTION
) {
geometries = /** @type {GeometryCollection} */ ( geometries = /** @type {GeometryCollection} */ (
geometry geometry
).getGeometriesArray(); ).getGeometriesArray();
@@ -847,22 +848,22 @@ const GeometryEncoder = {
* @return {string} WKT string for the geometry. * @return {string} WKT string for the geometry.
*/ */
function encode(geom) { function encode(geom) {
let type = geom.getType(); const type = geom.getType();
const geometryEncoder = GeometryEncoder[type]; const geometryEncoder = GeometryEncoder[type];
const enc = geometryEncoder(geom); const enc = geometryEncoder(geom);
type = type.toUpperCase(); let wktType = wktTypeLookup[type];
if (typeof (/** @type {?} */ (geom).getFlatCoordinates) === 'function') { if (typeof (/** @type {?} */ (geom).getFlatCoordinates) === 'function') {
const dimInfo = encodeGeometryLayout( const dimInfo = encodeGeometryLayout(
/** @type {import("../geom/SimpleGeometry.js").default} */ (geom) /** @type {import("../geom/SimpleGeometry.js").default} */ (geom)
); );
if (dimInfo.length > 0) { if (dimInfo.length > 0) {
type += ' ' + dimInfo; wktType += ' ' + dimInfo;
} }
} }
if (enc.length === 0) { if (enc.length === 0) {
return type + ' ' + EMPTY; return wktType + ' ' + EMPTY;
} }
return type + '(' + enc + ')'; return wktType + '(' + enc + ')';
} }
export default WKT; export default WKT;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Circle * @module ol/geom/Circle
*/ */
import GeometryType from './GeometryType.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
import {createOrUpdate, forEachCorner, intersects} from '../extent.js'; import {createOrUpdate, forEachCorner, intersects} from '../extent.js';
import {deflateCoordinate} from './flat/deflate.js'; import {deflateCoordinate} from './flat/deflate.js';
@@ -137,11 +136,11 @@ class Circle extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.CIRCLE; return 'Circle';
} }
/** /**

View File

@@ -18,6 +18,13 @@ import {get as getProjection, getTransform} from '../proj.js';
import {memoizeOne} from '../functions.js'; import {memoizeOne} from '../functions.js';
import {transform2D} from './flat/transform.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} * @type {import("../transform.js").Transform}
*/ */
@@ -237,7 +244,7 @@ class Geometry extends BaseObject {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @abstract * @abstract
* @return {import("./GeometryType.js").default} Geometry type. * @return {Type} Geometry type.
*/ */
getType() { getType() {
return abstract(); return abstract();

View File

@@ -3,7 +3,6 @@
*/ */
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import Geometry from './Geometry.js'; import Geometry from './Geometry.js';
import GeometryType from './GeometryType.js';
import { import {
closestSquaredDistanceXY, closestSquaredDistanceXY,
createOrUpdateEmpty, createOrUpdateEmpty,
@@ -204,11 +203,11 @@ class GeometryCollection extends Geometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.GEOMETRY_COLLECTION; return 'GeometryCollection';
} }
/** /**

View File

@@ -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',
};

View File

@@ -2,7 +2,6 @@
* @module ol/geom/LineString * @module ol/geom/LineString
*/ */
import GeometryLayout from './GeometryLayout.js'; import GeometryLayout from './GeometryLayout.js';
import GeometryType from './GeometryType.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js'; import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
import {closestSquaredDistanceXY} from '../extent.js'; import {closestSquaredDistanceXY} from '../extent.js';
@@ -269,11 +268,11 @@ class LineString extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.LINE_STRING; return 'LineString';
} }
/** /**

View File

@@ -2,7 +2,6 @@
* @module ol/geom/LinearRing * @module ol/geom/LinearRing
*/ */
import GeometryLayout from './GeometryLayout.js'; import GeometryLayout from './GeometryLayout.js';
import GeometryType from './GeometryType.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js'; import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
import {closestSquaredDistanceXY} from '../extent.js'; import {closestSquaredDistanceXY} from '../extent.js';
@@ -149,11 +148,11 @@ class LinearRing extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.LINEAR_RING; return 'LinearRing';
} }
/** /**

View File

@@ -2,7 +2,6 @@
* @module ol/geom/MultiLineString * @module ol/geom/MultiLineString
*/ */
import GeometryLayout from './GeometryLayout.js'; import GeometryLayout from './GeometryLayout.js';
import GeometryType from './GeometryType.js';
import LineString from './LineString.js'; import LineString from './LineString.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
import {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js'; import {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';
@@ -308,11 +307,11 @@ class MultiLineString extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.MULTI_LINE_STRING; return 'MultiLineString';
} }
/** /**

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/MultiPoint * @module ol/geom/MultiPoint
*/ */
import GeometryType from './GeometryType.js';
import Point from './Point.js'; import Point from './Point.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
import {closestSquaredDistanceXY, containsXY} from '../extent.js'; import {closestSquaredDistanceXY, containsXY} from '../extent.js';
@@ -154,11 +153,11 @@ class MultiPoint extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.MULTI_POINT; return 'MultiPoint';
} }
/** /**

View File

@@ -2,7 +2,6 @@
* @module ol/geom/MultiPolygon * @module ol/geom/MultiPolygon
*/ */
import GeometryLayout from './GeometryLayout.js'; import GeometryLayout from './GeometryLayout.js';
import GeometryType from './GeometryType.js';
import MultiPoint from './MultiPoint.js'; import MultiPoint from './MultiPoint.js';
import Polygon from './Polygon.js'; import Polygon from './Polygon.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
@@ -425,11 +424,11 @@ class MultiPolygon extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.MULTI_POLYGON; return 'MultiPolygon';
} }
/** /**

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Point * @module ol/geom/Point
*/ */
import GeometryType from './GeometryType.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
import {containsXY, createOrUpdateFromCoordinate} from '../extent.js'; import {containsXY, createOrUpdateFromCoordinate} from '../extent.js';
import {deflateCoordinate} from './flat/deflate.js'; import {deflateCoordinate} from './flat/deflate.js';
@@ -81,11 +80,11 @@ class Point extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.POINT; return 'Point';
} }
/** /**

View File

@@ -2,7 +2,6 @@
* @module ol/geom/Polygon * @module ol/geom/Polygon
*/ */
import GeometryLayout from './GeometryLayout.js'; import GeometryLayout from './GeometryLayout.js';
import GeometryType from './GeometryType.js';
import LinearRing from './LinearRing.js'; import LinearRing from './LinearRing.js';
import Point from './Point.js'; import Point from './Point.js';
import SimpleGeometry from './SimpleGeometry.js'; import SimpleGeometry from './SimpleGeometry.js';
@@ -363,11 +362,11 @@ class Polygon extends SimpleGeometry {
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @return {import("./GeometryType.js").default} Geometry type. * @return {import("./Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return GeometryType.POLYGON; return 'Polygon';
} }
/** /**

View File

@@ -6,7 +6,6 @@ import Event from '../events/Event.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import InteractionProperty from './Property.js'; import InteractionProperty from './Property.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import MapBrowserEvent from '../MapBrowserEvent.js'; import MapBrowserEvent from '../MapBrowserEvent.js';
@@ -35,7 +34,7 @@ import {squaredDistance as squaredCoordinateDistance} from '../coordinate.js';
/** /**
* @typedef {Object} Options * @typedef {Object} Options
* @property {import("../geom/GeometryType.js").default} type Geometry type of * @property {import("../geom/Geometry.js").Type} type Geometry type of
* the geometries being drawn with this instance. * the geometries being drawn with this instance.
* @property {number} [clickTolerance=6] The maximum distance in pixels between * @property {number} [clickTolerance=6] The maximum distance in pixels between
* "down" and "up" for a "up" event to be considered a "click" event and * "down" and "up" for a "up" event to be considered a "click" event and
@@ -282,10 +281,10 @@ class Draw extends PointerInteraction {
/** /**
* Geometry type. * Geometry type.
* @type {import("../geom/GeometryType.js").default} * @type {import("../geom/Geometry.js").Type}
* @private * @private
*/ */
this.type_ = /** @type {import("../geom/GeometryType.js").default} */ ( this.type_ = /** @type {import("../geom/Geometry.js").Type} */ (
options.type options.type
); );
@@ -890,10 +889,7 @@ class Draw extends PointerInteraction {
const sketchPointGeom = this.sketchPoint_.getGeometry(); const sketchPointGeom = this.sketchPoint_.getGeometry();
sketchPointGeom.setCoordinates(coordinate); sketchPointGeom.setCoordinates(coordinate);
} }
if ( if (geometry.getType() === 'Polygon' && this.mode_ !== Mode.POLYGON) {
geometry.getType() === GeometryType.POLYGON &&
this.mode_ !== Mode.POLYGON
) {
this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry)); this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry));
} else if (this.sketchLineCoords_) { } else if (this.sketchLineCoords_) {
const sketchLineGeom = this.sketchLine_.getGeometry(); const sketchLineGeom = this.sketchLine_.getGeometry();
@@ -970,7 +966,7 @@ class Draw extends PointerInteraction {
this.createOrUpdateSketchPoint_(finishCoordinate); this.createOrUpdateSketchPoint_(finishCoordinate);
} }
this.geometryFunction_(coordinates, geometry, projection); this.geometryFunction_(coordinates, geometry, projection);
if (geometry.getType() === GeometryType.POLYGON && this.sketchLine_) { if (geometry.getType() === 'Polygon' && this.sketchLine_) {
this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry)); this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry));
} }
} else if (mode === Mode.POLYGON) { } else if (mode === Mode.POLYGON) {
@@ -1019,15 +1015,15 @@ class Draw extends PointerInteraction {
} }
// cast multi-part geometries // cast multi-part geometries
if (this.type_ === GeometryType.MULTI_POINT) { if (this.type_ === 'MultiPoint') {
sketchFeature.setGeometry( sketchFeature.setGeometry(
new MultiPoint([/** @type {PointCoordType} */ (coordinates)]) new MultiPoint([/** @type {PointCoordType} */ (coordinates)])
); );
} else if (this.type_ === GeometryType.MULTI_LINE_STRING) { } else if (this.type_ === 'MultiLineString') {
sketchFeature.setGeometry( sketchFeature.setGeometry(
new MultiLineString([/** @type {LineCoordType} */ (coordinates)]) new MultiLineString([/** @type {LineCoordType} */ (coordinates)])
); );
} else if (this.type_ === GeometryType.MULTI_POLYGON) { } else if (this.type_ === 'MultiPolygon') {
sketchFeature.setGeometry( sketchFeature.setGeometry(
new MultiPolygon([/** @type {PolyCoordType} */ (coordinates)]) new MultiPolygon([/** @type {PolyCoordType} */ (coordinates)])
); );
@@ -1274,21 +1270,21 @@ export function createBox() {
/** /**
* Get the drawing mode. The mode for multi-part geometries is the same as for * Get the drawing mode. The mode for multi-part geometries is the same as for
* their single-part cousins. * their single-part cousins.
* @param {import("../geom/GeometryType.js").default} type Geometry type. * @param {import("../geom/Geometry.js").Type} type Geometry type.
* @return {Mode} Drawing mode. * @return {Mode} Drawing mode.
*/ */
function getMode(type) { function getMode(type) {
switch (type) { switch (type) {
case GeometryType.POINT: case 'Point':
case GeometryType.MULTI_POINT: case 'MultiPoint':
return Mode.POINT; return Mode.POINT;
case GeometryType.LINE_STRING: case 'LineString':
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
return Mode.LINE_STRING; return Mode.LINE_STRING;
case GeometryType.POLYGON: case 'Polygon':
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
return Mode.POLYGON; return Mode.POLYGON;
case GeometryType.CIRCLE: case 'Circle':
return Mode.CIRCLE; return Mode.CIRCLE;
default: default:
throw new Error('Invalid type: ' + type); throw new Error('Invalid type: ' + type);

View File

@@ -3,7 +3,6 @@
*/ */
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryType from '../geom/GeometryType.js';
import MapBrowserEventType from '../MapBrowserEventType.js'; import MapBrowserEventType from '../MapBrowserEventType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import PointerInteraction from './Pointer.js'; import PointerInteraction from './Pointer.js';
@@ -478,7 +477,7 @@ class Extent extends PointerInteraction {
function getDefaultExtentStyleFunction() { function getDefaultExtentStyleFunction() {
const style = createEditingStyle(); const style = createEditingStyle();
return function (feature, resolution) { return function (feature, resolution) {
return style[GeometryType.POLYGON]; return style['Polygon'];
}; };
} }
@@ -490,7 +489,7 @@ function getDefaultExtentStyleFunction() {
function getDefaultPointerStyleFunction() { function getDefaultPointerStyleFunction() {
const style = createEditingStyle(); const style = createEditingStyle();
return function (feature, resolution) { return function (feature, resolution) {
return style[GeometryType.POINT]; return style['Point'];
}; };
} }

View File

@@ -6,7 +6,6 @@ import CollectionEventType from '../CollectionEventType.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryType from '../geom/GeometryType.js';
import MapBrowserEventType from '../MapBrowserEventType.js'; import MapBrowserEventType from '../MapBrowserEventType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import PointerInteraction from './Pointer.js'; import PointerInteraction from './Pointer.js';
@@ -905,38 +904,38 @@ class Modify extends PointerInteraction {
} }
switch (geometry.getType()) { switch (geometry.getType()) {
case GeometryType.POINT: case 'Point':
coordinates = vertex; coordinates = vertex;
segment[0] = vertex; segment[0] = vertex;
segment[1] = vertex; segment[1] = vertex;
break; break;
case GeometryType.MULTI_POINT: case 'MultiPoint':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[segmentData.index] = vertex; coordinates[segmentData.index] = vertex;
segment[0] = vertex; segment[0] = vertex;
segment[1] = vertex; segment[1] = vertex;
break; break;
case GeometryType.LINE_STRING: case 'LineString':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[segmentData.index + index] = vertex; coordinates[segmentData.index + index] = vertex;
segment[index] = vertex; segment[index] = vertex;
break; break;
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[depth[0]][segmentData.index + index] = vertex; coordinates[depth[0]][segmentData.index + index] = vertex;
segment[index] = vertex; segment[index] = vertex;
break; break;
case GeometryType.POLYGON: case 'Polygon':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[depth[0]][segmentData.index + index] = vertex; coordinates[depth[0]][segmentData.index + index] = vertex;
segment[index] = vertex; segment[index] = vertex;
break; break;
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[depth[1]][depth[0]][segmentData.index + index] = vertex; coordinates[depth[1]][depth[0]][segmentData.index + index] = vertex;
segment[index] = vertex; segment[index] = vertex;
break; break;
case GeometryType.CIRCLE: case 'Circle':
segment[0] = vertex; segment[0] = vertex;
segment[1] = vertex; segment[1] = vertex;
if (segmentData.index === CIRCLE_CENTER_INDEX) { if (segmentData.index === CIRCLE_CENTER_INDEX) {
@@ -1011,7 +1010,7 @@ class Modify extends PointerInteraction {
} }
if ( if (
segmentDataMatch.geometry.getType() === GeometryType.CIRCLE && segmentDataMatch.geometry.getType() === 'Circle' &&
segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX
) { ) {
const closestVertex = closestOnSegmentData( const closestVertex = closestOnSegmentData(
@@ -1049,15 +1048,15 @@ class Modify extends PointerInteraction {
let coordinates = segmentDataMatch.geometry.getCoordinates(); let coordinates = segmentDataMatch.geometry.getCoordinates();
switch (segmentDataMatch.geometry.getType()) { switch (segmentDataMatch.geometry.getType()) {
// prevent dragging closed linestrings by the connecting node // prevent dragging closed linestrings by the connecting node
case GeometryType.LINE_STRING: case 'LineString':
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
continue; continue;
// if dragging the first vertex of a polygon, ensure the other segment // if dragging the first vertex of a polygon, ensure the other segment
// belongs to the closing vertex of the linear ring // belongs to the closing vertex of the linear ring
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
coordinates = coordinates[depth[1]]; coordinates = coordinates[depth[1]];
/* falls through */ /* falls through */
case GeometryType.POLYGON: case 'Polygon':
if ( if (
segmentDataMatch.index !== segmentDataMatch.index !==
coordinates[depth[0]].length - 2 coordinates[depth[0]].length - 2
@@ -1105,7 +1104,7 @@ class Modify extends PointerInteraction {
for (let i = this.dragSegments_.length - 1; i >= 0; --i) { for (let i = this.dragSegments_.length - 1; i >= 0; --i) {
const segmentData = this.dragSegments_[i][0]; const segmentData = this.dragSegments_[i][0];
const geometry = segmentData.geometry; const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE) { if (geometry.getType() === 'Circle') {
// Update a circle object in the R* bush: // Update a circle object in the R* bush:
const coordinates = geometry.getCenter(); const coordinates = geometry.getCenter();
const centerSegmentData = segmentData.featureSegments[0]; const centerSegmentData = segmentData.featureSegments[0];
@@ -1190,7 +1189,7 @@ class Modify extends PointerInteraction {
feature.getGeometry() feature.getGeometry()
); );
if ( if (
geometry.getType() === GeometryType.POINT && geometry.getType() === 'Point' &&
includes(this.features_.getArray(), feature) includes(this.features_.getArray(), feature)
) { ) {
hitPointGeometry = geometry; hitPointGeometry = geometry;
@@ -1237,7 +1236,7 @@ class Modify extends PointerInteraction {
this.delta_[1] = vertex[1] - pixelCoordinate[1]; this.delta_[1] = vertex[1] - pixelCoordinate[1];
} }
if ( if (
node.geometry.getType() === GeometryType.CIRCLE && node.geometry.getType() === 'Circle' &&
node.index === CIRCLE_CIRCUMFERENCE_INDEX node.index === CIRCLE_CIRCUMFERENCE_INDEX
) { ) {
this.snappedToVertex_ = true; this.snappedToVertex_ = true;
@@ -1313,19 +1312,19 @@ class Modify extends PointerInteraction {
} }
switch (geometry.getType()) { switch (geometry.getType()) {
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[depth[0]].splice(index + 1, 0, vertex); coordinates[depth[0]].splice(index + 1, 0, vertex);
break; break;
case GeometryType.POLYGON: case 'Polygon':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[depth[0]].splice(index + 1, 0, vertex); coordinates[depth[0]].splice(index + 1, 0, vertex);
break; break;
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex); coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex);
break; break;
case GeometryType.LINE_STRING: case 'LineString':
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates.splice(index + 1, 0, vertex); coordinates.splice(index + 1, 0, vertex);
break; break;
@@ -1441,22 +1440,22 @@ class Modify extends PointerInteraction {
component = coordinates; component = coordinates;
deleted = false; deleted = false;
switch (geometry.getType()) { switch (geometry.getType()) {
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
if (coordinates[segmentData.depth[0]].length > 2) { if (coordinates[segmentData.depth[0]].length > 2) {
coordinates[segmentData.depth[0]].splice(index, 1); coordinates[segmentData.depth[0]].splice(index, 1);
deleted = true; deleted = true;
} }
break; break;
case GeometryType.LINE_STRING: case 'LineString':
if (coordinates.length > 2) { if (coordinates.length > 2) {
coordinates.splice(index, 1); coordinates.splice(index, 1);
deleted = true; deleted = true;
} }
break; break;
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
component = component[segmentData.depth[1]]; component = component[segmentData.depth[1]];
/* falls through */ /* falls through */
case GeometryType.POLYGON: case 'Polygon':
component = component[segmentData.depth[0]]; component = component[segmentData.depth[0]];
if (component.length > 4) { if (component.length > 4) {
if (index == component.length - 1) { if (index == component.length - 1) {
@@ -1575,7 +1574,7 @@ function projectedDistanceToSegmentDataSquared(
) { ) {
const geometry = segmentData.geometry; const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE) { if (geometry.getType() === 'Circle') {
let circleGeometry = /** @type {import("../geom/Circle.js").default} */ ( let circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
geometry geometry
); );
@@ -1617,7 +1616,7 @@ function closestOnSegmentData(pointCoordinates, segmentData, projection) {
const geometry = segmentData.geometry; const geometry = segmentData.geometry;
if ( if (
geometry.getType() === GeometryType.CIRCLE && geometry.getType() === 'Circle' &&
segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX
) { ) {
let circleGeometry = /** @type {import("../geom/Circle.js").default} */ ( let circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
@@ -1651,7 +1650,7 @@ function closestOnSegmentData(pointCoordinates, segmentData, projection) {
function getDefaultStyleFunction() { function getDefaultStyleFunction() {
const style = createEditingStyle(); const style = createEditingStyle();
return function (feature, resolution) { return function (feature, resolution) {
return style[GeometryType.POINT]; return style['Point'];
}; };
} }

View File

@@ -4,7 +4,6 @@
import Collection from '../Collection.js'; import Collection from '../Collection.js';
import CollectionEventType from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import GeometryType from '../geom/GeometryType.js';
import Interaction from './Interaction.js'; import Interaction from './Interaction.js';
import VectorLayer from '../layer/Vector.js'; import VectorLayer from '../layer/Vector.js';
import {TRUE} from '../functions.js'; import {TRUE} from '../functions.js';
@@ -569,11 +568,8 @@ class Select extends Interaction {
*/ */
function getDefaultStyleFunction() { function getDefaultStyleFunction() {
const styles = createEditingStyle(); const styles = createEditingStyle();
extend(styles[GeometryType.POLYGON], styles[GeometryType.LINE_STRING]); extend(styles['Polygon'], styles['LineString']);
extend( extend(styles['GeometryCollection'], styles['LineString']);
styles[GeometryType.GEOMETRY_COLLECTION],
styles[GeometryType.LINE_STRING]
);
return function (feature) { return function (feature) {
if (!feature.getGeometry()) { if (!feature.getGeometry()) {

View File

@@ -3,7 +3,6 @@
*/ */
import CollectionEventType from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import GeometryType from '../geom/GeometryType.js';
import PointerInteraction from './Pointer.js'; import PointerInteraction from './Pointer.js';
import RBush from '../structs/RBush.js'; import RBush from '../structs/RBush.js';
import VectorEventType from '../source/VectorEventType.js'; import VectorEventType from '../source/VectorEventType.js';

View File

@@ -3,7 +3,6 @@
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js';
import { import {
LineString, LineString,
MultiLineString, MultiLineString,
@@ -45,7 +44,7 @@ const tmpTransform = createTransform();
*/ */
class RenderFeature { class RenderFeature {
/** /**
* @param {import("../geom/GeometryType.js").default} type Geometry type. * @param {import("../geom/Geometry.js").Type} type Geometry type.
* @param {Array<number>} flatCoordinates Flat coordinates. These always need * @param {Array<number>} flatCoordinates Flat coordinates. These always need
* to be right-handed for polygons. * to be right-handed for polygons.
* @param {Array<number>|Array<Array<number>>} ends Ends or Endss. * @param {Array<number>|Array<Array<number>>} ends Ends or Endss.
@@ -72,7 +71,7 @@ class RenderFeature {
/** /**
* @private * @private
* @type {import("../geom/GeometryType.js").default} * @type {import("../geom/Geometry.js").Type}
*/ */
this.type_ = type; this.type_ = type;
@@ -125,7 +124,7 @@ class RenderFeature {
getExtent() { getExtent() {
if (!this.extent_) { if (!this.extent_) {
this.extent_ = this.extent_ =
this.type_ === GeometryType.POINT this.type_ === 'Point'
? createOrUpdateFromCoordinate(this.flatCoordinates_) ? createOrUpdateFromCoordinate(this.flatCoordinates_)
: createOrUpdateFromFlatCoordinates( : createOrUpdateFromFlatCoordinates(
this.flatCoordinates_, this.flatCoordinates_,
@@ -283,7 +282,7 @@ class RenderFeature {
/** /**
* Get the type of this feature's geometry. * Get the type of this feature's geometry.
* @return {import("../geom/GeometryType.js").default} Geometry type. * @return {import("../geom/Geometry.js").Type} Geometry type.
* @api * @api
*/ */
getType() { getType() {

View File

@@ -2,7 +2,6 @@
* @module ol/render/canvas/Builder * @module ol/render/canvas/Builder
*/ */
import CanvasInstruction from './Instruction.js'; import CanvasInstruction from './Instruction.js';
import GeometryType from '../../geom/GeometryType.js';
import Relationship from '../../extent/Relationship.js'; import Relationship from '../../extent/Relationship.js';
import VectorContext from '../VectorContext.js'; import VectorContext from '../VectorContext.js';
import {asColorLike} from '../../colorlike.js'; import {asColorLike} from '../../colorlike.js';
@@ -260,7 +259,7 @@ class CanvasBuilder extends VectorContext {
let offset; let offset;
switch (type) { switch (type) {
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
flatCoordinates = flatCoordinates =
/** @type {import("../../geom/MultiPolygon.js").default} */ ( /** @type {import("../../geom/MultiPolygon.js").default} */ (
geometry geometry
@@ -299,11 +298,11 @@ class CanvasBuilder extends VectorContext {
inflateMultiCoordinatesArray, inflateMultiCoordinatesArray,
]); ]);
break; break;
case GeometryType.POLYGON: case 'Polygon':
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
builderEnds = []; builderEnds = [];
flatCoordinates = flatCoordinates =
type == GeometryType.POLYGON type == 'Polygon'
? /** @type {import("../../geom/Polygon.js").default} */ ( ? /** @type {import("../../geom/Polygon.js").default} */ (
geometry geometry
).getOrientedFlatCoordinates() ).getOrientedFlatCoordinates()
@@ -334,8 +333,8 @@ class CanvasBuilder extends VectorContext {
inflateCoordinatesArray, inflateCoordinatesArray,
]); ]);
break; break;
case GeometryType.LINE_STRING: case 'LineString':
case GeometryType.CIRCLE: case 'Circle':
flatCoordinates = geometry.getFlatCoordinates(); flatCoordinates = geometry.getFlatCoordinates();
builderEnd = this.appendFlatLineCoordinates( builderEnd = this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
@@ -362,7 +361,7 @@ class CanvasBuilder extends VectorContext {
inflateCoordinates, inflateCoordinates,
]); ]);
break; break;
case GeometryType.MULTI_POINT: case 'MultiPoint':
flatCoordinates = geometry.getFlatCoordinates(); flatCoordinates = geometry.getFlatCoordinates();
builderEnd = this.appendFlatPointCoordinates(flatCoordinates, stride); builderEnd = this.appendFlatPointCoordinates(flatCoordinates, stride);
@@ -385,7 +384,7 @@ class CanvasBuilder extends VectorContext {
]); ]);
} }
break; break;
case GeometryType.POINT: case 'Point':
flatCoordinates = geometry.getFlatCoordinates(); flatCoordinates = geometry.getFlatCoordinates();
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]); this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
builderEnd = this.coordinates.length; builderEnd = this.coordinates.length;

View File

@@ -5,7 +5,6 @@
// FIXME need to handle large thick features (where pixel size matters) // FIXME need to handle large thick features (where pixel size matters)
// FIXME add offset and end to ol/geom/flat/transform~transform2D? // FIXME add offset and end to ol/geom/flat/transform~transform2D?
import GeometryType from '../../geom/GeometryType.js';
import VectorContext from '../VectorContext.js'; import VectorContext from '../VectorContext.js';
import {asColorLike} from '../../colorlike.js'; import {asColorLike} from '../../colorlike.js';
import { import {
@@ -549,46 +548,46 @@ class CanvasImmediateRenderer extends VectorContext {
drawGeometry(geometry) { drawGeometry(geometry) {
const type = geometry.getType(); const type = geometry.getType();
switch (type) { switch (type) {
case GeometryType.POINT: case 'Point':
this.drawPoint( this.drawPoint(
/** @type {import("../../geom/Point.js").default} */ (geometry) /** @type {import("../../geom/Point.js").default} */ (geometry)
); );
break; break;
case GeometryType.LINE_STRING: case 'LineString':
this.drawLineString( this.drawLineString(
/** @type {import("../../geom/LineString.js").default} */ (geometry) /** @type {import("../../geom/LineString.js").default} */ (geometry)
); );
break; break;
case GeometryType.POLYGON: case 'Polygon':
this.drawPolygon( this.drawPolygon(
/** @type {import("../../geom/Polygon.js").default} */ (geometry) /** @type {import("../../geom/Polygon.js").default} */ (geometry)
); );
break; break;
case GeometryType.MULTI_POINT: case 'MultiPoint':
this.drawMultiPoint( this.drawMultiPoint(
/** @type {import("../../geom/MultiPoint.js").default} */ (geometry) /** @type {import("../../geom/MultiPoint.js").default} */ (geometry)
); );
break; break;
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
this.drawMultiLineString( this.drawMultiLineString(
/** @type {import("../../geom/MultiLineString.js").default} */ ( /** @type {import("../../geom/MultiLineString.js").default} */ (
geometry geometry
) )
); );
break; break;
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
this.drawMultiPolygon( this.drawMultiPolygon(
/** @type {import("../../geom/MultiPolygon.js").default} */ (geometry) /** @type {import("../../geom/MultiPolygon.js").default} */ (geometry)
); );
break; break;
case GeometryType.GEOMETRY_COLLECTION: case 'GeometryCollection':
this.drawGeometryCollection( this.drawGeometryCollection(
/** @type {import("../../geom/GeometryCollection.js").default} */ ( /** @type {import("../../geom/GeometryCollection.js").default} */ (
geometry geometry
) )
); );
break; break;
case GeometryType.CIRCLE: case 'Circle':
this.drawCircle( this.drawCircle(
/** @type {import("../../geom/Circle.js").default} */ (geometry) /** @type {import("../../geom/Circle.js").default} */ (geometry)
); );

View File

@@ -3,7 +3,6 @@
*/ */
import CanvasBuilder from './Builder.js'; import CanvasBuilder from './Builder.js';
import CanvasInstruction from './Instruction.js'; import CanvasInstruction from './Instruction.js';
import GeometryType from '../../geom/GeometryType.js';
import TextPlacement from '../../style/TextPlacement.js'; import TextPlacement from '../../style/TextPlacement.js';
import {asColorLike} from '../../colorlike.js'; import {asColorLike} from '../../colorlike.js';
import { import {
@@ -179,27 +178,27 @@ class CanvasTextBuilder extends CanvasBuilder {
if ( if (
textState.placement === TextPlacement.LINE && textState.placement === TextPlacement.LINE &&
(geometryType == GeometryType.LINE_STRING || (geometryType == 'LineString' ||
geometryType == GeometryType.MULTI_LINE_STRING || geometryType == 'MultiLineString' ||
geometryType == GeometryType.POLYGON || geometryType == 'Polygon' ||
geometryType == GeometryType.MULTI_POLYGON) geometryType == 'MultiPolygon')
) { ) {
if (!intersects(this.getBufferedMaxExtent(), geometry.getExtent())) { if (!intersects(this.getBufferedMaxExtent(), geometry.getExtent())) {
return; return;
} }
let ends; let ends;
flatCoordinates = geometry.getFlatCoordinates(); flatCoordinates = geometry.getFlatCoordinates();
if (geometryType == GeometryType.LINE_STRING) { if (geometryType == 'LineString') {
ends = [flatCoordinates.length]; ends = [flatCoordinates.length];
} else if (geometryType == GeometryType.MULTI_LINE_STRING) { } else if (geometryType == 'MultiLineString') {
ends = /** @type {import("../../geom/MultiLineString.js").default} */ ( ends = /** @type {import("../../geom/MultiLineString.js").default} */ (
geometry geometry
).getEnds(); ).getEnds();
} else if (geometryType == GeometryType.POLYGON) { } else if (geometryType == 'Polygon') {
ends = /** @type {import("../../geom/Polygon.js").default} */ (geometry) ends = /** @type {import("../../geom/Polygon.js").default} */ (geometry)
.getEnds() .getEnds()
.slice(0, 1); .slice(0, 1);
} else if (geometryType == GeometryType.MULTI_POLYGON) { } else if (geometryType == 'MultiPolygon') {
const endss = const endss =
/** @type {import("../../geom/MultiPolygon.js").default} */ ( /** @type {import("../../geom/MultiPolygon.js").default} */ (
geometry geometry
@@ -240,33 +239,33 @@ class CanvasTextBuilder extends CanvasBuilder {
} else { } else {
let geometryWidths = textState.overflow ? null : []; let geometryWidths = textState.overflow ? null : [];
switch (geometryType) { switch (geometryType) {
case GeometryType.POINT: case 'Point':
case GeometryType.MULTI_POINT: case 'MultiPoint':
flatCoordinates = flatCoordinates =
/** @type {import("../../geom/MultiPoint.js").default} */ ( /** @type {import("../../geom/MultiPoint.js").default} */ (
geometry geometry
).getFlatCoordinates(); ).getFlatCoordinates();
break; break;
case GeometryType.LINE_STRING: case 'LineString':
flatCoordinates = flatCoordinates =
/** @type {import("../../geom/LineString.js").default} */ ( /** @type {import("../../geom/LineString.js").default} */ (
geometry geometry
).getFlatMidpoint(); ).getFlatMidpoint();
break; break;
case GeometryType.CIRCLE: case 'Circle':
flatCoordinates = flatCoordinates =
/** @type {import("../../geom/Circle.js").default} */ ( /** @type {import("../../geom/Circle.js").default} */ (
geometry geometry
).getCenter(); ).getCenter();
break; break;
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
flatCoordinates = flatCoordinates =
/** @type {import("../../geom/MultiLineString.js").default} */ ( /** @type {import("../../geom/MultiLineString.js").default} */ (
geometry geometry
).getFlatMidpoints(); ).getFlatMidpoints();
stride = 2; stride = 2;
break; break;
case GeometryType.POLYGON: case 'Polygon':
flatCoordinates = flatCoordinates =
/** @type {import("../../geom/Polygon.js").default} */ ( /** @type {import("../../geom/Polygon.js").default} */ (
geometry geometry
@@ -276,7 +275,7 @@ class CanvasTextBuilder extends CanvasBuilder {
} }
stride = 3; stride = 3;
break; break;
case GeometryType.MULTI_POLYGON: case 'MultiPolygon':
const interiorPoints = const interiorPoints =
/** @type {import("../../geom/MultiPolygon.js").default} */ ( /** @type {import("../../geom/MultiPolygon.js").default} */ (
geometry geometry

View File

@@ -3,7 +3,6 @@
*/ */
import CanvasImmediateRenderer from './Immediate.js'; import CanvasImmediateRenderer from './Immediate.js';
import GeometryType from '../../geom/GeometryType.js';
import IconAnchorUnits from '../../style/IconAnchorUnits.js'; import IconAnchorUnits from '../../style/IconAnchorUnits.js';
import {Icon} from '../../style.js'; import {Icon} from '../../style.js';
import {clamp} from '../../math.js'; import {clamp} from '../../math.js';
@@ -121,10 +120,10 @@ export function createHitDetectionImageData(
if (!byGeometryType) { if (!byGeometryType) {
byGeometryType = {}; byGeometryType = {};
featuresByZIndex[zIndex] = byGeometryType; featuresByZIndex[zIndex] = byGeometryType;
byGeometryType[GeometryType.POLYGON] = []; byGeometryType['Polygon'] = [];
byGeometryType[GeometryType.CIRCLE] = []; byGeometryType['Circle'] = [];
byGeometryType[GeometryType.LINE_STRING] = []; byGeometryType['LineString'] = [];
byGeometryType[GeometryType.POINT] = []; byGeometryType['Point'] = [];
} }
byGeometryType[geometry.getType().replace('Multi', '')].push( byGeometryType[geometry.getType().replace('Multi', '')].push(
geometry, geometry,

View File

@@ -2,7 +2,6 @@
* @module ol/renderer/vector * @module ol/renderer/vector
*/ */
import BuilderType from '../render/canvas/BuilderType.js'; import BuilderType from '../render/canvas/BuilderType.js';
import GeometryType from '../geom/GeometryType.js';
import ImageState from '../ImageState.js'; import ImageState from '../ImageState.js';
import {getUid} from '../util.js'; import {getUid} from '../util.js';
@@ -24,7 +23,7 @@ const SIMPLIFY_TOLERANCE = 0.5;
/** /**
* @const * @const
* @type {Object<import("../geom/GeometryType.js").default, * @type {Object<import("../geom/Geometry.js").Type,
* function(import("../render/canvas/BuilderGroup.js").default, import("../geom/Geometry.js").default, * function(import("../render/canvas/BuilderGroup.js").default, import("../geom/Geometry.js").default,
* import("../style/Style.js").default, Object): void>} * import("../style/Style.js").default, Object): void>}
*/ */
@@ -193,7 +192,7 @@ function renderFeatureInternal(
* @param {import("../Feature.js").FeatureLike} feature Feature. * @param {import("../Feature.js").FeatureLike} feature Feature.
*/ */
function renderGeometry(replayGroup, geometry, style, feature) { function renderGeometry(replayGroup, geometry, style, feature) {
if (geometry.getType() == GeometryType.GEOMETRY_COLLECTION) { if (geometry.getType() == 'GeometryCollection') {
const geometries = const geometries =
/** @type {import("../geom/GeometryCollection.js").default} */ ( /** @type {import("../geom/GeometryCollection.js").default} */ (
geometry geometry

View File

@@ -2,7 +2,6 @@
* @module ol/renderer/webgl/PointsLayer * @module ol/renderer/webgl/PointsLayer
*/ */
import BaseVector from '../../layer/BaseVector.js'; import BaseVector from '../../layer/BaseVector.js';
import GeometryType from '../../geom/GeometryType.js';
import VectorEventType from '../../source/VectorEventType.js'; import VectorEventType from '../../source/VectorEventType.js';
import ViewHint from '../../ViewHint.js'; import ViewHint from '../../ViewHint.js';
import WebGLArrayBuffer from '../../webgl/Buffer.js'; import WebGLArrayBuffer from '../../webgl/Buffer.js';
@@ -599,7 +598,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
geometry = /** @type {import("../../geom").Point} */ ( geometry = /** @type {import("../../geom").Point} */ (
featureCache.geometry featureCache.geometry
); );
if (!geometry || geometry.getType() !== GeometryType.POINT) { if (!geometry || geometry.getType() !== 'Point') {
continue; continue;
} }

View File

@@ -4,7 +4,6 @@
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import VectorSource from './Vector.js'; import VectorSource from './Vector.js';
import {add as addCoordinate, scale as scaleCoordinate} from '../coordinate.js'; import {add as addCoordinate, scale as scaleCoordinate} from '../coordinate.js';
@@ -116,7 +115,7 @@ class Cluster extends VectorSource {
options.geometryFunction || options.geometryFunction ||
function (feature) { function (feature) {
const geometry = /** @type {Point} */ (feature.getGeometry()); const geometry = /** @type {Point} */ (feature.getGeometry());
assert(geometry.getType() == GeometryType.POINT, 10); // The default `geometryFunction` can only handle `Point` geometries assert(geometry.getType() == 'Point', 10); // The default `geometryFunction` can only handle `Point` geometries
return geometry; return geometry;
}; };

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/sphere * @module ol/sphere
*/ */
import GeometryType from './geom/GeometryType.js';
import {toDegrees, toRadians} from './math.js'; import {toDegrees, toRadians} from './math.js';
/** /**
@@ -78,26 +77,26 @@ export function getLength(geometry, opt_options) {
const radius = options.radius || DEFAULT_RADIUS; const radius = options.radius || DEFAULT_RADIUS;
const projection = options.projection || 'EPSG:3857'; const projection = options.projection || 'EPSG:3857';
const type = geometry.getType(); const type = geometry.getType();
if (type !== GeometryType.GEOMETRY_COLLECTION) { if (type !== 'GeometryCollection') {
geometry = geometry.clone().transform(projection, 'EPSG:4326'); geometry = geometry.clone().transform(projection, 'EPSG:4326');
} }
let length = 0; let length = 0;
let coordinates, coords, i, ii, j, jj; let coordinates, coords, i, ii, j, jj;
switch (type) { switch (type) {
case GeometryType.POINT: case 'Point':
case GeometryType.MULTI_POINT: { case 'MultiPoint': {
break; break;
} }
case GeometryType.LINE_STRING: case 'LineString':
case GeometryType.LINEAR_RING: { case 'LinearRing': {
coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ ( coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (
geometry geometry
).getCoordinates(); ).getCoordinates();
length = getLengthInternal(coordinates, radius); length = getLengthInternal(coordinates, radius);
break; break;
} }
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
case GeometryType.POLYGON: { case 'Polygon': {
coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ ( coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (
geometry geometry
).getCoordinates(); ).getCoordinates();
@@ -106,7 +105,7 @@ export function getLength(geometry, opt_options) {
} }
break; break;
} }
case GeometryType.MULTI_POLYGON: { case 'MultiPolygon': {
coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ ( coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (
geometry geometry
).getCoordinates(); ).getCoordinates();
@@ -118,7 +117,7 @@ export function getLength(geometry, opt_options) {
} }
break; break;
} }
case GeometryType.GEOMETRY_COLLECTION: { case 'GeometryCollection': {
const geometries = const geometries =
/** @type {import("./geom/GeometryCollection.js").default} */ ( /** @type {import("./geom/GeometryCollection.js").default} */ (
geometry geometry
@@ -181,20 +180,20 @@ export function getArea(geometry, opt_options) {
const radius = options.radius || DEFAULT_RADIUS; const radius = options.radius || DEFAULT_RADIUS;
const projection = options.projection || 'EPSG:3857'; const projection = options.projection || 'EPSG:3857';
const type = geometry.getType(); const type = geometry.getType();
if (type !== GeometryType.GEOMETRY_COLLECTION) { if (type !== 'GeometryCollection') {
geometry = geometry.clone().transform(projection, 'EPSG:4326'); geometry = geometry.clone().transform(projection, 'EPSG:4326');
} }
let area = 0; let area = 0;
let coordinates, coords, i, ii, j, jj; let coordinates, coords, i, ii, j, jj;
switch (type) { switch (type) {
case GeometryType.POINT: case 'Point':
case GeometryType.MULTI_POINT: case 'MultiPoint':
case GeometryType.LINE_STRING: case 'LineString':
case GeometryType.MULTI_LINE_STRING: case 'MultiLineString':
case GeometryType.LINEAR_RING: { case 'LinearRing': {
break; break;
} }
case GeometryType.POLYGON: { case 'Polygon': {
coordinates = /** @type {import("./geom/Polygon.js").default} */ ( coordinates = /** @type {import("./geom/Polygon.js").default} */ (
geometry geometry
).getCoordinates(); ).getCoordinates();
@@ -204,7 +203,7 @@ export function getArea(geometry, opt_options) {
} }
break; break;
} }
case GeometryType.MULTI_POLYGON: { case 'MultiPolygon': {
coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ ( coordinates = /** @type {import("./geom/SimpleGeometry.js").default} */ (
geometry geometry
).getCoordinates(); ).getCoordinates();
@@ -217,7 +216,7 @@ export function getArea(geometry, opt_options) {
} }
break; break;
} }
case GeometryType.GEOMETRY_COLLECTION: { case 'GeometryCollection': {
const geometries = const geometries =
/** @type {import("./geom/GeometryCollection.js").default} */ ( /** @type {import("./geom/GeometryCollection.js").default} */ (
geometry geometry

View File

@@ -4,7 +4,6 @@
import CircleStyle from './Circle.js'; import CircleStyle from './Circle.js';
import Fill from './Fill.js'; import Fill from './Fill.js';
import GeometryType from '../geom/GeometryType.js';
import Stroke from './Stroke.js'; import Stroke from './Stroke.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
@@ -89,23 +88,22 @@ import {assert} from '../asserts.js';
* *
* A separate editing style has the following defaults: * A separate editing style has the following defaults:
* ```js * ```js
* import GeometryType from 'ol/geom/GeometryType';
* import {Circle, Fill, Stroke, Style} from 'ol/style'; * import {Circle, Fill, Stroke, Style} from 'ol/style';
* *
* const styles = {}; * const styles = {};
* const white = [255, 255, 255, 1]; * const white = [255, 255, 255, 1];
* const blue = [0, 153, 255, 1]; * const blue = [0, 153, 255, 1];
* const width = 3; * const width = 3;
* styles[GeometryType.POLYGON] = [ * styles['Polygon'] = [
* new Style({ * new Style({
* fill: new Fill({ * fill: new Fill({
* color: [255, 255, 255, 0.5], * color: [255, 255, 255, 0.5],
* }), * }),
* }), * }),
* ]; * ];
* styles[GeometryType.MULTI_POLYGON] = styles[GeometryType.POLYGON]; * styles['MultiPolygon'] =
* * styles['Polygon'];
* styles[GeometryType.LINE_STRING] = [ * styles['LineString'] = [
* new Style({ * new Style({
* stroke: new Stroke({ * stroke: new Stroke({
* color: white, * color: white,
@@ -119,13 +117,13 @@ import {assert} from '../asserts.js';
* }), * }),
* }), * }),
* ]; * ];
* styles[GeometryType.MULTI_LINE_STRING] = styles[GeometryType.LINE_STRING]; * styles['MultiLineString'] = styles['LineString'];
* *
* styles[GeometryType.CIRCLE] = styles[GeometryType.POLYGON].concat( * styles['Circle'] = styles['Polygon'].concat(
* styles[GeometryType.LINE_STRING] * styles['LineString']
* ); * );
* *
* styles[GeometryType.POINT] = [ * styles['Point'] = [
* new Style({ * new Style({
* image: new Circle({ * image: new Circle({
* radius: width * 2, * radius: width * 2,
@@ -140,11 +138,13 @@ import {assert} from '../asserts.js';
* zIndex: Infinity, * zIndex: Infinity,
* }), * }),
* ]; * ];
* styles[GeometryType.MULTI_POINT] = styles[GeometryType.POINT]; * styles['MultiPoint'] =
* * styles['Point'];
* styles[GeometryType.GEOMETRY_COLLECTION] = styles[ * styles['GeometryCollection'] =
* GeometryType.POLYGON * styles['Polygon'].concat(
* ].concat(styles[GeometryType.LINE_STRING], styles[GeometryType.POINT]); * styles['LineString'],
* styles['Point']
* );
* ``` * ```
* *
* @api * @api
@@ -494,24 +494,24 @@ export function createDefaultStyle(feature, resolution) {
/** /**
* Default styles for editing features. * Default styles for editing features.
* @return {Object<import("../geom/GeometryType.js").default, Array<Style>>} Styles * @return {Object<import("../geom/Geometry.js").Type, Array<Style>>} Styles
*/ */
export function createEditingStyle() { export function createEditingStyle() {
/** @type {Object<import("../geom/GeometryType.js").default, Array<Style>>} */ /** @type {Object<import("../geom/Geometry.js").Type, Array<Style>>} */
const styles = {}; const styles = {};
const white = [255, 255, 255, 1]; const white = [255, 255, 255, 1];
const blue = [0, 153, 255, 1]; const blue = [0, 153, 255, 1];
const width = 3; const width = 3;
styles[GeometryType.POLYGON] = [ styles['Polygon'] = [
new Style({ new Style({
fill: new Fill({ fill: new Fill({
color: [255, 255, 255, 0.5], color: [255, 255, 255, 0.5],
}), }),
}), }),
]; ];
styles[GeometryType.MULTI_POLYGON] = styles[GeometryType.POLYGON]; styles['MultiPolygon'] = styles['Polygon'];
styles[GeometryType.LINE_STRING] = [ styles['LineString'] = [
new Style({ new Style({
stroke: new Stroke({ stroke: new Stroke({
color: white, color: white,
@@ -525,13 +525,11 @@ export function createEditingStyle() {
}), }),
}), }),
]; ];
styles[GeometryType.MULTI_LINE_STRING] = styles[GeometryType.LINE_STRING]; styles['MultiLineString'] = styles['LineString'];
styles[GeometryType.CIRCLE] = styles[GeometryType.POLYGON].concat( styles['Circle'] = styles['Polygon'].concat(styles['LineString']);
styles[GeometryType.LINE_STRING]
);
styles[GeometryType.POINT] = [ styles['Point'] = [
new Style({ new Style({
image: new CircleStyle({ image: new CircleStyle({
radius: width * 2, radius: width * 2,
@@ -546,11 +544,12 @@ export function createEditingStyle() {
zIndex: Infinity, zIndex: Infinity,
}), }),
]; ];
styles[GeometryType.MULTI_POINT] = styles[GeometryType.POINT]; styles['MultiPoint'] = styles['Point'];
styles[GeometryType.GEOMETRY_COLLECTION] = styles[ styles['GeometryCollection'] = styles['Polygon'].concat(
GeometryType.POLYGON styles['LineString'],
].concat(styles[GeometryType.LINE_STRING], styles[GeometryType.POINT]); styles['Point']
);
return styles; return styles;
} }

View File

@@ -5,7 +5,6 @@ import Draw, {
} from '../../../../../src/ol/interaction/Draw.js'; } from '../../../../../src/ol/interaction/Draw.js';
import Feature from '../../../../../src/ol/Feature.js'; import Feature from '../../../../../src/ol/Feature.js';
import GeometryLayout from '../../../../../src/ol/geom/GeometryLayout.js'; import GeometryLayout from '../../../../../src/ol/geom/GeometryLayout.js';
import GeometryType from '../../../../../src/ol/geom/GeometryType.js';
import Interaction from '../../../../../src/ol/interaction/Interaction.js'; import Interaction from '../../../../../src/ol/interaction/Interaction.js';
import LineString from '../../../../../src/ol/geom/LineString.js'; import LineString from '../../../../../src/ol/geom/LineString.js';
import Map from '../../../../../src/ol/Map.js'; import Map from '../../../../../src/ol/Map.js';
@@ -648,7 +647,7 @@ describe('ol.interaction.Draw', function () {
simulateEvent('pointerdown', x, y); simulateEvent('pointerdown', x, y);
simulateEvent('pointerup', x, y); simulateEvent('pointerup', x, y);
} }
if (amount > 1 && type !== GeometryType.CIRCLE) { if (amount > 1 && type !== 'Circle') {
const [x, y] = testCoordinates[amount - 1]; const [x, y] = testCoordinates[amount - 1];
simulateEvent('pointerdown', x, y); simulateEvent('pointerdown', x, y);
simulateEvent('pointerup', x, y); simulateEvent('pointerup', x, y);
@@ -664,25 +663,25 @@ describe('ol.interaction.Draw', function () {
expect(source.getFeatures()).to.have.length(1); expect(source.getFeatures()).to.have.length(1);
} }
it('calls finishCondition:true for POINT type', function () { it('calls finishCondition:true for POINT type', function () {
testFinishConditionTrue(GeometryType.POINT, 1); testFinishConditionTrue('Point', 1);
}); });
it('calls finishCondition:true for MULTI_POINT type', function () { it('calls finishCondition:true for MULTI_POINT type', function () {
testFinishConditionTrue(GeometryType.MULTI_POINT, 1); testFinishConditionTrue('MultiPoint', 1);
}); });
it('calls finishCondition:true for LINE_STRING type', function () { it('calls finishCondition:true for LINE_STRING type', function () {
testFinishConditionTrue(GeometryType.LINE_STRING, 2); testFinishConditionTrue('LineString', 2);
}); });
it('calls finishCondition:true for MULTI_LINE_STRING type', function () { it('calls finishCondition:true for MULTI_LINE_STRING type', function () {
testFinishConditionTrue(GeometryType.MULTI_LINE_STRING, 2); testFinishConditionTrue('MultiLineString', 2);
}); });
it('calls finishCondition:true for CIRCLE type', function () { it('calls finishCondition:true for CIRCLE type', function () {
testFinishConditionTrue(GeometryType.CIRCLE, 2); testFinishConditionTrue('Circle', 2);
}); });
it('calls finishCondition:true for POLYGON type', function () { it('calls finishCondition:true for POLYGON type', function () {
testFinishConditionTrue(GeometryType.POLYGON, 3); testFinishConditionTrue('Polygon', 3);
}); });
it('calls finishCondition:true for MULTI_POLYGON type', function () { it('calls finishCondition:true for MULTI_POLYGON type', function () {
testFinishConditionTrue(GeometryType.MULTI_POLYGON, 3); testFinishConditionTrue('MultiPolygon', 3);
}); });
function testFinishConditionFalse(type, amount) { function testFinishConditionFalse(type, amount) {
@@ -694,25 +693,25 @@ describe('ol.interaction.Draw', function () {
expect(source.getFeatures()).to.have.length(0); expect(source.getFeatures()).to.have.length(0);
} }
it('calls finishCondition:false for POINT type', function () { it('calls finishCondition:false for POINT type', function () {
testFinishConditionFalse(GeometryType.POINT, 1); testFinishConditionFalse('Point', 1);
}); });
it('calls finishCondition:false for MULTI_POINT type', function () { it('calls finishCondition:false for MULTI_POINT type', function () {
testFinishConditionFalse(GeometryType.MULTI_POINT, 1); testFinishConditionFalse('MultiPoint', 1);
}); });
it('calls finishCondition:false for LINE_STRING type', function () { it('calls finishCondition:false for LINE_STRING type', function () {
testFinishConditionFalse(GeometryType.LINE_STRING, 2); testFinishConditionFalse('LineString', 2);
}); });
it('calls finishCondition:false for MULTI_LINE_STRING type', function () { it('calls finishCondition:false for MULTI_LINE_STRING type', function () {
testFinishConditionFalse(GeometryType.MULTI_LINE_STRING, 2); testFinishConditionFalse('MultiLineString', 2);
}); });
it('calls finishCondition:false for CIRCLE type', function () { it('calls finishCondition:false for CIRCLE type', function () {
testFinishConditionFalse(GeometryType.CIRCLE, 2); testFinishConditionFalse('Circle', 2);
}); });
it('calls finishCondition:false for POLYGON type', function () { it('calls finishCondition:false for POLYGON type', function () {
testFinishConditionFalse(GeometryType.POLYGON, 3); testFinishConditionFalse('Polygon', 3);
}); });
it('calls finishCondition:false for MULTI_POLYGON type', function () { it('calls finishCondition:false for MULTI_POLYGON type', function () {
testFinishConditionFalse(GeometryType.MULTI_POLYGON, 3); testFinishConditionFalse('MultiPolygon', 3);
}); });
}); });