@@ -16,8 +16,8 @@ import MultiPoint from '../geom/MultiPoint.js';
|
|||||||
import MultiPolygon from '../geom/MultiPolygon.js';
|
import MultiPolygon from '../geom/MultiPolygon.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';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinates} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
|
import {linearRingIsClockwise} from '../geom/flat/orient.js';
|
||||||
import {assign, isEmpty} from '../obj.js';
|
import {assign, isEmpty} from '../obj.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
|
|
||||||
@@ -132,9 +132,9 @@ function convertRings(rings, layout) {
|
|||||||
let i, ii;
|
let i, ii;
|
||||||
for (i = 0, ii = rings.length; i < ii; ++i) {
|
for (i = 0, ii = rings.length; i < ii; ++i) {
|
||||||
flatRing.length = 0;
|
flatRing.length = 0;
|
||||||
_ol_geom_flat_deflate_.coordinates(flatRing, 0, rings[i], layout.length);
|
deflateCoordinates(flatRing, 0, rings[i], layout.length);
|
||||||
// is this ring an outer ring? is it clockwise?
|
// is this ring an outer ring? is it clockwise?
|
||||||
const clockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatRing, 0,
|
const clockwise = linearRingIsClockwise(flatRing, 0,
|
||||||
flatRing.length, layout.length);
|
flatRing.length, layout.length);
|
||||||
if (clockwise) {
|
if (clockwise) {
|
||||||
outerRings.push([rings[i]]);
|
outerRings.push([rings[i]]);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import MultiPoint from '../geom/MultiPoint.js';
|
|||||||
import MultiPolygon from '../geom/MultiPolygon.js';
|
import MultiPolygon from '../geom/MultiPolygon.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';
|
||||||
import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
|
import {linearRingIsClockwise} from '../geom/flat/orient.js';
|
||||||
import Projection from '../proj/Projection.js';
|
import Projection from '../proj/Projection.js';
|
||||||
import Units from '../proj/Units.js';
|
import Units from '../proj/Units.js';
|
||||||
import RenderFeature from '../render/Feature.js';
|
import RenderFeature from '../render/Feature.js';
|
||||||
@@ -309,7 +309,7 @@ MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
|
|||||||
let prevEndIndex = 0;
|
let prevEndIndex = 0;
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
if (!_ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, offset, end, 2)) {
|
if (!linearRingIsClockwise(flatCoordinates, offset, end, 2)) {
|
||||||
endss.push(ends.slice(prevEndIndex, i));
|
endss.push(ends.slice(prevEndIndex, i));
|
||||||
prevEndIndex = i;
|
prevEndIndex = i;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import GeometryLayout from '../geom/GeometryLayout.js';
|
|||||||
import LineString from '../geom/LineString.js';
|
import LineString from '../geom/LineString.js';
|
||||||
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
||||||
import {flipXY} from '../geom/flat/flip.js';
|
import {flipXY} from '../geom/flat/flip.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,7 +327,7 @@ Polyline.prototype.readGeometryFromText = function(text, opt_options) {
|
|||||||
const stride = getStrideForLayout(this.geometryLayout_);
|
const stride = getStrideForLayout(this.geometryLayout_);
|
||||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||||
const coordinates = _ol_geom_flat_inflate_.coordinates(
|
const coordinates = inflateCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {createOrUpdate, forEachCorner, intersects} from '../extent.js';
|
|||||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinate} from '../geom/flat/deflate.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -192,7 +192,7 @@ Circle.prototype.setCenterAndRadius = function(center, radius, opt_layout) {
|
|||||||
}
|
}
|
||||||
/** @type {Array.<number>} */
|
/** @type {Array.<number>} */
|
||||||
const flatCoordinates = this.flatCoordinates;
|
const flatCoordinates = this.flatCoordinates;
|
||||||
let offset = _ol_geom_flat_deflate_.coordinate(
|
let offset = deflateCoordinate(
|
||||||
flatCoordinates, 0, center, this.stride);
|
flatCoordinates, 0, center, this.stride);
|
||||||
flatCoordinates[offset++] = flatCoordinates[0] + radius;
|
flatCoordinates[offset++] = flatCoordinates[0] + radius;
|
||||||
for (let i = 1, ii = this.stride; i < ii; ++i) {
|
for (let i = 1, ii = this.stride; i < ii; ++i) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
|||||||
import BaseObject from '../Object.js';
|
import BaseObject from '../Object.js';
|
||||||
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
|
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
|
||||||
import {FALSE} from '../functions.js';
|
import {FALSE} from '../functions.js';
|
||||||
import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
|
import {transform2D} from '../geom/flat/transform.js';
|
||||||
import {get as getProjection, getTransform} from '../proj.js';
|
import {get as getProjection, getTransform} from '../proj.js';
|
||||||
import Units from '../proj/Units.js';
|
import Units from '../proj/Units.js';
|
||||||
import _ol_transform_ from '../transform.js';
|
import _ol_transform_ from '../transform.js';
|
||||||
@@ -265,7 +265,7 @@ Geometry.prototype.transform = function(source, destination) {
|
|||||||
projectedExtent[0], projectedExtent[3],
|
projectedExtent[0], projectedExtent[3],
|
||||||
scale, -scale, 0,
|
scale, -scale, 0,
|
||||||
0, 0);
|
0, 0);
|
||||||
_ol_geom_flat_transform_.transform2D(inCoordinates, 0, inCoordinates.length, stride,
|
transform2D(inCoordinates, 0, inCoordinates.length, stride,
|
||||||
tmpTransform, outCoordinates);
|
tmpTransform, outCoordinates);
|
||||||
return getTransform(source, destination)(inCoordinates, outCoordinates, stride);
|
return getTransform(source, destination)(inCoordinates, outCoordinates, stride);
|
||||||
} :
|
} :
|
||||||
|
|||||||
+16
-16
@@ -7,14 +7,14 @@ import {closestSquaredDistanceXY} from '../extent.js';
|
|||||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
import {assignClosestPoint, maxSquaredDelta} from '../geom/flat/closest.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinates} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
import {interpolatePoint, lineStringCoordinateAtM} from '../geom/flat/interpolate.js';
|
||||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
import {intersectsLineString} from '../geom/flat/intersectsextent.js';
|
||||||
import _ol_geom_flat_length_ from '../geom/flat/length.js';
|
import {lineStringLength} from '../geom/flat/length.js';
|
||||||
import {forEach as forEachSegment} from '../geom/flat/segments.js';
|
import {forEach as forEachSegment} from '../geom/flat/segments.js';
|
||||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
import {douglasPeucker} from '../geom/flat/simplify.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -97,11 +97,11 @@ LineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
|||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
}
|
}
|
||||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
this.maxDelta_ = Math.sqrt(maxSquaredDelta(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
||||||
this.maxDeltaRevision_ = this.getRevision();
|
this.maxDeltaRevision_ = this.getRevision();
|
||||||
}
|
}
|
||||||
return _ol_geom_flat_closest_.getClosestPoint(
|
return assignClosestPoint(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
||||||
};
|
};
|
||||||
@@ -143,7 +143,7 @@ LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||||
return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(this.flatCoordinates, 0,
|
return lineStringCoordinateAtM(this.flatCoordinates, 0,
|
||||||
this.flatCoordinates.length, this.stride, m, extrapolate);
|
this.flatCoordinates.length, this.stride, m, extrapolate);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
LineString.prototype.getCoordinates = function() {
|
LineString.prototype.getCoordinates = function() {
|
||||||
return _ol_geom_flat_inflate_.coordinates(
|
return inflateCoordinates(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ LineString.prototype.getCoordinates = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
LineString.prototype.getCoordinateAt = function(fraction, opt_dest) {
|
LineString.prototype.getCoordinateAt = function(fraction, opt_dest) {
|
||||||
return _ol_geom_flat_interpolate_.lineString(
|
return interpolatePoint(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
fraction, opt_dest);
|
fraction, opt_dest);
|
||||||
};
|
};
|
||||||
@@ -183,7 +183,7 @@ LineString.prototype.getCoordinateAt = function(fraction, opt_dest) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
LineString.prototype.getLength = function() {
|
LineString.prototype.getLength = function() {
|
||||||
return _ol_geom_flat_length_.lineString(
|
return lineStringLength(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ LineString.prototype.getFlatMidpoint = function() {
|
|||||||
*/
|
*/
|
||||||
LineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
LineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker(
|
simplifiedFlatCoordinates.length = douglasPeucker(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||||
const simplifiedLineString = new LineString(null);
|
const simplifiedLineString = new LineString(null);
|
||||||
@@ -229,7 +229,7 @@ LineString.prototype.getType = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
LineString.prototype.intersectsExtent = function(extent) {
|
LineString.prototype.intersectsExtent = function(extent) {
|
||||||
return _ol_geom_flat_intersectsextent_.lineString(
|
return intersectsLineString(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
extent);
|
extent);
|
||||||
};
|
};
|
||||||
@@ -250,7 +250,7 @@ LineString.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates(
|
this.flatCoordinates.length = deflateCoordinates(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride);
|
this.flatCoordinates, 0, coordinates, this.stride);
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import GeometryLayout from '../geom/GeometryLayout.js';
|
|||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import {linearRing as linearRingArea} from '../geom/flat/area.js';
|
import {linearRing as linearRingArea} from '../geom/flat/area.js';
|
||||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
import {assignClosestPoint, maxSquaredDelta} from '../geom/flat/closest.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinates} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
import {douglasPeucker} from '../geom/flat/simplify.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -67,11 +67,11 @@ LinearRing.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
|||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
}
|
}
|
||||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
this.maxDelta_ = Math.sqrt(maxSquaredDelta(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
||||||
this.maxDeltaRevision_ = this.getRevision();
|
this.maxDeltaRevision_ = this.getRevision();
|
||||||
}
|
}
|
||||||
return _ol_geom_flat_closest_.getClosestPoint(
|
return assignClosestPoint(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||||
};
|
};
|
||||||
@@ -94,7 +94,7 @@ LinearRing.prototype.getArea = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
LinearRing.prototype.getCoordinates = function() {
|
LinearRing.prototype.getCoordinates = function() {
|
||||||
return _ol_geom_flat_inflate_.coordinates(
|
return inflateCoordinates(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ LinearRing.prototype.getCoordinates = function() {
|
|||||||
*/
|
*/
|
||||||
LinearRing.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
LinearRing.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker(
|
simplifiedFlatCoordinates.length = douglasPeucker(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||||
const simplifiedLinearRing = new LinearRing(null);
|
const simplifiedLinearRing = new LinearRing(null);
|
||||||
@@ -144,7 +144,7 @@ LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates(
|
this.flatCoordinates.length = deflateCoordinates(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride);
|
this.flatCoordinates, 0, coordinates, this.stride);
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import GeometryLayout from '../geom/GeometryLayout.js';
|
|||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import LineString from '../geom/LineString.js';
|
import LineString from '../geom/LineString.js';
|
||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
import {assignClosestArrayPoint, arrayMaxSquaredDelta} from '../geom/flat/closest.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinatesArray} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateCoordinatesArray} from '../geom/flat/inflate.js';
|
||||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
import {interpolatePoint, lineStringsCoordinateAtM} from '../geom/flat/interpolate.js';
|
||||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
import {intersectsLineStringArray} from '../geom/flat/intersectsextent.js';
|
||||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
import {douglasPeuckerArray} from '../geom/flat/simplify.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -92,11 +92,11 @@ MultiLineString.prototype.closestPointXY = function(x, y, closestPoint, minSquar
|
|||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
}
|
}
|
||||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getsMaxSquaredDelta(
|
this.maxDelta_ = Math.sqrt(arrayMaxSquaredDelta(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||||
this.maxDeltaRevision_ = this.getRevision();
|
this.maxDeltaRevision_ = this.getRevision();
|
||||||
}
|
}
|
||||||
return _ol_geom_flat_closest_.getsClosestPoint(
|
return assignClosestArrayPoint(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||||
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
||||||
};
|
};
|
||||||
@@ -132,7 +132,7 @@ MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_in
|
|||||||
}
|
}
|
||||||
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||||
const interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
|
const interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
|
||||||
return _ol_geom_flat_interpolate_.lineStringsCoordinateAtM(this.flatCoordinates, 0,
|
return lineStringsCoordinateAtM(this.flatCoordinates, 0,
|
||||||
this.ends_, this.stride, m, extrapolate, interpolate);
|
this.ends_, this.stride, m, extrapolate, interpolate);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_in
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
MultiLineString.prototype.getCoordinates = function() {
|
MultiLineString.prototype.getCoordinates = function() {
|
||||||
return _ol_geom_flat_inflate_.coordinatess(
|
return inflateCoordinatesArray(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride);
|
this.flatCoordinates, 0, this.ends_, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ MultiLineString.prototype.getFlatMidpoints = function() {
|
|||||||
const stride = this.stride;
|
const stride = this.stride;
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
const midpoint = _ol_geom_flat_interpolate_.lineString(
|
const midpoint = interpolatePoint(
|
||||||
flatCoordinates, offset, end, stride, 0.5);
|
flatCoordinates, offset, end, stride, 0.5);
|
||||||
extend(midpoints, midpoint);
|
extend(midpoints, midpoint);
|
||||||
offset = end;
|
offset = end;
|
||||||
@@ -223,7 +223,7 @@ MultiLineString.prototype.getFlatMidpoints = function() {
|
|||||||
MultiLineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
MultiLineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
const simplifiedEnds = [];
|
const simplifiedEnds = [];
|
||||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeuckers(
|
simplifiedFlatCoordinates.length = douglasPeuckerArray(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
|
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||||
const simplifiedMultiLineString = new MultiLineString(null);
|
const simplifiedMultiLineString = new MultiLineString(null);
|
||||||
@@ -247,7 +247,7 @@ MultiLineString.prototype.getType = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
MultiLineString.prototype.intersectsExtent = function(extent) {
|
MultiLineString.prototype.intersectsExtent = function(extent) {
|
||||||
return _ol_geom_flat_intersectsextent_.lineStrings(
|
return intersectsLineStringArray(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride, extent);
|
this.flatCoordinates, 0, this.ends_, this.stride, extent);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ MultiLineString.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
const ends = _ol_geom_flat_deflate_.coordinatess(
|
const ends = deflateCoordinatesArray(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||||
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import GeometryLayout from '../geom/GeometryLayout.js';
|
|||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import Point from '../geom/Point.js';
|
import Point from '../geom/Point.js';
|
||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinates} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||||
import {squaredDistance as squaredDx} from '../math.js';
|
import {squaredDistance as squaredDx} from '../math.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,7 +89,7 @@ MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
MultiPoint.prototype.getCoordinates = function() {
|
MultiPoint.prototype.getCoordinates = function() {
|
||||||
return _ol_geom_flat_inflate_.coordinates(
|
return inflateCoordinates(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates(
|
this.flatCoordinates.length = deflateCoordinates(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride);
|
this.flatCoordinates, 0, coordinates, this.stride);
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-17
@@ -11,14 +11,14 @@ import Polygon from '../geom/Polygon.js';
|
|||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import {linearRingss as linearRingssArea} from '../geom/flat/area.js';
|
import {linearRingss as linearRingssArea} from '../geom/flat/area.js';
|
||||||
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
||||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
import {assignClosestMultiArrayPoint, multiArrayMaxSquaredDelta} from '../geom/flat/closest.js';
|
||||||
import {linearRingssContainsXY} from '../geom/flat/contains.js';
|
import {linearRingssContainsXY} from '../geom/flat/contains.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateMultiCoordinatesArray} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateMultiCoordinatesArray} from '../geom/flat/inflate.js';
|
||||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
import {getInteriorPointsOfMultiArray} from '../geom/flat/interiorpoint.js';
|
||||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
import {intersectsLinearRingMultiArray} from '../geom/flat/intersectsextent.js';
|
||||||
import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
|
import {linearRingsAreOriented, orientLinearRingsArray} from '../geom/flat/orient.js';
|
||||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
import {quantizeMultiArray} from '../geom/flat/simplify.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -137,11 +137,11 @@ MultiPolygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredD
|
|||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
}
|
}
|
||||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getssMaxSquaredDelta(
|
this.maxDelta_ = Math.sqrt(multiArrayMaxSquaredDelta(
|
||||||
this.flatCoordinates, 0, this.endss_, this.stride, 0));
|
this.flatCoordinates, 0, this.endss_, this.stride, 0));
|
||||||
this.maxDeltaRevision_ = this.getRevision();
|
this.maxDeltaRevision_ = this.getRevision();
|
||||||
}
|
}
|
||||||
return _ol_geom_flat_closest_.getssClosestPoint(
|
return assignClosestMultiArrayPoint(
|
||||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||||
};
|
};
|
||||||
@@ -183,13 +183,13 @@ MultiPolygon.prototype.getCoordinates = function(opt_right) {
|
|||||||
let flatCoordinates;
|
let flatCoordinates;
|
||||||
if (opt_right !== undefined) {
|
if (opt_right !== undefined) {
|
||||||
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
||||||
_ol_geom_flat_orient_.orientLinearRingss(
|
orientLinearRingsArray(
|
||||||
flatCoordinates, 0, this.endss_, this.stride, opt_right);
|
flatCoordinates, 0, this.endss_, this.stride, opt_right);
|
||||||
} else {
|
} else {
|
||||||
flatCoordinates = this.flatCoordinates;
|
flatCoordinates = this.flatCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _ol_geom_flat_inflate_.coordinatesss(
|
return inflateMultiCoordinatesArray(
|
||||||
flatCoordinates, 0, this.endss_, this.stride);
|
flatCoordinates, 0, this.endss_, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ MultiPolygon.prototype.getFlatInteriorPoints = function() {
|
|||||||
if (this.flatInteriorPointsRevision_ != this.getRevision()) {
|
if (this.flatInteriorPointsRevision_ != this.getRevision()) {
|
||||||
const flatCenters = linearRingssCenter(
|
const flatCenters = linearRingssCenter(
|
||||||
this.flatCoordinates, 0, this.endss_, this.stride);
|
this.flatCoordinates, 0, this.endss_, this.stride);
|
||||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
|
this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(
|
||||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||||
flatCenters);
|
flatCenters);
|
||||||
this.flatInteriorPointsRevision_ = this.getRevision();
|
this.flatInteriorPointsRevision_ = this.getRevision();
|
||||||
@@ -238,13 +238,13 @@ MultiPolygon.prototype.getInteriorPoints = function() {
|
|||||||
MultiPolygon.prototype.getOrientedFlatCoordinates = function() {
|
MultiPolygon.prototype.getOrientedFlatCoordinates = function() {
|
||||||
if (this.orientedRevision_ != this.getRevision()) {
|
if (this.orientedRevision_ != this.getRevision()) {
|
||||||
const flatCoordinates = this.flatCoordinates;
|
const flatCoordinates = this.flatCoordinates;
|
||||||
if (_ol_geom_flat_orient_.linearRingssAreOriented(
|
if (linearRingsAreOriented(
|
||||||
flatCoordinates, 0, this.endss_, this.stride)) {
|
flatCoordinates, 0, this.endss_, this.stride)) {
|
||||||
this.orientedFlatCoordinates_ = flatCoordinates;
|
this.orientedFlatCoordinates_ = flatCoordinates;
|
||||||
} else {
|
} else {
|
||||||
this.orientedFlatCoordinates_ = flatCoordinates.slice();
|
this.orientedFlatCoordinates_ = flatCoordinates.slice();
|
||||||
this.orientedFlatCoordinates_.length =
|
this.orientedFlatCoordinates_.length =
|
||||||
_ol_geom_flat_orient_.orientLinearRingss(
|
orientLinearRingsArray(
|
||||||
this.orientedFlatCoordinates_, 0, this.endss_, this.stride);
|
this.orientedFlatCoordinates_, 0, this.endss_, this.stride);
|
||||||
}
|
}
|
||||||
this.orientedRevision_ = this.getRevision();
|
this.orientedRevision_ = this.getRevision();
|
||||||
@@ -259,7 +259,7 @@ MultiPolygon.prototype.getOrientedFlatCoordinates = function() {
|
|||||||
MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
const simplifiedEndss = [];
|
const simplifiedEndss = [];
|
||||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.quantizess(
|
simplifiedFlatCoordinates.length = quantizeMultiArray(
|
||||||
this.flatCoordinates, 0, this.endss_, this.stride,
|
this.flatCoordinates, 0, this.endss_, this.stride,
|
||||||
Math.sqrt(squaredTolerance),
|
Math.sqrt(squaredTolerance),
|
||||||
simplifiedFlatCoordinates, 0, simplifiedEndss);
|
simplifiedFlatCoordinates, 0, simplifiedEndss);
|
||||||
@@ -344,7 +344,7 @@ MultiPolygon.prototype.getType = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
MultiPolygon.prototype.intersectsExtent = function(extent) {
|
MultiPolygon.prototype.intersectsExtent = function(extent) {
|
||||||
return _ol_geom_flat_intersectsextent_.linearRingss(
|
return intersectsLinearRingMultiArray(
|
||||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, extent);
|
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, extent);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
const endss = _ol_geom_flat_deflate_.coordinatesss(
|
const endss = deflateMultiCoordinatesArray(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride, this.endss_);
|
this.flatCoordinates, 0, coordinates, this.stride, this.endss_);
|
||||||
if (endss.length === 0) {
|
if (endss.length === 0) {
|
||||||
this.flatCoordinates.length = 0;
|
this.flatCoordinates.length = 0;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {createOrUpdateFromCoordinate, containsXY} from '../extent.js';
|
|||||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinate} from '../geom/flat/deflate.js';
|
||||||
import {squaredDistance as squaredDx} from '../math.js';
|
import {squaredDistance as squaredDx} from '../math.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +108,7 @@ Point.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinate(
|
this.flatCoordinates.length = deflateCoordinate(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride);
|
this.flatCoordinates, 0, coordinates, this.stride);
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-17
@@ -11,14 +11,14 @@ import Point from '../geom/Point.js';
|
|||||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||||
import {offset as sphereOffset} from '../sphere.js';
|
import {offset as sphereOffset} from '../sphere.js';
|
||||||
import {linearRings as linearRingsArea} from '../geom/flat/area.js';
|
import {linearRings as linearRingsArea} from '../geom/flat/area.js';
|
||||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
import {assignClosestArrayPoint, arrayMaxSquaredDelta} from '../geom/flat/closest.js';
|
||||||
import {linearRingsContainsXY} from '../geom/flat/contains.js';
|
import {linearRingsContainsXY} from '../geom/flat/contains.js';
|
||||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
import {deflateCoordinatesArray} from '../geom/flat/deflate.js';
|
||||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
import {inflateCoordinatesArray} from '../geom/flat/inflate.js';
|
||||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
import {getInteriorPointOfArray} from '../geom/flat/interiorpoint.js';
|
||||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
import {intersectsLinearRingArray} from '../geom/flat/intersectsextent.js';
|
||||||
import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
|
import {linearRingIsOriented, orientLinearRings} from '../geom/flat/orient.js';
|
||||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
import {quantizeArray} from '../geom/flat/simplify.js';
|
||||||
import {modulo} from '../math.js';
|
import {modulo} from '../math.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,11 +127,11 @@ Polygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistan
|
|||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
}
|
}
|
||||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getsMaxSquaredDelta(
|
this.maxDelta_ = Math.sqrt(arrayMaxSquaredDelta(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||||
this.maxDeltaRevision_ = this.getRevision();
|
this.maxDeltaRevision_ = this.getRevision();
|
||||||
}
|
}
|
||||||
return _ol_geom_flat_closest_.getsClosestPoint(
|
return assignClosestArrayPoint(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||||
};
|
};
|
||||||
@@ -173,13 +173,13 @@ Polygon.prototype.getCoordinates = function(opt_right) {
|
|||||||
let flatCoordinates;
|
let flatCoordinates;
|
||||||
if (opt_right !== undefined) {
|
if (opt_right !== undefined) {
|
||||||
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
||||||
_ol_geom_flat_orient_.orientLinearRings(
|
orientLinearRings(
|
||||||
flatCoordinates, 0, this.ends_, this.stride, opt_right);
|
flatCoordinates, 0, this.ends_, this.stride, opt_right);
|
||||||
} else {
|
} else {
|
||||||
flatCoordinates = this.flatCoordinates;
|
flatCoordinates = this.flatCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _ol_geom_flat_inflate_.coordinatess(
|
return inflateCoordinatesArray(
|
||||||
flatCoordinates, 0, this.ends_, this.stride);
|
flatCoordinates, 0, this.ends_, this.stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ Polygon.prototype.getEnds = function() {
|
|||||||
Polygon.prototype.getFlatInteriorPoint = function() {
|
Polygon.prototype.getFlatInteriorPoint = function() {
|
||||||
if (this.flatInteriorPointRevision_ != this.getRevision()) {
|
if (this.flatInteriorPointRevision_ != this.getRevision()) {
|
||||||
const flatCenter = getCenter(this.getExtent());
|
const flatCenter = getCenter(this.getExtent());
|
||||||
this.flatInteriorPoint_ = _ol_geom_flat_interiorpoint_.linearRings(
|
this.flatInteriorPoint_ = getInteriorPointOfArray(
|
||||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride,
|
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride,
|
||||||
flatCenter, 0);
|
flatCenter, 0);
|
||||||
this.flatInteriorPointRevision_ = this.getRevision();
|
this.flatInteriorPointRevision_ = this.getRevision();
|
||||||
@@ -279,13 +279,13 @@ Polygon.prototype.getLinearRings = function() {
|
|||||||
Polygon.prototype.getOrientedFlatCoordinates = function() {
|
Polygon.prototype.getOrientedFlatCoordinates = function() {
|
||||||
if (this.orientedRevision_ != this.getRevision()) {
|
if (this.orientedRevision_ != this.getRevision()) {
|
||||||
const flatCoordinates = this.flatCoordinates;
|
const flatCoordinates = this.flatCoordinates;
|
||||||
if (_ol_geom_flat_orient_.linearRingsAreOriented(
|
if (linearRingIsOriented(
|
||||||
flatCoordinates, 0, this.ends_, this.stride)) {
|
flatCoordinates, 0, this.ends_, this.stride)) {
|
||||||
this.orientedFlatCoordinates_ = flatCoordinates;
|
this.orientedFlatCoordinates_ = flatCoordinates;
|
||||||
} else {
|
} else {
|
||||||
this.orientedFlatCoordinates_ = flatCoordinates.slice();
|
this.orientedFlatCoordinates_ = flatCoordinates.slice();
|
||||||
this.orientedFlatCoordinates_.length =
|
this.orientedFlatCoordinates_.length =
|
||||||
_ol_geom_flat_orient_.orientLinearRings(
|
orientLinearRings(
|
||||||
this.orientedFlatCoordinates_, 0, this.ends_, this.stride);
|
this.orientedFlatCoordinates_, 0, this.ends_, this.stride);
|
||||||
}
|
}
|
||||||
this.orientedRevision_ = this.getRevision();
|
this.orientedRevision_ = this.getRevision();
|
||||||
@@ -300,7 +300,7 @@ Polygon.prototype.getOrientedFlatCoordinates = function() {
|
|||||||
Polygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
Polygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
const simplifiedEnds = [];
|
const simplifiedEnds = [];
|
||||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.quantizes(
|
simplifiedFlatCoordinates.length = quantizeArray(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||||
Math.sqrt(squaredTolerance),
|
Math.sqrt(squaredTolerance),
|
||||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||||
@@ -325,7 +325,7 @@ Polygon.prototype.getType = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
Polygon.prototype.intersectsExtent = function(extent) {
|
Polygon.prototype.intersectsExtent = function(extent) {
|
||||||
return _ol_geom_flat_intersectsextent_.linearRings(
|
return intersectsLinearRingArray(
|
||||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, extent);
|
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, extent);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|||||||
if (!this.flatCoordinates) {
|
if (!this.flatCoordinates) {
|
||||||
this.flatCoordinates = [];
|
this.flatCoordinates = [];
|
||||||
}
|
}
|
||||||
const ends = _ol_geom_flat_deflate_.coordinatess(
|
const ends = deflateCoordinatesArray(
|
||||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||||
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {FALSE} from '../functions.js';
|
|||||||
import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
|
import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
|
||||||
import Geometry from '../geom/Geometry.js';
|
import Geometry from '../geom/Geometry.js';
|
||||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||||
import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
|
import {rotate, scale, translate, transform2D} from '../geom/flat/transform.js';
|
||||||
import {clear} from '../obj.js';
|
import {clear} from '../obj.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,7 +267,7 @@ SimpleGeometry.prototype.rotate = function(angle, anchor) {
|
|||||||
const flatCoordinates = this.getFlatCoordinates();
|
const flatCoordinates = this.getFlatCoordinates();
|
||||||
if (flatCoordinates) {
|
if (flatCoordinates) {
|
||||||
const stride = this.getStride();
|
const stride = this.getStride();
|
||||||
_ol_geom_flat_transform_.rotate(
|
rotate(
|
||||||
flatCoordinates, 0, flatCoordinates.length,
|
flatCoordinates, 0, flatCoordinates.length,
|
||||||
stride, angle, anchor, flatCoordinates);
|
stride, angle, anchor, flatCoordinates);
|
||||||
this.changed();
|
this.changed();
|
||||||
@@ -291,7 +291,7 @@ SimpleGeometry.prototype.scale = function(sx, opt_sy, opt_anchor) {
|
|||||||
const flatCoordinates = this.getFlatCoordinates();
|
const flatCoordinates = this.getFlatCoordinates();
|
||||||
if (flatCoordinates) {
|
if (flatCoordinates) {
|
||||||
const stride = this.getStride();
|
const stride = this.getStride();
|
||||||
_ol_geom_flat_transform_.scale(
|
scale(
|
||||||
flatCoordinates, 0, flatCoordinates.length,
|
flatCoordinates, 0, flatCoordinates.length,
|
||||||
stride, sx, sy, anchor, flatCoordinates);
|
stride, sx, sy, anchor, flatCoordinates);
|
||||||
this.changed();
|
this.changed();
|
||||||
@@ -307,7 +307,7 @@ SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
|
|||||||
const flatCoordinates = this.getFlatCoordinates();
|
const flatCoordinates = this.getFlatCoordinates();
|
||||||
if (flatCoordinates) {
|
if (flatCoordinates) {
|
||||||
const stride = this.getStride();
|
const stride = this.getStride();
|
||||||
_ol_geom_flat_transform_.translate(
|
translate(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||||
deltaX, deltaY, flatCoordinates);
|
deltaX, deltaY, flatCoordinates);
|
||||||
this.changed();
|
this.changed();
|
||||||
@@ -327,7 +327,7 @@ SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) {
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
const stride = simpleGeometry.getStride();
|
const stride = simpleGeometry.getStride();
|
||||||
return _ol_geom_flat_transform_.transform2D(
|
return transform2D(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||||
transform, opt_dest);
|
transform, opt_dest);
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-32
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/geom/flat/closest
|
* @module ol/geom/flat/closest
|
||||||
*/
|
*/
|
||||||
import {lerp, squaredDistance as squaredDx} from '../../math.js';
|
import {lerp, squaredDistance as squaredDx} from '../../math.js';
|
||||||
const _ol_geom_flat_closest_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +16,7 @@ const _ol_geom_flat_closest_ = {};
|
|||||||
* @param {number} y Y.
|
* @param {number} y Y.
|
||||||
* @param {Array.<number>} closestPoint Closest point.
|
* @param {Array.<number>} closestPoint Closest point.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
|
function assignClosest(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
|
||||||
const x1 = flatCoordinates[offset1];
|
const x1 = flatCoordinates[offset1];
|
||||||
const y1 = flatCoordinates[offset1 + 1];
|
const y1 = flatCoordinates[offset1 + 1];
|
||||||
const dx = flatCoordinates[offset2] - x1;
|
const dx = flatCoordinates[offset2] - x1;
|
||||||
@@ -44,7 +43,7 @@ _ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, strid
|
|||||||
closestPoint[i] = flatCoordinates[offset + i];
|
closestPoint[i] = flatCoordinates[offset + i];
|
||||||
}
|
}
|
||||||
closestPoint.length = stride;
|
closestPoint.length = stride;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,24 +53,24 @@ _ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, strid
|
|||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @param {number} maxSquaredDelta Max squared delta.
|
* @param {number} max Max squared delta.
|
||||||
* @return {number} Max squared delta.
|
* @return {number} Max squared delta.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.getMaxSquaredDelta = function(flatCoordinates, offset, end, stride, maxSquaredDelta) {
|
export function maxSquaredDelta(flatCoordinates, offset, end, stride, max) {
|
||||||
let x1 = flatCoordinates[offset];
|
let x1 = flatCoordinates[offset];
|
||||||
let y1 = flatCoordinates[offset + 1];
|
let y1 = flatCoordinates[offset + 1];
|
||||||
for (offset += stride; offset < end; offset += stride) {
|
for (offset += stride; offset < end; offset += stride) {
|
||||||
const x2 = flatCoordinates[offset];
|
const x2 = flatCoordinates[offset];
|
||||||
const y2 = flatCoordinates[offset + 1];
|
const y2 = flatCoordinates[offset + 1];
|
||||||
const squaredDelta = squaredDx(x1, y1, x2, y2);
|
const squaredDelta = squaredDx(x1, y1, x2, y2);
|
||||||
if (squaredDelta > maxSquaredDelta) {
|
if (squaredDelta > max) {
|
||||||
maxSquaredDelta = squaredDelta;
|
max = squaredDelta;
|
||||||
}
|
}
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
}
|
}
|
||||||
return maxSquaredDelta;
|
return max;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,18 +78,18 @@ _ol_geom_flat_closest_.getMaxSquaredDelta = function(flatCoordinates, offset, en
|
|||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {Array.<number>} ends Ends.
|
* @param {Array.<number>} ends Ends.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @param {number} maxSquaredDelta Max squared delta.
|
* @param {number} max Max squared delta.
|
||||||
* @return {number} Max squared delta.
|
* @return {number} Max squared delta.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.getsMaxSquaredDelta = function(flatCoordinates, offset, ends, stride, maxSquaredDelta) {
|
export function arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max) {
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
maxSquaredDelta = _ol_geom_flat_closest_.getMaxSquaredDelta(
|
max = maxSquaredDelta(
|
||||||
flatCoordinates, offset, end, stride, maxSquaredDelta);
|
flatCoordinates, offset, end, stride, max);
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return maxSquaredDelta;
|
return max;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,18 +97,18 @@ _ol_geom_flat_closest_.getsMaxSquaredDelta = function(flatCoordinates, offset, e
|
|||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {Array.<Array.<number>>} endss Endss.
|
* @param {Array.<Array.<number>>} endss Endss.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @param {number} maxSquaredDelta Max squared delta.
|
* @param {number} max Max squared delta.
|
||||||
* @return {number} Max squared delta.
|
* @return {number} Max squared delta.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.getssMaxSquaredDelta = function(flatCoordinates, offset, endss, stride, maxSquaredDelta) {
|
export function multiArrayMaxSquaredDelta(flatCoordinates, offset, endss, stride, max) {
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
maxSquaredDelta = _ol_geom_flat_closest_.getsMaxSquaredDelta(
|
max = arrayMaxSquaredDelta(
|
||||||
flatCoordinates, offset, ends, stride, maxSquaredDelta);
|
flatCoordinates, offset, ends, stride, max);
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
return maxSquaredDelta;
|
return max;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +125,7 @@ _ol_geom_flat_closest_.getssMaxSquaredDelta = function(flatCoordinates, offset,
|
|||||||
* @param {Array.<number>=} opt_tmpPoint Temporary point object.
|
* @param {Array.<number>=} opt_tmpPoint Temporary point object.
|
||||||
* @return {number} Minimum squared distance.
|
* @return {number} Minimum squared distance.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
export function assignClosestPoint(flatCoordinates, offset, end,
|
||||||
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||||
opt_tmpPoint) {
|
opt_tmpPoint) {
|
||||||
if (offset == end) {
|
if (offset == end) {
|
||||||
@@ -150,7 +149,7 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
|||||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||||
let index = offset + stride;
|
let index = offset + stride;
|
||||||
while (index < end) {
|
while (index < end) {
|
||||||
_ol_geom_flat_closest_.point(
|
assignClosest(
|
||||||
flatCoordinates, index - stride, index, stride, x, y, tmpPoint);
|
flatCoordinates, index - stride, index, stride, x, y, tmpPoint);
|
||||||
squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
|
squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
|
||||||
if (squaredDistance < minSquaredDistance) {
|
if (squaredDistance < minSquaredDistance) {
|
||||||
@@ -178,7 +177,7 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
|||||||
}
|
}
|
||||||
if (isRing) {
|
if (isRing) {
|
||||||
// Check the closing segment.
|
// Check the closing segment.
|
||||||
_ol_geom_flat_closest_.point(
|
assignClosest(
|
||||||
flatCoordinates, end - stride, offset, stride, x, y, tmpPoint);
|
flatCoordinates, end - stride, offset, stride, x, y, tmpPoint);
|
||||||
squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
|
squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
|
||||||
if (squaredDistance < minSquaredDistance) {
|
if (squaredDistance < minSquaredDistance) {
|
||||||
@@ -190,7 +189,7 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,19 +206,19 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
|||||||
* @param {Array.<number>=} opt_tmpPoint Temporary point object.
|
* @param {Array.<number>=} opt_tmpPoint Temporary point object.
|
||||||
* @return {number} Minimum squared distance.
|
* @return {number} Minimum squared distance.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.getsClosestPoint = function(flatCoordinates, offset, ends,
|
export function assignClosestArrayPoint(flatCoordinates, offset, ends,
|
||||||
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||||
opt_tmpPoint) {
|
opt_tmpPoint) {
|
||||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
minSquaredDistance = _ol_geom_flat_closest_.getClosestPoint(
|
minSquaredDistance = assignClosestPoint(
|
||||||
flatCoordinates, offset, end, stride,
|
flatCoordinates, offset, end, stride,
|
||||||
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -236,17 +235,16 @@ _ol_geom_flat_closest_.getsClosestPoint = function(flatCoordinates, offset, ends
|
|||||||
* @param {Array.<number>=} opt_tmpPoint Temporary point object.
|
* @param {Array.<number>=} opt_tmpPoint Temporary point object.
|
||||||
* @return {number} Minimum squared distance.
|
* @return {number} Minimum squared distance.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_closest_.getssClosestPoint = function(flatCoordinates, offset,
|
export function assignClosestMultiArrayPoint(flatCoordinates, offset,
|
||||||
endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||||
opt_tmpPoint) {
|
opt_tmpPoint) {
|
||||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
minSquaredDistance = _ol_geom_flat_closest_.getsClosestPoint(
|
minSquaredDistance = assignClosestArrayPoint(
|
||||||
flatCoordinates, offset, ends, stride,
|
flatCoordinates, offset, ends, stride,
|
||||||
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
return minSquaredDistance;
|
return minSquaredDistance;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_closest_;
|
|
||||||
|
|||||||
+10
-12
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/deflate
|
* @module ol/geom/flat/deflate
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_deflate_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,12 +10,12 @@ const _ol_geom_flat_deflate_ = {};
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @return {number} offset Offset.
|
* @return {number} offset Offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_deflate_.coordinate = function(flatCoordinates, offset, coordinate, stride) {
|
export function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {
|
||||||
for (let i = 0, ii = coordinate.length; i < ii; ++i) {
|
for (let i = 0, ii = coordinate.length; i < ii; ++i) {
|
||||||
flatCoordinates[offset++] = coordinate[i];
|
flatCoordinates[offset++] = coordinate[i];
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +25,7 @@ _ol_geom_flat_deflate_.coordinate = function(flatCoordinates, offset, coordinate
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @return {number} offset Offset.
|
* @return {number} offset Offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_deflate_.coordinates = function(flatCoordinates, offset, coordinates, stride) {
|
export function deflateCoordinates(flatCoordinates, offset, coordinates, stride) {
|
||||||
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||||
const coordinate = coordinates[i];
|
const coordinate = coordinates[i];
|
||||||
for (let j = 0; j < stride; ++j) {
|
for (let j = 0; j < stride; ++j) {
|
||||||
@@ -34,7 +33,7 @@ _ol_geom_flat_deflate_.coordinates = function(flatCoordinates, offset, coordinat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,18 +44,18 @@ _ol_geom_flat_deflate_.coordinates = function(flatCoordinates, offset, coordinat
|
|||||||
* @param {Array.<number>=} opt_ends Ends.
|
* @param {Array.<number>=} opt_ends Ends.
|
||||||
* @return {Array.<number>} Ends.
|
* @return {Array.<number>} Ends.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_deflate_.coordinatess = function(flatCoordinates, offset, coordinatess, stride, opt_ends) {
|
export function deflateCoordinatesArray(flatCoordinates, offset, coordinatess, stride, opt_ends) {
|
||||||
const ends = opt_ends ? opt_ends : [];
|
const ends = opt_ends ? opt_ends : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = 0, jj = coordinatess.length; j < jj; ++j) {
|
for (let j = 0, jj = coordinatess.length; j < jj; ++j) {
|
||||||
const end = _ol_geom_flat_deflate_.coordinates(
|
const end = deflateCoordinates(
|
||||||
flatCoordinates, offset, coordinatess[j], stride);
|
flatCoordinates, offset, coordinatess[j], stride);
|
||||||
ends[i++] = end;
|
ends[i++] = end;
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
ends.length = i;
|
ends.length = i;
|
||||||
return ends;
|
return ends;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,16 +66,15 @@ _ol_geom_flat_deflate_.coordinatess = function(flatCoordinates, offset, coordina
|
|||||||
* @param {Array.<Array.<number>>=} opt_endss Endss.
|
* @param {Array.<Array.<number>>=} opt_endss Endss.
|
||||||
* @return {Array.<Array.<number>>} Endss.
|
* @return {Array.<Array.<number>>} Endss.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_deflate_.coordinatesss = function(flatCoordinates, offset, coordinatesss, stride, opt_endss) {
|
export function deflateMultiCoordinatesArray(flatCoordinates, offset, coordinatesss, stride, opt_endss) {
|
||||||
const endss = opt_endss ? opt_endss : [];
|
const endss = opt_endss ? opt_endss : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {
|
for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {
|
||||||
const ends = _ol_geom_flat_deflate_.coordinatess(
|
const ends = deflateCoordinatesArray(
|
||||||
flatCoordinates, offset, coordinatesss[j], stride, endss[i]);
|
flatCoordinates, offset, coordinatesss[j], stride, endss[i]);
|
||||||
endss[i++] = ends;
|
endss[i++] = ends;
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
endss.length = i;
|
endss.length = i;
|
||||||
return endss;
|
return endss;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_deflate_;
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/inflate
|
* @module ol/geom/flat/inflate
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_inflate_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +11,7 @@ const _ol_geom_flat_inflate_ = {};
|
|||||||
* @param {Array.<ol.Coordinate>=} opt_coordinates Coordinates.
|
* @param {Array.<ol.Coordinate>=} opt_coordinates Coordinates.
|
||||||
* @return {Array.<ol.Coordinate>} Coordinates.
|
* @return {Array.<ol.Coordinate>} Coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stride, opt_coordinates) {
|
export function inflateCoordinates(flatCoordinates, offset, end, stride, opt_coordinates) {
|
||||||
const coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
|
const coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = offset; j < end; j += stride) {
|
for (let j = offset; j < end; j += stride) {
|
||||||
@@ -20,7 +19,7 @@ _ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stri
|
|||||||
}
|
}
|
||||||
coordinates.length = i;
|
coordinates.length = i;
|
||||||
return coordinates;
|
return coordinates;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,18 +30,18 @@ _ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stri
|
|||||||
* @param {Array.<Array.<ol.Coordinate>>=} opt_coordinatess Coordinatess.
|
* @param {Array.<Array.<ol.Coordinate>>=} opt_coordinatess Coordinatess.
|
||||||
* @return {Array.<Array.<ol.Coordinate>>} Coordinatess.
|
* @return {Array.<Array.<ol.Coordinate>>} Coordinatess.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, stride, opt_coordinatess) {
|
export function inflateCoordinatesArray(flatCoordinates, offset, ends, stride, opt_coordinatess) {
|
||||||
const coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
|
const coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = 0, jj = ends.length; j < jj; ++j) {
|
for (let j = 0, jj = ends.length; j < jj; ++j) {
|
||||||
const end = ends[j];
|
const end = ends[j];
|
||||||
coordinatess[i++] = _ol_geom_flat_inflate_.coordinates(
|
coordinatess[i++] = inflateCoordinates(
|
||||||
flatCoordinates, offset, end, stride, coordinatess[i]);
|
flatCoordinates, offset, end, stride, coordinatess[i]);
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
coordinatess.length = i;
|
coordinatess.length = i;
|
||||||
return coordinatess;
|
return coordinatess;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,16 +53,15 @@ _ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, st
|
|||||||
* Coordinatesss.
|
* Coordinatesss.
|
||||||
* @return {Array.<Array.<Array.<ol.Coordinate>>>} Coordinatesss.
|
* @return {Array.<Array.<Array.<ol.Coordinate>>>} Coordinatesss.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_inflate_.coordinatesss = function(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
|
export function inflateMultiCoordinatesArray(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
|
||||||
const coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
|
const coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = 0, jj = endss.length; j < jj; ++j) {
|
for (let j = 0, jj = endss.length; j < jj; ++j) {
|
||||||
const ends = endss[j];
|
const ends = endss[j];
|
||||||
coordinatesss[i++] = _ol_geom_flat_inflate_.coordinatess(
|
coordinatesss[i++] = inflateCoordinatesArray(
|
||||||
flatCoordinates, offset, ends, stride, coordinatesss[i]);
|
flatCoordinates, offset, ends, stride, coordinatesss[i]);
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
coordinatesss.length = i;
|
coordinatesss.length = i;
|
||||||
return coordinatesss;
|
return coordinatesss;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_inflate_;
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
import {numberSafeCompareFunction} from '../../array.js';
|
import {numberSafeCompareFunction} from '../../array.js';
|
||||||
import {linearRingsContainsXY} from '../flat/contains.js';
|
import {linearRingsContainsXY} from '../flat/contains.js';
|
||||||
const _ol_geom_flat_interiorpoint_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +18,7 @@ const _ol_geom_flat_interiorpoint_ = {};
|
|||||||
* @return {Array.<number>} Destination point as XYM coordinate, where M is the
|
* @return {Array.<number>} Destination point as XYM coordinate, where M is the
|
||||||
* length of the horizontal intersection that the point belongs to.
|
* length of the horizontal intersection that the point belongs to.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
export function getInteriorPointOfArray(flatCoordinates, offset,
|
||||||
ends, stride, flatCenters, flatCentersOffset, opt_dest) {
|
ends, stride, flatCenters, flatCentersOffset, opt_dest) {
|
||||||
let i, ii, x, x1, x2, y1, y2;
|
let i, ii, x, x1, x2, y1, y2;
|
||||||
const y = flatCenters[flatCentersOffset + 1];
|
const y = flatCenters[flatCentersOffset + 1];
|
||||||
@@ -70,7 +69,7 @@ _ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
|||||||
} else {
|
} else {
|
||||||
return [pointX, y, maxSegmentLength];
|
return [pointX, y, maxSegmentLength];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,14 +81,13 @@ _ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
|||||||
* @return {Array.<number>} Interior points as XYM coordinates, where M is the
|
* @return {Array.<number>} Interior points as XYM coordinates, where M is the
|
||||||
* length of the horizontal intersection that the point belongs to.
|
* length of the horizontal intersection that the point belongs to.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_interiorpoint_.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) {
|
export function getInteriorPointsOfMultiArray(flatCoordinates, offset, endss, stride, flatCenters) {
|
||||||
let interiorPoints = [];
|
let interiorPoints = [];
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
interiorPoints = _ol_geom_flat_interiorpoint_.linearRings(flatCoordinates,
|
interiorPoints = getInteriorPointOfArray(flatCoordinates,
|
||||||
offset, ends, stride, flatCenters, 2 * i, interiorPoints);
|
offset, ends, stride, flatCenters, 2 * i, interiorPoints);
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
return interiorPoints;
|
return interiorPoints;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_interiorpoint_;
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
import {binarySearch} from '../../array.js';
|
import {binarySearch} from '../../array.js';
|
||||||
import {lerp} from '../../math.js';
|
import {lerp} from '../../math.js';
|
||||||
const _ol_geom_flat_interpolate_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +14,7 @@ const _ol_geom_flat_interpolate_ = {};
|
|||||||
* @param {Array.<number>=} opt_dest Destination.
|
* @param {Array.<number>=} opt_dest Destination.
|
||||||
* @return {Array.<number>} Destination.
|
* @return {Array.<number>} Destination.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) {
|
export function interpolatePoint(flatCoordinates, offset, end, stride, fraction, opt_dest) {
|
||||||
let pointX = NaN;
|
let pointX = NaN;
|
||||||
let pointY = NaN;
|
let pointY = NaN;
|
||||||
const n = (end - offset) / stride;
|
const n = (end - offset) / stride;
|
||||||
@@ -62,7 +61,7 @@ _ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, s
|
|||||||
} else {
|
} else {
|
||||||
return [pointX, pointY];
|
return [pointX, pointY];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +73,7 @@ _ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, s
|
|||||||
* @param {boolean} extrapolate Extrapolate.
|
* @param {boolean} extrapolate Extrapolate.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, offset, end, stride, m, extrapolate) {
|
export function lineStringCoordinateAtM(flatCoordinates, offset, end, stride, m, extrapolate) {
|
||||||
if (end == offset) {
|
if (end == offset) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -123,7 +122,7 @@ _ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, o
|
|||||||
}
|
}
|
||||||
coordinate.push(m);
|
coordinate.push(m);
|
||||||
return coordinate;
|
return coordinate;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,10 +135,10 @@ _ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, o
|
|||||||
* @param {boolean} interpolate Interpolate.
|
* @param {boolean} interpolate Interpolate.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_interpolate_.lineStringsCoordinateAtM = function(
|
export function lineStringsCoordinateAtM(
|
||||||
flatCoordinates, offset, ends, stride, m, extrapolate, interpolate) {
|
flatCoordinates, offset, ends, stride, m, extrapolate, interpolate) {
|
||||||
if (interpolate) {
|
if (interpolate) {
|
||||||
return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(
|
return lineStringCoordinateAtM(
|
||||||
flatCoordinates, offset, ends[ends.length - 1], stride, m, extrapolate);
|
flatCoordinates, offset, ends[ends.length - 1], stride, m, extrapolate);
|
||||||
}
|
}
|
||||||
let coordinate;
|
let coordinate;
|
||||||
@@ -169,11 +168,10 @@ _ol_geom_flat_interpolate_.lineStringsCoordinateAtM = function(
|
|||||||
if (m < flatCoordinates[offset + stride - 1]) {
|
if (m < flatCoordinates[offset + stride - 1]) {
|
||||||
return null;
|
return null;
|
||||||
} else if (m <= flatCoordinates[end - 1]) {
|
} else if (m <= flatCoordinates[end - 1]) {
|
||||||
return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(
|
return lineStringCoordinateAtM(
|
||||||
flatCoordinates, offset, end, stride, m, false);
|
flatCoordinates, offset, end, stride, m, false);
|
||||||
}
|
}
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_interpolate_;
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import {containsExtent, createEmpty, extendFlatCoordinates, intersects, intersectsSegment} from '../../extent.js';
|
import {containsExtent, createEmpty, extendFlatCoordinates, intersects, intersectsSegment} from '../../extent.js';
|
||||||
import {linearRingContainsXY, linearRingContainsExtent} from '../flat/contains.js';
|
import {linearRingContainsXY, linearRingContainsExtent} from '../flat/contains.js';
|
||||||
import {forEach as forEachSegment} from '../flat/segments.js';
|
import {forEach as forEachSegment} from '../flat/segments.js';
|
||||||
const _ol_geom_flat_intersectsextent_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +14,7 @@ const _ol_geom_flat_intersectsextent_ = {};
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, end, stride, extent) {
|
export function intersectsLineString(flatCoordinates, offset, end, stride, extent) {
|
||||||
const coordinatesExtent = extendFlatCoordinates(
|
const coordinatesExtent = extendFlatCoordinates(
|
||||||
createEmpty(), flatCoordinates, offset, end, stride);
|
createEmpty(), flatCoordinates, offset, end, stride);
|
||||||
if (!intersects(extent, coordinatesExtent)) {
|
if (!intersects(extent, coordinatesExtent)) {
|
||||||
@@ -42,7 +41,7 @@ _ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, e
|
|||||||
function(point1, point2) {
|
function(point1, point2) {
|
||||||
return intersectsSegment(extent, point1, point2);
|
return intersectsSegment(extent, point1, point2);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,16 +52,16 @@ _ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, e
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_intersectsextent_.lineStrings = function(flatCoordinates, offset, ends, stride, extent) {
|
export function intersectsLineStringArray(flatCoordinates, offset, ends, stride, extent) {
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
if (_ol_geom_flat_intersectsextent_.lineString(
|
if (intersectsLineString(
|
||||||
flatCoordinates, offset, ends[i], stride, extent)) {
|
flatCoordinates, offset, ends[i], stride, extent)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
offset = ends[i];
|
offset = ends[i];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +72,8 @@ _ol_geom_flat_intersectsextent_.lineStrings = function(flatCoordinates, offset,
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, end, stride, extent) {
|
export function intersectsLinearRing(flatCoordinates, offset, end, stride, extent) {
|
||||||
if (_ol_geom_flat_intersectsextent_.lineString(
|
if (intersectsLineString(
|
||||||
flatCoordinates, offset, end, stride, extent)) {
|
flatCoordinates, offset, end, stride, extent)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -91,7 +90,7 @@ _ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, e
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,8 +101,8 @@ _ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, e
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset, ends, stride, extent) {
|
export function intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent) {
|
||||||
if (!_ol_geom_flat_intersectsextent_.linearRing(
|
if (!intersectsLinearRing(
|
||||||
flatCoordinates, offset, ends[0], stride, extent)) {
|
flatCoordinates, offset, ends[0], stride, extent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -116,7 +115,7 @@ _ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,15 +126,14 @@ _ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset,
|
|||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @return {boolean} True if the geometry and the extent intersect.
|
* @return {boolean} True if the geometry and the extent intersect.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_intersectsextent_.linearRingss = function(flatCoordinates, offset, endss, stride, extent) {
|
export function intersectsLinearRingMultiArray(flatCoordinates, offset, endss, stride, extent) {
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
if (_ol_geom_flat_intersectsextent_.linearRings(
|
if (intersectsLinearRingArray(
|
||||||
flatCoordinates, offset, ends, stride, extent)) {
|
flatCoordinates, offset, ends, stride, extent)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_intersectsextent_;
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/length
|
* @module ol/geom/flat/length
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_length_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +10,7 @@ const _ol_geom_flat_length_ = {};
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @return {number} Length.
|
* @return {number} Length.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride) {
|
export function lineStringLength(flatCoordinates, offset, end, stride) {
|
||||||
let x1 = flatCoordinates[offset];
|
let x1 = flatCoordinates[offset];
|
||||||
let y1 = flatCoordinates[offset + 1];
|
let y1 = flatCoordinates[offset + 1];
|
||||||
let length = 0;
|
let length = 0;
|
||||||
@@ -23,7 +22,7 @@ _ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride
|
|||||||
y1 = y2;
|
y1 = y2;
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,11 +32,10 @@ _ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @return {number} Perimeter.
|
* @return {number} Perimeter.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_length_.linearRing = function(flatCoordinates, offset, end, stride) {
|
export function linearRingLength(flatCoordinates, offset, end, stride) {
|
||||||
let perimeter = _ol_geom_flat_length_.lineString(flatCoordinates, offset, end, stride);
|
let perimeter = lineStringLength(flatCoordinates, offset, end, stride);
|
||||||
const dx = flatCoordinates[end - stride] - flatCoordinates[offset];
|
const dx = flatCoordinates[end - stride] - flatCoordinates[offset];
|
||||||
const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
|
const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
|
||||||
perimeter += Math.sqrt(dx * dx + dy * dy);
|
perimeter += Math.sqrt(dx * dx + dy * dy);
|
||||||
return perimeter;
|
return perimeter;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_length_;
|
|
||||||
|
|||||||
+14
-16
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/geom/flat/orient
|
* @module ol/geom/flat/orient
|
||||||
*/
|
*/
|
||||||
import {coordinates as reverseCoordinates} from '../flat/reverse.js';
|
import {coordinates as reverseCoordinates} from '../flat/reverse.js';
|
||||||
const _ol_geom_flat_orient_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +11,7 @@ const _ol_geom_flat_orient_ = {};
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @return {boolean} Is clockwise.
|
* @return {boolean} Is clockwise.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_orient_.linearRingIsClockwise = function(flatCoordinates, offset, end, stride) {
|
export function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
|
||||||
// http://tinyurl.com/clockwise-method
|
// http://tinyurl.com/clockwise-method
|
||||||
// https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrlinearring.cpp
|
// https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrlinearring.cpp
|
||||||
let edge = 0;
|
let edge = 0;
|
||||||
@@ -26,7 +25,7 @@ _ol_geom_flat_orient_.linearRingIsClockwise = function(flatCoordinates, offset,
|
|||||||
y1 = y2;
|
y1 = y2;
|
||||||
}
|
}
|
||||||
return edge > 0;
|
return edge > 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,11 +41,11 @@ _ol_geom_flat_orient_.linearRingIsClockwise = function(flatCoordinates, offset,
|
|||||||
* (counter-clockwise exterior ring and clockwise interior rings).
|
* (counter-clockwise exterior ring and clockwise interior rings).
|
||||||
* @return {boolean} Rings are correctly oriented.
|
* @return {boolean} Rings are correctly oriented.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_orient_.linearRingsAreOriented = function(flatCoordinates, offset, ends, stride, opt_right) {
|
export function linearRingIsOriented(flatCoordinates, offset, ends, stride, opt_right) {
|
||||||
const right = opt_right !== undefined ? opt_right : false;
|
const right = opt_right !== undefined ? opt_right : false;
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
const isClockwise = linearRingIsClockwise(
|
||||||
flatCoordinates, offset, end, stride);
|
flatCoordinates, offset, end, stride);
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
if ((right && isClockwise) || (!right && !isClockwise)) {
|
if ((right && isClockwise) || (!right && !isClockwise)) {
|
||||||
@@ -60,7 +59,7 @@ _ol_geom_flat_orient_.linearRingsAreOriented = function(flatCoordinates, offset,
|
|||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,15 +75,15 @@ _ol_geom_flat_orient_.linearRingsAreOriented = function(flatCoordinates, offset,
|
|||||||
* (counter-clockwise exterior ring and clockwise interior rings).
|
* (counter-clockwise exterior ring and clockwise interior rings).
|
||||||
* @return {boolean} Rings are correctly oriented.
|
* @return {boolean} Rings are correctly oriented.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_orient_.linearRingssAreOriented = function(flatCoordinates, offset, endss, stride, opt_right) {
|
export function linearRingsAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
if (!_ol_geom_flat_orient_.linearRingsAreOriented(
|
if (!linearRingIsOriented(
|
||||||
flatCoordinates, offset, endss[i], stride, opt_right)) {
|
flatCoordinates, offset, endss[i], stride, opt_right)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,11 +99,11 @@ _ol_geom_flat_orient_.linearRingssAreOriented = function(flatCoordinates, offset
|
|||||||
* @param {boolean=} opt_right Follow the right-hand rule for orientation.
|
* @param {boolean=} opt_right Follow the right-hand rule for orientation.
|
||||||
* @return {number} End.
|
* @return {number} End.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends, stride, opt_right) {
|
export function orientLinearRings(flatCoordinates, offset, ends, stride, opt_right) {
|
||||||
const right = opt_right !== undefined ? opt_right : false;
|
const right = opt_right !== undefined ? opt_right : false;
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
const isClockwise = linearRingIsClockwise(
|
||||||
flatCoordinates, offset, end, stride);
|
flatCoordinates, offset, end, stride);
|
||||||
const reverse = i === 0 ?
|
const reverse = i === 0 ?
|
||||||
(right && isClockwise) || (!right && !isClockwise) :
|
(right && isClockwise) || (!right && !isClockwise) :
|
||||||
@@ -115,7 +114,7 @@ _ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends
|
|||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,11 +130,10 @@ _ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends
|
|||||||
* @param {boolean=} opt_right Follow the right-hand rule for orientation.
|
* @param {boolean=} opt_right Follow the right-hand rule for orientation.
|
||||||
* @return {number} End.
|
* @return {number} End.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_orient_.orientLinearRingss = function(flatCoordinates, offset, endss, stride, opt_right) {
|
export function orientLinearRingsArray(flatCoordinates, offset, endss, stride, opt_right) {
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
offset = _ol_geom_flat_orient_.orientLinearRings(
|
offset = orientLinearRings(
|
||||||
flatCoordinates, offset, endss[i], stride, opt_right);
|
flatCoordinates, offset, endss[i], stride, opt_right);
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_orient_;
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import {squaredSegmentDistance, squaredDistance} from '../../math.js';
|
import {squaredSegmentDistance, squaredDistance} from '../../math.js';
|
||||||
const _ol_geom_flat_simplify_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,23 +41,23 @@ const _ol_geom_flat_simplify_ = {};
|
|||||||
* coordinates.
|
* coordinates.
|
||||||
* @return {Array.<number>} Simplified line string.
|
* @return {Array.<number>} Simplified line string.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.lineString = function(flatCoordinates, offset, end,
|
export function simplifyLineString(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
||||||
const simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
|
const simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
|
||||||
opt_simplifiedFlatCoordinates : [];
|
opt_simplifiedFlatCoordinates : [];
|
||||||
if (!highQuality) {
|
if (!highQuality) {
|
||||||
end = _ol_geom_flat_simplify_.radialDistance(flatCoordinates, offset, end,
|
end = radialDistance(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance,
|
stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, 0);
|
simplifiedFlatCoordinates, 0);
|
||||||
flatCoordinates = simplifiedFlatCoordinates;
|
flatCoordinates = simplifiedFlatCoordinates;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
stride = 2;
|
stride = 2;
|
||||||
}
|
}
|
||||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker(
|
simplifiedFlatCoordinates.length = douglasPeucker(
|
||||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, 0);
|
simplifiedFlatCoordinates, 0);
|
||||||
return simplifiedFlatCoordinates;
|
return simplifiedFlatCoordinates;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +71,7 @@ _ol_geom_flat_simplify_.lineString = function(flatCoordinates, offset, end,
|
|||||||
* @param {number} simplifiedOffset Simplified offset.
|
* @param {number} simplifiedOffset Simplified offset.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
|
export function douglasPeucker(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||||
const n = (end - offset) / stride;
|
const n = (end - offset) / stride;
|
||||||
if (n < 3) {
|
if (n < 3) {
|
||||||
@@ -128,7 +127,7 @@ _ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,19 +142,19 @@ _ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
|
|||||||
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.douglasPeuckers = function(flatCoordinates, offset,
|
export function douglasPeuckerArray(flatCoordinates, offset,
|
||||||
ends, stride, squaredTolerance, simplifiedFlatCoordinates,
|
ends, stride, squaredTolerance, simplifiedFlatCoordinates,
|
||||||
simplifiedOffset, simplifiedEnds) {
|
simplifiedOffset, simplifiedEnds) {
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
simplifiedOffset = _ol_geom_flat_simplify_.douglasPeucker(
|
simplifiedOffset = douglasPeucker(
|
||||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset);
|
simplifiedFlatCoordinates, simplifiedOffset);
|
||||||
simplifiedEnds.push(simplifiedOffset);
|
simplifiedEnds.push(simplifiedOffset);
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,20 +169,20 @@ _ol_geom_flat_simplify_.douglasPeuckers = function(flatCoordinates, offset,
|
|||||||
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.douglasPeuckerss = function(
|
export function douglasPeuckerMultiArray(
|
||||||
flatCoordinates, offset, endss, stride, squaredTolerance,
|
flatCoordinates, offset, endss, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
const simplifiedEnds = [];
|
const simplifiedEnds = [];
|
||||||
simplifiedOffset = _ol_geom_flat_simplify_.douglasPeuckers(
|
simplifiedOffset = douglasPeuckerArray(
|
||||||
flatCoordinates, offset, ends, stride, squaredTolerance,
|
flatCoordinates, offset, ends, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||||
simplifiedEndss.push(simplifiedEnds);
|
simplifiedEndss.push(simplifiedEnds);
|
||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +196,7 @@ _ol_geom_flat_simplify_.douglasPeuckerss = function(
|
|||||||
* @param {number} simplifiedOffset Simplified offset.
|
* @param {number} simplifiedOffset Simplified offset.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end,
|
export function radialDistance(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||||
if (end <= offset + stride) {
|
if (end <= offset + stride) {
|
||||||
// zero or one point, no simplification possible, so copy and return
|
// zero or one point, no simplification possible, so copy and return
|
||||||
@@ -232,7 +231,7 @@ _ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end,
|
|||||||
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
|
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
|
||||||
}
|
}
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,9 +239,9 @@ _ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end,
|
|||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @return {number} Rounded value.
|
* @return {number} Rounded value.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.snap = function(value, tolerance) {
|
export function snap(value, tolerance) {
|
||||||
return tolerance * Math.round(value / tolerance);
|
return tolerance * Math.round(value / tolerance);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -264,15 +263,15 @@ _ol_geom_flat_simplify_.snap = function(value, tolerance) {
|
|||||||
* @param {number} simplifiedOffset Simplified offset.
|
* @param {number} simplifiedOffset Simplified offset.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride,
|
export function quantize(flatCoordinates, offset, end, stride,
|
||||||
tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||||
// do nothing if the line is empty
|
// do nothing if the line is empty
|
||||||
if (offset == end) {
|
if (offset == end) {
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
}
|
}
|
||||||
// snap the first coordinate (P1)
|
// snap the first coordinate (P1)
|
||||||
let x1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
let x1 = snap(flatCoordinates[offset], tolerance);
|
||||||
let y1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
let y1 = snap(flatCoordinates[offset + 1], tolerance);
|
||||||
offset += stride;
|
offset += stride;
|
||||||
// add the first coordinate to the output
|
// add the first coordinate to the output
|
||||||
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
|
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
|
||||||
@@ -281,8 +280,8 @@ _ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride
|
|||||||
// coordinate (P2)
|
// coordinate (P2)
|
||||||
let x2, y2;
|
let x2, y2;
|
||||||
do {
|
do {
|
||||||
x2 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
x2 = snap(flatCoordinates[offset], tolerance);
|
||||||
y2 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
y2 = snap(flatCoordinates[offset + 1], tolerance);
|
||||||
offset += stride;
|
offset += stride;
|
||||||
if (offset == end) {
|
if (offset == end) {
|
||||||
// all coordinates snap to the same value, the line collapses to a point
|
// all coordinates snap to the same value, the line collapses to a point
|
||||||
@@ -296,8 +295,8 @@ _ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride
|
|||||||
} while (x2 == x1 && y2 == y1);
|
} while (x2 == x1 && y2 == y1);
|
||||||
while (offset < end) {
|
while (offset < end) {
|
||||||
// snap the next coordinate (P3)
|
// snap the next coordinate (P3)
|
||||||
const x3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
const x3 = snap(flatCoordinates[offset], tolerance);
|
||||||
const y3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
const y3 = snap(flatCoordinates[offset + 1], tolerance);
|
||||||
offset += stride;
|
offset += stride;
|
||||||
// skip P3 if it is equal to P2
|
// skip P3 if it is equal to P2
|
||||||
if (x3 == x2 && y3 == y2) {
|
if (x3 == x2 && y3 == y2) {
|
||||||
@@ -334,7 +333,7 @@ _ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride
|
|||||||
simplifiedFlatCoordinates[simplifiedOffset++] = x2;
|
simplifiedFlatCoordinates[simplifiedOffset++] = x2;
|
||||||
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
|
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,13 +348,13 @@ _ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride
|
|||||||
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.quantizes = function(
|
export function quantizeArray(
|
||||||
flatCoordinates, offset, ends, stride,
|
flatCoordinates, offset, ends, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
simplifiedOffset = _ol_geom_flat_simplify_.quantize(
|
simplifiedOffset = quantize(
|
||||||
flatCoordinates, offset, end, stride,
|
flatCoordinates, offset, end, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset);
|
simplifiedFlatCoordinates, simplifiedOffset);
|
||||||
@@ -363,7 +362,7 @@ _ol_geom_flat_simplify_.quantizes = function(
|
|||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -378,14 +377,14 @@ _ol_geom_flat_simplify_.quantizes = function(
|
|||||||
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_simplify_.quantizess = function(
|
export function quantizeMultiArray(
|
||||||
flatCoordinates, offset, endss, stride,
|
flatCoordinates, offset, endss, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
const simplifiedEnds = [];
|
const simplifiedEnds = [];
|
||||||
simplifiedOffset = _ol_geom_flat_simplify_.quantizes(
|
simplifiedOffset = quantizeArray(
|
||||||
flatCoordinates, offset, ends, stride,
|
flatCoordinates, offset, ends, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||||
@@ -393,5 +392,4 @@ _ol_geom_flat_simplify_.quantizess = function(
|
|||||||
offset = ends[ends.length - 1];
|
offset = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_simplify_;
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/straightchunk
|
* @module ol/geom/flat/straightchunk
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_straightchunk_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +12,7 @@ const _ol_geom_flat_straightchunk_ = {};
|
|||||||
* @return {Array.<number>} Start and end of the first suitable chunk of the
|
* @return {Array.<number>} Start and end of the first suitable chunk of the
|
||||||
* given `flatCoordinates`.
|
* given `flatCoordinates`.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_straightchunk_.lineString = function(maxAngle, flatCoordinates, offset, end, stride) {
|
export function matchingChunk(maxAngle, flatCoordinates, offset, end, stride) {
|
||||||
let chunkStart = offset;
|
let chunkStart = offset;
|
||||||
let chunkEnd = offset;
|
let chunkEnd = offset;
|
||||||
let chunkM = 0;
|
let chunkM = 0;
|
||||||
@@ -49,5 +48,4 @@ _ol_geom_flat_straightchunk_.lineString = function(maxAngle, flatCoordinates, of
|
|||||||
}
|
}
|
||||||
m += m23;
|
m += m23;
|
||||||
return m > chunkM ? [start, i] : [chunkStart, chunkEnd];
|
return m > chunkM ? [start, i] : [chunkStart, chunkEnd];
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_straightchunk_;
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/geom/flat/textpath
|
* @module ol/geom/flat/textpath
|
||||||
*/
|
*/
|
||||||
import {lerp} from '../../math.js';
|
import {lerp} from '../../math.js';
|
||||||
const _ol_geom_flat_textpath_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +17,7 @@ const _ol_geom_flat_textpath_ = {};
|
|||||||
* @return {Array.<Array.<*>>} The result array of null if `maxAngle` was
|
* @return {Array.<Array.<*>>} The result array of null if `maxAngle` was
|
||||||
* exceeded. Entries of the array are x, y, anchorX, angle, chunk.
|
* exceeded. Entries of the array are x, y, anchorX, angle, chunk.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_textpath_.lineString = function(
|
export function drawTextOnPath(
|
||||||
flatCoordinates, offset, end, stride, text, measure, startM, maxAngle) {
|
flatCoordinates, offset, end, stride, text, measure, startM, maxAngle) {
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
@@ -90,5 +89,4 @@ _ol_geom_flat_textpath_.lineString = function(
|
|||||||
startM += charLength;
|
startM += charLength;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_textpath_;
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/transform
|
* @module ol/geom/flat/transform
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_transform_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +12,7 @@ const _ol_geom_flat_transform_ = {};
|
|||||||
* @param {Array.<number>=} opt_dest Destination.
|
* @param {Array.<number>=} opt_dest Destination.
|
||||||
* @return {Array.<number>} Transformed coordinates.
|
* @return {Array.<number>} Transformed coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_transform_.transform2D = function(flatCoordinates, offset, end, stride, transform, opt_dest) {
|
export function transform2D(flatCoordinates, offset, end, stride, transform, opt_dest) {
|
||||||
const dest = opt_dest ? opt_dest : [];
|
const dest = opt_dest ? opt_dest : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = offset; j < end; j += stride) {
|
for (let j = offset; j < end; j += stride) {
|
||||||
@@ -26,7 +25,7 @@ _ol_geom_flat_transform_.transform2D = function(flatCoordinates, offset, end, st
|
|||||||
dest.length = i;
|
dest.length = i;
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +38,7 @@ _ol_geom_flat_transform_.transform2D = function(flatCoordinates, offset, end, st
|
|||||||
* @param {Array.<number>=} opt_dest Destination.
|
* @param {Array.<number>=} opt_dest Destination.
|
||||||
* @return {Array.<number>} Transformed coordinates.
|
* @return {Array.<number>} Transformed coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_transform_.rotate = function(flatCoordinates, offset, end, stride, angle, anchor, opt_dest) {
|
export function rotate(flatCoordinates, offset, end, stride, angle, anchor, opt_dest) {
|
||||||
const dest = opt_dest ? opt_dest : [];
|
const dest = opt_dest ? opt_dest : [];
|
||||||
const cos = Math.cos(angle);
|
const cos = Math.cos(angle);
|
||||||
const sin = Math.sin(angle);
|
const sin = Math.sin(angle);
|
||||||
@@ -59,7 +58,7 @@ _ol_geom_flat_transform_.rotate = function(flatCoordinates, offset, end, stride,
|
|||||||
dest.length = i;
|
dest.length = i;
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +73,7 @@ _ol_geom_flat_transform_.rotate = function(flatCoordinates, offset, end, stride,
|
|||||||
* @param {Array.<number>=} opt_dest Destination.
|
* @param {Array.<number>=} opt_dest Destination.
|
||||||
* @return {Array.<number>} Transformed coordinates.
|
* @return {Array.<number>} Transformed coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_transform_.scale = function(flatCoordinates, offset, end, stride, sx, sy, anchor, opt_dest) {
|
export function scale(flatCoordinates, offset, end, stride, sx, sy, anchor, opt_dest) {
|
||||||
const dest = opt_dest ? opt_dest : [];
|
const dest = opt_dest ? opt_dest : [];
|
||||||
const anchorX = anchor[0];
|
const anchorX = anchor[0];
|
||||||
const anchorY = anchor[1];
|
const anchorY = anchor[1];
|
||||||
@@ -92,7 +91,7 @@ _ol_geom_flat_transform_.scale = function(flatCoordinates, offset, end, stride,
|
|||||||
dest.length = i;
|
dest.length = i;
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,7 +104,7 @@ _ol_geom_flat_transform_.scale = function(flatCoordinates, offset, end, stride,
|
|||||||
* @param {Array.<number>=} opt_dest Destination.
|
* @param {Array.<number>=} opt_dest Destination.
|
||||||
* @return {Array.<number>} Transformed coordinates.
|
* @return {Array.<number>} Transformed coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_transform_.translate = function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) {
|
export function translate(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) {
|
||||||
const dest = opt_dest ? opt_dest : [];
|
const dest = opt_dest ? opt_dest : [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let j = offset; j < end; j += stride) {
|
for (let j = offset; j < end; j += stride) {
|
||||||
@@ -119,5 +118,4 @@ _ol_geom_flat_transform_.translate = function(flatCoordinates, offset, end, stri
|
|||||||
dest.length = i;
|
dest.length = i;
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_transform_;
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {extend} from '../array.js';
|
|||||||
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
|
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
|
||||||
import GeometryType from '../geom/GeometryType.js';
|
import GeometryType from '../geom/GeometryType.js';
|
||||||
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
||||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
import {getInteriorPointOfArray, getInteriorPointsOfMultiArray} from '../geom/flat/interiorpoint.js';
|
||||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
import {interpolatePoint} from '../geom/flat/interpolate.js';
|
||||||
import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
|
import {transform2D} from '../geom/flat/transform.js';
|
||||||
import _ol_transform_ from '../transform.js';
|
import _ol_transform_ from '../transform.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,7 +125,7 @@ RenderFeature.prototype.getExtent = function() {
|
|||||||
RenderFeature.prototype.getFlatInteriorPoint = function() {
|
RenderFeature.prototype.getFlatInteriorPoint = function() {
|
||||||
if (!this.flatInteriorPoints_) {
|
if (!this.flatInteriorPoints_) {
|
||||||
const flatCenter = getCenter(this.getExtent());
|
const flatCenter = getCenter(this.getExtent());
|
||||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRings(
|
this.flatInteriorPoints_ = getInteriorPointOfArray(
|
||||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0);
|
this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0);
|
||||||
}
|
}
|
||||||
return this.flatInteriorPoints_;
|
return this.flatInteriorPoints_;
|
||||||
@@ -139,7 +139,7 @@ RenderFeature.prototype.getFlatInteriorPoints = function() {
|
|||||||
if (!this.flatInteriorPoints_) {
|
if (!this.flatInteriorPoints_) {
|
||||||
const flatCenters = linearRingssCenter(
|
const flatCenters = linearRingssCenter(
|
||||||
this.flatCoordinates_, 0, this.ends_, 2);
|
this.flatCoordinates_, 0, this.ends_, 2);
|
||||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
|
this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(
|
||||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
|
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
|
||||||
}
|
}
|
||||||
return this.flatInteriorPoints_;
|
return this.flatInteriorPoints_;
|
||||||
@@ -151,7 +151,7 @@ RenderFeature.prototype.getFlatInteriorPoints = function() {
|
|||||||
*/
|
*/
|
||||||
RenderFeature.prototype.getFlatMidpoint = function() {
|
RenderFeature.prototype.getFlatMidpoint = function() {
|
||||||
if (!this.flatMidpoints_) {
|
if (!this.flatMidpoints_) {
|
||||||
this.flatMidpoints_ = _ol_geom_flat_interpolate_.lineString(
|
this.flatMidpoints_ = interpolatePoint(
|
||||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
|
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
|
||||||
}
|
}
|
||||||
return this.flatMidpoints_;
|
return this.flatMidpoints_;
|
||||||
@@ -169,7 +169,7 @@ RenderFeature.prototype.getFlatMidpoints = function() {
|
|||||||
const ends = this.ends_;
|
const ends = this.ends_;
|
||||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
const end = ends[i];
|
const end = ends[i];
|
||||||
const midpoint = _ol_geom_flat_interpolate_.lineString(
|
const midpoint = interpolatePoint(
|
||||||
flatCoordinates, offset, end, 2, 0.5);
|
flatCoordinates, offset, end, 2, 0.5);
|
||||||
extend(this.flatMidpoints_, midpoint);
|
extend(this.flatMidpoints_, midpoint);
|
||||||
offset = end;
|
offset = end;
|
||||||
@@ -272,7 +272,7 @@ RenderFeature.prototype.transform = function(source, destination) {
|
|||||||
projectedExtent[0], projectedExtent[3],
|
projectedExtent[0], projectedExtent[3],
|
||||||
scale, -scale, 0,
|
scale, -scale, 0,
|
||||||
0, 0);
|
0, 0);
|
||||||
_ol_geom_flat_transform_.transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
|
transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
|
||||||
transform, this.flatCoordinates_);
|
transform, this.flatCoordinates_);
|
||||||
};
|
};
|
||||||
export default RenderFeature;
|
export default RenderFeature;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {asColorLike} from '../../colorlike.js';
|
|||||||
import {intersects} from '../../extent.js';
|
import {intersects} from '../../extent.js';
|
||||||
import GeometryType from '../../geom/GeometryType.js';
|
import GeometryType from '../../geom/GeometryType.js';
|
||||||
import SimpleGeometry from '../../geom/SimpleGeometry.js';
|
import SimpleGeometry from '../../geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
import {transform2D} from '../../geom/flat/transform.js';
|
||||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||||
import VectorContext from '../VectorContext.js';
|
import VectorContext from '../VectorContext.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
@@ -252,7 +252,7 @@ CanvasImmediateRenderer.prototype.drawImages_ = function(flatCoordinates, offset
|
|||||||
if (!this.image_) {
|
if (!this.image_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
const pixelCoordinates = transform2D(
|
||||||
flatCoordinates, offset, end, 2, this.transform_,
|
flatCoordinates, offset, end, 2, this.transform_,
|
||||||
this.pixelCoordinates_);
|
this.pixelCoordinates_);
|
||||||
const context = this.context_;
|
const context = this.context_;
|
||||||
@@ -313,7 +313,7 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
|
|||||||
this.setContextStrokeState_(this.textStrokeState_);
|
this.setContextStrokeState_(this.textStrokeState_);
|
||||||
}
|
}
|
||||||
this.setContextTextState_(this.textState_);
|
this.setContextTextState_(this.textState_);
|
||||||
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
const pixelCoordinates = transform2D(
|
||||||
flatCoordinates, offset, end, stride, this.transform_,
|
flatCoordinates, offset, end, stride, this.transform_,
|
||||||
this.pixelCoordinates_);
|
this.pixelCoordinates_);
|
||||||
const context = this.context_;
|
const context = this.context_;
|
||||||
@@ -356,7 +356,7 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
|
|||||||
*/
|
*/
|
||||||
CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) {
|
CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) {
|
||||||
const context = this.context_;
|
const context = this.context_;
|
||||||
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
const pixelCoordinates = transform2D(
|
||||||
flatCoordinates, offset, end, stride, this.transform_,
|
flatCoordinates, offset, end, stride, this.transform_,
|
||||||
this.pixelCoordinates_);
|
this.pixelCoordinates_);
|
||||||
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
|
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import {inherits} from '../../index.js';
|
import {inherits} from '../../index.js';
|
||||||
import {asString} from '../../color.js';
|
import {asString} from '../../color.js';
|
||||||
import _ol_geom_flat_simplify_ from '../../geom/flat/simplify.js';
|
import {snap} from '../../geom/flat/simplify.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
import CanvasInstruction, {
|
import CanvasInstruction, {
|
||||||
fillInstruction, strokeInstruction, beginPathInstruction, closePathInstruction
|
fillInstruction, strokeInstruction, beginPathInstruction, closePathInstruction
|
||||||
@@ -195,7 +195,7 @@ CanvasPolygonReplay.prototype.finish = function() {
|
|||||||
if (tolerance !== 0) {
|
if (tolerance !== 0) {
|
||||||
const coordinates = this.coordinates;
|
const coordinates = this.coordinates;
|
||||||
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||||
coordinates[i] = _ol_geom_flat_simplify_.snap(coordinates[i], tolerance);
|
coordinates[i] = snap(coordinates[i], tolerance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import {buffer, clone, coordinateRelationship, createEmpty, createOrUpdate,
|
|||||||
createOrUpdateEmpty, extend, extendCoordinate, intersects} from '../../extent.js';
|
createOrUpdateEmpty, extend, extendCoordinate, intersects} from '../../extent.js';
|
||||||
import Relationship from '../../extent/Relationship.js';
|
import Relationship from '../../extent/Relationship.js';
|
||||||
import GeometryType from '../../geom/GeometryType.js';
|
import GeometryType from '../../geom/GeometryType.js';
|
||||||
import _ol_geom_flat_inflate_ from '../../geom/flat/inflate.js';
|
import {inflateCoordinates, inflateCoordinatesArray, inflateMultiCoordinatesArray} from '../../geom/flat/inflate.js';
|
||||||
import _ol_geom_flat_length_ from '../../geom/flat/length.js';
|
import {lineStringLength} from '../../geom/flat/length.js';
|
||||||
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
|
import {drawTextOnPath} from '../../geom/flat/textpath.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
import {transform2D} from '../../geom/flat/transform.js';
|
||||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import VectorContext from '../VectorContext.js';
|
import VectorContext from '../VectorContext.js';
|
||||||
@@ -410,7 +410,7 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
|||||||
replayEndss.push(myEnds);
|
replayEndss.push(myEnds);
|
||||||
}
|
}
|
||||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEndss, geometry, renderer, _ol_geom_flat_inflate_.coordinatesss]);
|
replayBegin, replayEndss, geometry, renderer, inflateMultiCoordinatesArray]);
|
||||||
} else if (type == GeometryType.POLYGON || type == GeometryType.MULTI_LINE_STRING) {
|
} else if (type == GeometryType.POLYGON || type == GeometryType.MULTI_LINE_STRING) {
|
||||||
replayEnds = [];
|
replayEnds = [];
|
||||||
flatCoordinates = (type == GeometryType.POLYGON) ?
|
flatCoordinates = (type == GeometryType.POLYGON) ?
|
||||||
@@ -420,13 +420,13 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
|||||||
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
|
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
|
||||||
stride, replayEnds);
|
stride, replayEnds);
|
||||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]);
|
replayBegin, replayEnds, geometry, renderer, inflateCoordinatesArray]);
|
||||||
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
|
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
|
||||||
flatCoordinates = geometry.getFlatCoordinates();
|
flatCoordinates = geometry.getFlatCoordinates();
|
||||||
replayEnd = this.appendFlatCoordinates(
|
replayEnd = this.appendFlatCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]);
|
replayBegin, replayEnd, geometry, renderer, inflateCoordinates]);
|
||||||
} else if (type == GeometryType.POINT) {
|
} else if (type == GeometryType.POINT) {
|
||||||
flatCoordinates = geometry.getFlatCoordinates();
|
flatCoordinates = geometry.getFlatCoordinates();
|
||||||
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||||
@@ -549,7 +549,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
if (!this.pixelCoordinates_) {
|
if (!this.pixelCoordinates_) {
|
||||||
this.pixelCoordinates_ = [];
|
this.pixelCoordinates_ = [];
|
||||||
}
|
}
|
||||||
pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
pixelCoordinates = transform2D(
|
||||||
this.coordinates, 0, this.coordinates.length, 2,
|
this.coordinates, 0, this.coordinates.length, 2,
|
||||||
transform, this.pixelCoordinates_);
|
transform, this.pixelCoordinates_);
|
||||||
_ol_transform_.setFromArray(this.renderedTransform_, transform);
|
_ol_transform_.setFromArray(this.renderedTransform_, transform);
|
||||||
@@ -710,12 +710,12 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
const textKey = /** @type {string} */ (instruction[13]);
|
const textKey = /** @type {string} */ (instruction[13]);
|
||||||
const textScale = /** @type {number} */ (instruction[14]);
|
const textScale = /** @type {number} */ (instruction[14]);
|
||||||
|
|
||||||
const pathLength = _ol_geom_flat_length_.lineString(pixelCoordinates, begin, end, 2);
|
const pathLength = lineStringLength(pixelCoordinates, begin, end, 2);
|
||||||
const textLength = measure(text);
|
const textLength = measure(text);
|
||||||
if (overflow || textLength <= pathLength) {
|
if (overflow || textLength <= pathLength) {
|
||||||
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
|
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
|
||||||
const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
|
const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
|
||||||
const parts = _ol_geom_flat_textpath_.lineString(
|
const parts = drawTextOnPath(
|
||||||
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
|
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
|
||||||
if (parts) {
|
if (parts) {
|
||||||
let c, cc, chars, label, part;
|
let c, cc, chars, label, part;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {inherits} from '../../index.js';
|
|||||||
import {numberSafeCompareFunction} from '../../array.js';
|
import {numberSafeCompareFunction} from '../../array.js';
|
||||||
import {createCanvasContext2D} from '../../dom.js';
|
import {createCanvasContext2D} from '../../dom.js';
|
||||||
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
|
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
import {transform2D} from '../../geom/flat/transform.js';
|
||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import ReplayGroup from '../ReplayGroup.js';
|
import ReplayGroup from '../ReplayGroup.js';
|
||||||
import ReplayType from '../ReplayType.js';
|
import ReplayType from '../ReplayType.js';
|
||||||
@@ -407,7 +407,7 @@ CanvasReplayGroup.prototype.getClipCoords = function(transform) {
|
|||||||
const maxX = maxExtent[2];
|
const maxX = maxExtent[2];
|
||||||
const maxY = maxExtent[3];
|
const maxY = maxExtent[3];
|
||||||
const flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
|
const flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
|
||||||
_ol_geom_flat_transform_.transform2D(
|
transform2D(
|
||||||
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
|
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
|
||||||
return flatClipCoords;
|
return flatClipCoords;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js';
|
|||||||
import {asColorLike} from '../../colorlike.js';
|
import {asColorLike} from '../../colorlike.js';
|
||||||
import {createCanvasContext2D} from '../../dom.js';
|
import {createCanvasContext2D} from '../../dom.js';
|
||||||
import {intersects} from '../../extent.js';
|
import {intersects} from '../../extent.js';
|
||||||
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
import {matchingChunk} from '../../geom/flat/straightchunk.js';
|
||||||
import GeometryType from '../../geom/GeometryType.js';
|
import GeometryType from '../../geom/GeometryType.js';
|
||||||
import {CANVAS_LINE_DASH, SAFARI} from '../../has.js';
|
import {CANVAS_LINE_DASH, SAFARI} from '../../has.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
@@ -202,7 +202,7 @@ CanvasTextReplay.prototype.drawText = function(geometry, feature) {
|
|||||||
let flatEnd;
|
let flatEnd;
|
||||||
for (let o = 0, oo = ends.length; o < oo; ++o) {
|
for (let o = 0, oo = ends.length; o < oo; ++o) {
|
||||||
if (textAlign == undefined) {
|
if (textAlign == undefined) {
|
||||||
const range = _ol_geom_flat_straightchunk_.lineString(
|
const range = matchingChunk(
|
||||||
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
|
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
|
||||||
flatOffset = range[0];
|
flatOffset = range[0];
|
||||||
flatEnd = range[1];
|
flatEnd = range[1];
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {equals} from '../../array.js';
|
|||||||
import {asArray} from '../../color.js';
|
import {asArray} from '../../color.js';
|
||||||
import {intersects} from '../../extent.js';
|
import {intersects} from '../../extent.js';
|
||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
import {translate} from '../../geom/flat/transform.js';
|
||||||
import {fragment, vertex} from '../webgl/circlereplay/defaultshader.js';
|
import {fragment, vertex} from '../webgl/circlereplay/defaultshader.js';
|
||||||
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
|
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
|
||||||
import WebGLReplay from '../webgl/Replay.js';
|
import WebGLReplay from '../webgl/Replay.js';
|
||||||
@@ -134,7 +134,7 @@ WebGLCircleReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
|||||||
|
|
||||||
this.radius_ = radius;
|
this.radius_ = radius;
|
||||||
let flatCoordinates = circleGeometry.getFlatCoordinates();
|
let flatCoordinates = circleGeometry.getFlatCoordinates();
|
||||||
flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, 2,
|
flatCoordinates = translate(flatCoordinates, 0, 2,
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
this.drawCoordinates_(flatCoordinates, 0, 2, stride);
|
this.drawCoordinates_(flatCoordinates, 0, 2, stride);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import {getUid, inherits} from '../../index.js';
|
|||||||
import {equals} from '../../array.js';
|
import {equals} from '../../array.js';
|
||||||
import {asArray} from '../../color.js';
|
import {asArray} from '../../color.js';
|
||||||
import {intersects} from '../../extent.js';
|
import {intersects} from '../../extent.js';
|
||||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
import {linearRingIsClockwise} from '../../geom/flat/orient.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
import {translate} from '../../geom/flat/transform.js';
|
||||||
import {lineStringIsClosed} from '../../geom/flat/topology.js';
|
import {lineStringIsClosed} from '../../geom/flat/topology.js';
|
||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import _ol_render_webgl_ from '../webgl.js';
|
import _ol_render_webgl_ from '../webgl.js';
|
||||||
@@ -252,7 +252,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
|
|
||||||
if (closed) {
|
if (closed) {
|
||||||
n = n || numVertices / 7;
|
n = n || numVertices / 7;
|
||||||
sign = _ol_geom_flat_orient_.linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2)
|
sign = linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2)
|
||||||
? 1 : -1;
|
? 1 : -1;
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
@@ -322,7 +322,7 @@ WebGLLineStringReplay.prototype.drawLineString = function(lineStringGeometry, fe
|
|||||||
let flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
let flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
||||||
const stride = lineStringGeometry.getStride();
|
const stride = lineStringGeometry.getStride();
|
||||||
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
||||||
flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, flatCoordinates.length,
|
flatCoordinates = translate(flatCoordinates, 0, flatCoordinates.length,
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
if (this.state_.changed) {
|
if (this.state_.changed) {
|
||||||
this.styleIndices_.push(this.indices.length);
|
this.styleIndices_.push(this.indices.length);
|
||||||
@@ -349,7 +349,7 @@ WebGLLineStringReplay.prototype.drawMultiLineString = function(multiLineStringGe
|
|||||||
if (ends.length > 1) {
|
if (ends.length > 1) {
|
||||||
for (i = 1, ii = ends.length; i < ii; ++i) {
|
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||||
if (this.isValid_(flatCoordinates, ends[i - 1], ends[i], stride)) {
|
if (this.isValid_(flatCoordinates, ends[i - 1], ends[i], stride)) {
|
||||||
const lineString = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1], ends[i],
|
const lineString = translate(flatCoordinates, ends[i - 1], ends[i],
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
this.drawCoordinates_(
|
this.drawCoordinates_(
|
||||||
lineString, 0, lineString.length, stride);
|
lineString, 0, lineString.length, stride);
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import {asArray} from '../../color.js';
|
|||||||
import {intersects} from '../../extent.js';
|
import {intersects} from '../../extent.js';
|
||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import {linearRingContainsXY} from '../../geom/flat/contains.js';
|
import {linearRingContainsXY} from '../../geom/flat/contains.js';
|
||||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
import {linearRingIsClockwise} from '../../geom/flat/orient.js';
|
||||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
import {translate} from '../../geom/flat/transform.js';
|
||||||
import {fragment, vertex} from '../webgl/polygonreplay/defaultshader.js';
|
import {fragment, vertex} from '../webgl/polygonreplay/defaultshader.js';
|
||||||
import Locations from '../webgl/polygonreplay/defaultshader/Locations.js';
|
import Locations from '../webgl/polygonreplay/defaultshader/Locations.js';
|
||||||
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
|
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
|
||||||
@@ -140,7 +140,7 @@ WebGLPolygonReplay.prototype.drawCoordinates_ = function(
|
|||||||
*/
|
*/
|
||||||
WebGLPolygonReplay.prototype.processFlatCoordinates_ = function(
|
WebGLPolygonReplay.prototype.processFlatCoordinates_ = function(
|
||||||
flatCoordinates, stride, list, rtree, clockwise) {
|
flatCoordinates, stride, list, rtree, clockwise) {
|
||||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates,
|
const isClockwise = linearRingIsClockwise(flatCoordinates,
|
||||||
0, flatCoordinates.length, stride);
|
0, flatCoordinates.length, stride);
|
||||||
let i, ii;
|
let i, ii;
|
||||||
let n = this.vertices.length / 2;
|
let n = this.vertices.length / 2;
|
||||||
@@ -404,7 +404,7 @@ WebGLPolygonReplay.prototype.clipEars_ = function(list, rtree, simple, ccw) {
|
|||||||
variableCriterion) {
|
variableCriterion) {
|
||||||
//The diagonal is completely inside the polygon
|
//The diagonal is completely inside the polygon
|
||||||
if (simple || p0.reflex === false || p2.reflex === false ||
|
if (simple || p0.reflex === false || p2.reflex === false ||
|
||||||
_ol_geom_flat_orient_.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
|
linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
|
||||||
p0.y, p1.x, p1.y, p2.x, p2.y, s3.p1.x, s3.p1.y], 0, 10, 2) === !ccw) {
|
p0.y, p1.x, p1.y, p2.x, p2.y, s3.p1.x, s3.p1.y], 0, 10, 2) === !ccw) {
|
||||||
//The diagonal is persumably valid, we have an ear
|
//The diagonal is persumably valid, we have an ear
|
||||||
this.indices[numIndices++] = p0.i;
|
this.indices[numIndices++] = p0.i;
|
||||||
@@ -533,7 +533,7 @@ WebGLPolygonReplay.prototype.isClockwise_ = function(list) {
|
|||||||
flatCoordinates[i++] = seg.p0.y;
|
flatCoordinates[i++] = seg.p0.y;
|
||||||
seg = list.nextItem();
|
seg = list.nextItem();
|
||||||
} while (seg !== start);
|
} while (seg !== start);
|
||||||
return _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, 0, length, 2);
|
return linearRingIsClockwise(flatCoordinates, 0, length, 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -761,14 +761,14 @@ WebGLPolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, f
|
|||||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
const ends = endss[i];
|
const ends = endss[i];
|
||||||
if (ends.length > 0) {
|
if (ends.length > 0) {
|
||||||
const outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, start, ends[0],
|
const outerRing = translate(flatCoordinates, start, ends[0],
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
if (outerRing.length) {
|
if (outerRing.length) {
|
||||||
const holes = [];
|
const holes = [];
|
||||||
let holeFlatCoords;
|
let holeFlatCoords;
|
||||||
for (j = 1, jj = ends.length; j < jj; ++j) {
|
for (j = 1, jj = ends.length; j < jj; ++j) {
|
||||||
if (ends[j] !== ends[j - 1]) {
|
if (ends[j] !== ends[j - 1]) {
|
||||||
holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[j - 1],
|
holeFlatCoords = translate(flatCoordinates, ends[j - 1],
|
||||||
ends[j], stride, -this.origin[0], -this.origin[1]);
|
ends[j], stride, -this.origin[0], -this.origin[1]);
|
||||||
holes.push(holeFlatCoords);
|
holes.push(holeFlatCoords);
|
||||||
}
|
}
|
||||||
@@ -801,14 +801,14 @@ WebGLPolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
|||||||
const stride = polygonGeometry.getStride();
|
const stride = polygonGeometry.getStride();
|
||||||
if (ends.length > 0) {
|
if (ends.length > 0) {
|
||||||
const flatCoordinates = polygonGeometry.getFlatCoordinates().map(Number);
|
const flatCoordinates = polygonGeometry.getFlatCoordinates().map(Number);
|
||||||
const outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, 0, ends[0],
|
const outerRing = translate(flatCoordinates, 0, ends[0],
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
if (outerRing.length) {
|
if (outerRing.length) {
|
||||||
const holes = [];
|
const holes = [];
|
||||||
let i, ii, holeFlatCoords;
|
let i, ii, holeFlatCoords;
|
||||||
for (i = 1, ii = ends.length; i < ii; ++i) {
|
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||||
if (ends[i] !== ends[i - 1]) {
|
if (ends[i] !== ends[i - 1]) {
|
||||||
holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1],
|
holeFlatCoords = translate(flatCoordinates, ends[i - 1],
|
||||||
ends[i], stride, -this.origin[0], -this.origin[1]);
|
ends[i], stride, -this.origin[0], -this.origin[1]);
|
||||||
holes.push(holeFlatCoords);
|
holes.push(holeFlatCoords);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_geom_flat_closest_ from '../../../../../src/ol/geom/flat/closest.js';
|
import {assignClosestPoint, maxSquaredDelta} from '../../../../../src/ol/geom/flat/closest.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.closest', function() {
|
describe('ol.geom.flat.closest', function() {
|
||||||
@@ -7,35 +7,35 @@ describe('ol.geom.flat.closest', function() {
|
|||||||
|
|
||||||
const flatCoordinates = [0, 0, 1, 0, 3, 0, 5, 0, 6, 0, 8, 0, 11, 0];
|
const flatCoordinates = [0, 0, 1, 0, 3, 0, 5, 0, 6, 0, 8, 0, 11, 0];
|
||||||
|
|
||||||
describe('ol.geom.flat.closest.getMaxSquaredDelta', function() {
|
describe('ol.geom.flat.closest.maxSquaredDelta', function() {
|
||||||
|
|
||||||
it('returns the expected value in simple cases', function() {
|
it('returns the expected value in simple cases', function() {
|
||||||
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
expect(maxSquaredDelta(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
|
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.closest.getClosestPoint', function() {
|
describe('ol.geom.flat.closest.assignClosestPoint', function() {
|
||||||
|
|
||||||
it('returns the expected value', function() {
|
it('returns the expected value', function() {
|
||||||
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
const maxDelta = Math.sqrt(maxSquaredDelta(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 0));
|
flatCoordinates, 0, flatCoordinates.length, 2, 0));
|
||||||
expect(maxDelta).to.be(3);
|
expect(maxDelta).to.be(3);
|
||||||
const closestPoint = [NaN, NaN];
|
const closestPoint = [NaN, NaN];
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0);
|
maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0);
|
||||||
expect(closestPoint).to.eql([0, 0]);
|
expect(closestPoint).to.eql([0, 0]);
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1);
|
maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1);
|
||||||
expect(closestPoint).to.eql([4, 0]);
|
expect(closestPoint).to.eql([4, 0]);
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4);
|
maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4);
|
||||||
expect(closestPoint).to.eql([5, 0]);
|
expect(closestPoint).to.eql([5, 0]);
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
|
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
|
||||||
expect(closestPoint).to.eql([10, 0]);
|
expect(closestPoint).to.eql([10, 0]);
|
||||||
@@ -75,34 +75,34 @@ describe('ol.geom.flat.closest', function() {
|
|||||||
847.16, 458.44, 851.38, 462.79, 853.97, 471.15, 866.36, 480.77
|
847.16, 458.44, 851.38, 462.79, 853.97, 471.15, 866.36, 480.77
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('ol.geom.closet.maSquaredDelta', function() {
|
describe('ol.geom.closest.maxSquaredDelta', function() {
|
||||||
|
|
||||||
it('returns the expected value', function() {
|
it('returns the expected value', function() {
|
||||||
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
expect(maxSquaredDelta(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
|
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
|
||||||
to.roughlyEqual(1389.1058, 1e-9);
|
to.roughlyEqual(1389.1058, 1e-9);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.closest.getClosestPoint', function() {
|
describe('ol.geom.flat.closest.assignClosestPoint', function() {
|
||||||
|
|
||||||
it('returns the expected value', function() {
|
it('returns the expected value', function() {
|
||||||
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
const maxDelta = Math.sqrt(maxSquaredDelta(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 0));
|
flatCoordinates, 0, flatCoordinates.length, 2, 0));
|
||||||
expect(maxDelta).to.roughlyEqual(Math.sqrt(1389.1058), 1e-9);
|
expect(maxDelta).to.roughlyEqual(Math.sqrt(1389.1058), 1e-9);
|
||||||
const closestPoint = [NaN, NaN];
|
const closestPoint = [NaN, NaN];
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 0, 0, closestPoint, Infinity)).
|
maxDelta, false, 0, 0, closestPoint, Infinity)).
|
||||||
to.roughlyEqual(110902.405, 1e-9);
|
to.roughlyEqual(110902.405, 1e-9);
|
||||||
expect(closestPoint).to.eql([292.41, 159.37]);
|
expect(closestPoint).to.eql([292.41, 159.37]);
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 500, 500, closestPoint, Infinity)).
|
maxDelta, false, 500, 500, closestPoint, Infinity)).
|
||||||
to.roughlyEqual(106407.905, 1e-9);
|
to.roughlyEqual(106407.905, 1e-9);
|
||||||
expect(closestPoint).to.eql([671.55, 222.55]);
|
expect(closestPoint).to.eql([671.55, 222.55]);
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2,
|
flatCoordinates, 0, flatCoordinates.length, 2,
|
||||||
maxDelta, false, 1000, 500, closestPoint, Infinity)).
|
maxDelta, false, 1000, 500, closestPoint, Infinity)).
|
||||||
to.roughlyEqual(18229.4425, 1e-9);
|
to.roughlyEqual(18229.4425, 1e-9);
|
||||||
@@ -118,14 +118,14 @@ describe('ol.geom.flat.closest', function() {
|
|||||||
const flatCoordinates = [0, 0, 10, -10, 2, 2, 30, -20];
|
const flatCoordinates = [0, 0, 10, -10, 2, 2, 30, -20];
|
||||||
const stride = 4;
|
const stride = 4;
|
||||||
|
|
||||||
describe('ol.geom.flat.closest.getClosestPoint', function() {
|
describe('ol.geom.flat.closest.assignClosestPoint', function() {
|
||||||
|
|
||||||
it('interpolates M coordinates', function() {
|
it('interpolates M coordinates', function() {
|
||||||
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
const maxDelta = Math.sqrt(maxSquaredDelta(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride, 0));
|
flatCoordinates, 0, flatCoordinates.length, stride, 0));
|
||||||
expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9);
|
expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9);
|
||||||
const closestPoint = [NaN, NaN];
|
const closestPoint = [NaN, NaN];
|
||||||
expect(_ol_geom_flat_closest_.getClosestPoint(
|
expect(assignClosestPoint(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||||
maxDelta, false, 1, 1, closestPoint, Infinity)).
|
maxDelta, false, 1, 1, closestPoint, Infinity)).
|
||||||
to.roughlyEqual(0, 1e-9);
|
to.roughlyEqual(0, 1e-9);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import _ol_geom_flat_deflate_ from '../../../../../src/ol/geom/flat/deflate.js';
|
import {deflateCoordinates, deflateCoordinatesArray} from '../../../../../src/ol/geom/flat/deflate.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.deflate', function() {
|
describe('ol.geom.flat.deflate', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.deflate.coordinates', function() {
|
describe('ol.geom.flat.deflate.deflateCoordinates', function() {
|
||||||
|
|
||||||
let flatCoordinates;
|
let flatCoordinates;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -11,7 +11,7 @@ describe('ol.geom.flat.deflate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('flattens coordinates', function() {
|
it('flattens coordinates', function() {
|
||||||
const offset = _ol_geom_flat_deflate_.coordinates(
|
const offset = deflateCoordinates(
|
||||||
flatCoordinates, 0, [[1, 2], [3, 4]], 2);
|
flatCoordinates, 0, [[1, 2], [3, 4]], 2);
|
||||||
expect(offset).to.be(4);
|
expect(offset).to.be(4);
|
||||||
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
||||||
@@ -19,7 +19,7 @@ describe('ol.geom.flat.deflate', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.deflate.coordinatess', function() {
|
describe('ol.geom.flat.deflate.deflateCoordinatesArray', function() {
|
||||||
|
|
||||||
let flatCoordinates;
|
let flatCoordinates;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -27,7 +27,7 @@ describe('ol.geom.flat.deflate', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('flattens arrays of coordinates', function() {
|
it('flattens arrays of coordinates', function() {
|
||||||
const ends = _ol_geom_flat_deflate_.coordinatess(flatCoordinates, 0,
|
const ends = deflateCoordinatesArray(flatCoordinates, 0,
|
||||||
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 2);
|
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 2);
|
||||||
expect(ends).to.eql([4, 8]);
|
expect(ends).to.eql([4, 8]);
|
||||||
expect(flatCoordinates).to.eql([1, 2, 3, 4, 5, 6, 7, 8]);
|
expect(flatCoordinates).to.eql([1, 2, 3, 4, 5, 6, 7, 8]);
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import _ol_geom_flat_inflate_ from '../../../../../src/ol/geom/flat/inflate.js';
|
import {inflateCoordinates, inflateCoordinatesArray} from '../../../../../src/ol/geom/flat/inflate.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.inflate', function() {
|
describe('ol.geom.flat.inflate', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.inflate.coordinates', function() {
|
describe('ol.geom.flat.inflate.inflateCoordinates', function() {
|
||||||
|
|
||||||
it('inflates coordinates', function() {
|
it('inflates coordinates', function() {
|
||||||
const coordinates = _ol_geom_flat_inflate_.coordinates([1, 2, 3, 4], 0, 4, 2);
|
const coordinates = inflateCoordinates([1, 2, 3, 4], 0, 4, 2);
|
||||||
expect(coordinates).to.eql([[1, 2], [3, 4]]);
|
expect(coordinates).to.eql([[1, 2], [3, 4]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.inflate.coordinatess', function() {
|
describe('ol.geom.flat.inflate.inflateCoordinatesArray', function() {
|
||||||
|
|
||||||
it('inflates arrays of coordinates', function() {
|
it('inflates arrays of coordinates', function() {
|
||||||
const coordinatess = _ol_geom_flat_inflate_.coordinatess(
|
const coordinatess = inflateCoordinatesArray(
|
||||||
[1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2);
|
[1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2);
|
||||||
expect(coordinatess).to.eql([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
expect(coordinatess).to.eql([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import _ol_geom_flat_interpolate_ from '../../../../../src/ol/geom/flat/interpolate.js';
|
import {interpolatePoint} from '../../../../../src/ol/geom/flat/interpolate.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.interpolate', function() {
|
describe('ol.geom.flat.interpolate', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.interpolate.lineString', function() {
|
describe('ol.geom.flat.interpolate.interpolatePoint', function() {
|
||||||
|
|
||||||
it('returns the expected value for single points', function() {
|
it('returns the expected value for single points', function() {
|
||||||
const flatCoordinates = [0, 1];
|
const flatCoordinates = [0, 1];
|
||||||
const point =
|
const point =
|
||||||
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 2, 2, 0.5);
|
interpolatePoint(flatCoordinates, 0, 2, 2, 0.5);
|
||||||
expect(point).to.eql([0, 1]);
|
expect(point).to.eql([0, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the expected value for simple line segments', function() {
|
it('returns the expected value for simple line segments', function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3];
|
const flatCoordinates = [0, 1, 2, 3];
|
||||||
const point =
|
const point =
|
||||||
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 4, 2, 0.5);
|
interpolatePoint(flatCoordinates, 0, 4, 2, 0.5);
|
||||||
expect(point).to.eql([1, 2]);
|
expect(point).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -23,14 +23,14 @@ describe('ol.geom.flat.interpolate', function() {
|
|||||||
'coordinate',
|
'coordinate',
|
||||||
function() {
|
function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 4, 5];
|
const flatCoordinates = [0, 1, 2, 3, 4, 5];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 6, 2, 0.5);
|
flatCoordinates, 0, 6, 2, 0.5);
|
||||||
expect(point).to.eql([2, 3]);
|
expect(point).to.eql([2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('also when vertices are repeated', function() {
|
xit('also when vertices are repeated', function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5];
|
const flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 6, 2, 0.5);
|
flatCoordinates, 0, 6, 2, 0.5);
|
||||||
expect(point).to.eql([2, 3]);
|
expect(point).to.eql([2, 3]);
|
||||||
});
|
});
|
||||||
@@ -39,14 +39,14 @@ describe('ol.geom.flat.interpolate', function() {
|
|||||||
'two existing coordinates',
|
'two existing coordinates',
|
||||||
function() {
|
function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
|
const flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 8, 2, 0.5);
|
flatCoordinates, 0, 8, 2, 0.5);
|
||||||
expect(point).to.eql([3, 4]);
|
expect(point).to.eql([3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('also when vertices are repeated', function() {
|
xit('also when vertices are repeated', function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5, 6, 7];
|
const flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5, 6, 7];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 8, 2, 0.5);
|
flatCoordinates, 0, 8, 2, 0.5);
|
||||||
expect(point).to.eql([3, 4]);
|
expect(point).to.eql([3, 4]);
|
||||||
});
|
});
|
||||||
@@ -54,7 +54,7 @@ describe('ol.geom.flat.interpolate', function() {
|
|||||||
it('returns the expected value when the coordinates are not evenly spaced',
|
it('returns the expected value when the coordinates are not evenly spaced',
|
||||||
function() {
|
function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 6, 7];
|
const flatCoordinates = [0, 1, 2, 3, 6, 7];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 6, 2, 0.5);
|
flatCoordinates, 0, 6, 2, 0.5);
|
||||||
expect(point).to.eql([3, 4]);
|
expect(point).to.eql([3, 4]);
|
||||||
});
|
});
|
||||||
@@ -62,7 +62,7 @@ describe('ol.geom.flat.interpolate', function() {
|
|||||||
xit('also when vertices are repeated',
|
xit('also when vertices are repeated',
|
||||||
function() {
|
function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7];
|
const flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 6, 2, 0.5);
|
flatCoordinates, 0, 6, 2, 0.5);
|
||||||
expect(point).to.eql([3, 4]);
|
expect(point).to.eql([3, 4]);
|
||||||
});
|
});
|
||||||
@@ -70,7 +70,7 @@ describe('ol.geom.flat.interpolate', function() {
|
|||||||
it('returns the expected value when using opt_dest',
|
it('returns the expected value when using opt_dest',
|
||||||
function() {
|
function() {
|
||||||
const flatCoordinates = [0, 1, 2, 3, 6, 7];
|
const flatCoordinates = [0, 1, 2, 3, 6, 7];
|
||||||
const point = _ol_geom_flat_interpolate_.lineString(
|
const point = interpolatePoint(
|
||||||
flatCoordinates, 0, 6, 2, 0.5, [0, 0]);
|
flatCoordinates, 0, 6, 2, 0.5, [0, 0]);
|
||||||
expect(point).to.eql([3, 4]);
|
expect(point).to.eql([3, 4]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import _ol_geom_flat_intersectsextent_ from '../../../../../src/ol/geom/flat/intersectsextent.js';
|
import {intersectsLinearRing, intersectsLineString} from '../../../../../src/ol/geom/flat/intersectsextent.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.intersectsextent', function() {
|
describe('ol.geom.flat.intersectsextent', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.intersectsextent.lineString', function() {
|
describe('ol.geom.flat.intersectsextent.intersectsLineString', function() {
|
||||||
let flatCoordinates;
|
let flatCoordinates;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
flatCoordinates = [0, 0, 1, 1, 2, 2];
|
flatCoordinates = [0, 0, 1, 1, 2, 2];
|
||||||
@@ -11,7 +11,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
describe('linestring envelope does not intersect the extent', function() {
|
describe('linestring envelope does not intersect the extent', function() {
|
||||||
it('returns false', function() {
|
it('returns false', function() {
|
||||||
const extent = [3, 3, 4, 4];
|
const extent = [3, 3, 4, 4];
|
||||||
const r = _ol_geom_flat_intersectsextent_.lineString(
|
const r = intersectsLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(false);
|
expect(r).to.be(false);
|
||||||
});
|
});
|
||||||
@@ -19,7 +19,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
describe('linestring envelope within the extent', function() {
|
describe('linestring envelope within the extent', function() {
|
||||||
it('returns true', function() {
|
it('returns true', function() {
|
||||||
const extent = [-1, -1, 3, 3];
|
const extent = [-1, -1, 3, 3];
|
||||||
const r = _ol_geom_flat_intersectsextent_.lineString(
|
const r = intersectsLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(true);
|
expect(r).to.be(true);
|
||||||
});
|
});
|
||||||
@@ -28,7 +28,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
function() {
|
function() {
|
||||||
it('returns true', function() {
|
it('returns true', function() {
|
||||||
const extent = [-0.1, 0.1, 2.1, 0.1];
|
const extent = [-0.1, 0.1, 2.1, 0.1];
|
||||||
const r = _ol_geom_flat_intersectsextent_.lineString(
|
const r = intersectsLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(true);
|
expect(r).to.be(true);
|
||||||
});
|
});
|
||||||
@@ -36,7 +36,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
describe('a segment intersects the extent', function() {
|
describe('a segment intersects the extent', function() {
|
||||||
it('returns true', function() {
|
it('returns true', function() {
|
||||||
const extent = [-0.5, -0.5, 0.5, 0.5];
|
const extent = [-0.5, -0.5, 0.5, 0.5];
|
||||||
const r = _ol_geom_flat_intersectsextent_.lineString(
|
const r = intersectsLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(true);
|
expect(r).to.be(true);
|
||||||
});
|
});
|
||||||
@@ -44,20 +44,20 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
describe('no segments intersect the extent', function() {
|
describe('no segments intersect the extent', function() {
|
||||||
it('returns false', function() {
|
it('returns false', function() {
|
||||||
const extent = [0.5, 1.5, 1, 1.75];
|
const extent = [0.5, 1.5, 1, 1.75];
|
||||||
const r = _ol_geom_flat_intersectsextent_.lineString(
|
const r = intersectsLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(false);
|
expect(r).to.be(false);
|
||||||
});
|
});
|
||||||
it('returns false', function() {
|
it('returns false', function() {
|
||||||
const extent = [1, 0.25, 1.5, 0.5];
|
const extent = [1, 0.25, 1.5, 0.5];
|
||||||
const r = _ol_geom_flat_intersectsextent_.lineString(
|
const r = intersectsLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(false);
|
expect(r).to.be(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.intersectsextent.linearRing', function() {
|
describe('ol.geom.flat.intersectsextent.intersectsLinearRing', function() {
|
||||||
let flatCoordinates;
|
let flatCoordinates;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
flatCoordinates = [0, 0, 1, 1, 2, 0, 1, -1, 0, 0];
|
flatCoordinates = [0, 0, 1, 1, 2, 0, 1, -1, 0, 0];
|
||||||
@@ -65,7 +65,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
describe('boundary intersects the extent', function() {
|
describe('boundary intersects the extent', function() {
|
||||||
it('returns true', function() {
|
it('returns true', function() {
|
||||||
const extent = [1.5, 0.0, 2.5, 1.0];
|
const extent = [1.5, 0.0, 2.5, 1.0];
|
||||||
const r = _ol_geom_flat_intersectsextent_.linearRing(
|
const r = intersectsLinearRing(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(true);
|
expect(r).to.be(true);
|
||||||
});
|
});
|
||||||
@@ -75,7 +75,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
function() {
|
function() {
|
||||||
it('returns false', function() {
|
it('returns false', function() {
|
||||||
const extent = [2.0, 0.5, 3, 1.5];
|
const extent = [2.0, 0.5, 3, 1.5];
|
||||||
const r = _ol_geom_flat_intersectsextent_.linearRing(
|
const r = intersectsLinearRing(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(false);
|
expect(r).to.be(false);
|
||||||
});
|
});
|
||||||
@@ -83,7 +83,7 @@ describe('ol.geom.flat.intersectsextent', function() {
|
|||||||
describe('ring contains the extent', function() {
|
describe('ring contains the extent', function() {
|
||||||
it('returns true', function() {
|
it('returns true', function() {
|
||||||
const extent = [0.75, -0.25, 1.25, 0.25];
|
const extent = [0.75, -0.25, 1.25, 0.25];
|
||||||
const r = _ol_geom_flat_intersectsextent_.linearRing(
|
const r = intersectsLinearRing(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
flatCoordinates, 0, flatCoordinates.length, 2, extent);
|
||||||
expect(r).to.be(true);
|
expect(r).to.be(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
|
import {lineStringLength, linearRingLength} from '../../../../../src/ol/geom/flat/length.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.length', function() {
|
describe('ol.geom.flat.length', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.length.lineString', function() {
|
describe('ol.geom.flat.length.lineStringLength', function() {
|
||||||
|
|
||||||
describe('stride = 2', function() {
|
describe('stride = 2', function() {
|
||||||
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
|
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
|
||||||
@@ -13,7 +13,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
const end = 8;
|
const end = 8;
|
||||||
const expected = 3;
|
const expected = 3;
|
||||||
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
const got = lineStringLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 2;
|
const offset = 2;
|
||||||
const end = 8;
|
const end = 8;
|
||||||
const expected = 2;
|
const expected = 2;
|
||||||
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
const got = lineStringLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
const end = 4;
|
const end = 4;
|
||||||
const expected = 1;
|
const expected = 1;
|
||||||
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
const got = lineStringLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
const end = 12;
|
const end = 12;
|
||||||
const expected = 3;
|
const expected = 3;
|
||||||
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
const got = lineStringLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 3;
|
const offset = 3;
|
||||||
const end = 12;
|
const end = 12;
|
||||||
const expected = 2;
|
const expected = 2;
|
||||||
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
const got = lineStringLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,14 +59,14 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
const end = 6;
|
const end = 6;
|
||||||
const expected = 1;
|
const expected = 1;
|
||||||
const got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
|
const got = lineStringLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.length.linearRing', function() {
|
describe('ol.geom.flat.length.linearRingLength', function() {
|
||||||
|
|
||||||
it('calculates the total length of a simple linearRing', function() {
|
it('calculates the total length of a simple linearRing', function() {
|
||||||
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
|
const flatCoords = [0, 0, 1, 0, 1, 1, 0, 1];
|
||||||
@@ -74,7 +74,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
const end = 8;
|
const end = 8;
|
||||||
const expected = 4;
|
const expected = 4;
|
||||||
const got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
|
const got = linearRingLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ describe('ol.geom.flat.length', function() {
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
const end = 14;
|
const end = 14;
|
||||||
const expected = 8;
|
const expected = 8;
|
||||||
const got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
|
const got = linearRingLength(flatCoords, offset, end, stride);
|
||||||
expect(got).to.be(expected);
|
expect(got).to.be(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
import _ol_geom_flat_orient_ from '../../../../../src/ol/geom/flat/orient.js';
|
import {linearRingIsClockwise, linearRingIsOriented,
|
||||||
|
linearRingsAreOriented, orientLinearRings, orientLinearRingsArray} from '../../../../../src/ol/geom/flat/orient.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.orient', function() {
|
describe('ol.geom.flat.orient', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.orient.linearRingIsClockwise()', function() {
|
describe('ol.geom.flat.orient.linearRingIsClockwise', function() {
|
||||||
|
|
||||||
it('identifies clockwise rings', function() {
|
it('identifies clockwise rings', function() {
|
||||||
const flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
|
const flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
|
||||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
const isClockwise = linearRingIsClockwise(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
expect(isClockwise).to.be(true);
|
expect(isClockwise).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('identifies anti-clockwise rings', function() {
|
it('identifies anti-clockwise rings', function() {
|
||||||
const flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
|
const flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
|
||||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
const isClockwise = linearRingIsClockwise(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
expect(isClockwise).to.be(false);
|
expect(isClockwise).to.be(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.orient.linearRingsAreOriented()', function() {
|
describe('ol.geom.flat.orient.linearRingIsOriented', function() {
|
||||||
const oriented = _ol_geom_flat_orient_.linearRingsAreOriented;
|
const oriented = linearRingIsOriented;
|
||||||
|
|
||||||
const rightCoords = [
|
const rightCoords = [
|
||||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||||
@@ -48,8 +49,8 @@ describe('ol.geom.flat.orient', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.orient.linearRingssAreOriented()', function() {
|
describe('ol.geom.flat.orient.linearRingsAreOriented', function() {
|
||||||
const oriented = _ol_geom_flat_orient_.linearRingssAreOriented;
|
const oriented = linearRingsAreOriented;
|
||||||
|
|
||||||
const rightCoords = [
|
const rightCoords = [
|
||||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||||
@@ -79,8 +80,8 @@ describe('ol.geom.flat.orient', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.orient.orientLinearRings()', function() {
|
describe('ol.geom.flat.orient.orientLinearRings', function() {
|
||||||
const orient = _ol_geom_flat_orient_.orientLinearRings;
|
const orient = orientLinearRings;
|
||||||
|
|
||||||
const rightCoords = [
|
const rightCoords = [
|
||||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||||
@@ -116,8 +117,8 @@ describe('ol.geom.flat.orient', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.flat.orient.orientLinearRingss()', function() {
|
describe('ol.geom.flat.orient.orientLinearRingsArray', function() {
|
||||||
const orient = _ol_geom_flat_orient_.orientLinearRingss;
|
const orient = orientLinearRingsArray;
|
||||||
|
|
||||||
const rightCoords = [
|
const rightCoords = [
|
||||||
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_geom_flat_simplify_ from '../../../../../src/ol/geom/flat/simplify.js';
|
import {douglasPeucker, quantize, radialDistance, simplifyLineString} from '../../../../../src/ol/geom/flat/simplify.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.simplify', function() {
|
describe('ol.geom.flat.simplify', function() {
|
||||||
@@ -81,31 +81,31 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
866.36, 480.77
|
866.36, 480.77
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('ol.geom.flat.simplify.lineString', function() {
|
describe('ol.geom.flat.simplify.simplifyLineString', function() {
|
||||||
|
|
||||||
it('works with empty line strings', function() {
|
it('works with empty line strings', function() {
|
||||||
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, true)).to.
|
expect(simplifyLineString([], 0, 0, 2, 1, true)).to.
|
||||||
eql([]);
|
eql([]);
|
||||||
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, false)).to.
|
expect(simplifyLineString([], 0, 0, 2, 1, false)).to.
|
||||||
eql([]);
|
eql([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with a single point', function() {
|
it('works with a line string with a single point', function() {
|
||||||
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, true)).to.
|
expect(simplifyLineString([1, 2], 0, 2, 2, 1, true)).to.
|
||||||
eql([1, 2]);
|
eql([1, 2]);
|
||||||
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, false)).to.
|
expect(simplifyLineString([1, 2], 0, 2, 2, 1, false)).to.
|
||||||
eql([1, 2]);
|
eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the expected result with low quality', function() {
|
it('returns the expected result with low quality', function() {
|
||||||
const result = _ol_geom_flat_simplify_.lineString(
|
const result = simplifyLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
|
||||||
expect(result.length).to.be(simplifiedFlatCoordinates.length);
|
expect(result.length).to.be(simplifiedFlatCoordinates.length);
|
||||||
expect(result).to.eql(simplifiedFlatCoordinates);
|
expect(result).to.eql(simplifiedFlatCoordinates);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the expected result with high quality', function() {
|
it('returns the expected result with high quality', function() {
|
||||||
const result = _ol_geom_flat_simplify_.lineString(
|
const result = simplifyLineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
|
||||||
expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length);
|
expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length);
|
||||||
expect(result).to.eql(simplifiedHighQualityFlatCoordinates);
|
expect(result).to.eql(simplifiedHighQualityFlatCoordinates);
|
||||||
@@ -121,63 +121,63 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with empty line strings', function() {
|
it('works with empty line strings', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
||||||
expect(dest).to.eql([]);
|
expect(dest).to.eql([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with a single point', function() {
|
it('works with a line string with a single point', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
||||||
expect(dest).to.eql([1, 2]);
|
expect(dest).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with two points', function() {
|
it('works with a line string with two points', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([1, 2, 3, 4]);
|
expect(dest).to.eql([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are widely spaced', function() {
|
it('works when the points are widely spaced', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
||||||
expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the spacing matches the tolerance', function() {
|
it('works when the spacing matches the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are closely spaced', function() {
|
it('works when the points are closely spaced', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with widely spaced points', function() {
|
it('works when the line oscillates with widely spaced points', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
|
||||||
to.be(12);
|
to.be(12);
|
||||||
expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with closely spaced points', function() {
|
it('works when the line oscillates with closely spaced points', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates within the tolerance', function() {
|
it('works when the line oscillates within the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
||||||
to.be(2);
|
to.be(2);
|
||||||
expect(dest).to.eql([0, 0]);
|
expect(dest).to.eql([0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with real data', function() {
|
it('works with real data', function() {
|
||||||
expect(_ol_geom_flat_simplify_.radialDistance(
|
expect(radialDistance(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
||||||
to.be(simplifiedRadiallyFlatCoordinates.length);
|
to.be(simplifiedRadiallyFlatCoordinates.length);
|
||||||
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
|
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
|
||||||
@@ -193,93 +193,93 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with empty line strings', function() {
|
it('works with empty line strings', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
||||||
expect(dest).to.eql([]);
|
expect(dest).to.eql([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with a single point', function() {
|
it('works with a line string with a single point', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
||||||
expect(dest).to.eql([1, 2]);
|
expect(dest).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with two points', function() {
|
it('works with a line string with two points', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([1, 2, 3, 4]);
|
expect(dest).to.eql([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are widely spaced', function() {
|
it('works when the points are widely spaced', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the spacing matches the tolerance', function() {
|
it('works when the spacing matches the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are closely spaced', function() {
|
it('works when the points are closely spaced', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not elimnate points outside the tolerance', function() {
|
it('does not elimnate points outside the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
|
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([0, 0, 1, 1, 2, 0]);
|
expect(dest).to.eql([0, 0, 1, 1, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does eliminate points within the tolerance', function() {
|
it('does eliminate points within the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 2, 0]);
|
expect(dest).to.eql([0, 0, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not eliminate multiple points outside the tolerance', function() {
|
it('does not eliminate multiple points outside the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
||||||
expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]);
|
expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does eliminate multiple points within the tolerance', function() {
|
it('does eliminate multiple points within the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 2, 0]);
|
expect(dest).to.eql([0, 0, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with widely spaced points', function() {
|
it('works when the line oscillates with widely spaced points', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with closely spaced points', function() {
|
it('works when the line oscillates with closely spaced points', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
|
||||||
to.be(4);
|
to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates within the tolerance', function() {
|
it('works when the line oscillates within the tolerance', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
||||||
to.be(4);
|
to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 0, 0]);
|
expect(dest).to.eql([0, 0, 0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works on small triangles', function() {
|
it('works on small triangles', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([3, 0, 5, 2, 5, 0]);
|
expect(dest).to.eql([3, 0, 5, 2, 5, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is the same as high quality simplification', function() {
|
it('is the same as high quality simplification', function() {
|
||||||
expect(_ol_geom_flat_simplify_.douglasPeucker(
|
expect(douglasPeucker(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
||||||
to.be(simplifiedHighQualityFlatCoordinates.length);
|
to.be(simplifiedHighQualityFlatCoordinates.length);
|
||||||
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
|
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
|
||||||
@@ -291,28 +291,28 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
|
|
||||||
it('handles empty coordinates', function() {
|
it('handles empty coordinates', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
|
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
|
||||||
expect(simplifiedFlatCoordinates).to.be.empty();
|
expect(simplifiedFlatCoordinates).to.be.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('expands points to a zero-length line', function() {
|
it('expands points to a zero-length line', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('snaps near-by points to the same value', function() {
|
it('snaps near-by points to the same value', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('eliminates duplicate snapped points', function() {
|
it('eliminates duplicate snapped points', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2,
|
[0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]);
|
||||||
@@ -320,7 +320,7 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
|
|
||||||
it('eliminates horizontal colinear points', function() {
|
it('eliminates horizontal colinear points', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
|
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]);
|
||||||
@@ -328,7 +328,7 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
|
|
||||||
it('eliminates vertical colinear points', function() {
|
it('eliminates vertical colinear points', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
|
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]);
|
||||||
@@ -336,7 +336,7 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
|
|
||||||
it('eliminates diagonal colinear points', function() {
|
it('eliminates diagonal colinear points', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
|
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]);
|
||||||
@@ -344,7 +344,7 @@ describe('ol.geom.flat.simplify', function() {
|
|||||||
|
|
||||||
it('handles switchbacks', function() {
|
it('handles switchbacks', function() {
|
||||||
const simplifiedFlatCoordinates = [];
|
const simplifiedFlatCoordinates = [];
|
||||||
expect(_ol_geom_flat_simplify_.quantize(
|
expect(quantize(
|
||||||
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
|
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(8);
|
simplifiedFlatCoordinates, 0)).to.be(8);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]);
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import _ol_geom_flat_straightchunk_ from '../../../../../src/ol/geom/flat/straightchunk.js';
|
import {matchingChunk} from '../../../../../src/ol/geom/flat/straightchunk.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.straightchunk', function() {
|
describe('ol.geom.flat.straightchunk', function() {
|
||||||
|
|
||||||
describe('ol.geom.flat.straightchunk.lineString', function() {
|
describe('ol.geom.flat.straightchunk.matchingChunk', function() {
|
||||||
|
|
||||||
describe('single segment with stride == 3', function() {
|
describe('single segment with stride == 3', function() {
|
||||||
const flatCoords = [0, 0, 42, 1, 1, 42];
|
const flatCoords = [0, 0, 42, 1, 1, 42];
|
||||||
const stride = 3;
|
const stride = 3;
|
||||||
|
|
||||||
it('returns whole line with angle delta', function() {
|
it('returns whole line with angle delta', function() {
|
||||||
const got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 6, stride);
|
const got = matchingChunk(Math.PI / 4, flatCoords, 0, 6, stride);
|
||||||
expect(got).to.eql([0, 6]);
|
expect(got).to.eql([0, 6]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns whole line with zero angle delta', function() {
|
it('returns whole line with zero angle delta', function() {
|
||||||
const got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 6, stride);
|
const got = matchingChunk(0, flatCoords, 0, 6, stride);
|
||||||
expect(got).to.eql([0, 6]);
|
expect(got).to.eql([0, 6]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -26,12 +26,12 @@ describe('ol.geom.flat.straightchunk', function() {
|
|||||||
const stride = 2;
|
const stride = 2;
|
||||||
|
|
||||||
it('returns whole line if straight enough', function() {
|
it('returns whole line if straight enough', function() {
|
||||||
const got = _ol_geom_flat_straightchunk_.lineString(Math.PI, flatCoords, 0, 8, stride);
|
const got = matchingChunk(Math.PI, flatCoords, 0, 8, stride);
|
||||||
expect(got).to.eql([0, 8]);
|
expect(got).to.eql([0, 8]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns first matching chunk if all chunk lengths are the same', function() {
|
it('returns first matching chunk if all chunk lengths are the same', function() {
|
||||||
const got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 8, stride);
|
const got = matchingChunk(Math.PI / 4, flatCoords, 0, 8, stride);
|
||||||
expect(got).to.eql([0, 4]);
|
expect(got).to.eql([0, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ describe('ol.geom.flat.straightchunk', function() {
|
|||||||
const stride = 2;
|
const stride = 2;
|
||||||
|
|
||||||
it('returns stright chunk from within the linestring', function() {
|
it('returns stright chunk from within the linestring', function() {
|
||||||
const got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 18, stride);
|
const got = matchingChunk(0, flatCoords, 0, 18, stride);
|
||||||
expect(got).to.eql([10, 16]);
|
expect(got).to.eql([10, 16]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns long chunk at the end if angle and length within threshold', function() {
|
it('returns long chunk at the end if angle and length within threshold', function() {
|
||||||
const got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 18, stride);
|
const got = matchingChunk(Math.PI / 4, flatCoords, 0, 18, stride);
|
||||||
expect(got).to.eql([10, 18]);
|
expect(got).to.eql([10, 18]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import _ol_geom_flat_textpath_ from '../../../../../src/ol/geom/flat/textpath.js';
|
import {drawTextOnPath} from '../../../../../src/ol/geom/flat/textpath.js';
|
||||||
import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
|
import {lineStringLength} from '../../../../../src/ol/geom/flat/length.js';
|
||||||
|
|
||||||
describe('textpath', function() {
|
describe('ol.geom.flat.drawTextOnPath', function() {
|
||||||
|
|
||||||
const horizontal = [0, 0, 100, 0];
|
const horizontal = [0, 0, 100, 0];
|
||||||
const vertical = [0, 0, 0, 100];
|
const vertical = [0, 0, 0, 100];
|
||||||
@@ -16,27 +16,27 @@ describe('textpath', function() {
|
|||||||
|
|
||||||
it('center-aligns text on a horizontal line', function() {
|
it('center-aligns text on a horizontal line', function() {
|
||||||
const startM = 50 - 15;
|
const startM = 50 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
|
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions).to.eql([[40, 0, 5, 0, 'foo']]);
|
expect(instructions).to.eql([[40, 0, 5, 0, 'foo']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('left-aligns text on a horizontal line', function() {
|
it('left-aligns text on a horizontal line', function() {
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
horizontal, 0, horizontal.length, 2, 'foo', measure, 0, Infinity);
|
horizontal, 0, horizontal.length, 2, 'foo', measure, 0, Infinity);
|
||||||
expect(instructions).to.eql([[5, 0, 5, 0, 'foo']]);
|
expect(instructions).to.eql([[5, 0, 5, 0, 'foo']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('right-aligns text on a horizontal line', function() {
|
it('right-aligns text on a horizontal line', function() {
|
||||||
const startM = 100 - 30;
|
const startM = 100 - 30;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
|
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions).to.eql([[75, 0, 5, 0, 'foo']]);
|
expect(instructions).to.eql([[75, 0, 5, 0, 'foo']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('draws text on a vertical line', function() {
|
it('draws text on a vertical line', function() {
|
||||||
const startM = 50 - 15;
|
const startM = 50 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity);
|
vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity);
|
||||||
const a = 90 * Math.PI / 180;
|
const a = 90 * Math.PI / 180;
|
||||||
expect(instructions).to.eql([[0, 40, 5, a, 'foo']]);
|
expect(instructions).to.eql([[0, 40, 5, a, 'foo']]);
|
||||||
@@ -44,7 +44,7 @@ describe('textpath', function() {
|
|||||||
|
|
||||||
it('draws text on a diagonal line', function() {
|
it('draws text on a diagonal line', function() {
|
||||||
const startM = Math.sqrt(2) * 50 - 15;
|
const startM = Math.sqrt(2) * 50 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
diagonal, 0, diagonal.length, 2, 'foo', measure, startM, Infinity);
|
diagonal, 0, diagonal.length, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
|
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
|
||||||
expect(instructions.length).to.be(1);
|
expect(instructions.length).to.be(1);
|
||||||
@@ -52,7 +52,7 @@ describe('textpath', function() {
|
|||||||
|
|
||||||
it('draws reverse text on a diagonal line', function() {
|
it('draws reverse text on a diagonal line', function() {
|
||||||
const startM = Math.sqrt(2) * 50 - 15;
|
const startM = Math.sqrt(2) * 50 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
reverse, 0, reverse.length, 2, 'foo', measure, startM, Infinity);
|
reverse, 0, reverse.length, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
|
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
|
||||||
expect(instructions.length).to.be(1);
|
expect(instructions.length).to.be(1);
|
||||||
@@ -60,16 +60,16 @@ describe('textpath', function() {
|
|||||||
|
|
||||||
it('renders long text with extrapolation', function() {
|
it('renders long text with extrapolation', function() {
|
||||||
const startM = 50 - 75;
|
const startM = 50 - 75;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
horizontal, 0, horizontal.length, 2, 'foo-foo-foo-foo', measure, startM, Infinity);
|
horizontal, 0, horizontal.length, 2, 'foo-foo-foo-foo', measure, startM, Infinity);
|
||||||
expect(instructions[0]).to.eql([-20, 0, 5, 0, 'foo-foo-foo-foo']);
|
expect(instructions[0]).to.eql([-20, 0, 5, 0, 'foo-foo-foo-foo']);
|
||||||
expect(instructions.length).to.be(1);
|
expect(instructions.length).to.be(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders angled text', function() {
|
it('renders angled text', function() {
|
||||||
const length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
|
const length = lineStringLength(angled, 0, angled.length, 2);
|
||||||
const startM = length / 2 - 15;
|
const startM = length / 2 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
angled, 0, angled.length, 2, 'foo', measure, startM, Infinity);
|
angled, 0, angled.length, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions[0][3]).to.eql(45 * Math.PI / 180);
|
expect(instructions[0][3]).to.eql(45 * Math.PI / 180);
|
||||||
expect(instructions[0][4]).to.be('fo');
|
expect(instructions[0][4]).to.be('fo');
|
||||||
@@ -78,34 +78,34 @@ describe('textpath', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('respects maxAngle', function() {
|
it('respects maxAngle', function() {
|
||||||
const length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
|
const length = lineStringLength(angled, 0, angled.length, 2);
|
||||||
const startM = length / 2 - 15;
|
const startM = length / 2 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
angled, 0, angled.length, 2, 'foo', measure, startM, Math.PI / 4);
|
angled, 0, angled.length, 2, 'foo', measure, startM, Math.PI / 4);
|
||||||
expect(instructions).to.be(null);
|
expect(instructions).to.be(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the smallest angle for maxAngleDelta', function() {
|
it('uses the smallest angle for maxAngleDelta', function() {
|
||||||
const length = _ol_geom_flat_length_.lineString(reverseangled, 0, reverseangled.length, 2);
|
const length = lineStringLength(reverseangled, 0, reverseangled.length, 2);
|
||||||
const startM = length / 2 - 15;
|
const startM = length / 2 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
reverseangled, 0, reverseangled.length, 2, 'foo', measure, startM, Math.PI);
|
reverseangled, 0, reverseangled.length, 2, 'foo', measure, startM, Math.PI);
|
||||||
expect(instructions).to.not.be(undefined);
|
expect(instructions).to.not.be(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('respects the offset option', function() {
|
it('respects the offset option', function() {
|
||||||
const length = _ol_geom_flat_length_.lineString(angled, 2, angled.length, 2);
|
const length = lineStringLength(angled, 2, angled.length, 2);
|
||||||
const startM = length / 2 - 15;
|
const startM = length / 2 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
angled, 2, angled.length, 2, 'foo', measure, startM, Infinity);
|
angled, 2, angled.length, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
|
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
|
||||||
expect(instructions.length).to.be(1);
|
expect(instructions.length).to.be(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('respects the end option', function() {
|
it('respects the end option', function() {
|
||||||
const length = _ol_geom_flat_length_.lineString(angled, 0, 4, 2);
|
const length = lineStringLength(angled, 0, 4, 2);
|
||||||
const startM = length / 2 - 15;
|
const startM = length / 2 - 15;
|
||||||
const instructions = _ol_geom_flat_textpath_.lineString(
|
const instructions = drawTextOnPath(
|
||||||
angled, 0, 4, 2, 'foo', measure, startM, Infinity);
|
angled, 0, 4, 2, 'foo', measure, startM, Infinity);
|
||||||
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
|
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
|
||||||
expect(instructions.length).to.be(1);
|
expect(instructions.length).to.be(1);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||||
import SimpleGeometry from '../../../../../src/ol/geom/SimpleGeometry.js';
|
import SimpleGeometry from '../../../../../src/ol/geom/SimpleGeometry.js';
|
||||||
import _ol_geom_flat_transform_ from '../../../../../src/ol/geom/flat/transform.js';
|
import {rotate, translate} from '../../../../../src/ol/geom/flat/transform.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.transform', function() {
|
describe('ol.geom.flat.transform', function() {
|
||||||
@@ -75,7 +75,7 @@ describe('ol.geom.flat.transform', function() {
|
|||||||
const flatCoordinates = multiPolygon.getFlatCoordinates();
|
const flatCoordinates = multiPolygon.getFlatCoordinates();
|
||||||
const deltaX = 1;
|
const deltaX = 1;
|
||||||
const deltaY = 2;
|
const deltaY = 2;
|
||||||
_ol_geom_flat_transform_.translate(flatCoordinates, 0,
|
translate(flatCoordinates, 0,
|
||||||
flatCoordinates.length, multiPolygon.getStride(),
|
flatCoordinates.length, multiPolygon.getStride(),
|
||||||
deltaX, deltaY, flatCoordinates);
|
deltaX, deltaY, flatCoordinates);
|
||||||
expect(flatCoordinates).to.eql([
|
expect(flatCoordinates).to.eql([
|
||||||
@@ -92,7 +92,7 @@ describe('ol.geom.flat.transform', function() {
|
|||||||
const flatCoordinates = multiPolygon.getFlatCoordinates();
|
const flatCoordinates = multiPolygon.getFlatCoordinates();
|
||||||
const angle = Math.PI / 2;
|
const angle = Math.PI / 2;
|
||||||
const anchor = [0, 1];
|
const anchor = [0, 1];
|
||||||
_ol_geom_flat_transform_.rotate(flatCoordinates, 0,
|
rotate(flatCoordinates, 0,
|
||||||
flatCoordinates.length, multiPolygon.getStride(),
|
flatCoordinates.length, multiPolygon.getStride(),
|
||||||
angle, anchor, flatCoordinates);
|
angle, anchor, flatCoordinates);
|
||||||
expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9);
|
expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9);
|
||||||
|
|||||||
Reference in New Issue
Block a user