Merge pull request #13858 from MoonE/replace-enums-with-typedef
Replace enums with typedef
This commit is contained in:
@@ -13,17 +13,9 @@ import {assert} from '../asserts.js';
|
|||||||
const UNITS_PROP = 'units';
|
const UNITS_PROP = 'units';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Units for the scale line. Supported values are `'degrees'`, `'imperial'`,
|
* @typedef {'degrees' | 'imperial' | 'nautical' | 'metric' | 'us'} Units
|
||||||
* `'nautical'`, `'metric'`, `'us'`.
|
* Units for the scale line.
|
||||||
* @enum {string}
|
|
||||||
*/
|
*/
|
||||||
export const Units = {
|
|
||||||
DEGREES: 'degrees',
|
|
||||||
IMPERIAL: 'imperial',
|
|
||||||
NAUTICAL: 'nautical',
|
|
||||||
METRIC: 'metric',
|
|
||||||
US: 'us',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
@@ -57,7 +49,7 @@ const DEFAULT_DPI = 25.4 / 0.28;
|
|||||||
* should be re-rendered. This is called in a `requestAnimationFrame` callback.
|
* should be re-rendered. This is called in a `requestAnimationFrame` callback.
|
||||||
* @property {HTMLElement|string} [target] Specify a target if you want the control
|
* @property {HTMLElement|string} [target] Specify a target if you want the control
|
||||||
* to be rendered outside of the map's viewport.
|
* to be rendered outside of the map's viewport.
|
||||||
* @property {import("./ScaleLine.js").Units|string} [units='metric'] Units.
|
* @property {Units} [units='metric'] Units.
|
||||||
* @property {boolean} [bar=false] Render scalebars instead of a line.
|
* @property {boolean} [bar=false] Render scalebars instead of a line.
|
||||||
* @property {number} [steps=4] Number of steps the scalebar should use. Use even numbers
|
* @property {number} [steps=4] Number of steps the scalebar should use. Use even numbers
|
||||||
* for best results. Only applies when `bar` is `true`.
|
* for best results. Only applies when `bar` is `true`.
|
||||||
@@ -164,7 +156,7 @@ class ScaleLine extends Control {
|
|||||||
|
|
||||||
this.addChangeListener(UNITS_PROP, this.handleUnitsChanged_);
|
this.addChangeListener(UNITS_PROP, this.handleUnitsChanged_);
|
||||||
|
|
||||||
this.setUnits(options.units || Units.METRIC);
|
this.setUnits(options.units || 'metric');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -193,7 +185,7 @@ class ScaleLine extends Control {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the units to use in the scale line.
|
* Return the units to use in the scale line.
|
||||||
* @return {import("./ScaleLine.js").Units} The units
|
* @return {Units} The units
|
||||||
* to use in the scale line.
|
* to use in the scale line.
|
||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
@@ -211,7 +203,7 @@ class ScaleLine extends Control {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the units to use in the scale line.
|
* Set the units to use in the scale line.
|
||||||
* @param {import("./ScaleLine.js").Units} units The units to use in the scale line.
|
* @param {Units} units The units to use in the scale line.
|
||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -246,7 +238,7 @@ class ScaleLine extends Control {
|
|||||||
const projection = viewState.projection;
|
const projection = viewState.projection;
|
||||||
const units = this.getUnits();
|
const units = this.getUnits();
|
||||||
const pointResolutionUnits =
|
const pointResolutionUnits =
|
||||||
units == Units.DEGREES ? ProjUnits.DEGREES : ProjUnits.METERS;
|
units == 'degrees' ? ProjUnits.DEGREES : ProjUnits.METERS;
|
||||||
let pointResolution = getPointResolution(
|
let pointResolution = getPointResolution(
|
||||||
projection,
|
projection,
|
||||||
viewState.resolution,
|
viewState.resolution,
|
||||||
@@ -264,7 +256,7 @@ class ScaleLine extends Control {
|
|||||||
|
|
||||||
let nominalCount = minWidth * pointResolution;
|
let nominalCount = minWidth * pointResolution;
|
||||||
let suffix = '';
|
let suffix = '';
|
||||||
if (units == Units.DEGREES) {
|
if (units == 'degrees') {
|
||||||
const metersPerDegree = METERS_PER_UNIT[ProjUnits.DEGREES];
|
const metersPerDegree = METERS_PER_UNIT[ProjUnits.DEGREES];
|
||||||
nominalCount *= metersPerDegree;
|
nominalCount *= metersPerDegree;
|
||||||
if (nominalCount < metersPerDegree / 60) {
|
if (nominalCount < metersPerDegree / 60) {
|
||||||
@@ -276,7 +268,7 @@ class ScaleLine extends Control {
|
|||||||
} else {
|
} else {
|
||||||
suffix = '\u00b0'; // degrees
|
suffix = '\u00b0'; // degrees
|
||||||
}
|
}
|
||||||
} else if (units == Units.IMPERIAL) {
|
} else if (units == 'imperial') {
|
||||||
if (nominalCount < 0.9144) {
|
if (nominalCount < 0.9144) {
|
||||||
suffix = 'in';
|
suffix = 'in';
|
||||||
pointResolution /= 0.0254;
|
pointResolution /= 0.0254;
|
||||||
@@ -287,10 +279,10 @@ class ScaleLine extends Control {
|
|||||||
suffix = 'mi';
|
suffix = 'mi';
|
||||||
pointResolution /= 1609.344;
|
pointResolution /= 1609.344;
|
||||||
}
|
}
|
||||||
} else if (units == Units.NAUTICAL) {
|
} else if (units == 'nautical') {
|
||||||
pointResolution /= 1852;
|
pointResolution /= 1852;
|
||||||
suffix = 'NM';
|
suffix = 'NM';
|
||||||
} else if (units == Units.METRIC) {
|
} else if (units == 'metric') {
|
||||||
if (nominalCount < 0.001) {
|
if (nominalCount < 0.001) {
|
||||||
suffix = 'μm';
|
suffix = 'μm';
|
||||||
pointResolution *= 1000000;
|
pointResolution *= 1000000;
|
||||||
@@ -303,7 +295,7 @@ class ScaleLine extends Control {
|
|||||||
suffix = 'km';
|
suffix = 'km';
|
||||||
pointResolution /= 1000;
|
pointResolution /= 1000;
|
||||||
}
|
}
|
||||||
} else if (units == Units.US) {
|
} else if (units == 'us') {
|
||||||
if (nominalCount < 0.9144) {
|
if (nominalCount < 0.9144) {
|
||||||
suffix = 'in';
|
suffix = 'in';
|
||||||
pointResolution *= 39.37;
|
pointResolution *= 39.37;
|
||||||
|
|||||||
@@ -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',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,15 @@
|
|||||||
* @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';
|
||||||
import {transformGeometryWithOptions} from './Feature.js';
|
import {transformGeometryWithOptions} from './Feature.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @typedef {'barometric' | 'gps' | 'none'} IGCZ
|
||||||
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
||||||
* @enum {string}
|
|
||||||
*/
|
*/
|
||||||
const IGCZ = {
|
|
||||||
BAROMETRIC: 'barometric',
|
|
||||||
GPS: 'gps',
|
|
||||||
NONE: 'none',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
@@ -47,7 +41,7 @@ const NEWLINE_RE = /\r\n|\r|\n/;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
* @property {IGCZ|string} [altitudeMode='none'] Altitude mode. Possible
|
* @property {IGCZ} [altitudeMode='none'] Altitude mode. Possible
|
||||||
* values are `'barometric'`, `'gps'`, and `'none'`.
|
* values are `'barometric'`, `'gps'`, and `'none'`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -79,9 +73,7 @@ class IGC extends TextFeature {
|
|||||||
* @private
|
* @private
|
||||||
* @type {IGCZ}
|
* @type {IGCZ}
|
||||||
*/
|
*/
|
||||||
this.altitudeMode_ = options.altitudeMode
|
this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : 'none';
|
||||||
? options.altitudeMode
|
|
||||||
: IGCZ.NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,11 +111,11 @@ class IGC extends TextFeature {
|
|||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
flatCoordinates.push(x, y);
|
flatCoordinates.push(x, y);
|
||||||
if (altitudeMode != IGCZ.NONE) {
|
if (altitudeMode != 'none') {
|
||||||
let z;
|
let z;
|
||||||
if (altitudeMode == IGCZ.GPS) {
|
if (altitudeMode == 'gps') {
|
||||||
z = parseInt(m[11], 10);
|
z = parseInt(m[11], 10);
|
||||||
} else if (altitudeMode == IGCZ.BAROMETRIC) {
|
} else if (altitudeMode == 'barometric') {
|
||||||
z = parseInt(m[12], 10);
|
z = parseInt(m[12], 10);
|
||||||
} else {
|
} else {
|
||||||
z = 0;
|
z = 0;
|
||||||
@@ -155,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 == IGCZ.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)
|
||||||
|
|||||||
@@ -4,10 +4,7 @@
|
|||||||
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 IconOrigin from '../style/IconOrigin.js';
|
|
||||||
import ImageState from '../ImageState.js';
|
import ImageState from '../ImageState.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';
|
||||||
@@ -57,10 +54,10 @@ import {transformGeometryWithOptions} from './Feature.js';
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} Vec2
|
* @typedef {Object} Vec2
|
||||||
* @property {number} x X coordinate.
|
* @property {number} x X coordinate.
|
||||||
* @property {import("../style/IconAnchorUnits").default} xunits Units of x.
|
* @property {import("../style/Icon.js").IconAnchorUnits} xunits Units of x.
|
||||||
* @property {number} y Y coordinate.
|
* @property {number} y Y coordinate.
|
||||||
* @property {import("../style/IconAnchorUnits").default} yunits Units of Y.
|
* @property {import("../style/Icon.js").IconAnchorUnits} yunits Units of Y.
|
||||||
* @property {import("../style/IconOrigin.js").default} [origin] Origin.
|
* @property {import("../style/Icon.js").IconOrigin} [origin] Origin.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,12 +93,12 @@ const SCHEMA_LOCATION =
|
|||||||
'https://developers.google.com/kml/schema/kml22gx.xsd';
|
'https://developers.google.com/kml/schema/kml22gx.xsd';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object<string, import("../style/IconAnchorUnits").default>}
|
* @type {Object<string, import("../style/Icon.js").IconAnchorUnits>}
|
||||||
*/
|
*/
|
||||||
const ICON_ANCHOR_UNITS_MAP = {
|
const ICON_ANCHOR_UNITS_MAP = {
|
||||||
'fraction': IconAnchorUnits.FRACTION,
|
'fraction': 'fraction',
|
||||||
'pixels': IconAnchorUnits.PIXELS,
|
'pixels': 'pixels',
|
||||||
'insetPixels': IconAnchorUnits.PIXELS,
|
'insetPixels': 'pixels',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,12 +209,12 @@ export function getDefaultFillStyle() {
|
|||||||
let DEFAULT_IMAGE_STYLE_ANCHOR;
|
let DEFAULT_IMAGE_STYLE_ANCHOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import("../style/IconAnchorUnits").default}
|
* @type {import("../style/Icon.js").IconAnchorUnits}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS;
|
let DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import("../style/IconAnchorUnits").default}
|
* @type {import("../style/Icon.js").IconAnchorUnits}
|
||||||
*/
|
*/
|
||||||
let DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS;
|
let DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS;
|
||||||
|
|
||||||
@@ -324,9 +321,9 @@ function createStyleDefaults() {
|
|||||||
|
|
||||||
DEFAULT_IMAGE_STYLE_ANCHOR = [20, 2];
|
DEFAULT_IMAGE_STYLE_ANCHOR = [20, 2];
|
||||||
|
|
||||||
DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS = IconAnchorUnits.PIXELS;
|
DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS = 'pixels';
|
||||||
|
|
||||||
DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS = IconAnchorUnits.PIXELS;
|
DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS = 'pixels';
|
||||||
|
|
||||||
DEFAULT_IMAGE_STYLE_SIZE = [64, 64];
|
DEFAULT_IMAGE_STYLE_SIZE = [64, 64];
|
||||||
|
|
||||||
@@ -335,7 +332,7 @@ function createStyleDefaults() {
|
|||||||
|
|
||||||
DEFAULT_IMAGE_STYLE = new Icon({
|
DEFAULT_IMAGE_STYLE = new Icon({
|
||||||
anchor: DEFAULT_IMAGE_STYLE_ANCHOR,
|
anchor: DEFAULT_IMAGE_STYLE_ANCHOR,
|
||||||
anchorOrigin: IconOrigin.BOTTOM_LEFT,
|
anchorOrigin: 'bottom-left',
|
||||||
anchorXUnits: DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS,
|
anchorXUnits: DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS,
|
||||||
anchorYUnits: DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS,
|
anchorYUnits: DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS,
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
@@ -1175,18 +1172,19 @@ function readStyleURL(node) {
|
|||||||
function readVec2(node) {
|
function readVec2(node) {
|
||||||
const xunits = node.getAttribute('xunits');
|
const xunits = node.getAttribute('xunits');
|
||||||
const yunits = node.getAttribute('yunits');
|
const yunits = node.getAttribute('yunits');
|
||||||
|
/** @type {import('../style/Icon.js').IconOrigin} */
|
||||||
let origin;
|
let origin;
|
||||||
if (xunits !== 'insetPixels') {
|
if (xunits !== 'insetPixels') {
|
||||||
if (yunits !== 'insetPixels') {
|
if (yunits !== 'insetPixels') {
|
||||||
origin = IconOrigin.BOTTOM_LEFT;
|
origin = 'bottom-left';
|
||||||
} else {
|
} else {
|
||||||
origin = IconOrigin.TOP_LEFT;
|
origin = 'top-left';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (yunits !== 'insetPixels') {
|
if (yunits !== 'insetPixels') {
|
||||||
origin = IconOrigin.BOTTOM_RIGHT;
|
origin = 'bottom-right';
|
||||||
} else {
|
} else {
|
||||||
origin = IconOrigin.TOP_RIGHT;
|
origin = 'top-right';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -1267,7 +1265,8 @@ function iconStyleParser(node, objectStack) {
|
|||||||
src = DEFAULT_IMAGE_STYLE_SRC;
|
src = DEFAULT_IMAGE_STYLE_SRC;
|
||||||
}
|
}
|
||||||
let anchor, anchorXUnits, anchorYUnits;
|
let anchor, anchorXUnits, anchorYUnits;
|
||||||
let anchorOrigin = IconOrigin.BOTTOM_LEFT;
|
/** @type {import('../style/Icon.js').IconOrigin|undefined} */
|
||||||
|
let anchorOrigin = 'bottom-left';
|
||||||
const hotSpot = /** @type {Vec2|undefined} */ (object['hotSpot']);
|
const hotSpot = /** @type {Vec2|undefined} */ (object['hotSpot']);
|
||||||
if (hotSpot) {
|
if (hotSpot) {
|
||||||
anchor = [hotSpot.x, hotSpot.y];
|
anchor = [hotSpot.x, hotSpot.y];
|
||||||
@@ -1327,7 +1326,7 @@ function iconStyleParser(node, objectStack) {
|
|||||||
anchorYUnits: anchorYUnits,
|
anchorYUnits: anchorYUnits,
|
||||||
crossOrigin: this.crossOrigin_,
|
crossOrigin: this.crossOrigin_,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
offsetOrigin: IconOrigin.BOTTOM_LEFT,
|
offsetOrigin: 'bottom-left',
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
scale: scale,
|
scale: scale,
|
||||||
size: size,
|
size: size,
|
||||||
@@ -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
|
||||||
@@ -2628,9 +2627,9 @@ function writeIconStyle(node, style, objectStack) {
|
|||||||
if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) {
|
if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) {
|
||||||
const /** @type {Vec2} */ hotSpot = {
|
const /** @type {Vec2} */ hotSpot = {
|
||||||
x: anchor[0],
|
x: anchor[0],
|
||||||
xunits: IconAnchorUnits.PIXELS,
|
xunits: 'pixels',
|
||||||
y: size[1] - anchor[1],
|
y: size[1] - anchor[1],
|
||||||
yunits: IconAnchorUnits.PIXELS,
|
yunits: 'pixels',
|
||||||
};
|
};
|
||||||
properties['hotSpot'] = hotSpot;
|
properties['hotSpot'] = hotSpot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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} */ (
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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`.
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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'`,
|
||||||
|
|||||||
@@ -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',
|
|
||||||
};
|
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -118,16 +117,10 @@ import {squaredDistance as squaredCoordinateDistance} from '../coordinate.js';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @typedef {'Point' | 'LineString' | 'Polygon' | 'Circle'} Mode
|
||||||
* Draw mode. This collapses multi-part geometry types with their single-part
|
* Draw mode. This collapses multi-part geometry types with their single-part
|
||||||
* cousins.
|
* cousins.
|
||||||
* @enum {string}
|
|
||||||
*/
|
*/
|
||||||
const Mode = {
|
|
||||||
POINT: 'Point',
|
|
||||||
LINE_STRING: 'LineString',
|
|
||||||
POLYGON: 'Polygon',
|
|
||||||
CIRCLE: 'Circle',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
@@ -312,7 +305,7 @@ class Draw extends PointerInteraction {
|
|||||||
*/
|
*/
|
||||||
this.minPoints_ = options.minPoints
|
this.minPoints_ = options.minPoints
|
||||||
? options.minPoints
|
? options.minPoints
|
||||||
: this.mode_ === Mode.POLYGON
|
: this.mode_ === 'Polygon'
|
||||||
? 3
|
? 3
|
||||||
: 2;
|
: 2;
|
||||||
|
|
||||||
@@ -323,7 +316,7 @@ class Draw extends PointerInteraction {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxPoints_ =
|
this.maxPoints_ =
|
||||||
this.mode_ === Mode.CIRCLE
|
this.mode_ === 'Circle'
|
||||||
? 2
|
? 2
|
||||||
: options.maxPoints
|
: options.maxPoints
|
||||||
? options.maxPoints
|
? options.maxPoints
|
||||||
@@ -340,16 +333,16 @@ 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) {
|
||||||
const mode = this.mode_;
|
const mode = this.mode_;
|
||||||
if (mode === Mode.CIRCLE) {
|
if (mode === 'Circle') {
|
||||||
/**
|
/**
|
||||||
* @param {!LineCoordType} coordinates The coordinates.
|
* @param {!LineCoordType} coordinates The coordinates.
|
||||||
* @param {import("../geom/SimpleGeometry.js").default|undefined} geometry Optional geometry.
|
* @param {import("../geom/SimpleGeometry.js").default|undefined} geometry Optional geometry.
|
||||||
@@ -378,11 +371,11 @@ class Draw extends PointerInteraction {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
let Constructor;
|
let Constructor;
|
||||||
if (mode === Mode.POINT) {
|
if (mode === 'Point') {
|
||||||
Constructor = Point;
|
Constructor = Point;
|
||||||
} else if (mode === Mode.LINE_STRING) {
|
} else if (mode === 'LineString') {
|
||||||
Constructor = LineString;
|
Constructor = LineString;
|
||||||
} else if (mode === Mode.POLYGON) {
|
} else if (mode === 'Polygon') {
|
||||||
Constructor = Polygon;
|
Constructor = Polygon;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -393,7 +386,7 @@ class Draw extends PointerInteraction {
|
|||||||
*/
|
*/
|
||||||
geometryFunction = function (coordinates, geometry, projection) {
|
geometryFunction = function (coordinates, geometry, projection) {
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
if (mode === Mode.POLYGON) {
|
if (mode === 'Polygon') {
|
||||||
if (coordinates[0].length) {
|
if (coordinates[0].length) {
|
||||||
// Add a closing coordinate to match the first
|
// Add a closing coordinate to match the first
|
||||||
geometry.setCoordinates(
|
geometry.setCoordinates(
|
||||||
@@ -555,8 +548,7 @@ class Draw extends PointerInteraction {
|
|||||||
// Avoid context menu for long taps when drawing on mobile
|
// Avoid context menu for long taps when drawing on mobile
|
||||||
event.originalEvent.preventDefault();
|
event.originalEvent.preventDefault();
|
||||||
}
|
}
|
||||||
this.freehand_ =
|
this.freehand_ = this.mode_ !== 'Point' && this.freehandCondition_(event);
|
||||||
this.mode_ !== Mode.POINT && this.freehandCondition_(event);
|
|
||||||
let move = event.type === MapBrowserEventType.POINTERMOVE;
|
let move = event.type === MapBrowserEventType.POINTERMOVE;
|
||||||
let pass = true;
|
let pass = true;
|
||||||
if (
|
if (
|
||||||
@@ -674,7 +666,7 @@ class Draw extends PointerInteraction {
|
|||||||
this.finishDrawing();
|
this.finishDrawing();
|
||||||
} else if (
|
} else if (
|
||||||
!this.freehand_ &&
|
!this.freehand_ &&
|
||||||
(!startingToDraw || this.mode_ === Mode.POINT)
|
(!startingToDraw || this.mode_ === 'Point')
|
||||||
) {
|
) {
|
||||||
if (this.atFinish_(event.pixel)) {
|
if (this.atFinish_(event.pixel)) {
|
||||||
if (this.finishCondition_(event)) {
|
if (this.finishCondition_(event)) {
|
||||||
@@ -740,13 +732,13 @@ class Draw extends PointerInteraction {
|
|||||||
let potentiallyDone = false;
|
let potentiallyDone = false;
|
||||||
let potentiallyFinishCoordinates = [this.finishCoordinate_];
|
let potentiallyFinishCoordinates = [this.finishCoordinate_];
|
||||||
const mode = this.mode_;
|
const mode = this.mode_;
|
||||||
if (mode === Mode.POINT) {
|
if (mode === 'Point') {
|
||||||
at = true;
|
at = true;
|
||||||
} else if (mode === Mode.CIRCLE) {
|
} else if (mode === 'Circle') {
|
||||||
at = this.sketchCoords_.length === 2;
|
at = this.sketchCoords_.length === 2;
|
||||||
} else if (mode === Mode.LINE_STRING) {
|
} else if (mode === 'LineString') {
|
||||||
potentiallyDone = this.sketchCoords_.length > this.minPoints_;
|
potentiallyDone = this.sketchCoords_.length > this.minPoints_;
|
||||||
} else if (mode === Mode.POLYGON) {
|
} else if (mode === 'Polygon') {
|
||||||
const sketchCoords = /** @type {PolyCoordType} */ (this.sketchCoords_);
|
const sketchCoords = /** @type {PolyCoordType} */ (this.sketchCoords_);
|
||||||
potentiallyDone = sketchCoords[0].length > this.minPoints_;
|
potentiallyDone = sketchCoords[0].length > this.minPoints_;
|
||||||
potentiallyFinishCoordinates = [
|
potentiallyFinishCoordinates = [
|
||||||
@@ -824,9 +816,9 @@ class Draw extends PointerInteraction {
|
|||||||
start.push(0);
|
start.push(0);
|
||||||
}
|
}
|
||||||
this.finishCoordinate_ = start;
|
this.finishCoordinate_ = start;
|
||||||
if (this.mode_ === Mode.POINT) {
|
if (this.mode_ === 'Point') {
|
||||||
this.sketchCoords_ = start.slice();
|
this.sketchCoords_ = start.slice();
|
||||||
} else if (this.mode_ === Mode.POLYGON) {
|
} else if (this.mode_ === 'Polygon') {
|
||||||
this.sketchCoords_ = [[start.slice(), start.slice()]];
|
this.sketchCoords_ = [[start.slice(), start.slice()]];
|
||||||
this.sketchLineCoords_ = this.sketchCoords_[0];
|
this.sketchLineCoords_ = this.sketchCoords_[0];
|
||||||
} else {
|
} else {
|
||||||
@@ -865,9 +857,9 @@ class Draw extends PointerInteraction {
|
|||||||
while (coordinate.length < stride) {
|
while (coordinate.length < stride) {
|
||||||
coordinate.push(0);
|
coordinate.push(0);
|
||||||
}
|
}
|
||||||
if (this.mode_ === Mode.POINT) {
|
if (this.mode_ === 'Point') {
|
||||||
last = this.sketchCoords_;
|
last = this.sketchCoords_;
|
||||||
} else if (this.mode_ === Mode.POLYGON) {
|
} else if (this.mode_ === 'Polygon') {
|
||||||
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
|
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
|
||||||
last = coordinates[coordinates.length - 1];
|
last = coordinates[coordinates.length - 1];
|
||||||
if (this.atFinish_(map.getPixelFromCoordinate(coordinate))) {
|
if (this.atFinish_(map.getPixelFromCoordinate(coordinate))) {
|
||||||
@@ -889,7 +881,7 @@ class Draw extends PointerInteraction {
|
|||||||
const sketchPointGeom = this.sketchPoint_.getGeometry();
|
const sketchPointGeom = this.sketchPoint_.getGeometry();
|
||||||
sketchPointGeom.setCoordinates(coordinate);
|
sketchPointGeom.setCoordinates(coordinate);
|
||||||
}
|
}
|
||||||
if (geometry.getType() === 'Polygon' && this.mode_ !== Mode.POLYGON) {
|
if (geometry.getType() === 'Polygon' && this.mode_ !== 'Polygon') {
|
||||||
this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry));
|
this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry));
|
||||||
} else if (this.sketchLineCoords_) {
|
} else if (this.sketchLineCoords_) {
|
||||||
const sketchLineGeom = this.sketchLine_.getGeometry();
|
const sketchLineGeom = this.sketchLine_.getGeometry();
|
||||||
@@ -909,7 +901,7 @@ class Draw extends PointerInteraction {
|
|||||||
let done;
|
let done;
|
||||||
let coordinates;
|
let coordinates;
|
||||||
const mode = this.mode_;
|
const mode = this.mode_;
|
||||||
if (mode === Mode.LINE_STRING || mode === Mode.CIRCLE) {
|
if (mode === 'LineString' || mode === 'Circle') {
|
||||||
this.finishCoordinate_ = coordinate.slice();
|
this.finishCoordinate_ = coordinate.slice();
|
||||||
coordinates = /** @type {LineCoordType} */ (this.sketchCoords_);
|
coordinates = /** @type {LineCoordType} */ (this.sketchCoords_);
|
||||||
if (coordinates.length >= this.maxPoints_) {
|
if (coordinates.length >= this.maxPoints_) {
|
||||||
@@ -921,7 +913,7 @@ class Draw extends PointerInteraction {
|
|||||||
}
|
}
|
||||||
coordinates.push(coordinate.slice());
|
coordinates.push(coordinate.slice());
|
||||||
this.geometryFunction_(coordinates, geometry, projection);
|
this.geometryFunction_(coordinates, geometry, projection);
|
||||||
} else if (mode === Mode.POLYGON) {
|
} else if (mode === 'Polygon') {
|
||||||
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
|
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
|
||||||
if (coordinates.length >= this.maxPoints_) {
|
if (coordinates.length >= this.maxPoints_) {
|
||||||
if (this.freehand_) {
|
if (this.freehand_) {
|
||||||
@@ -956,7 +948,7 @@ class Draw extends PointerInteraction {
|
|||||||
const projection = this.getMap().getView().getProjection();
|
const projection = this.getMap().getView().getProjection();
|
||||||
let coordinates;
|
let coordinates;
|
||||||
const mode = this.mode_;
|
const mode = this.mode_;
|
||||||
if (mode === Mode.LINE_STRING || mode === Mode.CIRCLE) {
|
if (mode === 'LineString' || mode === 'Circle') {
|
||||||
coordinates = /** @type {LineCoordType} */ (this.sketchCoords_);
|
coordinates = /** @type {LineCoordType} */ (this.sketchCoords_);
|
||||||
coordinates.splice(-2, 1);
|
coordinates.splice(-2, 1);
|
||||||
if (coordinates.length >= 2) {
|
if (coordinates.length >= 2) {
|
||||||
@@ -969,7 +961,7 @@ class Draw extends PointerInteraction {
|
|||||||
if (geometry.getType() === 'Polygon' && this.sketchLine_) {
|
if (geometry.getType() === 'Polygon' && this.sketchLine_) {
|
||||||
this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry));
|
this.createOrUpdateCustomSketchLine_(/** @type {Polygon} */ (geometry));
|
||||||
}
|
}
|
||||||
} else if (mode === Mode.POLYGON) {
|
} else if (mode === 'Polygon') {
|
||||||
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
|
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
|
||||||
coordinates.splice(-2, 1);
|
coordinates.splice(-2, 1);
|
||||||
const sketchLineGeom = this.sketchLine_.getGeometry();
|
const sketchLineGeom = this.sketchLine_.getGeometry();
|
||||||
@@ -1003,11 +995,11 @@ class Draw extends PointerInteraction {
|
|||||||
let coordinates = this.sketchCoords_;
|
let coordinates = this.sketchCoords_;
|
||||||
const geometry = sketchFeature.getGeometry();
|
const geometry = sketchFeature.getGeometry();
|
||||||
const projection = this.getMap().getView().getProjection();
|
const projection = this.getMap().getView().getProjection();
|
||||||
if (this.mode_ === Mode.LINE_STRING) {
|
if (this.mode_ === 'LineString') {
|
||||||
// remove the redundant last point
|
// remove the redundant last point
|
||||||
coordinates.pop();
|
coordinates.pop();
|
||||||
this.geometryFunction_(coordinates, geometry, projection);
|
this.geometryFunction_(coordinates, geometry, projection);
|
||||||
} else if (this.mode_ === Mode.POLYGON) {
|
} else if (this.mode_ === 'Polygon') {
|
||||||
// remove the redundant last point in ring
|
// remove the redundant last point in ring
|
||||||
/** @type {PolyCoordType} */ (coordinates)[0].pop();
|
/** @type {PolyCoordType} */ (coordinates)[0].pop();
|
||||||
this.geometryFunction_(coordinates, geometry, projection);
|
this.geometryFunction_(coordinates, geometry, projection);
|
||||||
@@ -1084,9 +1076,9 @@ class Draw extends PointerInteraction {
|
|||||||
}
|
}
|
||||||
/** @type {LineCoordType} */
|
/** @type {LineCoordType} */
|
||||||
let sketchCoords;
|
let sketchCoords;
|
||||||
if (mode === Mode.LINE_STRING || mode === Mode.CIRCLE) {
|
if (mode === 'LineString' || mode === 'Circle') {
|
||||||
sketchCoords = /** @type {LineCoordType} */ (this.sketchCoords_);
|
sketchCoords = /** @type {LineCoordType} */ (this.sketchCoords_);
|
||||||
} else if (mode === Mode.POLYGON) {
|
} else if (mode === 'Polygon') {
|
||||||
sketchCoords =
|
sketchCoords =
|
||||||
this.sketchCoords_ && this.sketchCoords_.length
|
this.sketchCoords_ && this.sketchCoords_.length
|
||||||
? /** @type {PolyCoordType} */ (this.sketchCoords_)[0]
|
? /** @type {PolyCoordType} */ (this.sketchCoords_)[0]
|
||||||
@@ -1277,15 +1269,15 @@ function getMode(type) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Point':
|
case 'Point':
|
||||||
case 'MultiPoint':
|
case 'MultiPoint':
|
||||||
return Mode.POINT;
|
return 'Point';
|
||||||
case 'LineString':
|
case 'LineString':
|
||||||
case 'MultiLineString':
|
case 'MultiLineString':
|
||||||
return Mode.LINE_STRING;
|
return 'LineString';
|
||||||
case 'Polygon':
|
case 'Polygon':
|
||||||
case 'MultiPolygon':
|
case 'MultiPolygon':
|
||||||
return Mode.POLYGON;
|
return 'Polygon';
|
||||||
case 'Circle':
|
case 'Circle':
|
||||||
return Mode.CIRCLE;
|
return 'Circle';
|
||||||
default:
|
default:
|
||||||
throw new Error('Invalid type: ' + type);
|
throw new Error('Invalid type: ' + type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import {getFontParameters} from '../css.js';
|
|||||||
* @property {string} [textAlign] TextAlign.
|
* @property {string} [textAlign] TextAlign.
|
||||||
* @property {string} [justify] Justify.
|
* @property {string} [justify] Justify.
|
||||||
* @property {string} textBaseline TextBaseline.
|
* @property {string} textBaseline TextBaseline.
|
||||||
* @property {string} [placement] Placement.
|
* @property {import('../style/Text.js').TextPlacement} [placement] Placement.
|
||||||
* @property {number} [maxAngle] MaxAngle.
|
* @property {number} [maxAngle] MaxAngle.
|
||||||
* @property {boolean} [overflow] Overflow.
|
* @property {boolean} [overflow] Overflow.
|
||||||
* @property {import("../style/Fill.js").default} [backgroundFill] BackgroundFill.
|
* @property {import("../style/Fill.js").default} [backgroundFill] BackgroundFill.
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
import CanvasBuilder from './Builder.js';
|
import CanvasBuilder from './Builder.js';
|
||||||
import CanvasInstruction from './Instruction.js';
|
import CanvasInstruction from './Instruction.js';
|
||||||
import TextPlacement from '../../style/TextPlacement.js';
|
|
||||||
import {asColorLike} from '../../colorlike.js';
|
import {asColorLike} from '../../colorlike.js';
|
||||||
import {
|
import {
|
||||||
defaultFillStyle,
|
defaultFillStyle,
|
||||||
@@ -177,7 +176,7 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
let stride = geometry.getStride();
|
let stride = geometry.getStride();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
textState.placement === TextPlacement.LINE &&
|
textState.placement === 'line' &&
|
||||||
(geometryType == 'LineString' ||
|
(geometryType == 'LineString' ||
|
||||||
geometryType == 'MultiLineString' ||
|
geometryType == 'MultiLineString' ||
|
||||||
geometryType == 'Polygon' ||
|
geometryType == 'Polygon' ||
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import CanvasImmediateRenderer from './Immediate.js';
|
import CanvasImmediateRenderer from './Immediate.js';
|
||||||
import IconAnchorUnits from '../../style/IconAnchorUnits.js';
|
|
||||||
import {Icon} from '../../style.js';
|
import {Icon} from '../../style.js';
|
||||||
import {clamp} from '../../math.js';
|
import {clamp} from '../../math.js';
|
||||||
import {createCanvasContext2D} from '../../dom.js';
|
import {createCanvasContext2D} from '../../dom.js';
|
||||||
@@ -104,8 +103,8 @@ export function createHitDetectionImageData(
|
|||||||
img: img,
|
img: img,
|
||||||
imgSize: imgSize,
|
imgSize: imgSize,
|
||||||
anchor: image.getAnchor(),
|
anchor: image.getAnchor(),
|
||||||
anchorXUnits: IconAnchorUnits.PIXELS,
|
anchorXUnits: 'pixels',
|
||||||
anchorYUnits: IconAnchorUnits.PIXELS,
|
anchorYUnits: 'pixels',
|
||||||
offset: image.getOrigin(),
|
offset: image.getOrigin(),
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
size: image.getSize(),
|
size: image.getSize(),
|
||||||
|
|||||||
@@ -14,12 +14,8 @@ import {getCenter} from '../extent.js';
|
|||||||
import {toSize} from '../size.js';
|
import {toSize} from '../size.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @typedef {'default' | 'truncated'} TierSizeCalculation
|
||||||
*/
|
*/
|
||||||
const TierSizeCalculation = {
|
|
||||||
DEFAULT: 'default',
|
|
||||||
TRUNCATED: 'truncated',
|
|
||||||
};
|
|
||||||
|
|
||||||
export class CustomTile extends ImageTile {
|
export class CustomTile extends ImageTile {
|
||||||
/**
|
/**
|
||||||
@@ -105,7 +101,7 @@ export class CustomTile extends ImageTile {
|
|||||||
* `http://my.zoomify.info?FIF=IMAGE.TIF&JTL={z},{tileIndex}`.
|
* `http://my.zoomify.info?FIF=IMAGE.TIF&JTL={z},{tileIndex}`.
|
||||||
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
|
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
|
||||||
* used instead of defining each one separately in the `urls` option.
|
* used instead of defining each one separately in the `urls` option.
|
||||||
* @property {string} [tierSizeCalculation] Tier size calculation method: `default` or `truncated`.
|
* @property {TierSizeCalculation} [tierSizeCalculation] Tier size calculation method: `default` or `truncated`.
|
||||||
* @property {import("../size.js").Size} size Size.
|
* @property {import("../size.js").Size} size Size.
|
||||||
* @property {import("../extent.js").Extent} [extent] Extent for the TileGrid that is created.
|
* @property {import("../extent.js").Extent} [extent] Extent for the TileGrid that is created.
|
||||||
* Default sets the TileGrid in the
|
* Default sets the TileGrid in the
|
||||||
@@ -143,7 +139,7 @@ class Zoomify extends TileImage {
|
|||||||
const tierSizeCalculation =
|
const tierSizeCalculation =
|
||||||
options.tierSizeCalculation !== undefined
|
options.tierSizeCalculation !== undefined
|
||||||
? options.tierSizeCalculation
|
? options.tierSizeCalculation
|
||||||
: TierSizeCalculation.DEFAULT;
|
: 'default';
|
||||||
|
|
||||||
const tilePixelRatio = options.tilePixelRatio || 1;
|
const tilePixelRatio = options.tilePixelRatio || 1;
|
||||||
const imageWidth = size[0];
|
const imageWidth = size[0];
|
||||||
@@ -153,7 +149,7 @@ class Zoomify extends TileImage {
|
|||||||
let tileSizeForTierSizeCalculation = tileSize * tilePixelRatio;
|
let tileSizeForTierSizeCalculation = tileSize * tilePixelRatio;
|
||||||
|
|
||||||
switch (tierSizeCalculation) {
|
switch (tierSizeCalculation) {
|
||||||
case TierSizeCalculation.DEFAULT:
|
case 'default':
|
||||||
while (
|
while (
|
||||||
imageWidth > tileSizeForTierSizeCalculation ||
|
imageWidth > tileSizeForTierSizeCalculation ||
|
||||||
imageHeight > tileSizeForTierSizeCalculation
|
imageHeight > tileSizeForTierSizeCalculation
|
||||||
@@ -165,7 +161,7 @@ class Zoomify extends TileImage {
|
|||||||
tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation;
|
tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TierSizeCalculation.TRUNCATED:
|
case 'truncated':
|
||||||
let width = imageWidth;
|
let width = imageWidth;
|
||||||
let height = imageHeight;
|
let height = imageHeight;
|
||||||
while (
|
while (
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
* @module ol/style/Icon
|
* @module ol/style/Icon
|
||||||
*/
|
*/
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import IconAnchorUnits from './IconAnchorUnits.js';
|
|
||||||
import IconOrigin from './IconOrigin.js';
|
|
||||||
import ImageState from '../ImageState.js';
|
import ImageState from '../ImageState.js';
|
||||||
import ImageStyle from './Image.js';
|
import ImageStyle from './Image.js';
|
||||||
import {asArray} from '../color.js';
|
import {asArray} from '../color.js';
|
||||||
@@ -11,15 +9,25 @@ import {assert} from '../asserts.js';
|
|||||||
import {get as getIconImage} from './IconImage.js';
|
import {get as getIconImage} from './IconImage.js';
|
||||||
import {getUid} from '../util.js';
|
import {getUid} from '../util.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'fraction' | 'pixels'} IconAnchorUnits
|
||||||
|
* Anchor unit can be either a fraction of the icon size or in pixels.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} IconOrigin
|
||||||
|
* Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
* @property {Array<number>} [anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
|
* @property {Array<number>} [anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
|
||||||
* @property {import("./IconOrigin.js").default} [anchorOrigin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,
|
* @property {IconOrigin} [anchorOrigin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,
|
||||||
* `top-left` or `top-right`.
|
* `top-left` or `top-right`.
|
||||||
* @property {import("./IconAnchorUnits.js").default} [anchorXUnits='fraction'] Units in which the anchor x value is
|
* @property {IconAnchorUnits} [anchorXUnits='fraction'] Units in which the anchor x value is
|
||||||
* specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates
|
* specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates
|
||||||
* the x value in pixels.
|
* the x value in pixels.
|
||||||
* @property {import("./IconAnchorUnits.js").default} [anchorYUnits='fraction'] Units in which the anchor y value is
|
* @property {IconAnchorUnits} [anchorYUnits='fraction'] Units in which the anchor y value is
|
||||||
* specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates
|
* specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates
|
||||||
* the y value in pixels.
|
* the y value in pixels.
|
||||||
* @property {import("../color.js").Color|string} [color] Color to tint the icon. If not specified,
|
* @property {import("../color.js").Color|string} [color] Color to tint the icon. If not specified,
|
||||||
@@ -33,7 +41,7 @@ import {getUid} from '../util.js';
|
|||||||
* @property {Array<number>} [offset=[0, 0]] Offset, which, together with the size and the offset origin, define the
|
* @property {Array<number>} [offset=[0, 0]] Offset, which, together with the size and the offset origin, define the
|
||||||
* sub-rectangle to use from the original icon image.
|
* sub-rectangle to use from the original icon image.
|
||||||
* @property {Array<number>} [displacement=[0,0]] Displacement of the icon.
|
* @property {Array<number>} [displacement=[0,0]] Displacement of the icon.
|
||||||
* @property {import("./IconOrigin.js").default} [offsetOrigin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,
|
* @property {IconOrigin} [offsetOrigin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,
|
||||||
* `top-left` or `top-right`.
|
* `top-left` or `top-right`.
|
||||||
* @property {number} [opacity=1] Opacity of the icon.
|
* @property {number} [opacity=1] Opacity of the icon.
|
||||||
* @property {number|import("../size.js").Size} [scale=1] Scale.
|
* @property {number|import("../size.js").Size} [scale=1] Scale.
|
||||||
@@ -104,30 +112,24 @@ class Icon extends ImageStyle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("./IconOrigin.js").default}
|
* @type {IconOrigin}
|
||||||
*/
|
*/
|
||||||
this.anchorOrigin_ =
|
this.anchorOrigin_ =
|
||||||
options.anchorOrigin !== undefined
|
options.anchorOrigin !== undefined ? options.anchorOrigin : 'top-left';
|
||||||
? options.anchorOrigin
|
|
||||||
: IconOrigin.TOP_LEFT;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("./IconAnchorUnits.js").default}
|
* @type {IconAnchorUnits}
|
||||||
*/
|
*/
|
||||||
this.anchorXUnits_ =
|
this.anchorXUnits_ =
|
||||||
options.anchorXUnits !== undefined
|
options.anchorXUnits !== undefined ? options.anchorXUnits : 'fraction';
|
||||||
? options.anchorXUnits
|
|
||||||
: IconAnchorUnits.FRACTION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("./IconAnchorUnits.js").default}
|
* @type {IconAnchorUnits}
|
||||||
*/
|
*/
|
||||||
this.anchorYUnits_ =
|
this.anchorYUnits_ =
|
||||||
options.anchorYUnits !== undefined
|
options.anchorYUnits !== undefined ? options.anchorYUnits : 'fraction';
|
||||||
? options.anchorYUnits
|
|
||||||
: IconAnchorUnits.FRACTION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -192,12 +194,10 @@ class Icon extends ImageStyle {
|
|||||||
this.offset_ = options.offset !== undefined ? options.offset : [0, 0];
|
this.offset_ = options.offset !== undefined ? options.offset : [0, 0];
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("./IconOrigin.js").default}
|
* @type {IconOrigin}
|
||||||
*/
|
*/
|
||||||
this.offsetOrigin_ =
|
this.offsetOrigin_ =
|
||||||
options.offsetOrigin !== undefined
|
options.offsetOrigin !== undefined ? options.offsetOrigin : 'top-left';
|
||||||
? options.offsetOrigin
|
|
||||||
: IconOrigin.TOP_LEFT;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -255,22 +255,22 @@ class Icon extends ImageStyle {
|
|||||||
anchor = this.anchor_;
|
anchor = this.anchor_;
|
||||||
const size = this.getSize();
|
const size = this.getSize();
|
||||||
if (
|
if (
|
||||||
this.anchorXUnits_ == IconAnchorUnits.FRACTION ||
|
this.anchorXUnits_ == 'fraction' ||
|
||||||
this.anchorYUnits_ == IconAnchorUnits.FRACTION
|
this.anchorYUnits_ == 'fraction'
|
||||||
) {
|
) {
|
||||||
if (!size) {
|
if (!size) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
anchor = this.anchor_.slice();
|
anchor = this.anchor_.slice();
|
||||||
if (this.anchorXUnits_ == IconAnchorUnits.FRACTION) {
|
if (this.anchorXUnits_ == 'fraction') {
|
||||||
anchor[0] *= size[0];
|
anchor[0] *= size[0];
|
||||||
}
|
}
|
||||||
if (this.anchorYUnits_ == IconAnchorUnits.FRACTION) {
|
if (this.anchorYUnits_ == 'fraction') {
|
||||||
anchor[1] *= size[1];
|
anchor[1] *= size[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.anchorOrigin_ != IconOrigin.TOP_LEFT) {
|
if (this.anchorOrigin_ != 'top-left') {
|
||||||
if (!size) {
|
if (!size) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -278,14 +278,14 @@ class Icon extends ImageStyle {
|
|||||||
anchor = this.anchor_.slice();
|
anchor = this.anchor_.slice();
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.anchorOrigin_ == IconOrigin.TOP_RIGHT ||
|
this.anchorOrigin_ == 'top-right' ||
|
||||||
this.anchorOrigin_ == IconOrigin.BOTTOM_RIGHT
|
this.anchorOrigin_ == 'bottom-right'
|
||||||
) {
|
) {
|
||||||
anchor[0] = -anchor[0] + size[0];
|
anchor[0] = -anchor[0] + size[0];
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.anchorOrigin_ == IconOrigin.BOTTOM_LEFT ||
|
this.anchorOrigin_ == 'bottom-left' ||
|
||||||
this.anchorOrigin_ == IconOrigin.BOTTOM_RIGHT
|
this.anchorOrigin_ == 'bottom-right'
|
||||||
) {
|
) {
|
||||||
anchor[1] = -anchor[1] + size[1];
|
anchor[1] = -anchor[1] + size[1];
|
||||||
}
|
}
|
||||||
@@ -369,7 +369,7 @@ class Icon extends ImageStyle {
|
|||||||
}
|
}
|
||||||
let offset = this.offset_;
|
let offset = this.offset_;
|
||||||
|
|
||||||
if (this.offsetOrigin_ != IconOrigin.TOP_LEFT) {
|
if (this.offsetOrigin_ != 'top-left') {
|
||||||
const size = this.getSize();
|
const size = this.getSize();
|
||||||
const iconImageSize = this.iconImage_.getSize();
|
const iconImageSize = this.iconImage_.getSize();
|
||||||
if (!size || !iconImageSize) {
|
if (!size || !iconImageSize) {
|
||||||
@@ -377,14 +377,14 @@ class Icon extends ImageStyle {
|
|||||||
}
|
}
|
||||||
offset = offset.slice();
|
offset = offset.slice();
|
||||||
if (
|
if (
|
||||||
this.offsetOrigin_ == IconOrigin.TOP_RIGHT ||
|
this.offsetOrigin_ == 'top-right' ||
|
||||||
this.offsetOrigin_ == IconOrigin.BOTTOM_RIGHT
|
this.offsetOrigin_ == 'bottom-right'
|
||||||
) {
|
) {
|
||||||
offset[0] = iconImageSize[0] - size[0] - offset[0];
|
offset[0] = iconImageSize[0] - size[0] - offset[0];
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.offsetOrigin_ == IconOrigin.BOTTOM_LEFT ||
|
this.offsetOrigin_ == 'bottom-left' ||
|
||||||
this.offsetOrigin_ == IconOrigin.BOTTOM_RIGHT
|
this.offsetOrigin_ == 'bottom-right'
|
||||||
) {
|
) {
|
||||||
offset[1] = iconImageSize[1] - size[1] - offset[1];
|
offset[1] = iconImageSize[1] - size[1] - offset[1];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/style/IconAnchorUnits
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Icon anchor units. One of 'fraction', 'pixels'.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
/**
|
|
||||||
* Anchor is a fraction
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
FRACTION: 'fraction',
|
|
||||||
/**
|
|
||||||
* Anchor is in pixels
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
PIXELS: 'pixels',
|
|
||||||
};
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/style/IconOrigin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
/**
|
|
||||||
* Origin is at bottom left
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
BOTTOM_LEFT: 'bottom-left',
|
|
||||||
/**
|
|
||||||
* Origin is at bottom right
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
BOTTOM_RIGHT: 'bottom-right',
|
|
||||||
/**
|
|
||||||
* Origin is at top left
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
TOP_LEFT: 'top-left',
|
|
||||||
/**
|
|
||||||
* Origin is at top right
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
TOP_RIGHT: 'top-right',
|
|
||||||
};
|
|
||||||
@@ -2,9 +2,16 @@
|
|||||||
* @module ol/style/Text
|
* @module ol/style/Text
|
||||||
*/
|
*/
|
||||||
import Fill from './Fill.js';
|
import Fill from './Fill.js';
|
||||||
import TextPlacement from './TextPlacement.js';
|
|
||||||
import {toSize} from '../size.js';
|
import {toSize} from '../size.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'point' | 'line'} TextPlacement
|
||||||
|
* Default text placement is `'point'`. Note that
|
||||||
|
* `'line'` requires the underlying geometry to be a {@link module:ol/geom/LineString~LineString},
|
||||||
|
* {@link module:ol/geom/Polygon~Polygon}, {@link module:ol/geom/MultiLineString~MultiLineString} or
|
||||||
|
* {@link module:ol/geom/MultiPolygon~MultiPolygon}.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default fill color to use if no fill was set at construction time; a
|
* The default fill color to use if no fill was set at construction time; a
|
||||||
* blackish `#333`.
|
* blackish `#333`.
|
||||||
@@ -23,7 +30,7 @@ const DEFAULT_FILL_COLOR = '#333';
|
|||||||
* @property {number} [offsetY=0] Vertical text offset in pixels. A positive will shift the text down.
|
* @property {number} [offsetY=0] Vertical text offset in pixels. A positive will shift the text down.
|
||||||
* @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
|
* @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
|
||||||
* the width of the polygon at the label position or the length of the path that it follows.
|
* the width of the polygon at the label position or the length of the path that it follows.
|
||||||
* @property {import("./TextPlacement.js").default|string} [placement='point'] Text placement.
|
* @property {TextPlacement} [placement='point'] Text placement.
|
||||||
* @property {number|import("../size.js").Size} [scale] Scale.
|
* @property {number|import("../size.js").Size} [scale] Scale.
|
||||||
* @property {boolean} [rotateWithView=false] Whether to rotate the text with the view.
|
* @property {boolean} [rotateWithView=false] Whether to rotate the text with the view.
|
||||||
* @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
|
* @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
|
||||||
@@ -135,10 +142,10 @@ class Text {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("./TextPlacement.js").default|string}
|
* @type {TextPlacement}
|
||||||
*/
|
*/
|
||||||
this.placement_ =
|
this.placement_ =
|
||||||
options.placement !== undefined ? options.placement : TextPlacement.POINT;
|
options.placement !== undefined ? options.placement : 'point';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -249,7 +256,7 @@ class Text {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the label placement.
|
* Get the label placement.
|
||||||
* @return {import("./TextPlacement.js").default|string} Text placement.
|
* @return {TextPlacement} Text placement.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getPlacement() {
|
getPlacement() {
|
||||||
@@ -443,7 +450,7 @@ class Text {
|
|||||||
/**
|
/**
|
||||||
* Set the text placement.
|
* Set the text placement.
|
||||||
*
|
*
|
||||||
* @param {import("./TextPlacement.js").default|string} placement Placement.
|
* @param {TextPlacement} placement Placement.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
setPlacement(placement) {
|
setPlacement(placement) {
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/style/TextPlacement
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Text placement. One of `'point'`, `'line'`. Default is `'point'`. Note that
|
|
||||||
* `'line'` requires the underlying geometry to be a {@link module:ol/geom/LineString~LineString},
|
|
||||||
* {@link module:ol/geom/Polygon~Polygon}, {@link module:ol/geom/MultiLineString~MultiLineString} or
|
|
||||||
* {@link module:ol/geom/MultiPolygon~MultiPolygon}.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
POINT: 'point',
|
|
||||||
LINE: 'line',
|
|
||||||
};
|
|
||||||
@@ -4,8 +4,6 @@ import Fill from '../../../../../src/ol/style/Fill.js';
|
|||||||
import GeoJSON from '../../../../../src/ol/format/GeoJSON.js';
|
import GeoJSON from '../../../../../src/ol/format/GeoJSON.js';
|
||||||
import GeometryCollection from '../../../../../src/ol/geom/GeometryCollection.js';
|
import GeometryCollection from '../../../../../src/ol/geom/GeometryCollection.js';
|
||||||
import Icon from '../../../../../src/ol/style/Icon.js';
|
import Icon from '../../../../../src/ol/style/Icon.js';
|
||||||
import IconAnchorUnits from '../../../../../src/ol/style/IconAnchorUnits.js';
|
|
||||||
import IconOrigin from '../../../../../src/ol/style/IconOrigin.js';
|
|
||||||
import ImageState from '../../../../../src/ol/ImageState.js';
|
import ImageState from '../../../../../src/ol/ImageState.js';
|
||||||
import KML, {
|
import KML, {
|
||||||
getDefaultFillStyle,
|
getDefaultFillStyle,
|
||||||
@@ -2430,25 +2428,25 @@ describe('ol.format.KML', function () {
|
|||||||
if (f.getId() == 1) {
|
if (f.getId() == 1) {
|
||||||
expect(imageStyle.anchor_[0]).to.be(0.5);
|
expect(imageStyle.anchor_[0]).to.be(0.5);
|
||||||
expect(imageStyle.anchor_[1]).to.be(0.5);
|
expect(imageStyle.anchor_[1]).to.be(0.5);
|
||||||
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT);
|
expect(imageStyle.anchorOrigin_).to.be('bottom-left');
|
||||||
expect(imageStyle.anchorXUnits_).to.be(IconAnchorUnits.FRACTION);
|
expect(imageStyle.anchorXUnits_).to.be('fraction');
|
||||||
expect(imageStyle.anchorYUnits_).to.be(IconAnchorUnits.FRACTION);
|
expect(imageStyle.anchorYUnits_).to.be('fraction');
|
||||||
} else {
|
} else {
|
||||||
expect(imageStyle.anchor_[0]).to.be(5);
|
expect(imageStyle.anchor_[0]).to.be(5);
|
||||||
expect(imageStyle.anchor_[1]).to.be(5);
|
expect(imageStyle.anchor_[1]).to.be(5);
|
||||||
expect(imageStyle.anchorXUnits_).to.be(IconAnchorUnits.PIXELS);
|
expect(imageStyle.anchorXUnits_).to.be('pixels');
|
||||||
expect(imageStyle.anchorYUnits_).to.be(IconAnchorUnits.PIXELS);
|
expect(imageStyle.anchorYUnits_).to.be('pixels');
|
||||||
if (f.getId() == 2) {
|
if (f.getId() == 2) {
|
||||||
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT);
|
expect(imageStyle.anchorOrigin_).to.be('bottom-left');
|
||||||
}
|
}
|
||||||
if (f.getId() == 3) {
|
if (f.getId() == 3) {
|
||||||
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_RIGHT);
|
expect(imageStyle.anchorOrigin_).to.be('bottom-right');
|
||||||
}
|
}
|
||||||
if (f.getId() == 4) {
|
if (f.getId() == 4) {
|
||||||
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.TOP_LEFT);
|
expect(imageStyle.anchorOrigin_).to.be('top-left');
|
||||||
}
|
}
|
||||||
if (f.getId() == 5) {
|
if (f.getId() == 5) {
|
||||||
expect(imageStyle.anchorOrigin_).to.be(IconOrigin.TOP_RIGHT);
|
expect(imageStyle.anchorOrigin_).to.be('top-right');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect(imageStyle.getRotation()).to.eql(0);
|
expect(imageStyle.getRotation()).to.eql(0);
|
||||||
|
|||||||
@@ -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');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user