Replace GeometryLayout enum with typedef

This commit is contained in:
Maximilian Krög
2022-07-17 02:43:32 +02:00
parent ac6edc704a
commit 185485b0f7
26 changed files with 211 additions and 237 deletions

View File

@@ -2,7 +2,6 @@
* @module ol/format/EsriJSON * @module ol/format/EsriJSON
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.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';
@@ -295,7 +294,7 @@ function readGeometry(object, opt_options) {
* array. It is used for checking for holes. * array. It is used for checking for holes.
* Logic inspired by: https://github.com/Esri/terraformer-arcgis-parser * Logic inspired by: https://github.com/Esri/terraformer-arcgis-parser
* @param {Array<!Array<!Array<number>>>} rings Rings. * @param {Array<!Array<!Array<number>>>} rings Rings.
* @param {import("../geom/GeometryLayout.js").default} layout Geometry layout. * @param {import("../geom/Geometry.js").GeometryLayout} layout Geometry layout.
* @return {Array<!Array<!Array<!Array<number>>>>} Transformed rings. * @return {Array<!Array<!Array<!Array<number>>>>} Transformed rings.
*/ */
function convertRings(rings, layout) { function convertRings(rings, layout) {
@@ -352,14 +351,11 @@ function convertRings(rings, layout) {
function readPointGeometry(object) { function readPointGeometry(object) {
let point; let point;
if (object.m !== undefined && object.z !== undefined) { if (object.m !== undefined && object.z !== undefined) {
point = new Point( point = new Point([object.x, object.y, object.z, object.m], 'XYZM');
[object.x, object.y, object.z, object.m],
GeometryLayout.XYZM
);
} else if (object.z !== undefined) { } else if (object.z !== undefined) {
point = new Point([object.x, object.y, object.z], GeometryLayout.XYZ); point = new Point([object.x, object.y, object.z], 'XYZ');
} else if (object.m !== undefined) { } else if (object.m !== undefined) {
point = new Point([object.x, object.y, object.m], GeometryLayout.XYM); point = new Point([object.x, object.y, object.m], 'XYM');
} else { } else {
point = new Point([object.x, object.y]); point = new Point([object.x, object.y]);
} }
@@ -386,16 +382,17 @@ function readMultiLineStringGeometry(object) {
/** /**
* @param {EsriJSONHasZM} object Object. * @param {EsriJSONHasZM} object Object.
* @return {import("../geom/GeometryLayout.js").default} The geometry layout to use. * @return {import("../geom/Geometry.js").GeometryLayout} The geometry layout to use.
*/ */
function getGeometryLayout(object) { function getGeometryLayout(object) {
let layout = GeometryLayout.XY; /** @type {import("../geom/Geometry.js").GeometryLayout} */
let layout = 'XY';
if (object.hasZ === true && object.hasM === true) { if (object.hasZ === true && object.hasM === true) {
layout = GeometryLayout.XYZM; layout = 'XYZM';
} else if (object.hasZ === true) { } else if (object.hasZ === true) {
layout = GeometryLayout.XYZ; layout = 'XYZ';
} else if (object.hasM === true) { } else if (object.hasM === true) {
layout = GeometryLayout.XYM; layout = 'XYM';
} }
return layout; return layout;
} }
@@ -437,26 +434,26 @@ function writePointGeometry(geometry, opt_options) {
/** @type {EsriJSONPoint} */ /** @type {EsriJSONPoint} */
let esriJSON; let esriJSON;
const layout = geometry.getLayout(); const layout = geometry.getLayout();
if (layout === GeometryLayout.XYZ) { if (layout === 'XYZ') {
esriJSON = { esriJSON = {
x: coordinates[0], x: coordinates[0],
y: coordinates[1], y: coordinates[1],
z: coordinates[2], z: coordinates[2],
}; };
} else if (layout === GeometryLayout.XYM) { } else if (layout === 'XYM') {
esriJSON = { esriJSON = {
x: coordinates[0], x: coordinates[0],
y: coordinates[1], y: coordinates[1],
m: coordinates[2], m: coordinates[2],
}; };
} else if (layout === GeometryLayout.XYZM) { } else if (layout === 'XYZM') {
esriJSON = { esriJSON = {
x: coordinates[0], x: coordinates[0],
y: coordinates[1], y: coordinates[1],
z: coordinates[2], z: coordinates[2],
m: coordinates[3], m: coordinates[3],
}; };
} else if (layout === GeometryLayout.XY) { } else if (layout === 'XY') {
esriJSON = { esriJSON = {
x: coordinates[0], x: coordinates[0],
y: coordinates[1], y: coordinates[1],
@@ -474,8 +471,8 @@ function writePointGeometry(geometry, opt_options) {
function getHasZM(geometry) { function getHasZM(geometry) {
const layout = geometry.getLayout(); const layout = geometry.getLayout();
return { return {
hasZ: layout === GeometryLayout.XYZ || layout === GeometryLayout.XYZM, hasZ: layout === 'XYZ' || layout === 'XYZM',
hasM: layout === GeometryLayout.XYM || layout === GeometryLayout.XYZM, hasM: layout === 'XYM' || layout === 'XYZM',
}; };
} }

View File

@@ -3,7 +3,6 @@
*/ */
import GML2 from './GML2.js'; import GML2 from './GML2.js';
import GMLBase, {GMLNS} from './GMLBase.js'; import GMLBase, {GMLNS} from './GMLBase.js';
import GeometryLayout from '../geom/GeometryLayout.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 MultiPolygon from '../geom/MultiPolygon.js'; import MultiPolygon from '../geom/MultiPolygon.js';
@@ -308,7 +307,7 @@ class GML3 extends GMLBase {
extend(flatCoordinates, flatLinearRings[i]); extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length); ends.push(flatCoordinates.length);
} }
return new Polygon(flatCoordinates, GeometryLayout.XYZ, ends); return new Polygon(flatCoordinates, 'XYZ', ends);
} else { } else {
return undefined; return undefined;
} }
@@ -329,7 +328,7 @@ class GML3 extends GMLBase {
this this
); );
if (flatCoordinates) { if (flatCoordinates) {
const lineString = new LineString(flatCoordinates, GeometryLayout.XYZ); const lineString = new LineString(flatCoordinates, 'XYZ');
return lineString; return lineString;
} else { } else {
return undefined; return undefined;

View File

@@ -5,7 +5,6 @@
// of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect // of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect
// envelopes/extents, only geometries! // envelopes/extents, only geometries!
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.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';
import MultiLineString from '../geom/MultiLineString.js'; import MultiLineString from '../geom/MultiLineString.js';
@@ -370,7 +369,7 @@ class GMLBase extends XMLFeature {
readPoint(node, objectStack) { readPoint(node, objectStack) {
const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack); const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) { if (flatCoordinates) {
return new Point(flatCoordinates, GeometryLayout.XYZ); return new Point(flatCoordinates, 'XYZ');
} }
} }
@@ -465,7 +464,7 @@ class GMLBase extends XMLFeature {
readLineString(node, objectStack) { readLineString(node, objectStack) {
const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack); const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) { if (flatCoordinates) {
const lineString = new LineString(flatCoordinates, GeometryLayout.XYZ); const lineString = new LineString(flatCoordinates, 'XYZ');
return lineString; return lineString;
} else { } else {
return undefined; return undefined;
@@ -500,7 +499,7 @@ class GMLBase extends XMLFeature {
readLinearRing(node, objectStack) { readLinearRing(node, objectStack) {
const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack); const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) { if (flatCoordinates) {
return new LinearRing(flatCoordinates, GeometryLayout.XYZ); return new LinearRing(flatCoordinates, 'XYZ');
} }
} }
@@ -526,7 +525,7 @@ class GMLBase extends XMLFeature {
extend(flatCoordinates, flatLinearRings[i]); extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length); ends.push(flatCoordinates.length);
} }
return new Polygon(flatCoordinates, GeometryLayout.XYZ, ends); return new Polygon(flatCoordinates, 'XYZ', ends);
} else { } else {
return undefined; return undefined;
} }

View File

@@ -2,7 +2,6 @@
* @module ol/format/GPX * @module ol/format/GPX
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.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';
@@ -557,19 +556,20 @@ function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
* @param {LayoutOptions} layoutOptions Layout options. * @param {LayoutOptions} layoutOptions Layout options.
* @param {Array<number>} flatCoordinates Flat coordinates. * @param {Array<number>} flatCoordinates Flat coordinates.
* @param {Array<number>} [ends] Ends. * @param {Array<number>} [ends] Ends.
* @return {import("../geom/GeometryLayout.js").default} Layout. * @return {import("../geom/Geometry.js").GeometryLayout} Layout.
*/ */
function applyLayoutOptions(layoutOptions, flatCoordinates, ends) { function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
let layout = GeometryLayout.XY; /** @type {import("../geom/Geometry.js").GeometryLayout} */
let layout = 'XY';
let stride = 2; let stride = 2;
if (layoutOptions.hasZ && layoutOptions.hasM) { if (layoutOptions.hasZ && layoutOptions.hasM) {
layout = GeometryLayout.XYZM; layout = 'XYZM';
stride = 4; stride = 4;
} else if (layoutOptions.hasZ) { } else if (layoutOptions.hasZ) {
layout = GeometryLayout.XYZ; layout = 'XYZ';
stride = 3; stride = 3;
} else if (layoutOptions.hasM) { } else if (layoutOptions.hasM) {
layout = GeometryLayout.XYM; layout = 'XYM';
stride = 3; stride = 3;
} }
if (stride !== 4) { if (stride !== 4) {
@@ -800,17 +800,17 @@ function writeWptType(node, coordinate, objectStack) {
node.setAttributeNS(null, 'lon', String(coordinate[0])); node.setAttributeNS(null, 'lon', String(coordinate[0]));
const geometryLayout = context['geometryLayout']; const geometryLayout = context['geometryLayout'];
switch (geometryLayout) { switch (geometryLayout) {
case GeometryLayout.XYZM: case 'XYZM':
if (coordinate[3] !== 0) { if (coordinate[3] !== 0) {
properties['time'] = coordinate[3]; properties['time'] = coordinate[3];
} }
// fall through // fall through
case GeometryLayout.XYZ: case 'XYZ':
if (coordinate[2] !== 0) { if (coordinate[2] !== 0) {
properties['ele'] = coordinate[2]; properties['ele'] = coordinate[2];
} }
break; break;
case GeometryLayout.XYM: case 'XYM':
if (coordinate[2] !== 0) { if (coordinate[2] !== 0) {
properties['time'] = coordinate[2]; properties['time'] = coordinate[2];
} }

View File

@@ -2,7 +2,6 @@
* @module ol/format/IGC * @module ol/format/IGC
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import TextFeature from './TextFeature.js'; import TextFeature from './TextFeature.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
@@ -148,8 +147,7 @@ class IGC extends TextFeature {
if (flatCoordinates.length === 0) { if (flatCoordinates.length === 0) {
return null; return null;
} }
const layout = const layout = altitudeMode == 'none' ? 'XYM' : 'XYZM';
altitudeMode == 'none' ? GeometryLayout.XYM : GeometryLayout.XYZM;
const lineString = new LineString(flatCoordinates, layout); const lineString = new LineString(flatCoordinates, layout);
const feature = new Feature( const feature = new Feature(
transformGeometryWithOptions(lineString, false, opt_options) transformGeometryWithOptions(lineString, false, opt_options)

View File

@@ -4,7 +4,6 @@
import Feature from '../Feature.js'; 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 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';
@@ -1594,7 +1593,7 @@ function readGxTrack(node, objectStack) {
); );
} }
} }
return new LineString(flatCoordinates, GeometryLayout.XYZM); return new LineString(flatCoordinates, 'XYZM');
} }
/** /**
@@ -1677,7 +1676,7 @@ function readLineString(node, objectStack) {
); );
const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack); const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) { if (flatCoordinates) {
const lineString = new LineString(flatCoordinates, GeometryLayout.XYZ); const lineString = new LineString(flatCoordinates, 'XYZ');
lineString.setProperties(properties, true); lineString.setProperties(properties, true);
return lineString; return lineString;
} else { } else {
@@ -1699,7 +1698,7 @@ function readLinearRing(node, objectStack) {
); );
const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack); const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) { if (flatCoordinates) {
const polygon = new Polygon(flatCoordinates, GeometryLayout.XYZ, [ const polygon = new Polygon(flatCoordinates, 'XYZ', [
flatCoordinates.length, flatCoordinates.length,
]); ]);
polygon.setProperties(properties, true); polygon.setProperties(properties, true);
@@ -1795,7 +1794,7 @@ function readPoint(node, objectStack) {
); );
const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack); const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) { if (flatCoordinates) {
const point = new Point(flatCoordinates, GeometryLayout.XYZ); const point = new Point(flatCoordinates, 'XYZ');
point.setProperties(properties, true); point.setProperties(properties, true);
return point; return point;
} else { } else {
@@ -1838,7 +1837,7 @@ function readPolygon(node, objectStack) {
extend(flatCoordinates, flatLinearRings[i]); extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length); ends.push(flatCoordinates.length);
} }
const polygon = new Polygon(flatCoordinates, GeometryLayout.XYZ, ends); const polygon = new Polygon(flatCoordinates, 'XYZ', ends);
polygon.setProperties(properties, true); polygon.setProperties(properties, true);
return polygon; return polygon;
} else { } else {
@@ -2338,9 +2337,9 @@ function writeCoordinatesTextNode(node, coordinates, objectStack) {
const stride = context['stride']; const stride = context['stride'];
let dimension; let dimension;
if (layout == GeometryLayout.XY || layout == GeometryLayout.XYM) { if (layout == 'XY' || layout == 'XYM') {
dimension = 2; dimension = 2;
} else if (layout == GeometryLayout.XYZ || layout == GeometryLayout.XYZM) { } else if (layout == 'XYZ' || layout == 'XYZM') {
dimension = 3; dimension = 3;
} else { } else {
assert(false, 34); // Invalid geometry layout assert(false, 34); // Invalid geometry layout

View File

@@ -4,7 +4,6 @@
//FIXME Implement projection handling //FIXME Implement projection handling
import FeatureFormat, {transformGeometryWithOptions} from './Feature.js'; import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
import GeometryLayout from '../geom/GeometryLayout.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';
@@ -204,18 +203,18 @@ class MVT extends FeatureFormat {
const endss = inflateEnds(flatCoordinates, ends); const endss = inflateEnds(flatCoordinates, ends);
geom = geom =
endss.length > 1 endss.length > 1
? new MultiPolygon(flatCoordinates, GeometryLayout.XY, endss) ? new MultiPolygon(flatCoordinates, 'XY', endss)
: new Polygon(flatCoordinates, GeometryLayout.XY, ends); : new Polygon(flatCoordinates, 'XY', ends);
} else { } else {
geom = geom =
geometryType === 'Point' geometryType === 'Point'
? new Point(flatCoordinates, GeometryLayout.XY) ? new Point(flatCoordinates, 'XY')
: geometryType === 'LineString' : geometryType === 'LineString'
? new LineString(flatCoordinates, GeometryLayout.XY) ? new LineString(flatCoordinates, 'XY')
: geometryType === 'MultiPoint' : geometryType === 'MultiPoint'
? new MultiPoint(flatCoordinates, GeometryLayout.XY) ? new MultiPoint(flatCoordinates, 'XY')
: geometryType === 'MultiLineString' : geometryType === 'MultiLineString'
? new MultiLineString(flatCoordinates, GeometryLayout.XY, ends) ? new MultiLineString(flatCoordinates, 'XY', ends)
: null; : null;
} }
const ctor = /** @type {typeof import("../Feature.js").default} */ ( const ctor = /** @type {typeof import("../Feature.js").default} */ (

View File

@@ -3,7 +3,6 @@
*/ */
// FIXME add typedef for stack state objects // FIXME add typedef for stack state objects
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js'; import Polygon from '../geom/Polygon.js';
@@ -88,11 +87,11 @@ class OSMXML extends XMLFeature {
let geometry; let geometry;
if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) { if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) {
// closed way // closed way
geometry = new Polygon(flatCoordinates, GeometryLayout.XY, [ geometry = new Polygon(flatCoordinates, 'XY', [
flatCoordinates.length, flatCoordinates.length,
]); ]);
} else { } else {
geometry = new LineString(flatCoordinates, GeometryLayout.XY); geometry = new LineString(flatCoordinates, 'XY');
} }
transformGeometryWithOptions(geometry, false, options); transformGeometryWithOptions(geometry, false, options);
const feature = new Feature(geometry); const feature = new Feature(geometry);

View File

@@ -2,7 +2,6 @@
* @module ol/format/Polyline * @module ol/format/Polyline
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import TextFeature from './TextFeature.js'; import TextFeature from './TextFeature.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
@@ -15,7 +14,7 @@ import {transformGeometryWithOptions} from './Feature.js';
/** /**
* @typedef {Object} Options * @typedef {Object} Options
* @property {number} [factor=1e5] The factor by which the coordinates values will be scaled. * @property {number} [factor=1e5] The factor by which the coordinates values will be scaled.
* @property {GeometryLayout} [geometryLayout='XY'] Layout of the * @property {import("../geom/Geometry.js").GeometryLayout} [geometryLayout='XY'] Layout of the
* feature geometries created by the format reader. * feature geometries created by the format reader.
*/ */
@@ -55,11 +54,11 @@ class Polyline extends TextFeature {
/** /**
* @private * @private
* @type {import("../geom/GeometryLayout").default} * @type {import("../geom/Geometry.js").GeometryLayout}
*/ */
this.geometryLayout_ = options.geometryLayout this.geometryLayout_ = options.geometryLayout
? options.geometryLayout ? options.geometryLayout
: GeometryLayout.XY; : 'XY';
} }
/** /**

View File

@@ -4,7 +4,6 @@
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import FeatureFormat, {transformGeometryWithOptions} from './Feature.js'; import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js'; import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.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';
@@ -53,17 +52,50 @@ class WkbReader {
* @param {DataView} view source to read * @param {DataView} view source to read
*/ */
constructor(view) { constructor(view) {
/** @private */
this.view_ = view; this.view_ = view;
/**
* @type {number}
* @private
*/
this.pos_ = 0; this.pos_ = 0;
/**
* @type {boolean}
* @private
*/
this.initialized_ = false; this.initialized_ = false;
/**
* @type {boolean}
* @private
*/
this.isLittleEndian_ = false; this.isLittleEndian_ = false;
/**
* @type {boolean}
* @private
*/
this.hasZ_ = false; this.hasZ_ = false;
/**
* @type {boolean}
* @private
*/
this.hasM_ = false; this.hasM_ = false;
/** @type {number|null} */
/**
* @type {number|null}
* @private
*/
this.srid_ = null; this.srid_ = null;
this.layout_ = GeometryLayout.XY; /**
* @type {import("../geom/Geometry.js").GeometryLayout}
* @private
*/
this.layout_ = 'XY';
} }
/** /**
@@ -164,7 +196,9 @@ class WkbReader {
wkbTypeThousandth === 3; wkbTypeThousandth === 3;
const hasSRID = Boolean(wkbType & 0x20000000); const hasSRID = Boolean(wkbType & 0x20000000);
const typeId = (wkbType & 0x0fffffff) % 1000; // Assume 1000 is an upper limit for type ID const typeId = (wkbType & 0x0fffffff) % 1000; // Assume 1000 is an upper limit for type ID
const layout = ['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join(''); const layout = /** @type {import("../geom/Geometry.js").GeometryLayout} */ (
['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join('')
);
const srid = hasSRID ? this.readUint32(isLittleEndian) : null; const srid = hasSRID ? this.readUint32(isLittleEndian) : null;
@@ -415,7 +449,7 @@ class WkbWriter {
/** /**
* @param {import('../coordinate.js').Coordinate} coords coords * @param {import('../coordinate.js').Coordinate} coords coords
* @param {import("../geom/GeometryLayout").default} layout layout * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/ */
writePoint(coords, layout) { writePoint(coords, layout) {
/** /**
@@ -439,7 +473,7 @@ class WkbWriter {
/** /**
* @param {Array<import('../coordinate.js').Coordinate>} coords coords * @param {Array<import('../coordinate.js').Coordinate>} coords coords
* @param {import("../geom/GeometryLayout").default} layout layout * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/ */
writeLineString(coords, layout) { writeLineString(coords, layout) {
this.writeUint32(coords.length); // numPoints this.writeUint32(coords.length); // numPoints
@@ -450,7 +484,7 @@ class WkbWriter {
/** /**
* @param {Array<Array<import('../coordinate.js').Coordinate>>} rings rings * @param {Array<Array<import('../coordinate.js').Coordinate>>} rings rings
* @param {import("../geom/GeometryLayout").default} layout layout * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/ */
writePolygon(rings, layout) { writePolygon(rings, layout) {
this.writeUint32(rings.length); // numRings this.writeUint32(rings.length); // numRings
@@ -484,7 +518,7 @@ class WkbWriter {
/** /**
* @param {Array<import('../coordinate.js').Coordinate>} coords coords * @param {Array<import('../coordinate.js').Coordinate>} coords coords
* @param {string} layout layout * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/ */
writeMultiPoint(coords, layout) { writeMultiPoint(coords, layout) {
this.writeUint32(coords.length); // numItems this.writeUint32(coords.length); // numItems
@@ -496,7 +530,7 @@ class WkbWriter {
/** /**
* @param {Array<Array<import('../coordinate.js').Coordinate>>} coords coords * @param {Array<Array<import('../coordinate.js').Coordinate>>} coords coords
* @param {string} layout layout * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/ */
writeMultiLineString(coords, layout) { writeMultiLineString(coords, layout) {
this.writeUint32(coords.length); // numItems this.writeUint32(coords.length); // numItems
@@ -508,7 +542,7 @@ class WkbWriter {
/** /**
* @param {Array<Array<Array<import('../coordinate.js').Coordinate>>>} coords coords * @param {Array<Array<Array<import('../coordinate.js').Coordinate>>>} coords coords
* @param {string} layout layout * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/ */
writeMultiPolygon(coords, layout) { writeMultiPolygon(coords, layout) {
this.writeUint32(coords.length); // numItems this.writeUint32(coords.length); // numItems
@@ -531,31 +565,31 @@ class WkbWriter {
/** /**
* @param {import("../geom/Geometry.js").default} geom geometry * @param {import("../geom/Geometry.js").default} geom geometry
* @param {import("../geom/GeometryLayout.js").default} [layout] layout * @param {import("../geom/Geometry.js").GeometryLayout} [layout] layout
* @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes * @return {import("../geom/Geometry.js").GeometryLayout} minumum layout made by common axes
*/ */
findMinimumLayout(geom, layout = GeometryLayout.XYZM) { findMinimumLayout(geom, layout = 'XYZM') {
/** /**
* @param {import("../geom/GeometryLayout.js").default} a A * @param {import("../geom/Geometry.js").GeometryLayout} a A
* @param {import("../geom/GeometryLayout.js").default} b B * @param {import("../geom/Geometry.js").GeometryLayout} b B
* @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes * @return {import("../geom/Geometry.js").GeometryLayout} minumum layout made by common axes
*/ */
const GeometryLayout_min = (a, b) => { const GeometryLayout_min = (a, b) => {
if (a === b) { if (a === b) {
return a; return a;
} }
if (a === GeometryLayout.XYZM) { if (a === 'XYZM') {
// anything `b` is minimum // anything `b` is minimum
return b; return b;
} }
if (b === GeometryLayout.XYZM) { if (b === 'XYZM') {
// anything `a` is minimum // anything `a` is minimum
return a; return a;
} }
// otherwise, incompatible // otherwise, incompatible
return GeometryLayout.XY; return 'XY';
}; };
if (geom instanceof SimpleGeometry) { if (geom instanceof SimpleGeometry) {
@@ -564,7 +598,7 @@ class WkbWriter {
if (geom instanceof GeometryCollection) { if (geom instanceof GeometryCollection) {
const geoms = geom.getGeometriesArray(); const geoms = geom.getGeometriesArray();
for (let i = 0; i < geoms.length && layout !== GeometryLayout.XY; i++) { for (let i = 0; i < geoms.length && layout !== 'XY'; i++) {
layout = this.findMinimumLayout(geoms[i], layout); layout = this.findMinimumLayout(geoms[i], layout);
} }
} }
@@ -652,7 +686,7 @@ class WkbWriter {
* @property {boolean} [hex=true] Returns hex string instead of ArrayBuffer for output. This also is used as a hint internally whether it should load contents as text or ArrayBuffer on reading. * @property {boolean} [hex=true] Returns hex string instead of ArrayBuffer for output. This also is used as a hint internally whether it should load contents as text or ArrayBuffer on reading.
* @property {boolean} [littleEndian=true] Use littleEndian for output. * @property {boolean} [littleEndian=true] Use littleEndian for output.
* @property {boolean} [ewkb=true] Use EWKB format for output. * @property {boolean} [ewkb=true] Use EWKB format for output.
* @property {import("../geom/GeometryLayout").default} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect) * @property {import("../geom/Geometry.js").GeometryLayout} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect)
* @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z. * @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z.
* @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M. * @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M.
* @property {number|boolean} [srid=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`. * @property {number|boolean} [srid=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`.

View File

@@ -3,7 +3,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 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';
@@ -15,7 +14,7 @@ import {transformGeometryWithOptions} from './Feature.js';
/** /**
* Geometry constructors * Geometry constructors
* @enum {function (new:import("../geom/Geometry.js").default, Array, import("../geom/GeometryLayout.js").default)} * @enum {function (new:import("../geom/Geometry.js").default, Array, import("../geom/Geometry.js").GeometryLayout)}
*/ */
const GeometryConstructor = { const GeometryConstructor = {
'POINT': Point, 'POINT': Point,
@@ -249,10 +248,10 @@ class Parser {
}; };
/** /**
* @type {import("../geom/GeometryLayout.js").default} * @type {import("../geom/Geometry.js").GeometryLayout}
* @private * @private
*/ */
this.layout_ = GeometryLayout.XY; this.layout_ = 'XY';
} }
/** /**
@@ -296,22 +295,23 @@ class Parser {
/** /**
* Try to parse the dimensional info. * Try to parse the dimensional info.
* @return {import("../geom/GeometryLayout.js").default} The layout. * @return {import("../geom/Geometry.js").GeometryLayout} The layout.
* @private * @private
*/ */
parseGeometryLayout_() { parseGeometryLayout_() {
let layout = GeometryLayout.XY; /** @type {import("../geom/Geometry.js").GeometryLayout} */
let layout = 'XY';
const dimToken = this.token_; const dimToken = this.token_;
if (this.isTokenType(TokenType.TEXT)) { if (this.isTokenType(TokenType.TEXT)) {
const dimInfo = dimToken.value; const dimInfo = dimToken.value;
if (dimInfo === Z) { if (dimInfo === Z) {
layout = GeometryLayout.XYZ; layout = 'XYZ';
} else if (dimInfo === M) { } else if (dimInfo === M) {
layout = GeometryLayout.XYM; layout = 'XYM';
} else if (dimInfo === ZM) { } else if (dimInfo === ZM) {
layout = GeometryLayout.XYZM; layout = 'XYZM';
} }
if (layout !== GeometryLayout.XY) { if (layout !== 'XY') {
this.consume_(); this.consume_();
} }
} }
@@ -819,10 +819,10 @@ function encodeMultiPolygonGeometry(geom) {
function encodeGeometryLayout(geom) { function encodeGeometryLayout(geom) {
const layout = geom.getLayout(); const layout = geom.getLayout();
let dimInfo = ''; let dimInfo = '';
if (layout === GeometryLayout.XYZ || layout === GeometryLayout.XYZM) { if (layout === 'XYZ' || layout === 'XYZM') {
dimInfo += Z; dimInfo += Z;
} }
if (layout === GeometryLayout.XYM || layout === GeometryLayout.XYZM) { if (layout === 'XYM' || layout === 'XYZM') {
dimInfo += M; dimInfo += M;
} }
return dimInfo; return dimInfo;

View File

@@ -18,7 +18,7 @@ class Circle extends SimpleGeometry {
* For internal use, flat coordinates in combination with `opt_layout` and no * For internal use, flat coordinates in combination with `opt_layout` and no
* `opt_radius` are also accepted. * `opt_radius` are also accepted.
* @param {number} [opt_radius] Radius. * @param {number} [opt_radius] Radius.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
*/ */
constructor(center, opt_radius, opt_layout) { constructor(center, opt_radius, opt_layout) {
super(); super();
@@ -188,7 +188,7 @@ class Circle extends SimpleGeometry {
* number) of the circle. * number) of the circle.
* @param {!import("../coordinate.js").Coordinate} center Center. * @param {!import("../coordinate.js").Coordinate} center Center.
* @param {number} radius Radius. * @param {number} radius Radius.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCenterAndRadius(center, radius, opt_layout) { setCenterAndRadius(center, radius, opt_layout) {

View File

@@ -18,6 +18,12 @@ 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 {'XY' | 'XYZ' | 'XYM' | 'XYZM'} GeometryLayout
* The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')
* or measure ('M') coordinate is available.
*/
/** /**
* @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type
* The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`, * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,

View File

@@ -1,16 +0,0 @@
/**
* @module ol/geom/GeometryLayout
*/
/**
* The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')
* or measure ('M') coordinate is available. Supported values are `'XY'`,
* `'XYZ'`, `'XYM'`, `'XYZM'`.
* @enum {string}
*/
export default {
XY: 'XY',
XYZ: 'XYZ',
XYM: 'XYM',
XYZM: 'XYZM',
};

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/LineString * @module ol/geom/LineString
*/ */
import GeometryLayout from './GeometryLayout.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';
@@ -24,7 +23,7 @@ class LineString extends SimpleGeometry {
/** /**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates. * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `opt_layout` are also accepted. * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
*/ */
constructor(coordinates, opt_layout) { constructor(coordinates, opt_layout) {
super(); super();
@@ -169,10 +168,7 @@ class LineString extends SimpleGeometry {
* @api * @api
*/ */
getCoordinateAtM(m, opt_extrapolate) { getCoordinateAtM(m, opt_extrapolate) {
if ( if (this.layout != 'XYM' && this.layout != 'XYZM') {
this.layout != GeometryLayout.XYM &&
this.layout != GeometryLayout.XYZM
) {
return null; return null;
} }
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false; const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
@@ -263,7 +259,7 @@ class LineString extends SimpleGeometry {
simplifiedFlatCoordinates, simplifiedFlatCoordinates,
0 0
); );
return new LineString(simplifiedFlatCoordinates, GeometryLayout.XY); return new LineString(simplifiedFlatCoordinates, 'XY');
} }
/** /**
@@ -294,7 +290,7 @@ class LineString extends SimpleGeometry {
/** /**
* Set the coordinates of the linestring. * Set the coordinates of the linestring.
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates. * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/LinearRing * @module ol/geom/LinearRing
*/ */
import GeometryLayout from './GeometryLayout.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';
@@ -21,7 +20,7 @@ class LinearRing extends SimpleGeometry {
/** /**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates. * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `opt_layout` are also accepted. * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
*/ */
constructor(coordinates, opt_layout) { constructor(coordinates, opt_layout) {
super(); super();
@@ -143,7 +142,7 @@ class LinearRing extends SimpleGeometry {
simplifiedFlatCoordinates, simplifiedFlatCoordinates,
0 0
); );
return new LinearRing(simplifiedFlatCoordinates, GeometryLayout.XY); return new LinearRing(simplifiedFlatCoordinates, 'XY');
} }
/** /**
@@ -168,7 +167,7 @@ class LinearRing extends SimpleGeometry {
/** /**
* Set the coordinates of the linear ring. * Set the coordinates of the linear ring.
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates. * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/MultiLineString * @module ol/geom/MultiLineString
*/ */
import GeometryLayout from './GeometryLayout.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';
@@ -27,7 +26,7 @@ class MultiLineString extends SimpleGeometry {
* @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates * @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates
* Coordinates or LineString geometries. (For internal use, flat coordinates in * Coordinates or LineString geometries. (For internal use, flat coordinates in
* combination with `opt_layout` and `opt_ends` are also accepted.) * combination with `opt_layout` and `opt_ends` are also accepted.)
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @param {Array<number>} [opt_ends] Flat coordinate ends for internal use. * @param {Array<number>} [opt_ends] Flat coordinate ends for internal use.
*/ */
constructor(coordinates, opt_layout, opt_ends) { constructor(coordinates, opt_layout, opt_ends) {
@@ -173,8 +172,7 @@ class MultiLineString extends SimpleGeometry {
*/ */
getCoordinateAtM(m, opt_extrapolate, opt_interpolate) { getCoordinateAtM(m, opt_extrapolate, opt_interpolate) {
if ( if (
(this.layout != GeometryLayout.XYM && (this.layout != 'XYM' && this.layout != 'XYZM') ||
this.layout != GeometryLayout.XYZM) ||
this.flatCoordinates.length === 0 this.flatCoordinates.length === 0
) { ) {
return null; return null;
@@ -298,11 +296,7 @@ class MultiLineString extends SimpleGeometry {
0, 0,
simplifiedEnds simplifiedEnds
); );
return new MultiLineString( return new MultiLineString(simplifiedFlatCoordinates, 'XY', simplifiedEnds);
simplifiedFlatCoordinates,
GeometryLayout.XY,
simplifiedEnds
);
} }
/** /**
@@ -333,7 +327,7 @@ class MultiLineString extends SimpleGeometry {
/** /**
* Set the coordinates of the multilinestring. * Set the coordinates of the multilinestring.
* @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates. * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
* @param {GeometryLayout} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {

View File

@@ -19,7 +19,7 @@ class MultiPoint extends SimpleGeometry {
/** /**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates. * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `opt_layout` are also accepted. * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
*/ */
constructor(coordinates, opt_layout) { constructor(coordinates, opt_layout) {
super(); super();
@@ -182,7 +182,7 @@ class MultiPoint extends SimpleGeometry {
/** /**
* Set the coordinates of the multipoint. * Set the coordinates of the multipoint.
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates. * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/MultiPolygon * @module ol/geom/MultiPolygon
*/ */
import GeometryLayout from './GeometryLayout.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';
@@ -34,7 +33,7 @@ class MultiPolygon extends SimpleGeometry {
/** /**
* @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates. * @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `opt_layout` and `opt_endss` are also accepted. * For internal use, flat coordinates in combination with `opt_layout` and `opt_endss` are also accepted.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @param {Array<Array<number>>} [opt_endss] Array of ends for internal use with flat coordinates. * @param {Array<Array<number>>} [opt_endss] Array of ends for internal use with flat coordinates.
*/ */
constructor(coordinates, opt_layout, opt_endss) { constructor(coordinates, opt_layout, opt_endss) {
@@ -306,10 +305,7 @@ class MultiPolygon extends SimpleGeometry {
* @api * @api
*/ */
getInteriorPoints() { getInteriorPoints() {
return new MultiPoint( return new MultiPoint(this.getFlatInteriorPoints().slice(), 'XYM');
this.getFlatInteriorPoints().slice(),
GeometryLayout.XYM
);
} }
/** /**
@@ -354,11 +350,7 @@ class MultiPolygon extends SimpleGeometry {
0, 0,
simplifiedEndss simplifiedEndss
); );
return new MultiPolygon( return new MultiPolygon(simplifiedFlatCoordinates, 'XY', simplifiedEndss);
simplifiedFlatCoordinates,
GeometryLayout.XY,
simplifiedEndss
);
} }
/** /**
@@ -450,7 +442,7 @@ class MultiPolygon extends SimpleGeometry {
/** /**
* Set the coordinates of the multipolygon. * Set the coordinates of the multipolygon.
* @param {!Array<Array<Array<import("../coordinate.js").Coordinate>>>} coordinates Coordinates. * @param {!Array<Array<Array<import("../coordinate.js").Coordinate>>>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {

View File

@@ -15,7 +15,7 @@ import {squaredDistance as squaredDx} from '../math.js';
class Point extends SimpleGeometry { class Point extends SimpleGeometry {
/** /**
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates. * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
*/ */
constructor(coordinates, opt_layout) { constructor(coordinates, opt_layout) {
super(); super();
@@ -99,7 +99,7 @@ class Point extends SimpleGeometry {
/** /**
* @param {!Array<*>} coordinates Coordinates. * @param {!Array<*>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Polygon * @module ol/geom/Polygon
*/ */
import GeometryLayout from './GeometryLayout.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';
@@ -34,7 +33,7 @@ class Polygon extends SimpleGeometry {
* an array of vertices' coordinates where the first coordinate and the last are * an array of vertices' coordinates where the first coordinate and the last are
* equivalent. (For internal use, flat coordinates in combination with * equivalent. (For internal use, flat coordinates in combination with
* `opt_layout` and `opt_ends` are also accepted.) * `opt_layout` and `opt_ends` are also accepted.)
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @param {Array<number>} [opt_ends] Ends (for internal use with flat coordinates). * @param {Array<number>} [opt_ends] Ends (for internal use with flat coordinates).
*/ */
constructor(coordinates, opt_layout, opt_ends) { constructor(coordinates, opt_layout, opt_ends) {
@@ -253,7 +252,7 @@ class Polygon extends SimpleGeometry {
* @api * @api
*/ */
getInteriorPoint() { getInteriorPoint() {
return new Point(this.getFlatInteriorPoint(), GeometryLayout.XYM); return new Point(this.getFlatInteriorPoint(), 'XYM');
} }
/** /**
@@ -353,11 +352,7 @@ class Polygon extends SimpleGeometry {
0, 0,
simplifiedEnds simplifiedEnds
); );
return new Polygon( return new Polygon(simplifiedFlatCoordinates, 'XY', simplifiedEnds);
simplifiedFlatCoordinates,
GeometryLayout.XY,
simplifiedEnds
);
} }
/** /**
@@ -388,7 +383,7 @@ class Polygon extends SimpleGeometry {
/** /**
* Set the coordinates of the polygon. * Set the coordinates of the polygon.
* @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates. * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api * @api
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {
@@ -433,9 +428,7 @@ export function circular(center, radius, opt_n, opt_sphereRadius) {
); );
} }
flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]); flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
return new Polygon(flatCoordinates, GeometryLayout.XY, [ return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);
flatCoordinates.length,
]);
} }
/** /**
@@ -461,9 +454,7 @@ export function fromExtent(extent) {
minX, minX,
minY, minY,
]; ];
return new Polygon(flatCoordinates, GeometryLayout.XY, [ return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);
flatCoordinates.length,
]);
} }
/** /**

View File

@@ -2,7 +2,6 @@
* @module ol/geom/SimpleGeometry * @module ol/geom/SimpleGeometry
*/ */
import Geometry from './Geometry.js'; import Geometry from './Geometry.js';
import GeometryLayout from './GeometryLayout.js';
import {abstract} from '../util.js'; import {abstract} from '../util.js';
import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js'; import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
import {rotate, scale, transform2D, translate} from './flat/transform.js'; import {rotate, scale, transform2D, translate} from './flat/transform.js';
@@ -21,9 +20,9 @@ class SimpleGeometry extends Geometry {
/** /**
* @protected * @protected
* @type {import("./GeometryLayout.js").default} * @type {import("./Geometry.js").GeometryLayout}
*/ */
this.layout = GeometryLayout.XY; this.layout = 'XY';
/** /**
* @protected * @protected
@@ -89,8 +88,8 @@ class SimpleGeometry extends Geometry {
} }
/** /**
* Return the {@link module:ol/geom/GeometryLayout layout} of the geometry. * Return the {@link import("./Geometry.js").GeometryLayout layout} of the geometry.
* @return {import("./GeometryLayout.js").default} Layout. * @return {import("./Geometry.js").GeometryLayout} Layout.
* @api * @api
*/ */
getLayout() { getLayout() {
@@ -151,7 +150,7 @@ class SimpleGeometry extends Geometry {
} }
/** /**
* @param {import("./GeometryLayout.js").default} layout Layout. * @param {import("./Geometry.js").GeometryLayout} layout Layout.
* @param {Array<number>} flatCoordinates Flat coordinates. * @param {Array<number>} flatCoordinates Flat coordinates.
*/ */
setFlatCoordinates(layout, flatCoordinates) { setFlatCoordinates(layout, flatCoordinates) {
@@ -163,14 +162,14 @@ class SimpleGeometry extends Geometry {
/** /**
* @abstract * @abstract
* @param {!Array<*>} coordinates Coordinates. * @param {!Array<*>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout. * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
*/ */
setCoordinates(coordinates, opt_layout) { setCoordinates(coordinates, opt_layout) {
abstract(); abstract();
} }
/** /**
* @param {import("./GeometryLayout.js").default|undefined} layout Layout. * @param {import("./Geometry.js").GeometryLayout|undefined} layout Layout.
* @param {Array<*>} coordinates Coordinates. * @param {Array<*>} coordinates Coordinates.
* @param {number} nesting Nesting. * @param {number} nesting Nesting.
* @protected * @protected
@@ -183,7 +182,7 @@ class SimpleGeometry extends Geometry {
} else { } else {
for (let i = 0; i < nesting; ++i) { for (let i = 0; i < nesting; ++i) {
if (coordinates.length === 0) { if (coordinates.length === 0) {
this.layout = GeometryLayout.XY; this.layout = 'XY';
this.stride = 2; this.stride = 2;
return; return;
} else { } else {
@@ -299,31 +298,31 @@ class SimpleGeometry extends Geometry {
/** /**
* @param {number} stride Stride. * @param {number} stride Stride.
* @return {import("./GeometryLayout.js").default} layout Layout. * @return {import("./Geometry.js").GeometryLayout} layout Layout.
*/ */
function getLayoutForStride(stride) { function getLayoutForStride(stride) {
let layout; let layout;
if (stride == 2) { if (stride == 2) {
layout = GeometryLayout.XY; layout = 'XY';
} else if (stride == 3) { } else if (stride == 3) {
layout = GeometryLayout.XYZ; layout = 'XYZ';
} else if (stride == 4) { } else if (stride == 4) {
layout = GeometryLayout.XYZM; layout = 'XYZM';
} }
return /** @type {import("./GeometryLayout.js").default} */ (layout); return /** @type {import("./Geometry.js").GeometryLayout} */ (layout);
} }
/** /**
* @param {import("./GeometryLayout.js").default} layout Layout. * @param {import("./Geometry.js").GeometryLayout} layout Layout.
* @return {number} Stride. * @return {number} Stride.
*/ */
export function getStrideForLayout(layout) { export function getStrideForLayout(layout) {
let stride; let stride;
if (layout == GeometryLayout.XY) { if (layout == 'XY') {
stride = 2; stride = 2;
} else if (layout == GeometryLayout.XYZ || layout == GeometryLayout.XYM) { } else if (layout == 'XYZ' || layout == 'XYM') {
stride = 3; stride = 3;
} else if (layout == GeometryLayout.XYZM) { } else if (layout == 'XYZM') {
stride = 4; stride = 4;
} }
return /** @type {number} */ (stride); return /** @type {number} */ (stride);

View File

@@ -5,7 +5,6 @@ import Circle from '../geom/Circle.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 GeometryLayout from '../geom/GeometryLayout.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';
@@ -83,7 +82,7 @@ import {squaredDistance as squaredCoordinateDistance} from '../coordinate.js';
* Shift key activates freehand drawing. * Shift key activates freehand drawing.
* @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch * @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch
* overlay. * overlay.
* @property {GeometryLayout} [geometryLayout='XY'] Layout of the * @property {import("../geom/Geometry.js").GeometryLayout} [geometryLayout='XY'] Layout of the
* feature geometries created by the draw interaction. * feature geometries created by the draw interaction.
*/ */
@@ -340,11 +339,11 @@ class Draw extends PointerInteraction {
/** /**
* @private * @private
* @type {import("../geom/GeometryLayout").default} * @type {import("../geom/Geometry.js").GeometryLayout}
*/ */
this.geometryLayout_ = options.geometryLayout this.geometryLayout_ = options.geometryLayout
? options.geometryLayout ? options.geometryLayout
: GeometryLayout.XY; : 'XY';
let geometryFunction = options.geometryFunction; let geometryFunction = options.geometryFunction;
if (!geometryFunction) { if (!geometryFunction) {

View File

@@ -5,7 +5,6 @@ import Collection from '../Collection.js';
import EventType from '../render/EventType.js'; import EventType from '../render/EventType.js';
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import Fill from '../style/Fill.js'; import Fill from '../style/Fill.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js'; import LineString from '../geom/LineString.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Stroke from '../style/Stroke.js'; import Stroke from '../style/Stroke.js';
@@ -1037,10 +1036,10 @@ class Graticule extends VectorLayer {
); );
let lineString = this.meridians_[index]; let lineString = this.meridians_[index];
if (!lineString) { if (!lineString) {
lineString = new LineString(flatCoordinates, GeometryLayout.XY); lineString = new LineString(flatCoordinates, 'XY');
this.meridians_[index] = lineString; this.meridians_[index] = lineString;
} else { } else {
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates); lineString.setFlatCoordinates('XY', flatCoordinates);
lineString.changed(); lineString.changed();
} }
return lineString; return lineString;
@@ -1107,9 +1106,9 @@ class Graticule extends VectorLayer {
); );
let lineString = this.parallels_[index]; let lineString = this.parallels_[index];
if (!lineString) { if (!lineString) {
lineString = new LineString(flatCoordinates, GeometryLayout.XY); lineString = new LineString(flatCoordinates, 'XY');
} else { } else {
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates); lineString.setFlatCoordinates('XY', flatCoordinates);
lineString.changed(); lineString.changed();
} }
return lineString; return lineString;

View File

@@ -2,7 +2,6 @@
* @module ol/render/Feature * @module ol/render/Feature
*/ */
import Feature from '../Feature.js'; import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import { import {
LineString, LineString,
MultiLineString, MultiLineString,
@@ -350,19 +349,13 @@ export function toGeometry(renderFeature) {
case 'Point': case 'Point':
return new Point(renderFeature.getFlatCoordinates()); return new Point(renderFeature.getFlatCoordinates());
case 'MultiPoint': case 'MultiPoint':
return new MultiPoint( return new MultiPoint(renderFeature.getFlatCoordinates(), 'XY');
renderFeature.getFlatCoordinates(),
GeometryLayout.XY
);
case 'LineString': case 'LineString':
return new LineString( return new LineString(renderFeature.getFlatCoordinates(), 'XY');
renderFeature.getFlatCoordinates(),
GeometryLayout.XY
);
case 'MultiLineString': case 'MultiLineString':
return new MultiLineString( return new MultiLineString(
renderFeature.getFlatCoordinates(), renderFeature.getFlatCoordinates(),
GeometryLayout.XY, 'XY',
/** @type {Array<number>} */ (renderFeature.getEnds()) /** @type {Array<number>} */ (renderFeature.getEnds())
); );
case 'Polygon': case 'Polygon':
@@ -370,8 +363,8 @@ export function toGeometry(renderFeature) {
const ends = /** @type {Array<number>} */ (renderFeature.getEnds()); const ends = /** @type {Array<number>} */ (renderFeature.getEnds());
const endss = inflateEnds(flatCoordinates, ends); const endss = inflateEnds(flatCoordinates, ends);
return endss.length > 1 return endss.length > 1
? new MultiPolygon(flatCoordinates, GeometryLayout.XY, endss) ? new MultiPolygon(flatCoordinates, 'XY', endss)
: new Polygon(flatCoordinates, GeometryLayout.XY, ends); : new Polygon(flatCoordinates, 'XY', ends);
default: default:
throw new Error('Invalid geometry type:' + geometryType); throw new Error('Invalid geometry type:' + geometryType);
} }

View File

@@ -4,7 +4,6 @@ import Draw, {
createRegularPolygon, createRegularPolygon,
} 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 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';
@@ -2027,83 +2026,83 @@ describe('ol.interaction.Draw', function () {
} }
it('respects XY layout for POINT type', function () { it('respects XY layout for POINT type', function () {
drawPoint(GeometryLayout.XY); drawPoint('XY');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([10, -20]); expect(geometry.getCoordinates()).to.eql([10, -20]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XY); expect(geometry.getLayout()).to.eql('XY');
}); });
it('respects XYZ layout for POINT type', function () { it('respects XYZ layout for POINT type', function () {
drawPoint(GeometryLayout.XYZ); drawPoint('XYZ');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([10, -20, 0]); expect(geometry.getCoordinates()).to.eql([10, -20, 0]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZ); expect(geometry.getLayout()).to.eql('XYZ');
}); });
it('respects XYM layout for POINT type', function () { it('respects XYM layout for POINT type', function () {
drawPoint(GeometryLayout.XYM); drawPoint('XYM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([10, -20, 0]); expect(geometry.getCoordinates()).to.eql([10, -20, 0]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYM); expect(geometry.getLayout()).to.eql('XYM');
}); });
it('respects XYZM layout for POINT type', function () { it('respects XYZM layout for POINT type', function () {
drawPoint(GeometryLayout.XYZM); drawPoint('XYZM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([10, -20, 0, 0]); expect(geometry.getCoordinates()).to.eql([10, -20, 0, 0]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZM); expect(geometry.getLayout()).to.eql('XYZM');
}); });
it('respects XY layout for LINESTRING type', function () { it('respects XY layout for LINESTRING type', function () {
drawLineString(GeometryLayout.XY); drawLineString('XY');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
[10, -20], [10, -20],
[30, -20], [30, -20],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XY); expect(geometry.getLayout()).to.eql('XY');
}); });
it('respects XYZ layout for LINESTRING type', function () { it('respects XYZ layout for LINESTRING type', function () {
drawLineString(GeometryLayout.XYZ); drawLineString('XYZ');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
[10, -20, 0], [10, -20, 0],
[30, -20, 0], [30, -20, 0],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZ); expect(geometry.getLayout()).to.eql('XYZ');
}); });
it('respects XYM layout for LINESTRING type', function () { it('respects XYM layout for LINESTRING type', function () {
drawLineString(GeometryLayout.XYM); drawLineString('XYM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
[10, -20, 0], [10, -20, 0],
[30, -20, 0], [30, -20, 0],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYM); expect(geometry.getLayout()).to.eql('XYM');
}); });
it('respects XYZM layout for LINESTRING type', function () { it('respects XYZM layout for LINESTRING type', function () {
drawLineString(GeometryLayout.XYZM); drawLineString('XYZM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
[10, -20, 0, 0], [10, -20, 0, 0],
[30, -20, 0, 0], [30, -20, 0, 0],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZM); expect(geometry.getLayout()).to.eql('XYZM');
}); });
it('respects XY layout for POLYGON type', function () { it('respects XY layout for POLYGON type', function () {
drawPolygon(GeometryLayout.XY); drawPolygon('XY');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
@@ -2114,11 +2113,11 @@ describe('ol.interaction.Draw', function () {
[10, -20], [10, -20],
], ],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XY); expect(geometry.getLayout()).to.eql('XY');
}); });
it('respects XYZ layout for POLYGON type', function () { it('respects XYZ layout for POLYGON type', function () {
drawPolygon(GeometryLayout.XYZ); drawPolygon('XYZ');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
@@ -2129,11 +2128,11 @@ describe('ol.interaction.Draw', function () {
[10, -20, 0], [10, -20, 0],
], ],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZ); expect(geometry.getLayout()).to.eql('XYZ');
}); });
it('respects XYM layout for POLYGON type', function () { it('respects XYM layout for POLYGON type', function () {
drawPolygon(GeometryLayout.XYM); drawPolygon('XYM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
@@ -2144,11 +2143,11 @@ describe('ol.interaction.Draw', function () {
[10, -20, 0], [10, -20, 0],
], ],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYM); expect(geometry.getLayout()).to.eql('XYM');
}); });
it('respects XYZM layout for POLYGON type', function () { it('respects XYZM layout for POLYGON type', function () {
drawPolygon(GeometryLayout.XYZM); drawPolygon('XYZM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCoordinates()).to.eql([ expect(geometry.getCoordinates()).to.eql([
@@ -2159,43 +2158,43 @@ describe('ol.interaction.Draw', function () {
[10, -20, 0, 0], [10, -20, 0, 0],
], ],
]); ]);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZM); expect(geometry.getLayout()).to.eql('XYZM');
}); });
it('respects XY layout for CIRCLE type', function () { it('respects XY layout for CIRCLE type', function () {
drawCircle(GeometryLayout.XY); drawCircle('XY');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCenter()).to.eql([10, -20]); expect(geometry.getCenter()).to.eql([10, -20]);
expect(geometry.getRadius()).to.eql(20); expect(geometry.getRadius()).to.eql(20);
expect(geometry.getLayout()).to.eql(GeometryLayout.XY); expect(geometry.getLayout()).to.eql('XY');
}); });
it('respects XYZ layout for CIRCLE type', function () { it('respects XYZ layout for CIRCLE type', function () {
drawCircle(GeometryLayout.XYZ); drawCircle('XYZ');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCenter()).to.eql([10, -20, 0]); expect(geometry.getCenter()).to.eql([10, -20, 0]);
expect(geometry.getRadius()).to.eql(20); expect(geometry.getRadius()).to.eql(20);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZ); expect(geometry.getLayout()).to.eql('XYZ');
}); });
it('respects XYM layout for CIRCLE type', function () { it('respects XYM layout for CIRCLE type', function () {
drawCircle(GeometryLayout.XYM); drawCircle('XYM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCenter()).to.eql([10, -20, 0]); expect(geometry.getCenter()).to.eql([10, -20, 0]);
expect(geometry.getRadius()).to.eql(20); expect(geometry.getRadius()).to.eql(20);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYM); expect(geometry.getLayout()).to.eql('XYM');
}); });
it('respects XYZM layout for CIRCLE type', function () { it('respects XYZM layout for CIRCLE type', function () {
drawCircle(GeometryLayout.XYZM); drawCircle('XYZM');
const features = source.getFeatures(); const features = source.getFeatures();
const geometry = features[0].getGeometry(); const geometry = features[0].getGeometry();
expect(geometry.getCenter()).to.eql([10, -20, 0, 0]); expect(geometry.getCenter()).to.eql([10, -20, 0, 0]);
expect(geometry.getRadius()).to.eql(20); expect(geometry.getRadius()).to.eql(20);
expect(geometry.getLayout()).to.eql(GeometryLayout.XYZM); expect(geometry.getLayout()).to.eql('XYZM');
}); });
}); });
}); });