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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,6 @@
* @module ol/format/Polyline
*/
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import TextFeature from './TextFeature.js';
import {assert} from '../asserts.js';
@@ -15,7 +14,7 @@ import {transformGeometryWithOptions} from './Feature.js';
/**
* @typedef {Object} Options
* @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.
*/
@@ -55,11 +54,11 @@ class Polyline extends TextFeature {
/**
* @private
* @type {import("../geom/GeometryLayout").default}
* @type {import("../geom/Geometry.js").GeometryLayout}
*/
this.geometryLayout_ = options.geometryLayout
? options.geometryLayout
: GeometryLayout.XY;
: 'XY';
}
/**

View File

@@ -4,7 +4,6 @@
import Feature from '../Feature.js';
import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
@@ -53,17 +52,50 @@ class WkbReader {
* @param {DataView} view source to read
*/
constructor(view) {
/** @private */
this.view_ = view;
/**
* @type {number}
* @private
*/
this.pos_ = 0;
/**
* @type {boolean}
* @private
*/
this.initialized_ = false;
/**
* @type {boolean}
* @private
*/
this.isLittleEndian_ = false;
/**
* @type {boolean}
* @private
*/
this.hasZ_ = false;
/**
* @type {boolean}
* @private
*/
this.hasM_ = false;
/** @type {number|null} */
/**
* @type {number|null}
* @private
*/
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;
const hasSRID = Boolean(wkbType & 0x20000000);
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;
@@ -415,7 +449,7 @@ class WkbWriter {
/**
* @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) {
/**
@@ -439,7 +473,7 @@ class WkbWriter {
/**
* @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) {
this.writeUint32(coords.length); // numPoints
@@ -450,7 +484,7 @@ class WkbWriter {
/**
* @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) {
this.writeUint32(rings.length); // numRings
@@ -484,7 +518,7 @@ class WkbWriter {
/**
* @param {Array<import('../coordinate.js').Coordinate>} coords coords
* @param {string} layout layout
* @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/
writeMultiPoint(coords, layout) {
this.writeUint32(coords.length); // numItems
@@ -496,7 +530,7 @@ class WkbWriter {
/**
* @param {Array<Array<import('../coordinate.js').Coordinate>>} coords coords
* @param {string} layout layout
* @param {import("../geom/Geometry.js").GeometryLayout} layout layout
*/
writeMultiLineString(coords, layout) {
this.writeUint32(coords.length); // numItems
@@ -508,7 +542,7 @@ class WkbWriter {
/**
* @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) {
this.writeUint32(coords.length); // numItems
@@ -531,31 +565,31 @@ class WkbWriter {
/**
* @param {import("../geom/Geometry.js").default} geom geometry
* @param {import("../geom/GeometryLayout.js").default} [layout] layout
* @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes
* @param {import("../geom/Geometry.js").GeometryLayout} [layout] layout
* @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/GeometryLayout.js").default} b B
* @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes
* @param {import("../geom/Geometry.js").GeometryLayout} a A
* @param {import("../geom/Geometry.js").GeometryLayout} b B
* @return {import("../geom/Geometry.js").GeometryLayout} minumum layout made by common axes
*/
const GeometryLayout_min = (a, b) => {
if (a === b) {
return a;
}
if (a === GeometryLayout.XYZM) {
if (a === 'XYZM') {
// anything `b` is minimum
return b;
}
if (b === GeometryLayout.XYZM) {
if (b === 'XYZM') {
// anything `a` is minimum
return a;
}
// otherwise, incompatible
return GeometryLayout.XY;
return 'XY';
};
if (geom instanceof SimpleGeometry) {
@@ -564,7 +598,7 @@ class WkbWriter {
if (geom instanceof GeometryCollection) {
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);
}
}
@@ -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} [littleEndian=true] Use littleEndian 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} [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`.

View File

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

View File

@@ -18,7 +18,7 @@ class Circle extends SimpleGeometry {
* For internal use, flat coordinates in combination with `opt_layout` and no
* `opt_radius` are also accepted.
* @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) {
super();
@@ -188,7 +188,7 @@ class Circle extends SimpleGeometry {
* number) of the circle.
* @param {!import("../coordinate.js").Coordinate} center Center.
* @param {number} radius Radius.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
* @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
* @api
*/
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 {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
* 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
*/
import GeometryLayout from './GeometryLayout.js';
import SimpleGeometry from './SimpleGeometry.js';
import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
import {closestSquaredDistanceXY} from '../extent.js';
@@ -24,7 +23,7 @@ class LineString extends SimpleGeometry {
/**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* 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) {
super();
@@ -169,10 +168,7 @@ class LineString extends SimpleGeometry {
* @api
*/
getCoordinateAtM(m, opt_extrapolate) {
if (
this.layout != GeometryLayout.XYM &&
this.layout != GeometryLayout.XYZM
) {
if (this.layout != 'XYM' && this.layout != 'XYZM') {
return null;
}
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
@@ -263,7 +259,7 @@ class LineString extends SimpleGeometry {
simplifiedFlatCoordinates,
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.
* @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
*/
setCoordinates(coordinates, opt_layout) {

View File

@@ -1,7 +1,6 @@
/**
* @module ol/geom/LinearRing
*/
import GeometryLayout from './GeometryLayout.js';
import SimpleGeometry from './SimpleGeometry.js';
import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
import {closestSquaredDistanceXY} from '../extent.js';
@@ -21,7 +20,7 @@ class LinearRing extends SimpleGeometry {
/**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* 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) {
super();
@@ -143,7 +142,7 @@ class LinearRing extends SimpleGeometry {
simplifiedFlatCoordinates,
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.
* @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
*/
setCoordinates(coordinates, opt_layout) {

View File

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

View File

@@ -19,7 +19,7 @@ class MultiPoint extends SimpleGeometry {
/**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* 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) {
super();
@@ -182,7 +182,7 @@ class MultiPoint extends SimpleGeometry {
/**
* Set the coordinates of the multipoint.
* @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
*/
setCoordinates(coordinates, opt_layout) {

View File

@@ -1,7 +1,6 @@
/**
* @module ol/geom/MultiPolygon
*/
import GeometryLayout from './GeometryLayout.js';
import MultiPoint from './MultiPoint.js';
import Polygon from './Polygon.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.
* 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.
*/
constructor(coordinates, opt_layout, opt_endss) {
@@ -306,10 +305,7 @@ class MultiPolygon extends SimpleGeometry {
* @api
*/
getInteriorPoints() {
return new MultiPoint(
this.getFlatInteriorPoints().slice(),
GeometryLayout.XYM
);
return new MultiPoint(this.getFlatInteriorPoints().slice(), 'XYM');
}
/**
@@ -354,11 +350,7 @@ class MultiPolygon extends SimpleGeometry {
0,
simplifiedEndss
);
return new MultiPolygon(
simplifiedFlatCoordinates,
GeometryLayout.XY,
simplifiedEndss
);
return new MultiPolygon(simplifiedFlatCoordinates, 'XY', simplifiedEndss);
}
/**
@@ -450,7 +442,7 @@ class MultiPolygon extends SimpleGeometry {
/**
* Set the coordinates of the multipolygon.
* @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
*/
setCoordinates(coordinates, opt_layout) {

View File

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

View File

@@ -1,7 +1,6 @@
/**
* @module ol/geom/Polygon
*/
import GeometryLayout from './GeometryLayout.js';
import LinearRing from './LinearRing.js';
import Point from './Point.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
* equivalent. (For internal use, flat coordinates in 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] Ends (for internal use with flat coordinates).
*/
constructor(coordinates, opt_layout, opt_ends) {
@@ -253,7 +252,7 @@ class Polygon extends SimpleGeometry {
* @api
*/
getInteriorPoint() {
return new Point(this.getFlatInteriorPoint(), GeometryLayout.XYM);
return new Point(this.getFlatInteriorPoint(), 'XYM');
}
/**
@@ -353,11 +352,7 @@ class Polygon extends SimpleGeometry {
0,
simplifiedEnds
);
return new Polygon(
simplifiedFlatCoordinates,
GeometryLayout.XY,
simplifiedEnds
);
return new Polygon(simplifiedFlatCoordinates, 'XY', simplifiedEnds);
}
/**
@@ -388,7 +383,7 @@ class Polygon extends SimpleGeometry {
/**
* Set the coordinates of the polygon.
* @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
*/
setCoordinates(coordinates, opt_layout) {
@@ -433,9 +428,7 @@ export function circular(center, radius, opt_n, opt_sphereRadius) {
);
}
flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
return new Polygon(flatCoordinates, GeometryLayout.XY, [
flatCoordinates.length,
]);
return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);
}
/**
@@ -461,9 +454,7 @@ export function fromExtent(extent) {
minX,
minY,
];
return new Polygon(flatCoordinates, GeometryLayout.XY, [
flatCoordinates.length,
]);
return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);
}
/**

View File

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

View File

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

View File

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

View File

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

View File

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