Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
+29
-29
@@ -19,9 +19,9 @@ import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var Circle = function(center, opt_radius, opt_layout) {
|
||||
const Circle = function(center, opt_radius, opt_layout) {
|
||||
SimpleGeometry.call(this);
|
||||
var radius = opt_radius ? opt_radius : 0;
|
||||
const radius = opt_radius ? opt_radius : 0;
|
||||
this.setCenterAndRadius(center, radius, opt_layout);
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ inherits(Circle, SimpleGeometry);
|
||||
* @api
|
||||
*/
|
||||
Circle.prototype.clone = function() {
|
||||
var circle = new Circle(null);
|
||||
const circle = new Circle(null);
|
||||
circle.setFlatCoordinates(this.layout, this.flatCoordinates.slice());
|
||||
return circle;
|
||||
};
|
||||
@@ -45,18 +45,18 @@ Circle.prototype.clone = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
Circle.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var dx = x - flatCoordinates[0];
|
||||
var dy = y - flatCoordinates[1];
|
||||
var squaredDistance = dx * dx + dy * dy;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const dx = x - flatCoordinates[0];
|
||||
const dy = y - flatCoordinates[1];
|
||||
const squaredDistance = dx * dx + dy * dy;
|
||||
if (squaredDistance < minSquaredDistance) {
|
||||
var i;
|
||||
let i;
|
||||
if (squaredDistance === 0) {
|
||||
for (i = 0; i < this.stride; ++i) {
|
||||
closestPoint[i] = flatCoordinates[i];
|
||||
}
|
||||
} else {
|
||||
var delta = this.getRadius() / Math.sqrt(squaredDistance);
|
||||
const delta = this.getRadius() / Math.sqrt(squaredDistance);
|
||||
closestPoint[0] = flatCoordinates[0] + delta * dx;
|
||||
closestPoint[1] = flatCoordinates[1] + delta * dy;
|
||||
for (i = 2; i < this.stride; ++i) {
|
||||
@@ -75,9 +75,9 @@ Circle.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistanc
|
||||
* @inheritDoc
|
||||
*/
|
||||
Circle.prototype.containsXY = function(x, y) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var dx = x - flatCoordinates[0];
|
||||
var dy = y - flatCoordinates[1];
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const dx = x - flatCoordinates[0];
|
||||
const dy = y - flatCoordinates[1];
|
||||
return dx * dx + dy * dy <= this.getRadiusSquared_();
|
||||
};
|
||||
|
||||
@@ -96,12 +96,12 @@ Circle.prototype.getCenter = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
Circle.prototype.computeExtent = function(extent) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var radius = flatCoordinates[this.stride] - flatCoordinates[0];
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const radius = flatCoordinates[this.stride] - flatCoordinates[0];
|
||||
return createOrUpdate(
|
||||
flatCoordinates[0] - radius, flatCoordinates[1] - radius,
|
||||
flatCoordinates[0] + radius, flatCoordinates[1] + radius,
|
||||
extent);
|
||||
flatCoordinates[0] - radius, flatCoordinates[1] - radius,
|
||||
flatCoordinates[0] + radius, flatCoordinates[1] + radius,
|
||||
extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ Circle.prototype.getRadius = function() {
|
||||
* @return {number} Radius squared.
|
||||
*/
|
||||
Circle.prototype.getRadiusSquared_ = function() {
|
||||
var dx = this.flatCoordinates[this.stride] - this.flatCoordinates[0];
|
||||
var dy = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1];
|
||||
const dx = this.flatCoordinates[this.stride] - this.flatCoordinates[0];
|
||||
const dy = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1];
|
||||
return dx * dx + dy * dy;
|
||||
};
|
||||
|
||||
@@ -140,9 +140,9 @@ Circle.prototype.getType = function() {
|
||||
* @api
|
||||
*/
|
||||
Circle.prototype.intersectsExtent = function(extent) {
|
||||
var circleExtent = this.getExtent();
|
||||
const circleExtent = this.getExtent();
|
||||
if (intersects(extent, circleExtent)) {
|
||||
var center = this.getCenter();
|
||||
const center = this.getCenter();
|
||||
|
||||
if (extent[0] <= center[0] && extent[2] >= center[0]) {
|
||||
return true;
|
||||
@@ -164,11 +164,11 @@ Circle.prototype.intersectsExtent = function(extent) {
|
||||
* @api
|
||||
*/
|
||||
Circle.prototype.setCenter = function(center) {
|
||||
var stride = this.stride;
|
||||
var radius = this.flatCoordinates[stride] - this.flatCoordinates[0];
|
||||
var flatCoordinates = center.slice();
|
||||
const stride = this.stride;
|
||||
const radius = this.flatCoordinates[stride] - this.flatCoordinates[0];
|
||||
const flatCoordinates = center.slice();
|
||||
flatCoordinates[stride] = flatCoordinates[0] + radius;
|
||||
var i;
|
||||
let i;
|
||||
for (i = 1; i < stride; ++i) {
|
||||
flatCoordinates[stride + i] = center[i];
|
||||
}
|
||||
@@ -193,11 +193,11 @@ Circle.prototype.setCenterAndRadius = function(center, radius, opt_layout) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
/** @type {Array.<number>} */
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var offset = _ol_geom_flat_deflate_.coordinate(
|
||||
flatCoordinates, 0, center, this.stride);
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
let offset = _ol_geom_flat_deflate_.coordinate(
|
||||
flatCoordinates, 0, center, this.stride);
|
||||
flatCoordinates[offset++] = flatCoordinates[0] + radius;
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 1, ii = this.stride; i < ii; ++i) {
|
||||
flatCoordinates[offset++] = flatCoordinates[i];
|
||||
}
|
||||
|
||||
+11
-11
@@ -24,7 +24,7 @@ import _ol_transform_ from '../transform.js';
|
||||
* @extends {ol.Object}
|
||||
* @api
|
||||
*/
|
||||
var Geometry = function() {
|
||||
const Geometry = function() {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
@@ -97,7 +97,7 @@ Geometry.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDista
|
||||
* @api
|
||||
*/
|
||||
Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) {
|
||||
var closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
|
||||
const closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
|
||||
this.closestPointXY(point[0], point[1], closestPoint, Infinity);
|
||||
return closestPoint;
|
||||
};
|
||||
@@ -254,19 +254,19 @@ Geometry.prototype.translate = function(deltaX, deltaY) {};
|
||||
* @api
|
||||
*/
|
||||
Geometry.prototype.transform = function(source, destination) {
|
||||
var tmpTransform = this.tmpTransform_;
|
||||
const tmpTransform = this.tmpTransform_;
|
||||
source = getProjection(source);
|
||||
var transformFn = source.getUnits() == Units.TILE_PIXELS ?
|
||||
const transformFn = source.getUnits() == Units.TILE_PIXELS ?
|
||||
function(inCoordinates, outCoordinates, stride) {
|
||||
var pixelExtent = source.getExtent();
|
||||
var projectedExtent = source.getWorldExtent();
|
||||
var scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
const pixelExtent = source.getExtent();
|
||||
const projectedExtent = source.getWorldExtent();
|
||||
const scale = getHeight(projectedExtent) / getHeight(pixelExtent);
|
||||
_ol_transform_.compose(tmpTransform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
_ol_geom_flat_transform_.transform2D(inCoordinates, 0, inCoordinates.length, stride,
|
||||
tmpTransform, outCoordinates);
|
||||
tmpTransform, outCoordinates);
|
||||
return getTransform(source, destination)(inCoordinates, outCoordinates, stride);
|
||||
} :
|
||||
getTransform(source, destination);
|
||||
|
||||
@@ -18,7 +18,7 @@ import _ol_obj_ from '../obj.js';
|
||||
* @param {Array.<ol.geom.Geometry>=} opt_geometries Geometries.
|
||||
* @api
|
||||
*/
|
||||
var GeometryCollection = function(opt_geometries) {
|
||||
const GeometryCollection = function(opt_geometries) {
|
||||
|
||||
Geometry.call(this);
|
||||
|
||||
@@ -40,8 +40,8 @@ inherits(GeometryCollection, Geometry);
|
||||
* @return {Array.<ol.geom.Geometry>} Cloned geometries.
|
||||
*/
|
||||
GeometryCollection.cloneGeometries_ = function(geometries) {
|
||||
var clonedGeometries = [];
|
||||
var i, ii;
|
||||
const clonedGeometries = [];
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
clonedGeometries.push(geometries[i].clone());
|
||||
}
|
||||
@@ -53,14 +53,14 @@ GeometryCollection.cloneGeometries_ = function(geometries) {
|
||||
* @private
|
||||
*/
|
||||
GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
if (!this.geometries_) {
|
||||
return;
|
||||
}
|
||||
for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
|
||||
_ol_events_.unlisten(
|
||||
this.geometries_[i], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
this.geometries_[i], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -69,14 +69,14 @@ GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
|
||||
* @private
|
||||
*/
|
||||
GeometryCollection.prototype.listenGeometriesChange_ = function() {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
if (!this.geometries_) {
|
||||
return;
|
||||
}
|
||||
for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
|
||||
_ol_events_.listen(
|
||||
this.geometries_[i], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
this.geometries_[i], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ GeometryCollection.prototype.listenGeometriesChange_ = function() {
|
||||
* @api
|
||||
*/
|
||||
GeometryCollection.prototype.clone = function() {
|
||||
var geometryCollection = new GeometryCollection(null);
|
||||
const geometryCollection = new GeometryCollection(null);
|
||||
geometryCollection.setGeometries(this.geometries_);
|
||||
return geometryCollection;
|
||||
};
|
||||
@@ -101,11 +101,11 @@ GeometryCollection.prototype.closestPointXY = function(x, y, closestPoint, minSq
|
||||
if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
|
||||
return minSquaredDistance;
|
||||
}
|
||||
var geometries = this.geometries_;
|
||||
var i, ii;
|
||||
const geometries = this.geometries_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
minSquaredDistance = geometries[i].closestPointXY(
|
||||
x, y, closestPoint, minSquaredDistance);
|
||||
x, y, closestPoint, minSquaredDistance);
|
||||
}
|
||||
return minSquaredDistance;
|
||||
};
|
||||
@@ -115,8 +115,8 @@ GeometryCollection.prototype.closestPointXY = function(x, y, closestPoint, minSq
|
||||
* @inheritDoc
|
||||
*/
|
||||
GeometryCollection.prototype.containsXY = function(x, y) {
|
||||
var geometries = this.geometries_;
|
||||
var i, ii;
|
||||
const geometries = this.geometries_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
if (geometries[i].containsXY(x, y)) {
|
||||
return true;
|
||||
@@ -131,8 +131,8 @@ GeometryCollection.prototype.containsXY = function(x, y) {
|
||||
*/
|
||||
GeometryCollection.prototype.computeExtent = function(extent) {
|
||||
createOrUpdateEmpty(extent);
|
||||
var geometries = this.geometries_;
|
||||
for (var i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
const geometries = this.geometries_;
|
||||
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
extend(extent, geometries[i].getExtent());
|
||||
}
|
||||
return extent;
|
||||
@@ -171,24 +171,24 @@ GeometryCollection.prototype.getSimplifiedGeometry = function(squaredTolerance)
|
||||
squaredTolerance < this.simplifiedGeometryMaxMinSquaredTolerance)) {
|
||||
return this;
|
||||
}
|
||||
var key = squaredTolerance.toString();
|
||||
const key = squaredTolerance.toString();
|
||||
if (this.simplifiedGeometryCache.hasOwnProperty(key)) {
|
||||
return this.simplifiedGeometryCache[key];
|
||||
} else {
|
||||
var simplifiedGeometries = [];
|
||||
var geometries = this.geometries_;
|
||||
var simplified = false;
|
||||
var i, ii;
|
||||
const simplifiedGeometries = [];
|
||||
const geometries = this.geometries_;
|
||||
let simplified = false;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
var geometry = geometries[i];
|
||||
var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance);
|
||||
const geometry = geometries[i];
|
||||
const simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance);
|
||||
simplifiedGeometries.push(simplifiedGeometry);
|
||||
if (simplifiedGeometry !== geometry) {
|
||||
simplified = true;
|
||||
}
|
||||
}
|
||||
if (simplified) {
|
||||
var simplifiedGeometryCollection = new GeometryCollection(null);
|
||||
const simplifiedGeometryCollection = new GeometryCollection(null);
|
||||
simplifiedGeometryCollection.setGeometriesArray(simplifiedGeometries);
|
||||
this.simplifiedGeometryCache[key] = simplifiedGeometryCollection;
|
||||
return simplifiedGeometryCollection;
|
||||
@@ -214,8 +214,8 @@ GeometryCollection.prototype.getType = function() {
|
||||
* @api
|
||||
*/
|
||||
GeometryCollection.prototype.intersectsExtent = function(extent) {
|
||||
var geometries = this.geometries_;
|
||||
var i, ii;
|
||||
const geometries = this.geometries_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
if (geometries[i].intersectsExtent(extent)) {
|
||||
return true;
|
||||
@@ -238,8 +238,8 @@ GeometryCollection.prototype.isEmpty = function() {
|
||||
* @api
|
||||
*/
|
||||
GeometryCollection.prototype.rotate = function(angle, anchor) {
|
||||
var geometries = this.geometries_;
|
||||
for (var i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
const geometries = this.geometries_;
|
||||
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
geometries[i].rotate(angle, anchor);
|
||||
}
|
||||
this.changed();
|
||||
@@ -251,12 +251,12 @@ GeometryCollection.prototype.rotate = function(angle, anchor) {
|
||||
* @api
|
||||
*/
|
||||
GeometryCollection.prototype.scale = function(sx, opt_sy, opt_anchor) {
|
||||
var anchor = opt_anchor;
|
||||
let anchor = opt_anchor;
|
||||
if (!anchor) {
|
||||
anchor = getCenter(this.getExtent());
|
||||
}
|
||||
var geometries = this.geometries_;
|
||||
for (var i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
const geometries = this.geometries_;
|
||||
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
geometries[i].scale(sx, opt_sy, anchor);
|
||||
}
|
||||
this.changed();
|
||||
@@ -270,7 +270,7 @@ GeometryCollection.prototype.scale = function(sx, opt_sy, opt_anchor) {
|
||||
*/
|
||||
GeometryCollection.prototype.setGeometries = function(geometries) {
|
||||
this.setGeometriesArray(
|
||||
GeometryCollection.cloneGeometries_(geometries));
|
||||
GeometryCollection.cloneGeometries_(geometries));
|
||||
};
|
||||
|
||||
|
||||
@@ -290,8 +290,8 @@ GeometryCollection.prototype.setGeometriesArray = function(geometries) {
|
||||
* @api
|
||||
*/
|
||||
GeometryCollection.prototype.applyTransform = function(transformFn) {
|
||||
var geometries = this.geometries_;
|
||||
var i, ii;
|
||||
const geometries = this.geometries_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
geometries[i].applyTransform(transformFn);
|
||||
}
|
||||
@@ -307,8 +307,8 @@ GeometryCollection.prototype.applyTransform = function(transformFn) {
|
||||
* @api
|
||||
*/
|
||||
GeometryCollection.prototype.translate = function(deltaX, deltaY) {
|
||||
var geometries = this.geometries_;
|
||||
var i, ii;
|
||||
const geometries = this.geometries_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
geometries[i].translate(deltaX, deltaY);
|
||||
}
|
||||
|
||||
+20
-20
@@ -26,7 +26,7 @@ import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var LineString = function(coordinates, opt_layout) {
|
||||
const LineString = function(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
|
||||
@@ -83,7 +83,7 @@ LineString.prototype.appendCoordinate = function(coordinate) {
|
||||
* @api
|
||||
*/
|
||||
LineString.prototype.clone = function() {
|
||||
var lineString = new LineString(null);
|
||||
const lineString = new LineString(null);
|
||||
lineString.setFlatCoordinates(this.layout, this.flatCoordinates.slice());
|
||||
return lineString;
|
||||
};
|
||||
@@ -98,12 +98,12 @@ LineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
}
|
||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
||||
this.maxDeltaRevision_ = this.getRevision();
|
||||
}
|
||||
return _ol_geom_flat_closest_.getClosestPoint(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
||||
};
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ LineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
*/
|
||||
LineString.prototype.forEachSegment = function(callback) {
|
||||
return _ol_geom_flat_segments_.forEach(this.flatCoordinates, 0,
|
||||
this.flatCoordinates.length, this.stride, callback);
|
||||
this.flatCoordinates.length, this.stride, callback);
|
||||
};
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
|
||||
this.layout != GeometryLayout.XYZM) {
|
||||
return null;
|
||||
}
|
||||
var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||
return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(this.flatCoordinates, 0,
|
||||
this.flatCoordinates.length, this.stride, m, extrapolate);
|
||||
this.flatCoordinates.length, this.stride, m, extrapolate);
|
||||
};
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
|
||||
*/
|
||||
LineString.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinates(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -173,8 +173,8 @@ LineString.prototype.getCoordinates = function() {
|
||||
*/
|
||||
LineString.prototype.getCoordinateAt = function(fraction, opt_dest) {
|
||||
return _ol_geom_flat_interpolate_.lineString(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
fraction, opt_dest);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
fraction, opt_dest);
|
||||
};
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ LineString.prototype.getCoordinateAt = function(fraction, opt_dest) {
|
||||
*/
|
||||
LineString.prototype.getLength = function() {
|
||||
return _ol_geom_flat_length_.lineString(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -205,13 +205,13 @@ LineString.prototype.getFlatMidpoint = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
LineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
const simplifiedFlatCoordinates = [];
|
||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||
var simplifiedLineString = new LineString(null);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||
const simplifiedLineString = new LineString(null);
|
||||
simplifiedLineString.setFlatCoordinates(
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates);
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates);
|
||||
return simplifiedLineString;
|
||||
};
|
||||
|
||||
@@ -231,8 +231,8 @@ LineString.prototype.getType = function() {
|
||||
*/
|
||||
LineString.prototype.intersectsExtent = function(extent) {
|
||||
return _ol_geom_flat_intersectsextent_.lineString(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
extent);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ LineString.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates(
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
|
||||
+13
-13
@@ -23,7 +23,7 @@ import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var LinearRing = function(coordinates, opt_layout) {
|
||||
const LinearRing = function(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
|
||||
@@ -53,7 +53,7 @@ inherits(LinearRing, SimpleGeometry);
|
||||
* @api
|
||||
*/
|
||||
LinearRing.prototype.clone = function() {
|
||||
var linearRing = new LinearRing(null);
|
||||
const linearRing = new LinearRing(null);
|
||||
linearRing.setFlatCoordinates(this.layout, this.flatCoordinates.slice());
|
||||
return linearRing;
|
||||
};
|
||||
@@ -68,12 +68,12 @@ LinearRing.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
}
|
||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0));
|
||||
this.maxDeltaRevision_ = this.getRevision();
|
||||
}
|
||||
return _ol_geom_flat_closest_.getClosestPoint(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||
};
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ LinearRing.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
*/
|
||||
LinearRing.prototype.getArea = function() {
|
||||
return _ol_geom_flat_area_.linearRing(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ LinearRing.prototype.getArea = function() {
|
||||
*/
|
||||
LinearRing.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinates(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -104,13 +104,13 @@ LinearRing.prototype.getCoordinates = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
LinearRing.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
const simplifiedFlatCoordinates = [];
|
||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||
var simplifiedLinearRing = new LinearRing(null);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||
const simplifiedLinearRing = new LinearRing(null);
|
||||
simplifiedLinearRing.setFlatCoordinates(
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates);
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates);
|
||||
return simplifiedLinearRing;
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates(
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var MultiLineString = function(coordinates, opt_layout) {
|
||||
const MultiLineString = function(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
|
||||
@@ -77,9 +77,9 @@ MultiLineString.prototype.appendLineString = function(lineString) {
|
||||
* @api
|
||||
*/
|
||||
MultiLineString.prototype.clone = function() {
|
||||
var multiLineString = new MultiLineString(null);
|
||||
const multiLineString = new MultiLineString(null);
|
||||
multiLineString.setFlatCoordinates(
|
||||
this.layout, this.flatCoordinates.slice(), this.ends_.slice());
|
||||
this.layout, this.flatCoordinates.slice(), this.ends_.slice());
|
||||
return multiLineString;
|
||||
};
|
||||
|
||||
@@ -93,12 +93,12 @@ MultiLineString.prototype.closestPointXY = function(x, y, closestPoint, minSquar
|
||||
}
|
||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getsMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||
this.maxDeltaRevision_ = this.getRevision();
|
||||
}
|
||||
return _ol_geom_flat_closest_.getsClosestPoint(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||
this.maxDelta_, false, x, y, closestPoint, minSquaredDistance);
|
||||
};
|
||||
|
||||
|
||||
@@ -130,10 +130,10 @@ MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_in
|
||||
this.flatCoordinates.length === 0) {
|
||||
return null;
|
||||
}
|
||||
var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||
var interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
|
||||
const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
|
||||
const interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
|
||||
return _ol_geom_flat_interpolate_.lineStringsCoordinateAtM(this.flatCoordinates, 0,
|
||||
this.ends_, this.stride, m, extrapolate, interpolate);
|
||||
this.ends_, this.stride, m, extrapolate, interpolate);
|
||||
};
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_in
|
||||
*/
|
||||
MultiLineString.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinatess(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride);
|
||||
this.flatCoordinates, 0, this.ends_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -167,9 +167,9 @@ MultiLineString.prototype.getLineString = function(index) {
|
||||
if (index < 0 || this.ends_.length <= index) {
|
||||
return null;
|
||||
}
|
||||
var lineString = new LineString(null);
|
||||
const lineString = new LineString(null);
|
||||
lineString.setFlatCoordinates(this.layout, this.flatCoordinates.slice(
|
||||
index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]));
|
||||
index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]));
|
||||
return lineString;
|
||||
};
|
||||
|
||||
@@ -180,16 +180,16 @@ MultiLineString.prototype.getLineString = function(index) {
|
||||
* @api
|
||||
*/
|
||||
MultiLineString.prototype.getLineStrings = function() {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var ends = this.ends_;
|
||||
var layout = this.layout;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const ends = this.ends_;
|
||||
const layout = this.layout;
|
||||
/** @type {Array.<ol.geom.LineString>} */
|
||||
var lineStrings = [];
|
||||
var offset = 0;
|
||||
var i, ii;
|
||||
const lineStrings = [];
|
||||
let offset = 0;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var lineString = new LineString(null);
|
||||
const end = ends[i];
|
||||
const lineString = new LineString(null);
|
||||
lineString.setFlatCoordinates(layout, flatCoordinates.slice(offset, end));
|
||||
lineStrings.push(lineString);
|
||||
offset = end;
|
||||
@@ -202,16 +202,16 @@ MultiLineString.prototype.getLineStrings = function() {
|
||||
* @return {Array.<number>} Flat midpoints.
|
||||
*/
|
||||
MultiLineString.prototype.getFlatMidpoints = function() {
|
||||
var midpoints = [];
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var offset = 0;
|
||||
var ends = this.ends_;
|
||||
var stride = this.stride;
|
||||
var i, ii;
|
||||
const midpoints = [];
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
let offset = 0;
|
||||
const ends = this.ends_;
|
||||
const stride = this.stride;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var midpoint = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, offset, end, stride, 0.5);
|
||||
const end = ends[i];
|
||||
const midpoint = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, offset, end, stride, 0.5);
|
||||
extend(midpoints, midpoint);
|
||||
offset = end;
|
||||
}
|
||||
@@ -223,14 +223,14 @@ MultiLineString.prototype.getFlatMidpoints = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiLineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
var simplifiedEnds = [];
|
||||
const simplifiedFlatCoordinates = [];
|
||||
const simplifiedEnds = [];
|
||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeuckers(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||
var simplifiedMultiLineString = new MultiLineString(null);
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||
const simplifiedMultiLineString = new MultiLineString(null);
|
||||
simplifiedMultiLineString.setFlatCoordinates(
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds);
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds);
|
||||
return simplifiedMultiLineString;
|
||||
};
|
||||
|
||||
@@ -250,7 +250,7 @@ MultiLineString.prototype.getType = function() {
|
||||
*/
|
||||
MultiLineString.prototype.intersectsExtent = function(extent) {
|
||||
return _ol_geom_flat_intersectsextent_.lineStrings(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, extent);
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -269,8 +269,8 @@ MultiLineString.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
var ends = _ol_geom_flat_deflate_.coordinatess(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||
const ends = _ol_geom_flat_deflate_.coordinatess(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
||||
this.changed();
|
||||
}
|
||||
@@ -293,12 +293,12 @@ MultiLineString.prototype.setFlatCoordinates = function(layout, flatCoordinates,
|
||||
* @param {Array.<ol.geom.LineString>} lineStrings LineStrings.
|
||||
*/
|
||||
MultiLineString.prototype.setLineStrings = function(lineStrings) {
|
||||
var layout = this.getLayout();
|
||||
var flatCoordinates = [];
|
||||
var ends = [];
|
||||
var i, ii;
|
||||
let layout = this.getLayout();
|
||||
const flatCoordinates = [];
|
||||
const ends = [];
|
||||
let i, ii;
|
||||
for (i = 0, ii = lineStrings.length; i < ii; ++i) {
|
||||
var lineString = lineStrings[i];
|
||||
const lineString = lineStrings[i];
|
||||
if (i === 0) {
|
||||
layout = lineString.getLayout();
|
||||
}
|
||||
|
||||
+21
-21
@@ -22,7 +22,7 @@ import {squaredDistance as squaredDx} from '../math.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var MultiPoint = function(coordinates, opt_layout) {
|
||||
const MultiPoint = function(coordinates, opt_layout) {
|
||||
SimpleGeometry.call(this);
|
||||
this.setCoordinates(coordinates, opt_layout);
|
||||
};
|
||||
@@ -52,7 +52,7 @@ MultiPoint.prototype.appendPoint = function(point) {
|
||||
* @api
|
||||
*/
|
||||
MultiPoint.prototype.clone = function() {
|
||||
var multiPoint = new MultiPoint(null);
|
||||
const multiPoint = new MultiPoint(null);
|
||||
multiPoint.setFlatCoordinates(this.layout, this.flatCoordinates.slice());
|
||||
return multiPoint;
|
||||
};
|
||||
@@ -65,12 +65,12 @@ MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
|
||||
return minSquaredDistance;
|
||||
}
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var stride = this.stride;
|
||||
var i, ii, j;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const stride = this.stride;
|
||||
let i, ii, j;
|
||||
for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
|
||||
var squaredDistance = squaredDx(
|
||||
x, y, flatCoordinates[i], flatCoordinates[i + 1]);
|
||||
const squaredDistance = squaredDx(
|
||||
x, y, flatCoordinates[i], flatCoordinates[i + 1]);
|
||||
if (squaredDistance < minSquaredDistance) {
|
||||
minSquaredDistance = squaredDistance;
|
||||
for (j = 0; j < stride; ++j) {
|
||||
@@ -91,7 +91,7 @@ MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
*/
|
||||
MultiPoint.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinates(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -102,14 +102,14 @@ MultiPoint.prototype.getCoordinates = function() {
|
||||
* @api
|
||||
*/
|
||||
MultiPoint.prototype.getPoint = function(index) {
|
||||
var n = !this.flatCoordinates ?
|
||||
const n = !this.flatCoordinates ?
|
||||
0 : this.flatCoordinates.length / this.stride;
|
||||
if (index < 0 || n <= index) {
|
||||
return null;
|
||||
}
|
||||
var point = new Point(null);
|
||||
const point = new Point(null);
|
||||
point.setFlatCoordinates(this.layout, this.flatCoordinates.slice(
|
||||
index * this.stride, (index + 1) * this.stride));
|
||||
index * this.stride, (index + 1) * this.stride));
|
||||
return point;
|
||||
};
|
||||
|
||||
@@ -120,14 +120,14 @@ MultiPoint.prototype.getPoint = function(index) {
|
||||
* @api
|
||||
*/
|
||||
MultiPoint.prototype.getPoints = function() {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var layout = this.layout;
|
||||
var stride = this.stride;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const layout = this.layout;
|
||||
const stride = this.stride;
|
||||
/** @type {Array.<ol.geom.Point>} */
|
||||
var points = [];
|
||||
var i, ii;
|
||||
const points = [];
|
||||
let i, ii;
|
||||
for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
|
||||
var point = new Point(null);
|
||||
const point = new Point(null);
|
||||
point.setFlatCoordinates(layout, flatCoordinates.slice(i, i + stride));
|
||||
points.push(point);
|
||||
}
|
||||
@@ -149,9 +149,9 @@ MultiPoint.prototype.getType = function() {
|
||||
* @api
|
||||
*/
|
||||
MultiPoint.prototype.intersectsExtent = function(extent) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var stride = this.stride;
|
||||
var i, ii, x, y;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const stride = this.stride;
|
||||
let i, ii, x, y;
|
||||
for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
|
||||
x = flatCoordinates[i];
|
||||
y = flatCoordinates[i + 1];
|
||||
@@ -179,7 +179,7 @@ MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates(
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
|
||||
+63
-64
@@ -30,7 +30,7 @@ import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var MultiPolygon = function(coordinates, opt_layout) {
|
||||
const MultiPolygon = function(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
|
||||
@@ -90,16 +90,16 @@ inherits(MultiPolygon, SimpleGeometry);
|
||||
*/
|
||||
MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||
/** @type {Array.<number>} */
|
||||
var ends;
|
||||
let ends;
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = polygon.getFlatCoordinates().slice();
|
||||
ends = polygon.getEnds().slice();
|
||||
this.endss_.push();
|
||||
} else {
|
||||
var offset = this.flatCoordinates.length;
|
||||
const offset = this.flatCoordinates.length;
|
||||
extend(this.flatCoordinates, polygon.getFlatCoordinates());
|
||||
ends = polygon.getEnds().slice();
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
ends[i] += offset;
|
||||
}
|
||||
@@ -116,16 +116,16 @@ MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||
* @api
|
||||
*/
|
||||
MultiPolygon.prototype.clone = function() {
|
||||
var multiPolygon = new MultiPolygon(null);
|
||||
const multiPolygon = new MultiPolygon(null);
|
||||
|
||||
var len = this.endss_.length;
|
||||
var newEndss = new Array(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
const len = this.endss_.length;
|
||||
const newEndss = new Array(len);
|
||||
for (let i = 0; i < len; ++i) {
|
||||
newEndss[i] = this.endss_[i].slice();
|
||||
}
|
||||
|
||||
multiPolygon.setFlatCoordinates(
|
||||
this.layout, this.flatCoordinates.slice(), newEndss);
|
||||
this.layout, this.flatCoordinates.slice(), newEndss);
|
||||
return multiPolygon;
|
||||
};
|
||||
|
||||
@@ -139,12 +139,12 @@ MultiPolygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredD
|
||||
}
|
||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getssMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.endss_, this.stride, 0));
|
||||
this.flatCoordinates, 0, this.endss_, this.stride, 0));
|
||||
this.maxDeltaRevision_ = this.getRevision();
|
||||
}
|
||||
return _ol_geom_flat_closest_.getssClosestPoint(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||
};
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ MultiPolygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredD
|
||||
*/
|
||||
MultiPolygon.prototype.containsXY = function(x, y) {
|
||||
return _ol_geom_flat_contains_.linearRingssContainsXY(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, x, y);
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, x, y);
|
||||
};
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ MultiPolygon.prototype.containsXY = function(x, y) {
|
||||
*/
|
||||
MultiPolygon.prototype.getArea = function() {
|
||||
return _ol_geom_flat_area_.linearRingss(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride);
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -183,17 +183,17 @@ MultiPolygon.prototype.getArea = function() {
|
||||
* @api
|
||||
*/
|
||||
MultiPolygon.prototype.getCoordinates = function(opt_right) {
|
||||
var flatCoordinates;
|
||||
let flatCoordinates;
|
||||
if (opt_right !== undefined) {
|
||||
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
||||
_ol_geom_flat_orient_.orientLinearRingss(
|
||||
flatCoordinates, 0, this.endss_, this.stride, opt_right);
|
||||
flatCoordinates, 0, this.endss_, this.stride, opt_right);
|
||||
} else {
|
||||
flatCoordinates = this.flatCoordinates;
|
||||
}
|
||||
|
||||
return _ol_geom_flat_inflate_.coordinatesss(
|
||||
flatCoordinates, 0, this.endss_, this.stride);
|
||||
flatCoordinates, 0, this.endss_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -210,11 +210,11 @@ MultiPolygon.prototype.getEndss = function() {
|
||||
*/
|
||||
MultiPolygon.prototype.getFlatInteriorPoints = function() {
|
||||
if (this.flatInteriorPointsRevision_ != this.getRevision()) {
|
||||
var flatCenters = _ol_geom_flat_center_.linearRingss(
|
||||
this.flatCoordinates, 0, this.endss_, this.stride);
|
||||
const flatCenters = _ol_geom_flat_center_.linearRingss(
|
||||
this.flatCoordinates, 0, this.endss_, this.stride);
|
||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||
flatCenters);
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||
flatCenters);
|
||||
this.flatInteriorPointsRevision_ = this.getRevision();
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
@@ -228,9 +228,9 @@ MultiPolygon.prototype.getFlatInteriorPoints = function() {
|
||||
* @api
|
||||
*/
|
||||
MultiPolygon.prototype.getInteriorPoints = function() {
|
||||
var interiorPoints = new MultiPoint(null);
|
||||
const interiorPoints = new MultiPoint(null);
|
||||
interiorPoints.setFlatCoordinates(GeometryLayout.XYM,
|
||||
this.getFlatInteriorPoints().slice());
|
||||
this.getFlatInteriorPoints().slice());
|
||||
return interiorPoints;
|
||||
};
|
||||
|
||||
@@ -240,15 +240,15 @@ MultiPolygon.prototype.getInteriorPoints = function() {
|
||||
*/
|
||||
MultiPolygon.prototype.getOrientedFlatCoordinates = function() {
|
||||
if (this.orientedRevision_ != this.getRevision()) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
if (_ol_geom_flat_orient_.linearRingssAreOriented(
|
||||
flatCoordinates, 0, this.endss_, this.stride)) {
|
||||
flatCoordinates, 0, this.endss_, this.stride)) {
|
||||
this.orientedFlatCoordinates_ = flatCoordinates;
|
||||
} else {
|
||||
this.orientedFlatCoordinates_ = flatCoordinates.slice();
|
||||
this.orientedFlatCoordinates_.length =
|
||||
_ol_geom_flat_orient_.orientLinearRingss(
|
||||
this.orientedFlatCoordinates_, 0, this.endss_, this.stride);
|
||||
this.orientedFlatCoordinates_, 0, this.endss_, this.stride);
|
||||
}
|
||||
this.orientedRevision_ = this.getRevision();
|
||||
}
|
||||
@@ -260,15 +260,15 @@ MultiPolygon.prototype.getOrientedFlatCoordinates = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
var simplifiedEndss = [];
|
||||
const simplifiedFlatCoordinates = [];
|
||||
const simplifiedEndss = [];
|
||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.quantizess(
|
||||
this.flatCoordinates, 0, this.endss_, this.stride,
|
||||
Math.sqrt(squaredTolerance),
|
||||
simplifiedFlatCoordinates, 0, simplifiedEndss);
|
||||
var simplifiedMultiPolygon = new MultiPolygon(null);
|
||||
this.flatCoordinates, 0, this.endss_, this.stride,
|
||||
Math.sqrt(squaredTolerance),
|
||||
simplifiedFlatCoordinates, 0, simplifiedEndss);
|
||||
const simplifiedMultiPolygon = new MultiPolygon(null);
|
||||
simplifiedMultiPolygon.setFlatCoordinates(
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEndss);
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEndss);
|
||||
return simplifiedMultiPolygon;
|
||||
};
|
||||
|
||||
@@ -283,24 +283,24 @@ MultiPolygon.prototype.getPolygon = function(index) {
|
||||
if (index < 0 || this.endss_.length <= index) {
|
||||
return null;
|
||||
}
|
||||
var offset;
|
||||
let offset;
|
||||
if (index === 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
var prevEnds = this.endss_[index - 1];
|
||||
const prevEnds = this.endss_[index - 1];
|
||||
offset = prevEnds[prevEnds.length - 1];
|
||||
}
|
||||
var ends = this.endss_[index].slice();
|
||||
var end = ends[ends.length - 1];
|
||||
const ends = this.endss_[index].slice();
|
||||
const end = ends[ends.length - 1];
|
||||
if (offset !== 0) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
ends[i] -= offset;
|
||||
}
|
||||
}
|
||||
var polygon = new Polygon(null);
|
||||
const polygon = new Polygon(null);
|
||||
polygon.setFlatCoordinates(
|
||||
this.layout, this.flatCoordinates.slice(offset, end), ends);
|
||||
this.layout, this.flatCoordinates.slice(offset, end), ends);
|
||||
return polygon;
|
||||
};
|
||||
|
||||
@@ -311,23 +311,23 @@ MultiPolygon.prototype.getPolygon = function(index) {
|
||||
* @api
|
||||
*/
|
||||
MultiPolygon.prototype.getPolygons = function() {
|
||||
var layout = this.layout;
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var endss = this.endss_;
|
||||
var polygons = [];
|
||||
var offset = 0;
|
||||
var i, ii, j, jj;
|
||||
const layout = this.layout;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const endss = this.endss_;
|
||||
const polygons = [];
|
||||
let offset = 0;
|
||||
let i, ii, j, jj;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i].slice();
|
||||
var end = ends[ends.length - 1];
|
||||
const ends = endss[i].slice();
|
||||
const end = ends[ends.length - 1];
|
||||
if (offset !== 0) {
|
||||
for (j = 0, jj = ends.length; j < jj; ++j) {
|
||||
ends[j] -= offset;
|
||||
}
|
||||
}
|
||||
var polygon = new Polygon(null);
|
||||
const polygon = new Polygon(null);
|
||||
polygon.setFlatCoordinates(
|
||||
layout, flatCoordinates.slice(offset, end), ends);
|
||||
layout, flatCoordinates.slice(offset, end), ends);
|
||||
polygons.push(polygon);
|
||||
offset = end;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ MultiPolygon.prototype.getType = function() {
|
||||
*/
|
||||
MultiPolygon.prototype.intersectsExtent = function(extent) {
|
||||
return _ol_geom_flat_intersectsextent_.linearRingss(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, extent);
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -369,12 +369,12 @@ MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
var endss = _ol_geom_flat_deflate_.coordinatesss(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.endss_);
|
||||
const endss = _ol_geom_flat_deflate_.coordinatesss(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.endss_);
|
||||
if (endss.length === 0) {
|
||||
this.flatCoordinates.length = 0;
|
||||
} else {
|
||||
var lastEnds = endss[endss.length - 1];
|
||||
const lastEnds = endss[endss.length - 1];
|
||||
this.flatCoordinates.length = lastEnds.length === 0 ?
|
||||
0 : lastEnds[lastEnds.length - 1];
|
||||
}
|
||||
@@ -399,19 +399,17 @@ MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, en
|
||||
* @param {Array.<ol.geom.Polygon>} polygons Polygons.
|
||||
*/
|
||||
MultiPolygon.prototype.setPolygons = function(polygons) {
|
||||
var layout = this.getLayout();
|
||||
var flatCoordinates = [];
|
||||
var endss = [];
|
||||
var i, ii, ends;
|
||||
for (i = 0, ii = polygons.length; i < ii; ++i) {
|
||||
var polygon = polygons[i];
|
||||
let layout = this.getLayout();
|
||||
const flatCoordinates = [];
|
||||
const endss = [];
|
||||
for (let i = 0, ii = polygons.length; i < ii; ++i) {
|
||||
const polygon = polygons[i];
|
||||
if (i === 0) {
|
||||
layout = polygon.getLayout();
|
||||
}
|
||||
var offset = flatCoordinates.length;
|
||||
ends = polygon.getEnds();
|
||||
var j, jj;
|
||||
for (j = 0, jj = ends.length; j < jj; ++j) {
|
||||
const offset = flatCoordinates.length;
|
||||
const ends = polygon.getEnds();
|
||||
for (let j = 0, jj = ends.length; j < jj; ++j) {
|
||||
ends[j] += offset;
|
||||
}
|
||||
extend(flatCoordinates, polygon.getFlatCoordinates());
|
||||
@@ -419,4 +417,5 @@ MultiPolygon.prototype.setPolygons = function(polygons) {
|
||||
}
|
||||
this.setFlatCoordinates(layout, flatCoordinates, endss);
|
||||
};
|
||||
|
||||
export default MultiPolygon;
|
||||
|
||||
@@ -19,7 +19,7 @@ import {squaredDistance as squaredDx} from '../math.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var Point = function(coordinates, opt_layout) {
|
||||
const Point = function(coordinates, opt_layout) {
|
||||
SimpleGeometry.call(this);
|
||||
this.setCoordinates(coordinates, opt_layout);
|
||||
};
|
||||
@@ -34,7 +34,7 @@ inherits(Point, SimpleGeometry);
|
||||
* @api
|
||||
*/
|
||||
Point.prototype.clone = function() {
|
||||
var point = new Point(null);
|
||||
const point = new Point(null);
|
||||
point.setFlatCoordinates(this.layout, this.flatCoordinates.slice());
|
||||
return point;
|
||||
};
|
||||
@@ -44,12 +44,12 @@ Point.prototype.clone = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
Point.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var squaredDistance = squaredDx(
|
||||
x, y, flatCoordinates[0], flatCoordinates[1]);
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const squaredDistance = squaredDx(
|
||||
x, y, flatCoordinates[0], flatCoordinates[1]);
|
||||
if (squaredDistance < minSquaredDistance) {
|
||||
var stride = this.stride;
|
||||
var i;
|
||||
const stride = this.stride;
|
||||
let i;
|
||||
for (i = 0; i < stride; ++i) {
|
||||
closestPoint[i] = flatCoordinates[i];
|
||||
}
|
||||
@@ -111,7 +111,7 @@ Point.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinate(
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
|
||||
+65
-65
@@ -36,7 +36,7 @@ import {modulo} from '../math.js';
|
||||
* @param {ol.geom.GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
var Polygon = function(coordinates, opt_layout) {
|
||||
const Polygon = function(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
|
||||
@@ -112,9 +112,9 @@ Polygon.prototype.appendLinearRing = function(linearRing) {
|
||||
* @api
|
||||
*/
|
||||
Polygon.prototype.clone = function() {
|
||||
var polygon = new Polygon(null);
|
||||
const polygon = new Polygon(null);
|
||||
polygon.setFlatCoordinates(
|
||||
this.layout, this.flatCoordinates.slice(), this.ends_.slice());
|
||||
this.layout, this.flatCoordinates.slice(), this.ends_.slice());
|
||||
return polygon;
|
||||
};
|
||||
|
||||
@@ -128,12 +128,12 @@ Polygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistan
|
||||
}
|
||||
if (this.maxDeltaRevision_ != this.getRevision()) {
|
||||
this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getsMaxSquaredDelta(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||
this.flatCoordinates, 0, this.ends_, this.stride, 0));
|
||||
this.maxDeltaRevision_ = this.getRevision();
|
||||
}
|
||||
return _ol_geom_flat_closest_.getsClosestPoint(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||
this.maxDelta_, true, x, y, closestPoint, minSquaredDistance);
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ Polygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistan
|
||||
*/
|
||||
Polygon.prototype.containsXY = function(x, y) {
|
||||
return _ol_geom_flat_contains_.linearRingsContainsXY(
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, x, y);
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, x, y);
|
||||
};
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ Polygon.prototype.containsXY = function(x, y) {
|
||||
*/
|
||||
Polygon.prototype.getArea = function() {
|
||||
return _ol_geom_flat_area_.linearRings(
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride);
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -172,17 +172,17 @@ Polygon.prototype.getArea = function() {
|
||||
* @api
|
||||
*/
|
||||
Polygon.prototype.getCoordinates = function(opt_right) {
|
||||
var flatCoordinates;
|
||||
let flatCoordinates;
|
||||
if (opt_right !== undefined) {
|
||||
flatCoordinates = this.getOrientedFlatCoordinates().slice();
|
||||
_ol_geom_flat_orient_.orientLinearRings(
|
||||
flatCoordinates, 0, this.ends_, this.stride, opt_right);
|
||||
flatCoordinates, 0, this.ends_, this.stride, opt_right);
|
||||
} else {
|
||||
flatCoordinates = this.flatCoordinates;
|
||||
}
|
||||
|
||||
return _ol_geom_flat_inflate_.coordinatess(
|
||||
flatCoordinates, 0, this.ends_, this.stride);
|
||||
flatCoordinates, 0, this.ends_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -199,10 +199,10 @@ Polygon.prototype.getEnds = function() {
|
||||
*/
|
||||
Polygon.prototype.getFlatInteriorPoint = function() {
|
||||
if (this.flatInteriorPointRevision_ != this.getRevision()) {
|
||||
var flatCenter = getCenter(this.getExtent());
|
||||
const flatCenter = getCenter(this.getExtent());
|
||||
this.flatInteriorPoint_ = _ol_geom_flat_interiorpoint_.linearRings(
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride,
|
||||
flatCenter, 0);
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride,
|
||||
flatCenter, 0);
|
||||
this.flatInteriorPointRevision_ = this.getRevision();
|
||||
}
|
||||
return this.flatInteriorPoint_;
|
||||
@@ -246,9 +246,9 @@ Polygon.prototype.getLinearRing = function(index) {
|
||||
if (index < 0 || this.ends_.length <= index) {
|
||||
return null;
|
||||
}
|
||||
var linearRing = new LinearRing(null);
|
||||
const linearRing = new LinearRing(null);
|
||||
linearRing.setFlatCoordinates(this.layout, this.flatCoordinates.slice(
|
||||
index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]));
|
||||
index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]));
|
||||
return linearRing;
|
||||
};
|
||||
|
||||
@@ -259,15 +259,15 @@ Polygon.prototype.getLinearRing = function(index) {
|
||||
* @api
|
||||
*/
|
||||
Polygon.prototype.getLinearRings = function() {
|
||||
var layout = this.layout;
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
var ends = this.ends_;
|
||||
var linearRings = [];
|
||||
var offset = 0;
|
||||
var i, ii;
|
||||
const layout = this.layout;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
const ends = this.ends_;
|
||||
const linearRings = [];
|
||||
let offset = 0;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var linearRing = new LinearRing(null);
|
||||
const end = ends[i];
|
||||
const linearRing = new LinearRing(null);
|
||||
linearRing.setFlatCoordinates(layout, flatCoordinates.slice(offset, end));
|
||||
linearRings.push(linearRing);
|
||||
offset = end;
|
||||
@@ -281,15 +281,15 @@ Polygon.prototype.getLinearRings = function() {
|
||||
*/
|
||||
Polygon.prototype.getOrientedFlatCoordinates = function() {
|
||||
if (this.orientedRevision_ != this.getRevision()) {
|
||||
var flatCoordinates = this.flatCoordinates;
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
if (_ol_geom_flat_orient_.linearRingsAreOriented(
|
||||
flatCoordinates, 0, this.ends_, this.stride)) {
|
||||
flatCoordinates, 0, this.ends_, this.stride)) {
|
||||
this.orientedFlatCoordinates_ = flatCoordinates;
|
||||
} else {
|
||||
this.orientedFlatCoordinates_ = flatCoordinates.slice();
|
||||
this.orientedFlatCoordinates_.length =
|
||||
_ol_geom_flat_orient_.orientLinearRings(
|
||||
this.orientedFlatCoordinates_, 0, this.ends_, this.stride);
|
||||
this.orientedFlatCoordinates_, 0, this.ends_, this.stride);
|
||||
}
|
||||
this.orientedRevision_ = this.getRevision();
|
||||
}
|
||||
@@ -301,15 +301,15 @@ Polygon.prototype.getOrientedFlatCoordinates = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
Polygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) {
|
||||
var simplifiedFlatCoordinates = [];
|
||||
var simplifiedEnds = [];
|
||||
const simplifiedFlatCoordinates = [];
|
||||
const simplifiedEnds = [];
|
||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.quantizes(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||
Math.sqrt(squaredTolerance),
|
||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||
var simplifiedPolygon = new Polygon(null);
|
||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||
Math.sqrt(squaredTolerance),
|
||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||
const simplifiedPolygon = new Polygon(null);
|
||||
simplifiedPolygon.setFlatCoordinates(
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds);
|
||||
GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds);
|
||||
return simplifiedPolygon;
|
||||
};
|
||||
|
||||
@@ -329,7 +329,7 @@ Polygon.prototype.getType = function() {
|
||||
*/
|
||||
Polygon.prototype.intersectsExtent = function(extent) {
|
||||
return _ol_geom_flat_intersectsextent_.linearRings(
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, extent);
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -348,8 +348,8 @@ Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
var ends = _ol_geom_flat_deflate_.coordinatess(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||
const ends = _ol_geom_flat_deflate_.coordinatess(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
||||
this.changed();
|
||||
}
|
||||
@@ -383,17 +383,17 @@ export default Polygon;
|
||||
* @api
|
||||
*/
|
||||
export function circular(center, radius, opt_n, opt_sphereRadius) {
|
||||
var n = opt_n ? opt_n : 32;
|
||||
const n = opt_n ? opt_n : 32;
|
||||
/** @type {Array.<number>} */
|
||||
var flatCoordinates = [];
|
||||
var i;
|
||||
const flatCoordinates = [];
|
||||
let i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
extend(flatCoordinates, sphereOffset(center, radius, 2 * Math.PI * i / n, opt_sphereRadius));
|
||||
}
|
||||
flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||
var polygon = new Polygon(null);
|
||||
const polygon = new Polygon(null);
|
||||
polygon.setFlatCoordinates(
|
||||
GeometryLayout.XY, flatCoordinates, [flatCoordinates.length]);
|
||||
GeometryLayout.XY, flatCoordinates, [flatCoordinates.length]);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
@@ -405,15 +405,15 @@ export function circular(center, radius, opt_n, opt_sphereRadius) {
|
||||
* @api
|
||||
*/
|
||||
export function fromExtent(extent) {
|
||||
var minX = extent[0];
|
||||
var minY = extent[1];
|
||||
var maxX = extent[2];
|
||||
var maxY = extent[3];
|
||||
var flatCoordinates =
|
||||
const minX = extent[0];
|
||||
const minY = extent[1];
|
||||
const maxX = extent[2];
|
||||
const maxY = extent[3];
|
||||
const flatCoordinates =
|
||||
[minX, minY, minX, maxY, maxX, maxY, maxX, minY, minX, minY];
|
||||
var polygon = new Polygon(null);
|
||||
const polygon = new Polygon(null);
|
||||
polygon.setFlatCoordinates(
|
||||
GeometryLayout.XY, flatCoordinates, [flatCoordinates.length]);
|
||||
GeometryLayout.XY, flatCoordinates, [flatCoordinates.length]);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
@@ -428,16 +428,16 @@ export function fromExtent(extent) {
|
||||
* @api
|
||||
*/
|
||||
export function fromCircle(circle, opt_sides, opt_angle) {
|
||||
var sides = opt_sides ? opt_sides : 32;
|
||||
var stride = circle.getStride();
|
||||
var layout = circle.getLayout();
|
||||
var polygon = new Polygon(null, layout);
|
||||
var arrayLength = stride * (sides + 1);
|
||||
var flatCoordinates = new Array(arrayLength);
|
||||
for (var i = 0; i < arrayLength; i++) {
|
||||
const sides = opt_sides ? opt_sides : 32;
|
||||
const stride = circle.getStride();
|
||||
const layout = circle.getLayout();
|
||||
const polygon = new Polygon(null, layout);
|
||||
const arrayLength = stride * (sides + 1);
|
||||
const flatCoordinates = new Array(arrayLength);
|
||||
for (let i = 0; i < arrayLength; i++) {
|
||||
flatCoordinates[i] = 0;
|
||||
}
|
||||
var ends = [flatCoordinates.length];
|
||||
const ends = [flatCoordinates.length];
|
||||
polygon.setFlatCoordinates(layout, flatCoordinates, ends);
|
||||
makeRegular(polygon, circle.getCenter(), circle.getRadius(), opt_angle);
|
||||
return polygon;
|
||||
@@ -453,14 +453,14 @@ export function fromCircle(circle, opt_sides, opt_angle) {
|
||||
* radians. Default is 0.
|
||||
*/
|
||||
export function makeRegular(polygon, center, radius, opt_angle) {
|
||||
var flatCoordinates = polygon.getFlatCoordinates();
|
||||
var layout = polygon.getLayout();
|
||||
var stride = polygon.getStride();
|
||||
var ends = polygon.getEnds();
|
||||
var sides = flatCoordinates.length / stride - 1;
|
||||
var startAngle = opt_angle ? opt_angle : 0;
|
||||
var angle, offset;
|
||||
for (var i = 0; i <= sides; ++i) {
|
||||
const flatCoordinates = polygon.getFlatCoordinates();
|
||||
const layout = polygon.getLayout();
|
||||
const stride = polygon.getStride();
|
||||
const ends = polygon.getEnds();
|
||||
const sides = flatCoordinates.length / stride - 1;
|
||||
const startAngle = opt_angle ? opt_angle : 0;
|
||||
let angle, offset;
|
||||
for (let i = 0; i <= sides; ++i) {
|
||||
offset = i * stride;
|
||||
angle = startAngle + (modulo(i, sides) * 2 * Math.PI / sides);
|
||||
flatCoordinates[offset] = center[0] + (radius * Math.cos(angle));
|
||||
|
||||
@@ -19,7 +19,7 @@ import _ol_obj_ from '../obj.js';
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @api
|
||||
*/
|
||||
var SimpleGeometry = function() {
|
||||
const SimpleGeometry = function() {
|
||||
|
||||
Geometry.call(this);
|
||||
|
||||
@@ -51,7 +51,7 @@ inherits(SimpleGeometry, Geometry);
|
||||
* @return {ol.geom.GeometryLayout} layout Layout.
|
||||
*/
|
||||
function getLayoutForStride(stride) {
|
||||
var layout;
|
||||
let layout;
|
||||
if (stride == 2) {
|
||||
layout = GeometryLayout.XY;
|
||||
} else if (stride == 3) {
|
||||
@@ -68,7 +68,7 @@ function getLayoutForStride(stride) {
|
||||
* @return {number} Stride.
|
||||
*/
|
||||
export function getStrideForLayout(layout) {
|
||||
var stride;
|
||||
let stride;
|
||||
if (layout == GeometryLayout.XY) {
|
||||
stride = 2;
|
||||
} else if (layout == GeometryLayout.XYZ || layout == GeometryLayout.XYM) {
|
||||
@@ -91,7 +91,7 @@ SimpleGeometry.prototype.containsXY = FALSE;
|
||||
*/
|
||||
SimpleGeometry.prototype.computeExtent = function(extent) {
|
||||
return createOrUpdateFromFlatCoordinates(this.flatCoordinates,
|
||||
0, this.flatCoordinates.length, this.stride, extent);
|
||||
0, this.flatCoordinates.length, this.stride, extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -156,13 +156,13 @@ SimpleGeometry.prototype.getSimplifiedGeometry = function(squaredTolerance) {
|
||||
squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)) {
|
||||
return this;
|
||||
}
|
||||
var key = squaredTolerance.toString();
|
||||
const key = squaredTolerance.toString();
|
||||
if (this.simplifiedGeometryCache.hasOwnProperty(key)) {
|
||||
return this.simplifiedGeometryCache[key];
|
||||
} else {
|
||||
var simplifiedGeometry =
|
||||
const simplifiedGeometry =
|
||||
this.getSimplifiedGeometryInternal(squaredTolerance);
|
||||
var simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();
|
||||
const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();
|
||||
if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {
|
||||
this.simplifiedGeometryCache[key] = simplifiedGeometry;
|
||||
return simplifiedGeometry;
|
||||
@@ -226,11 +226,11 @@ SimpleGeometry.prototype.setCoordinates = function(coordinates, opt_layout) {};
|
||||
*/
|
||||
SimpleGeometry.prototype.setLayout = function(layout, coordinates, nesting) {
|
||||
/** @type {number} */
|
||||
var stride;
|
||||
let stride;
|
||||
if (layout) {
|
||||
stride = getStrideForLayout(layout);
|
||||
} else {
|
||||
var i;
|
||||
let i;
|
||||
for (i = 0; i < nesting; ++i) {
|
||||
if (coordinates.length === 0) {
|
||||
this.layout = GeometryLayout.XY;
|
||||
@@ -265,12 +265,12 @@ SimpleGeometry.prototype.applyTransform = function(transformFn) {
|
||||
* @api
|
||||
*/
|
||||
SimpleGeometry.prototype.rotate = function(angle, anchor) {
|
||||
var flatCoordinates = this.getFlatCoordinates();
|
||||
const flatCoordinates = this.getFlatCoordinates();
|
||||
if (flatCoordinates) {
|
||||
var stride = this.getStride();
|
||||
const stride = this.getStride();
|
||||
_ol_geom_flat_transform_.rotate(
|
||||
flatCoordinates, 0, flatCoordinates.length,
|
||||
stride, angle, anchor, flatCoordinates);
|
||||
flatCoordinates, 0, flatCoordinates.length,
|
||||
stride, angle, anchor, flatCoordinates);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
@@ -281,20 +281,20 @@ SimpleGeometry.prototype.rotate = function(angle, anchor) {
|
||||
* @api
|
||||
*/
|
||||
SimpleGeometry.prototype.scale = function(sx, opt_sy, opt_anchor) {
|
||||
var sy = opt_sy;
|
||||
let sy = opt_sy;
|
||||
if (sy === undefined) {
|
||||
sy = sx;
|
||||
}
|
||||
var anchor = opt_anchor;
|
||||
let anchor = opt_anchor;
|
||||
if (!anchor) {
|
||||
anchor = getCenter(this.getExtent());
|
||||
}
|
||||
var flatCoordinates = this.getFlatCoordinates();
|
||||
const flatCoordinates = this.getFlatCoordinates();
|
||||
if (flatCoordinates) {
|
||||
var stride = this.getStride();
|
||||
const stride = this.getStride();
|
||||
_ol_geom_flat_transform_.scale(
|
||||
flatCoordinates, 0, flatCoordinates.length,
|
||||
stride, sx, sy, anchor, flatCoordinates);
|
||||
flatCoordinates, 0, flatCoordinates.length,
|
||||
stride, sx, sy, anchor, flatCoordinates);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
@@ -305,12 +305,12 @@ SimpleGeometry.prototype.scale = function(sx, opt_sy, opt_anchor) {
|
||||
* @api
|
||||
*/
|
||||
SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
|
||||
var flatCoordinates = this.getFlatCoordinates();
|
||||
const flatCoordinates = this.getFlatCoordinates();
|
||||
if (flatCoordinates) {
|
||||
var stride = this.getStride();
|
||||
const stride = this.getStride();
|
||||
_ol_geom_flat_transform_.translate(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||
deltaX, deltaY, flatCoordinates);
|
||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||
deltaX, deltaY, flatCoordinates);
|
||||
this.changed();
|
||||
}
|
||||
};
|
||||
@@ -323,14 +323,14 @@ SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
|
||||
* @return {Array.<number>} Transformed flat coordinates.
|
||||
*/
|
||||
SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) {
|
||||
var flatCoordinates = simpleGeometry.getFlatCoordinates();
|
||||
const flatCoordinates = simpleGeometry.getFlatCoordinates();
|
||||
if (!flatCoordinates) {
|
||||
return null;
|
||||
} else {
|
||||
var stride = simpleGeometry.getStride();
|
||||
const stride = simpleGeometry.getStride();
|
||||
return _ol_geom_flat_transform_.transform2D(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||
transform, opt_dest);
|
||||
flatCoordinates, 0, flatCoordinates.length, stride,
|
||||
transform, opt_dest);
|
||||
}
|
||||
};
|
||||
export default SimpleGeometry;
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/area
|
||||
*/
|
||||
var _ol_geom_flat_area_ = {};
|
||||
const _ol_geom_flat_area_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,12 +12,12 @@ var _ol_geom_flat_area_ = {};
|
||||
* @return {number} Area.
|
||||
*/
|
||||
_ol_geom_flat_area_.linearRing = function(flatCoordinates, offset, end, stride) {
|
||||
var twiceArea = 0;
|
||||
var x1 = flatCoordinates[end - stride];
|
||||
var y1 = flatCoordinates[end - stride + 1];
|
||||
let twiceArea = 0;
|
||||
let x1 = flatCoordinates[end - stride];
|
||||
let y1 = flatCoordinates[end - stride + 1];
|
||||
for (; offset < end; offset += stride) {
|
||||
var x2 = flatCoordinates[offset];
|
||||
var y2 = flatCoordinates[offset + 1];
|
||||
const x2 = flatCoordinates[offset];
|
||||
const y2 = flatCoordinates[offset + 1];
|
||||
twiceArea += y1 * x2 - x1 * y2;
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
@@ -34,10 +34,10 @@ _ol_geom_flat_area_.linearRing = function(flatCoordinates, offset, end, stride)
|
||||
* @return {number} Area.
|
||||
*/
|
||||
_ol_geom_flat_area_.linearRings = function(flatCoordinates, offset, ends, stride) {
|
||||
var area = 0;
|
||||
var i, ii;
|
||||
let area = 0;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
const end = ends[i];
|
||||
area += _ol_geom_flat_area_.linearRing(flatCoordinates, offset, end, stride);
|
||||
offset = end;
|
||||
}
|
||||
@@ -53,10 +53,10 @@ _ol_geom_flat_area_.linearRings = function(flatCoordinates, offset, ends, stride
|
||||
* @return {number} Area.
|
||||
*/
|
||||
_ol_geom_flat_area_.linearRingss = function(flatCoordinates, offset, endss, stride) {
|
||||
var area = 0;
|
||||
var i, ii;
|
||||
let area = 0;
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
area +=
|
||||
_ol_geom_flat_area_.linearRings(flatCoordinates, offset, ends, stride);
|
||||
offset = ends[ends.length - 1];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/center
|
||||
*/
|
||||
import {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js';
|
||||
var _ol_geom_flat_center_ = {};
|
||||
const _ol_geom_flat_center_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,11 +13,11 @@ var _ol_geom_flat_center_ = {};
|
||||
* @return {Array.<number>} Flat centers.
|
||||
*/
|
||||
_ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, stride) {
|
||||
var flatCenters = [];
|
||||
var i, ii;
|
||||
var extent = createEmpty();
|
||||
const flatCenters = [];
|
||||
let i, ii;
|
||||
let extent = createEmpty();
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
extent = createOrUpdateFromFlatCoordinates(flatCoordinates, offset, ends[0], stride);
|
||||
flatCenters.push((extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2);
|
||||
offset = ends[ends.length - 1];
|
||||
|
||||
+42
-42
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/closest
|
||||
*/
|
||||
import {lerp, squaredDistance as squaredDx} from '../../math.js';
|
||||
var _ol_geom_flat_closest_ = {};
|
||||
const _ol_geom_flat_closest_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,21 +18,21 @@ var _ol_geom_flat_closest_ = {};
|
||||
* @param {Array.<number>} closestPoint Closest point.
|
||||
*/
|
||||
_ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
|
||||
var x1 = flatCoordinates[offset1];
|
||||
var y1 = flatCoordinates[offset1 + 1];
|
||||
var dx = flatCoordinates[offset2] - x1;
|
||||
var dy = flatCoordinates[offset2 + 1] - y1;
|
||||
var i, offset;
|
||||
const x1 = flatCoordinates[offset1];
|
||||
const y1 = flatCoordinates[offset1 + 1];
|
||||
const dx = flatCoordinates[offset2] - x1;
|
||||
const dy = flatCoordinates[offset2 + 1] - y1;
|
||||
let i, offset;
|
||||
if (dx === 0 && dy === 0) {
|
||||
offset = offset1;
|
||||
} else {
|
||||
var t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
|
||||
const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
|
||||
if (t > 1) {
|
||||
offset = offset2;
|
||||
} else if (t > 0) {
|
||||
for (i = 0; i < stride; ++i) {
|
||||
closestPoint[i] = lerp(flatCoordinates[offset1 + i],
|
||||
flatCoordinates[offset2 + i], t);
|
||||
flatCoordinates[offset2 + i], t);
|
||||
}
|
||||
closestPoint.length = stride;
|
||||
return;
|
||||
@@ -58,12 +58,12 @@ _ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, strid
|
||||
* @return {number} Max squared delta.
|
||||
*/
|
||||
_ol_geom_flat_closest_.getMaxSquaredDelta = function(flatCoordinates, offset, end, stride, maxSquaredDelta) {
|
||||
var x1 = flatCoordinates[offset];
|
||||
var y1 = flatCoordinates[offset + 1];
|
||||
let x1 = flatCoordinates[offset];
|
||||
let y1 = flatCoordinates[offset + 1];
|
||||
for (offset += stride; offset < end; offset += stride) {
|
||||
var x2 = flatCoordinates[offset];
|
||||
var y2 = flatCoordinates[offset + 1];
|
||||
var squaredDelta = squaredDx(x1, y1, x2, y2);
|
||||
const x2 = flatCoordinates[offset];
|
||||
const y2 = flatCoordinates[offset + 1];
|
||||
const squaredDelta = squaredDx(x1, y1, x2, y2);
|
||||
if (squaredDelta > maxSquaredDelta) {
|
||||
maxSquaredDelta = squaredDelta;
|
||||
}
|
||||
@@ -83,11 +83,11 @@ _ol_geom_flat_closest_.getMaxSquaredDelta = function(flatCoordinates, offset, en
|
||||
* @return {number} Max squared delta.
|
||||
*/
|
||||
_ol_geom_flat_closest_.getsMaxSquaredDelta = function(flatCoordinates, offset, ends, stride, maxSquaredDelta) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
const end = ends[i];
|
||||
maxSquaredDelta = _ol_geom_flat_closest_.getMaxSquaredDelta(
|
||||
flatCoordinates, offset, end, stride, maxSquaredDelta);
|
||||
flatCoordinates, offset, end, stride, maxSquaredDelta);
|
||||
offset = end;
|
||||
}
|
||||
return maxSquaredDelta;
|
||||
@@ -103,11 +103,11 @@ _ol_geom_flat_closest_.getsMaxSquaredDelta = function(flatCoordinates, offset, e
|
||||
* @return {number} Max squared delta.
|
||||
*/
|
||||
_ol_geom_flat_closest_.getssMaxSquaredDelta = function(flatCoordinates, offset, endss, stride, maxSquaredDelta) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
maxSquaredDelta = _ol_geom_flat_closest_.getsMaxSquaredDelta(
|
||||
flatCoordinates, offset, ends, stride, maxSquaredDelta);
|
||||
flatCoordinates, offset, ends, stride, maxSquaredDelta);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
return maxSquaredDelta;
|
||||
@@ -129,16 +129,16 @@ _ol_geom_flat_closest_.getssMaxSquaredDelta = function(flatCoordinates, offset,
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
_ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
||||
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||
opt_tmpPoint) {
|
||||
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||
opt_tmpPoint) {
|
||||
if (offset == end) {
|
||||
return minSquaredDistance;
|
||||
}
|
||||
var i, squaredDistance;
|
||||
let i, squaredDistance;
|
||||
if (maxDelta === 0) {
|
||||
// All points are identical, so just test the first point.
|
||||
squaredDistance = squaredDx(
|
||||
x, y, flatCoordinates[offset], flatCoordinates[offset + 1]);
|
||||
x, y, flatCoordinates[offset], flatCoordinates[offset + 1]);
|
||||
if (squaredDistance < minSquaredDistance) {
|
||||
for (i = 0; i < stride; ++i) {
|
||||
closestPoint[i] = flatCoordinates[offset + i];
|
||||
@@ -149,11 +149,11 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
||||
return minSquaredDistance;
|
||||
}
|
||||
}
|
||||
var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
var index = offset + stride;
|
||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
let index = offset + stride;
|
||||
while (index < end) {
|
||||
_ol_geom_flat_closest_.point(
|
||||
flatCoordinates, index - stride, index, stride, x, y, tmpPoint);
|
||||
flatCoordinates, index - stride, index, stride, x, y, tmpPoint);
|
||||
squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
|
||||
if (squaredDistance < minSquaredDistance) {
|
||||
minSquaredDistance = squaredDistance;
|
||||
@@ -174,14 +174,14 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
||||
// finding a closer point. We use Math.max(..., 1) to ensure that we
|
||||
// always advance at least one point, to avoid an infinite loop.
|
||||
index += stride * Math.max(
|
||||
((Math.sqrt(squaredDistance) -
|
||||
((Math.sqrt(squaredDistance) -
|
||||
Math.sqrt(minSquaredDistance)) / maxDelta) | 0, 1);
|
||||
}
|
||||
}
|
||||
if (isRing) {
|
||||
// Check the closing segment.
|
||||
_ol_geom_flat_closest_.point(
|
||||
flatCoordinates, end - stride, offset, stride, x, y, tmpPoint);
|
||||
flatCoordinates, end - stride, offset, stride, x, y, tmpPoint);
|
||||
squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
|
||||
if (squaredDistance < minSquaredDistance) {
|
||||
minSquaredDistance = squaredDistance;
|
||||
@@ -210,15 +210,15 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
_ol_geom_flat_closest_.getsClosestPoint = function(flatCoordinates, offset, ends,
|
||||
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||
opt_tmpPoint) {
|
||||
var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
var i, ii;
|
||||
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||
opt_tmpPoint) {
|
||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
const end = ends[i];
|
||||
minSquaredDistance = _ol_geom_flat_closest_.getClosestPoint(
|
||||
flatCoordinates, offset, end, stride,
|
||||
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
||||
flatCoordinates, offset, end, stride,
|
||||
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
||||
offset = end;
|
||||
}
|
||||
return minSquaredDistance;
|
||||
@@ -240,15 +240,15 @@ _ol_geom_flat_closest_.getsClosestPoint = function(flatCoordinates, offset, ends
|
||||
* @return {number} Minimum squared distance.
|
||||
*/
|
||||
_ol_geom_flat_closest_.getssClosestPoint = function(flatCoordinates, offset,
|
||||
endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||
opt_tmpPoint) {
|
||||
var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
var i, ii;
|
||||
endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
|
||||
opt_tmpPoint) {
|
||||
const tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
minSquaredDistance = _ol_geom_flat_closest_.getsClosestPoint(
|
||||
flatCoordinates, offset, ends, stride,
|
||||
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
||||
flatCoordinates, offset, ends, stride,
|
||||
maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
return minSquaredDistance;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/contains
|
||||
*/
|
||||
import {forEachCorner} from '../../extent.js';
|
||||
var _ol_geom_flat_contains_ = {};
|
||||
const _ol_geom_flat_contains_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,15 +14,15 @@ var _ol_geom_flat_contains_ = {};
|
||||
* @return {boolean} Contains extent.
|
||||
*/
|
||||
_ol_geom_flat_contains_.linearRingContainsExtent = function(flatCoordinates, offset, end, stride, extent) {
|
||||
var outside = forEachCorner(extent,
|
||||
/**
|
||||
const outside = forEachCorner(extent,
|
||||
/**
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {boolean} Contains (x, y).
|
||||
*/
|
||||
function(coordinate) {
|
||||
return !_ol_geom_flat_contains_.linearRingContainsXY(flatCoordinates,
|
||||
offset, end, stride, coordinate[0], coordinate[1]);
|
||||
});
|
||||
function(coordinate) {
|
||||
return !_ol_geom_flat_contains_.linearRingContainsXY(flatCoordinates,
|
||||
offset, end, stride, coordinate[0], coordinate[1]);
|
||||
});
|
||||
return !outside;
|
||||
};
|
||||
|
||||
@@ -44,12 +44,12 @@ _ol_geom_flat_contains_.linearRingContainsXY = function(flatCoordinates, offset,
|
||||
// SoftSurfer makes no warranty for this code, and cannot be held
|
||||
// liable for any real or imagined damage resulting from its use.
|
||||
// Users of this code must verify correctness for their application.
|
||||
var wn = 0;
|
||||
var x1 = flatCoordinates[end - stride];
|
||||
var y1 = flatCoordinates[end - stride + 1];
|
||||
let wn = 0;
|
||||
let x1 = flatCoordinates[end - stride];
|
||||
let y1 = flatCoordinates[end - stride + 1];
|
||||
for (; offset < end; offset += stride) {
|
||||
var x2 = flatCoordinates[offset];
|
||||
var y2 = flatCoordinates[offset + 1];
|
||||
const x2 = flatCoordinates[offset];
|
||||
const y2 = flatCoordinates[offset + 1];
|
||||
if (y1 <= y) {
|
||||
if (y2 > y && ((x2 - x1) * (y - y1)) - ((x - x1) * (y2 - y1)) > 0) {
|
||||
wn++;
|
||||
@@ -78,13 +78,13 @@ _ol_geom_flat_contains_.linearRingsContainsXY = function(flatCoordinates, offset
|
||||
return false;
|
||||
}
|
||||
if (!_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, ends[0], stride, x, y)) {
|
||||
flatCoordinates, offset, ends[0], stride, x, y)) {
|
||||
return false;
|
||||
}
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, ends[i - 1], ends[i], stride, x, y)) {
|
||||
flatCoordinates, ends[i - 1], ends[i], stride, x, y)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -105,11 +105,11 @@ _ol_geom_flat_contains_.linearRingssContainsXY = function(flatCoordinates, offse
|
||||
if (endss.length === 0) {
|
||||
return false;
|
||||
}
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
if (_ol_geom_flat_contains_.linearRingsContainsXY(
|
||||
flatCoordinates, offset, ends, stride, x, y)) {
|
||||
flatCoordinates, offset, ends, stride, x, y)) {
|
||||
return true;
|
||||
}
|
||||
offset = ends[ends.length - 1];
|
||||
|
||||
+15
-16
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/deflate
|
||||
*/
|
||||
var _ol_geom_flat_deflate_ = {};
|
||||
const _ol_geom_flat_deflate_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ var _ol_geom_flat_deflate_ = {};
|
||||
* @return {number} offset Offset.
|
||||
*/
|
||||
_ol_geom_flat_deflate_.coordinate = function(flatCoordinates, offset, coordinate, stride) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = coordinate.length; i < ii; ++i) {
|
||||
flatCoordinates[offset++] = coordinate[i];
|
||||
}
|
||||
@@ -28,11 +28,10 @@ _ol_geom_flat_deflate_.coordinate = function(flatCoordinates, offset, coordinate
|
||||
* @return {number} offset Offset.
|
||||
*/
|
||||
_ol_geom_flat_deflate_.coordinates = function(flatCoordinates, offset, coordinates, stride) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
var coordinate = coordinates[i];
|
||||
var j;
|
||||
for (j = 0; j < stride; ++j) {
|
||||
const coordinate = coordinates[i];
|
||||
for (let j = 0; j < stride; ++j) {
|
||||
flatCoordinates[offset++] = coordinate[j];
|
||||
}
|
||||
}
|
||||
@@ -49,12 +48,12 @@ _ol_geom_flat_deflate_.coordinates = function(flatCoordinates, offset, coordinat
|
||||
* @return {Array.<number>} Ends.
|
||||
*/
|
||||
_ol_geom_flat_deflate_.coordinatess = function(flatCoordinates, offset, coordinatess, stride, opt_ends) {
|
||||
var ends = opt_ends ? opt_ends : [];
|
||||
var i = 0;
|
||||
var j, jj;
|
||||
const ends = opt_ends ? opt_ends : [];
|
||||
let i = 0;
|
||||
let j, jj;
|
||||
for (j = 0, jj = coordinatess.length; j < jj; ++j) {
|
||||
var end = _ol_geom_flat_deflate_.coordinates(
|
||||
flatCoordinates, offset, coordinatess[j], stride);
|
||||
const end = _ol_geom_flat_deflate_.coordinates(
|
||||
flatCoordinates, offset, coordinatess[j], stride);
|
||||
ends[i++] = end;
|
||||
offset = end;
|
||||
}
|
||||
@@ -72,12 +71,12 @@ _ol_geom_flat_deflate_.coordinatess = function(flatCoordinates, offset, coordina
|
||||
* @return {Array.<Array.<number>>} Endss.
|
||||
*/
|
||||
_ol_geom_flat_deflate_.coordinatesss = function(flatCoordinates, offset, coordinatesss, stride, opt_endss) {
|
||||
var endss = opt_endss ? opt_endss : [];
|
||||
var i = 0;
|
||||
var j, jj;
|
||||
const endss = opt_endss ? opt_endss : [];
|
||||
let i = 0;
|
||||
let j, jj;
|
||||
for (j = 0, jj = coordinatesss.length; j < jj; ++j) {
|
||||
var ends = _ol_geom_flat_deflate_.coordinatess(
|
||||
flatCoordinates, offset, coordinatesss[j], stride, endss[i]);
|
||||
const ends = _ol_geom_flat_deflate_.coordinatess(
|
||||
flatCoordinates, offset, coordinatesss[j], stride, endss[i]);
|
||||
endss[i++] = ends;
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/flip
|
||||
*/
|
||||
var _ol_geom_flat_flip_ = {};
|
||||
const _ol_geom_flat_flip_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@ var _ol_geom_flat_flip_ = {};
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) {
|
||||
var dest, destOffset;
|
||||
let dest, destOffset;
|
||||
if (opt_dest !== undefined) {
|
||||
dest = opt_dest;
|
||||
destOffset = opt_destOffset !== undefined ? opt_destOffset : 0;
|
||||
@@ -22,12 +22,12 @@ _ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_
|
||||
dest = [];
|
||||
destOffset = 0;
|
||||
}
|
||||
var j = offset;
|
||||
let j = offset;
|
||||
while (j < end) {
|
||||
var x = flatCoordinates[j++];
|
||||
const x = flatCoordinates[j++];
|
||||
dest[destOffset++] = flatCoordinates[j++];
|
||||
dest[destOffset++] = x;
|
||||
for (var k = 2; k < stride; ++k) {
|
||||
for (let k = 2; k < stride; ++k) {
|
||||
dest[destOffset++] = flatCoordinates[j++];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {squaredSegmentDistance, toRadians, toDegrees} from '../../math.js';
|
||||
import {get as getProjection, getTransform} from '../../proj.js';
|
||||
var _ol_geom_flat_geodesic_ = {};
|
||||
const _ol_geom_flat_geodesic_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,26 +19,26 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
|
||||
// FIXME optimize stack operations
|
||||
|
||||
/** @type {Array.<number>} */
|
||||
var flatCoordinates = [];
|
||||
const flatCoordinates = [];
|
||||
|
||||
var geoA = interpolate(0);
|
||||
var geoB = interpolate(1);
|
||||
let geoA = interpolate(0);
|
||||
let geoB = interpolate(1);
|
||||
|
||||
var a = transform(geoA);
|
||||
var b = transform(geoB);
|
||||
let a = transform(geoA);
|
||||
let b = transform(geoB);
|
||||
|
||||
/** @type {Array.<ol.Coordinate>} */
|
||||
var geoStack = [geoB, geoA];
|
||||
const geoStack = [geoB, geoA];
|
||||
/** @type {Array.<ol.Coordinate>} */
|
||||
var stack = [b, a];
|
||||
const stack = [b, a];
|
||||
/** @type {Array.<number>} */
|
||||
var fractionStack = [1, 0];
|
||||
const fractionStack = [1, 0];
|
||||
|
||||
/** @type {Object.<string, boolean>} */
|
||||
var fractions = {};
|
||||
const fractions = {};
|
||||
|
||||
var maxIterations = 1e5;
|
||||
var geoM, m, fracA, fracB, fracM, key;
|
||||
let maxIterations = 1e5;
|
||||
let geoM, m, fracA, fracB, fracM, key;
|
||||
|
||||
while (--maxIterations > 0 && fractionStack.length > 0) {
|
||||
// Pop the a coordinate off the stack
|
||||
@@ -60,7 +60,7 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
|
||||
geoM = interpolate(fracM);
|
||||
m = transform(geoM);
|
||||
if (squaredSegmentDistance(m[0], m[1], a[0], a[1],
|
||||
b[0], b[1]) < squaredTolerance) {
|
||||
b[0], b[1]) < squaredTolerance) {
|
||||
// If the m point is sufficiently close to the straight line, then we
|
||||
// discard it. Just use the b coordinate and move on to the next line
|
||||
// segment.
|
||||
@@ -91,39 +91,39 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
||||
lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
||||
|
||||
var geoProjection = getProjection('EPSG:4326');
|
||||
const geoProjection = getProjection('EPSG:4326');
|
||||
|
||||
var cosLat1 = Math.cos(toRadians(lat1));
|
||||
var sinLat1 = Math.sin(toRadians(lat1));
|
||||
var cosLat2 = Math.cos(toRadians(lat2));
|
||||
var sinLat2 = Math.sin(toRadians(lat2));
|
||||
var cosDeltaLon = Math.cos(toRadians(lon2 - lon1));
|
||||
var sinDeltaLon = Math.sin(toRadians(lon2 - lon1));
|
||||
var d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
|
||||
const cosLat1 = Math.cos(toRadians(lat1));
|
||||
const sinLat1 = Math.sin(toRadians(lat1));
|
||||
const cosLat2 = Math.cos(toRadians(lat2));
|
||||
const sinLat2 = Math.sin(toRadians(lat2));
|
||||
const cosDeltaLon = Math.cos(toRadians(lon2 - lon1));
|
||||
const sinDeltaLon = Math.sin(toRadians(lon2 - lon1));
|
||||
const d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
|
||||
|
||||
return _ol_geom_flat_geodesic_.line_(
|
||||
/**
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
function(frac) {
|
||||
if (1 <= d) {
|
||||
return [lon2, lat2];
|
||||
}
|
||||
var D = frac * Math.acos(d);
|
||||
var cosD = Math.cos(D);
|
||||
var sinD = Math.sin(D);
|
||||
var y = sinDeltaLon * cosLat2;
|
||||
var x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon;
|
||||
var theta = Math.atan2(y, x);
|
||||
var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
|
||||
var lon = toRadians(lon1) +
|
||||
function(frac) {
|
||||
if (1 <= d) {
|
||||
return [lon2, lat2];
|
||||
}
|
||||
const D = frac * Math.acos(d);
|
||||
const cosD = Math.cos(D);
|
||||
const sinD = Math.sin(D);
|
||||
const y = sinDeltaLon * cosLat2;
|
||||
const x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon;
|
||||
const theta = Math.atan2(y, x);
|
||||
const lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
|
||||
const lon = toRadians(lon1) +
|
||||
Math.atan2(Math.sin(theta) * sinD * cosLat1,
|
||||
cosD - sinLat1 * Math.sin(lat));
|
||||
return [toDegrees(lon), toDegrees(lat)];
|
||||
}, getTransform(geoProjection, projection), squaredTolerance);
|
||||
cosD - sinLat1 * Math.sin(lat));
|
||||
return [toDegrees(lon), toDegrees(lat)];
|
||||
}, getTransform(geoProjection, projection), squaredTolerance);
|
||||
};
|
||||
|
||||
|
||||
@@ -137,16 +137,16 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squaredTolerance) {
|
||||
var epsg4326Projection = getProjection('EPSG:4326');
|
||||
const epsg4326Projection = getProjection('EPSG:4326');
|
||||
return _ol_geom_flat_geodesic_.line_(
|
||||
/**
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
function(frac) {
|
||||
return [lon, lat1 + ((lat2 - lat1) * frac)];
|
||||
},
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
function(frac) {
|
||||
return [lon, lat1 + ((lat2 - lat1) * frac)];
|
||||
},
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
};
|
||||
|
||||
|
||||
@@ -160,15 +160,15 @@ _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squared
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squaredTolerance) {
|
||||
var epsg4326Projection = getProjection('EPSG:4326');
|
||||
const epsg4326Projection = getProjection('EPSG:4326');
|
||||
return _ol_geom_flat_geodesic_.line_(
|
||||
/**
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
function(frac) {
|
||||
return [lon1 + ((lon2 - lon1) * frac), lat];
|
||||
},
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
function(frac) {
|
||||
return [lon1 + ((lon2 - lon1) * frac), lat];
|
||||
},
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
};
|
||||
export default _ol_geom_flat_geodesic_;
|
||||
|
||||
+14
-14
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/inflate
|
||||
*/
|
||||
var _ol_geom_flat_inflate_ = {};
|
||||
const _ol_geom_flat_inflate_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,9 +13,9 @@ var _ol_geom_flat_inflate_ = {};
|
||||
* @return {Array.<ol.Coordinate>} Coordinates.
|
||||
*/
|
||||
_ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stride, opt_coordinates) {
|
||||
var coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
|
||||
var i = 0;
|
||||
var j;
|
||||
const coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
|
||||
let i = 0;
|
||||
let j;
|
||||
for (j = offset; j < end; j += stride) {
|
||||
coordinates[i++] = flatCoordinates.slice(j, j + stride);
|
||||
}
|
||||
@@ -33,13 +33,13 @@ _ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stri
|
||||
* @return {Array.<Array.<ol.Coordinate>>} Coordinatess.
|
||||
*/
|
||||
_ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, stride, opt_coordinatess) {
|
||||
var coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
|
||||
var i = 0;
|
||||
var j, jj;
|
||||
const coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
|
||||
let i = 0;
|
||||
let j, jj;
|
||||
for (j = 0, jj = ends.length; j < jj; ++j) {
|
||||
var end = ends[j];
|
||||
const end = ends[j];
|
||||
coordinatess[i++] = _ol_geom_flat_inflate_.coordinates(
|
||||
flatCoordinates, offset, end, stride, coordinatess[i]);
|
||||
flatCoordinates, offset, end, stride, coordinatess[i]);
|
||||
offset = end;
|
||||
}
|
||||
coordinatess.length = i;
|
||||
@@ -57,13 +57,13 @@ _ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, st
|
||||
* @return {Array.<Array.<Array.<ol.Coordinate>>>} Coordinatesss.
|
||||
*/
|
||||
_ol_geom_flat_inflate_.coordinatesss = function(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
|
||||
var coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
|
||||
var i = 0;
|
||||
var j, jj;
|
||||
const coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
|
||||
let i = 0;
|
||||
let j, jj;
|
||||
for (j = 0, jj = endss.length; j < jj; ++j) {
|
||||
var ends = endss[j];
|
||||
const ends = endss[j];
|
||||
coordinatesss[i++] = _ol_geom_flat_inflate_.coordinatess(
|
||||
flatCoordinates, offset, ends, stride, coordinatesss[i]);
|
||||
flatCoordinates, offset, ends, stride, coordinatesss[i]);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
coordinatesss.length = i;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import _ol_geom_flat_contains_ from '../flat/contains.js';
|
||||
var _ol_geom_flat_interiorpoint_ = {};
|
||||
const _ol_geom_flat_interiorpoint_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,14 +20,14 @@ var _ol_geom_flat_interiorpoint_ = {};
|
||||
* length of the horizontal intersection that the point belongs to.
|
||||
*/
|
||||
_ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
||||
ends, stride, flatCenters, flatCentersOffset, opt_dest) {
|
||||
var i, ii, x, x1, x2, y1, y2;
|
||||
var y = flatCenters[flatCentersOffset + 1];
|
||||
ends, stride, flatCenters, flatCentersOffset, opt_dest) {
|
||||
let i, ii, x, x1, x2, y1, y2;
|
||||
const y = flatCenters[flatCentersOffset + 1];
|
||||
/** @type {Array.<number>} */
|
||||
var intersections = [];
|
||||
const intersections = [];
|
||||
// Calculate intersections with the horizontal line
|
||||
for (var r = 0, rr = ends.length; r < rr; ++r) {
|
||||
var end = ends[r];
|
||||
for (let r = 0, rr = ends.length; r < rr; ++r) {
|
||||
const end = ends[r];
|
||||
x1 = flatCoordinates[end - stride];
|
||||
y1 = flatCoordinates[end - stride + 1];
|
||||
for (i = offset; i < end; i += stride) {
|
||||
@@ -43,17 +43,17 @@ _ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
||||
}
|
||||
// Find the longest segment of the horizontal line that has its center point
|
||||
// inside the linear ring.
|
||||
var pointX = NaN;
|
||||
var maxSegmentLength = -Infinity;
|
||||
let pointX = NaN;
|
||||
let maxSegmentLength = -Infinity;
|
||||
intersections.sort(numberSafeCompareFunction);
|
||||
x1 = intersections[0];
|
||||
for (i = 1, ii = intersections.length; i < ii; ++i) {
|
||||
x2 = intersections[i];
|
||||
var segmentLength = Math.abs(x2 - x1);
|
||||
const segmentLength = Math.abs(x2 - x1);
|
||||
if (segmentLength > maxSegmentLength) {
|
||||
x = (x1 + x2) / 2;
|
||||
if (_ol_geom_flat_contains_.linearRingsContainsXY(
|
||||
flatCoordinates, offset, ends, stride, x, y)) {
|
||||
flatCoordinates, offset, ends, stride, x, y)) {
|
||||
pointX = x;
|
||||
maxSegmentLength = segmentLength;
|
||||
}
|
||||
@@ -84,12 +84,12 @@ _ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
||||
* length of the horizontal intersection that the point belongs to.
|
||||
*/
|
||||
_ol_geom_flat_interiorpoint_.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) {
|
||||
var interiorPoints = [];
|
||||
var i, ii;
|
||||
let interiorPoints = [];
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
interiorPoints = _ol_geom_flat_interiorpoint_.linearRings(flatCoordinates,
|
||||
offset, ends, stride, flatCenters, 2 * i, interiorPoints);
|
||||
offset, ends, stride, flatCenters, 2 * i, interiorPoints);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
return interiorPoints;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {binarySearch} from '../../array.js';
|
||||
import {lerp} from '../../math.js';
|
||||
var _ol_geom_flat_interpolate_ = {};
|
||||
const _ol_geom_flat_interpolate_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,9 +16,9 @@ var _ol_geom_flat_interpolate_ = {};
|
||||
* @return {Array.<number>} Destination.
|
||||
*/
|
||||
_ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) {
|
||||
var pointX = NaN;
|
||||
var pointY = NaN;
|
||||
var n = (end - offset) / stride;
|
||||
let pointX = NaN;
|
||||
let pointY = NaN;
|
||||
const n = (end - offset) / stride;
|
||||
if (n === 1) {
|
||||
pointX = flatCoordinates[offset];
|
||||
pointY = flatCoordinates[offset + 1];
|
||||
@@ -28,29 +28,29 @@ _ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, s
|
||||
pointY = (1 - fraction) * flatCoordinates[offset + 1] +
|
||||
fraction * flatCoordinates[offset + stride + 1];
|
||||
} else if (n !== 0) {
|
||||
var x1 = flatCoordinates[offset];
|
||||
var y1 = flatCoordinates[offset + 1];
|
||||
var length = 0;
|
||||
var cumulativeLengths = [0];
|
||||
var i;
|
||||
let x1 = flatCoordinates[offset];
|
||||
let y1 = flatCoordinates[offset + 1];
|
||||
let length = 0;
|
||||
const cumulativeLengths = [0];
|
||||
let i;
|
||||
for (i = offset + stride; i < end; i += stride) {
|
||||
var x2 = flatCoordinates[i];
|
||||
var y2 = flatCoordinates[i + 1];
|
||||
const x2 = flatCoordinates[i];
|
||||
const y2 = flatCoordinates[i + 1];
|
||||
length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||
cumulativeLengths.push(length);
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
var target = fraction * length;
|
||||
var index = binarySearch(cumulativeLengths, target);
|
||||
const target = fraction * length;
|
||||
const index = binarySearch(cumulativeLengths, target);
|
||||
if (index < 0) {
|
||||
var t = (target - cumulativeLengths[-index - 2]) /
|
||||
const t = (target - cumulativeLengths[-index - 2]) /
|
||||
(cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);
|
||||
var o = offset + (-index - 2) * stride;
|
||||
const o = offset + (-index - 2) * stride;
|
||||
pointX = lerp(
|
||||
flatCoordinates[o], flatCoordinates[o + stride], t);
|
||||
flatCoordinates[o], flatCoordinates[o + stride], t);
|
||||
pointY = lerp(
|
||||
flatCoordinates[o + 1], flatCoordinates[o + stride + 1], t);
|
||||
flatCoordinates[o + 1], flatCoordinates[o + stride + 1], t);
|
||||
} else {
|
||||
pointX = flatCoordinates[offset + index * stride];
|
||||
pointY = flatCoordinates[offset + index * stride + 1];
|
||||
@@ -79,7 +79,7 @@ _ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, o
|
||||
if (end == offset) {
|
||||
return null;
|
||||
}
|
||||
var coordinate;
|
||||
let coordinate;
|
||||
if (m < flatCoordinates[offset + stride - 1]) {
|
||||
if (extrapolate) {
|
||||
coordinate = flatCoordinates.slice(offset, offset + stride);
|
||||
@@ -101,27 +101,27 @@ _ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, o
|
||||
if (m == flatCoordinates[offset + stride - 1]) {
|
||||
return flatCoordinates.slice(offset, offset + stride);
|
||||
}
|
||||
var lo = offset / stride;
|
||||
var hi = end / stride;
|
||||
let lo = offset / stride;
|
||||
let hi = end / stride;
|
||||
while (lo < hi) {
|
||||
var mid = (lo + hi) >> 1;
|
||||
const mid = (lo + hi) >> 1;
|
||||
if (m < flatCoordinates[(mid + 1) * stride - 1]) {
|
||||
hi = mid;
|
||||
} else {
|
||||
lo = mid + 1;
|
||||
}
|
||||
}
|
||||
var m0 = flatCoordinates[lo * stride - 1];
|
||||
const m0 = flatCoordinates[lo * stride - 1];
|
||||
if (m == m0) {
|
||||
return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);
|
||||
}
|
||||
var m1 = flatCoordinates[(lo + 1) * stride - 1];
|
||||
var t = (m - m0) / (m1 - m0);
|
||||
const m1 = flatCoordinates[(lo + 1) * stride - 1];
|
||||
const t = (m - m0) / (m1 - m0);
|
||||
coordinate = [];
|
||||
var i;
|
||||
let i;
|
||||
for (i = 0; i < stride - 1; ++i) {
|
||||
coordinate.push(lerp(flatCoordinates[(lo - 1) * stride + i],
|
||||
flatCoordinates[lo * stride + i], t));
|
||||
flatCoordinates[lo * stride + i], t));
|
||||
}
|
||||
coordinate.push(m);
|
||||
return coordinate;
|
||||
@@ -139,12 +139,12 @@ _ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, o
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
_ol_geom_flat_interpolate_.lineStringsCoordinateAtM = function(
|
||||
flatCoordinates, offset, ends, stride, m, extrapolate, interpolate) {
|
||||
flatCoordinates, offset, ends, stride, m, extrapolate, interpolate) {
|
||||
if (interpolate) {
|
||||
return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(
|
||||
flatCoordinates, offset, ends[ends.length - 1], stride, m, extrapolate);
|
||||
flatCoordinates, offset, ends[ends.length - 1], stride, m, extrapolate);
|
||||
}
|
||||
var coordinate;
|
||||
let coordinate;
|
||||
if (m < flatCoordinates[stride - 1]) {
|
||||
if (extrapolate) {
|
||||
coordinate = flatCoordinates.slice(0, stride);
|
||||
@@ -163,9 +163,9 @@ _ol_geom_flat_interpolate_.lineStringsCoordinateAtM = function(
|
||||
return null;
|
||||
}
|
||||
}
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
const end = ends[i];
|
||||
if (offset == end) {
|
||||
continue;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ _ol_geom_flat_interpolate_.lineStringsCoordinateAtM = function(
|
||||
return null;
|
||||
} else if (m <= flatCoordinates[end - 1]) {
|
||||
return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(
|
||||
flatCoordinates, offset, end, stride, m, false);
|
||||
flatCoordinates, offset, end, stride, m, false);
|
||||
}
|
||||
offset = end;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {containsExtent, createEmpty, extendFlatCoordinates, intersects, intersectsSegment} from '../../extent.js';
|
||||
import _ol_geom_flat_contains_ from '../flat/contains.js';
|
||||
import _ol_geom_flat_segments_ from '../flat/segments.js';
|
||||
var _ol_geom_flat_intersectsextent_ = {};
|
||||
const _ol_geom_flat_intersectsextent_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,8 +16,8 @@ var _ol_geom_flat_intersectsextent_ = {};
|
||||
* @return {boolean} True if the geometry and the extent intersect.
|
||||
*/
|
||||
_ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, end, stride, extent) {
|
||||
var coordinatesExtent = extendFlatCoordinates(
|
||||
createEmpty(), flatCoordinates, offset, end, stride);
|
||||
const coordinatesExtent = extendFlatCoordinates(
|
||||
createEmpty(), flatCoordinates, offset, end, stride);
|
||||
if (!intersects(extent, coordinatesExtent)) {
|
||||
return false;
|
||||
}
|
||||
@@ -33,15 +33,15 @@ _ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, e
|
||||
return true;
|
||||
}
|
||||
return _ol_geom_flat_segments_.forEach(flatCoordinates, offset, end, stride,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Coordinate} point1 Start point.
|
||||
* @param {ol.Coordinate} point2 End point.
|
||||
* @return {boolean} `true` if the segment and the extent intersect,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
function(point1, point2) {
|
||||
return intersectsSegment(extent, point1, point2);
|
||||
});
|
||||
function(point1, point2) {
|
||||
return intersectsSegment(extent, point1, point2);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ _ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, e
|
||||
* @return {boolean} True if the geometry and the extent intersect.
|
||||
*/
|
||||
_ol_geom_flat_intersectsextent_.lineStrings = function(flatCoordinates, offset, ends, stride, extent) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
if (_ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, offset, ends[i], stride, extent)) {
|
||||
flatCoordinates, offset, ends[i], stride, extent)) {
|
||||
return true;
|
||||
}
|
||||
offset = ends[i];
|
||||
@@ -76,23 +76,23 @@ _ol_geom_flat_intersectsextent_.lineStrings = function(flatCoordinates, offset,
|
||||
*/
|
||||
_ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, end, stride, extent) {
|
||||
if (_ol_geom_flat_intersectsextent_.lineString(
|
||||
flatCoordinates, offset, end, stride, extent)) {
|
||||
flatCoordinates, offset, end, stride, extent)) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[0], extent[1])) {
|
||||
flatCoordinates, offset, end, stride, extent[0], extent[1])) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[0], extent[3])) {
|
||||
flatCoordinates, offset, end, stride, extent[0], extent[3])) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[2], extent[1])) {
|
||||
flatCoordinates, offset, end, stride, extent[2], extent[1])) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[2], extent[3])) {
|
||||
flatCoordinates, offset, end, stride, extent[2], extent[3])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -109,16 +109,16 @@ _ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, e
|
||||
*/
|
||||
_ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset, ends, stride, extent) {
|
||||
if (!_ol_geom_flat_intersectsextent_.linearRing(
|
||||
flatCoordinates, offset, ends[0], stride, extent)) {
|
||||
flatCoordinates, offset, ends[0], stride, extent)) {
|
||||
return false;
|
||||
}
|
||||
if (ends.length === 1) {
|
||||
return true;
|
||||
}
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||
if (_ol_geom_flat_contains_.linearRingContainsExtent(
|
||||
flatCoordinates, ends[i - 1], ends[i], stride, extent)) {
|
||||
flatCoordinates, ends[i - 1], ends[i], stride, extent)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -135,11 +135,11 @@ _ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset,
|
||||
* @return {boolean} True if the geometry and the extent intersect.
|
||||
*/
|
||||
_ol_geom_flat_intersectsextent_.linearRingss = function(flatCoordinates, offset, endss, stride, extent) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
const ends = endss[i];
|
||||
if (_ol_geom_flat_intersectsextent_.linearRings(
|
||||
flatCoordinates, offset, ends, stride, extent)) {
|
||||
flatCoordinates, offset, ends, stride, extent)) {
|
||||
return true;
|
||||
}
|
||||
offset = ends[ends.length - 1];
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/length
|
||||
*/
|
||||
var _ol_geom_flat_length_ = {};
|
||||
const _ol_geom_flat_length_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,13 +12,13 @@ var _ol_geom_flat_length_ = {};
|
||||
* @return {number} Length.
|
||||
*/
|
||||
_ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride) {
|
||||
var x1 = flatCoordinates[offset];
|
||||
var y1 = flatCoordinates[offset + 1];
|
||||
var length = 0;
|
||||
var i;
|
||||
let x1 = flatCoordinates[offset];
|
||||
let y1 = flatCoordinates[offset + 1];
|
||||
let length = 0;
|
||||
let i;
|
||||
for (i = offset + stride; i < end; i += stride) {
|
||||
var x2 = flatCoordinates[i];
|
||||
var y2 = flatCoordinates[i + 1];
|
||||
const x2 = flatCoordinates[i];
|
||||
const y2 = flatCoordinates[i + 1];
|
||||
length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
@@ -35,10 +35,10 @@ _ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride
|
||||
* @return {number} Perimeter.
|
||||
*/
|
||||
_ol_geom_flat_length_.linearRing = function(flatCoordinates, offset, end, stride) {
|
||||
var perimeter =
|
||||
let perimeter =
|
||||
_ol_geom_flat_length_.lineString(flatCoordinates, offset, end, stride);
|
||||
var dx = flatCoordinates[end - stride] - flatCoordinates[offset];
|
||||
var dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
|
||||
const dx = flatCoordinates[end - stride] - flatCoordinates[offset];
|
||||
const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
|
||||
perimeter += Math.sqrt(dx * dx + dy * dy);
|
||||
return perimeter;
|
||||
};
|
||||
|
||||
+21
-21
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/orient
|
||||
*/
|
||||
import _ol_geom_flat_reverse_ from '../flat/reverse.js';
|
||||
var _ol_geom_flat_orient_ = {};
|
||||
const _ol_geom_flat_orient_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -15,12 +15,12 @@ var _ol_geom_flat_orient_ = {};
|
||||
_ol_geom_flat_orient_.linearRingIsClockwise = function(flatCoordinates, offset, end, stride) {
|
||||
// http://tinyurl.com/clockwise-method
|
||||
// https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrlinearring.cpp
|
||||
var edge = 0;
|
||||
var x1 = flatCoordinates[end - stride];
|
||||
var y1 = flatCoordinates[end - stride + 1];
|
||||
let edge = 0;
|
||||
let x1 = flatCoordinates[end - stride];
|
||||
let y1 = flatCoordinates[end - stride + 1];
|
||||
for (; offset < end; offset += stride) {
|
||||
var x2 = flatCoordinates[offset];
|
||||
var y2 = flatCoordinates[offset + 1];
|
||||
const x2 = flatCoordinates[offset];
|
||||
const y2 = flatCoordinates[offset + 1];
|
||||
edge += (x2 - x1) * (y2 + y1);
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
@@ -43,12 +43,12 @@ _ol_geom_flat_orient_.linearRingIsClockwise = function(flatCoordinates, offset,
|
||||
* @return {boolean} Rings are correctly oriented.
|
||||
*/
|
||||
_ol_geom_flat_orient_.linearRingsAreOriented = function(flatCoordinates, offset, ends, stride, opt_right) {
|
||||
var right = opt_right !== undefined ? opt_right : false;
|
||||
var i, ii;
|
||||
const right = opt_right !== undefined ? opt_right : false;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
||||
flatCoordinates, offset, end, stride);
|
||||
const end = ends[i];
|
||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
||||
flatCoordinates, offset, end, stride);
|
||||
if (i === 0) {
|
||||
if ((right && isClockwise) || (!right && !isClockwise)) {
|
||||
return false;
|
||||
@@ -78,10 +78,10 @@ _ol_geom_flat_orient_.linearRingsAreOriented = function(flatCoordinates, offset,
|
||||
* @return {boolean} Rings are correctly oriented.
|
||||
*/
|
||||
_ol_geom_flat_orient_.linearRingssAreOriented = function(flatCoordinates, offset, endss, stride, opt_right) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
if (!_ol_geom_flat_orient_.linearRingsAreOriented(
|
||||
flatCoordinates, offset, endss[i], stride, opt_right)) {
|
||||
flatCoordinates, offset, endss[i], stride, opt_right)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -103,13 +103,13 @@ _ol_geom_flat_orient_.linearRingssAreOriented = function(flatCoordinates, offset
|
||||
* @return {number} End.
|
||||
*/
|
||||
_ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends, stride, opt_right) {
|
||||
var right = opt_right !== undefined ? opt_right : false;
|
||||
var i, ii;
|
||||
const right = opt_right !== undefined ? opt_right : false;
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
||||
flatCoordinates, offset, end, stride);
|
||||
var reverse = i === 0 ?
|
||||
const end = ends[i];
|
||||
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
|
||||
flatCoordinates, offset, end, stride);
|
||||
const reverse = i === 0 ?
|
||||
(right && isClockwise) || (!right && !isClockwise) :
|
||||
(right && !isClockwise) || (!right && isClockwise);
|
||||
if (reverse) {
|
||||
@@ -135,10 +135,10 @@ _ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends
|
||||
* @return {number} End.
|
||||
*/
|
||||
_ol_geom_flat_orient_.orientLinearRingss = function(flatCoordinates, offset, endss, stride, opt_right) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
offset = _ol_geom_flat_orient_.orientLinearRings(
|
||||
flatCoordinates, offset, endss[i], stride, opt_right);
|
||||
flatCoordinates, offset, endss[i], stride, opt_right);
|
||||
}
|
||||
return offset;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/reverse
|
||||
*/
|
||||
var _ol_geom_flat_reverse_ = {};
|
||||
const _ol_geom_flat_reverse_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,9 +12,8 @@ var _ol_geom_flat_reverse_ = {};
|
||||
*/
|
||||
_ol_geom_flat_reverse_.coordinates = function(flatCoordinates, offset, end, stride) {
|
||||
while (offset < end - stride) {
|
||||
var i;
|
||||
for (i = 0; i < stride; ++i) {
|
||||
var tmp = flatCoordinates[offset + i];
|
||||
for (let i = 0; i < stride; ++i) {
|
||||
const tmp = flatCoordinates[offset + i];
|
||||
flatCoordinates[offset + i] = flatCoordinates[end - stride + i];
|
||||
flatCoordinates[end - stride + i] = tmp;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/segments
|
||||
*/
|
||||
var _ol_geom_flat_segments_ = {};
|
||||
const _ol_geom_flat_segments_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,9 +20,9 @@ var _ol_geom_flat_segments_ = {};
|
||||
* @template T,S
|
||||
*/
|
||||
_ol_geom_flat_segments_.forEach = function(flatCoordinates, offset, end, stride, callback, opt_this) {
|
||||
var point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]];
|
||||
var point2 = [];
|
||||
var ret;
|
||||
const point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]];
|
||||
const point2 = [];
|
||||
let ret;
|
||||
for (; (offset + stride) < end; offset += stride) {
|
||||
point2[0] = flatCoordinates[offset + stride];
|
||||
point2[1] = flatCoordinates[offset + stride + 1];
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {squaredSegmentDistance, squaredDistance} from '../../math.js';
|
||||
var _ol_geom_flat_simplify_ = {};
|
||||
const _ol_geom_flat_simplify_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -43,20 +43,20 @@ var _ol_geom_flat_simplify_ = {};
|
||||
* @return {Array.<number>} Simplified line string.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.lineString = function(flatCoordinates, offset, end,
|
||||
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
||||
var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
|
||||
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
||||
const simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
|
||||
opt_simplifiedFlatCoordinates : [];
|
||||
if (!highQuality) {
|
||||
end = _ol_geom_flat_simplify_.radialDistance(flatCoordinates, offset, end,
|
||||
stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, 0);
|
||||
stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, 0);
|
||||
flatCoordinates = simplifiedFlatCoordinates;
|
||||
offset = 0;
|
||||
stride = 2;
|
||||
}
|
||||
simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker(
|
||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, 0);
|
||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, 0);
|
||||
return simplifiedFlatCoordinates;
|
||||
};
|
||||
|
||||
@@ -73,8 +73,8 @@ _ol_geom_flat_simplify_.lineString = function(flatCoordinates, offset, end,
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
|
||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||
var n = (end - offset) / stride;
|
||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||
const n = (end - offset) / stride;
|
||||
if (n < 3) {
|
||||
for (; offset < end; offset += stride) {
|
||||
simplifiedFlatCoordinates[simplifiedOffset++] =
|
||||
@@ -85,26 +85,26 @@ _ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
|
||||
return simplifiedOffset;
|
||||
}
|
||||
/** @type {Array.<number>} */
|
||||
var markers = new Array(n);
|
||||
const markers = new Array(n);
|
||||
markers[0] = 1;
|
||||
markers[n - 1] = 1;
|
||||
/** @type {Array.<number>} */
|
||||
var stack = [offset, end - stride];
|
||||
var index = 0;
|
||||
var i;
|
||||
const stack = [offset, end - stride];
|
||||
let index = 0;
|
||||
let i;
|
||||
while (stack.length > 0) {
|
||||
var last = stack.pop();
|
||||
var first = stack.pop();
|
||||
var maxSquaredDistance = 0;
|
||||
var x1 = flatCoordinates[first];
|
||||
var y1 = flatCoordinates[first + 1];
|
||||
var x2 = flatCoordinates[last];
|
||||
var y2 = flatCoordinates[last + 1];
|
||||
const last = stack.pop();
|
||||
const first = stack.pop();
|
||||
let maxSquaredDistance = 0;
|
||||
const x1 = flatCoordinates[first];
|
||||
const y1 = flatCoordinates[first + 1];
|
||||
const x2 = flatCoordinates[last];
|
||||
const y2 = flatCoordinates[last + 1];
|
||||
for (i = first + stride; i < last; i += stride) {
|
||||
var x = flatCoordinates[i];
|
||||
var y = flatCoordinates[i + 1];
|
||||
var squaredDistance = squaredSegmentDistance(
|
||||
x, y, x1, y1, x2, y2);
|
||||
const x = flatCoordinates[i];
|
||||
const y = flatCoordinates[i + 1];
|
||||
const squaredDistance = squaredSegmentDistance(
|
||||
x, y, x1, y1, x2, y2);
|
||||
if (squaredDistance > maxSquaredDistance) {
|
||||
index = i;
|
||||
maxSquaredDistance = squaredDistance;
|
||||
@@ -145,14 +145,14 @@ _ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.douglasPeuckers = function(flatCoordinates, offset,
|
||||
ends, stride, squaredTolerance, simplifiedFlatCoordinates,
|
||||
simplifiedOffset, simplifiedEnds) {
|
||||
var i, ii;
|
||||
ends, stride, squaredTolerance, simplifiedFlatCoordinates,
|
||||
simplifiedOffset, simplifiedEnds) {
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
const end = ends[i];
|
||||
simplifiedOffset = _ol_geom_flat_simplify_.douglasPeucker(
|
||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset);
|
||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset);
|
||||
simplifiedEnds.push(simplifiedOffset);
|
||||
offset = end;
|
||||
}
|
||||
@@ -173,15 +173,15 @@ _ol_geom_flat_simplify_.douglasPeuckers = function(flatCoordinates, offset,
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.douglasPeuckerss = function(
|
||||
flatCoordinates, offset, endss, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||
var i, ii;
|
||||
flatCoordinates, offset, endss, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
var simplifiedEnds = [];
|
||||
const ends = endss[i];
|
||||
const simplifiedEnds = [];
|
||||
simplifiedOffset = _ol_geom_flat_simplify_.douglasPeuckers(
|
||||
flatCoordinates, offset, ends, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||
flatCoordinates, offset, ends, stride, squaredTolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||
simplifiedEndss.push(simplifiedEnds);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
@@ -201,7 +201,7 @@ _ol_geom_flat_simplify_.douglasPeuckerss = function(
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end,
|
||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||
if (end <= offset + stride) {
|
||||
// zero or one point, no simplification possible, so copy and return
|
||||
for (; offset < end; offset += stride) {
|
||||
@@ -211,13 +211,13 @@ _ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end,
|
||||
}
|
||||
return simplifiedOffset;
|
||||
}
|
||||
var x1 = flatCoordinates[offset];
|
||||
var y1 = flatCoordinates[offset + 1];
|
||||
let x1 = flatCoordinates[offset];
|
||||
let y1 = flatCoordinates[offset + 1];
|
||||
// copy first point
|
||||
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
|
||||
simplifiedFlatCoordinates[simplifiedOffset++] = y1;
|
||||
var x2 = x1;
|
||||
var y2 = y1;
|
||||
let x2 = x1;
|
||||
let y2 = y1;
|
||||
for (offset += stride; offset < end; offset += stride) {
|
||||
x2 = flatCoordinates[offset];
|
||||
y2 = flatCoordinates[offset + 1];
|
||||
@@ -268,21 +268,21 @@ _ol_geom_flat_simplify_.snap = function(value, tolerance) {
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride,
|
||||
tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||
tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||
// do nothing if the line is empty
|
||||
if (offset == end) {
|
||||
return simplifiedOffset;
|
||||
}
|
||||
// snap the first coordinate (P1)
|
||||
var x1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
||||
var y1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
||||
let x1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
||||
let y1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
||||
offset += stride;
|
||||
// add the first coordinate to the output
|
||||
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
|
||||
simplifiedFlatCoordinates[simplifiedOffset++] = y1;
|
||||
// find the next coordinate that does not snap to the same value as the first
|
||||
// coordinate (P2)
|
||||
var x2, y2;
|
||||
let x2, y2;
|
||||
do {
|
||||
x2 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
||||
y2 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
||||
@@ -298,21 +298,20 @@ _ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride
|
||||
}
|
||||
} while (x2 == x1 && y2 == y1);
|
||||
while (offset < end) {
|
||||
var x3, y3;
|
||||
// snap the next coordinate (P3)
|
||||
x3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
||||
y3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
||||
const x3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance);
|
||||
const y3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance);
|
||||
offset += stride;
|
||||
// skip P3 if it is equal to P2
|
||||
if (x3 == x2 && y3 == y2) {
|
||||
continue;
|
||||
}
|
||||
// calculate the delta between P1 and P2
|
||||
var dx1 = x2 - x1;
|
||||
var dy1 = y2 - y1;
|
||||
const dx1 = x2 - x1;
|
||||
const dy1 = y2 - y1;
|
||||
// calculate the delta between P3 and P1
|
||||
var dx2 = x3 - x1;
|
||||
var dy2 = y3 - y1;
|
||||
const dx2 = x3 - x1;
|
||||
const dy2 = y3 - y1;
|
||||
// if P1, P2, and P3 are colinear and P3 is further from P1 than P2 is from
|
||||
// P1 in the same direction then P2 is on the straight line between P1 and
|
||||
// P3
|
||||
@@ -354,16 +353,16 @@ _ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.quantizes = function(
|
||||
flatCoordinates, offset, ends, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
|
||||
var i, ii;
|
||||
flatCoordinates, offset, ends, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
|
||||
let i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
const end = ends[i];
|
||||
simplifiedOffset = _ol_geom_flat_simplify_.quantize(
|
||||
flatCoordinates, offset, end, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset);
|
||||
flatCoordinates, offset, end, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset);
|
||||
simplifiedEnds.push(simplifiedOffset);
|
||||
offset = end;
|
||||
}
|
||||
@@ -384,17 +383,17 @@ _ol_geom_flat_simplify_.quantizes = function(
|
||||
* @return {number} Simplified offset.
|
||||
*/
|
||||
_ol_geom_flat_simplify_.quantizess = function(
|
||||
flatCoordinates, offset, endss, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||
var i, ii;
|
||||
flatCoordinates, offset, endss, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||
let i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
var simplifiedEnds = [];
|
||||
const ends = endss[i];
|
||||
const simplifiedEnds = [];
|
||||
simplifiedOffset = _ol_geom_flat_simplify_.quantizes(
|
||||
flatCoordinates, offset, ends, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||
flatCoordinates, offset, ends, stride,
|
||||
tolerance,
|
||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||
simplifiedEndss.push(simplifiedEnds);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/straightchunk
|
||||
*/
|
||||
var _ol_geom_flat_straightchunk_ = {};
|
||||
const _ol_geom_flat_straightchunk_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,15 +14,15 @@ var _ol_geom_flat_straightchunk_ = {};
|
||||
* given `flatCoordinates`.
|
||||
*/
|
||||
_ol_geom_flat_straightchunk_.lineString = function(maxAngle, flatCoordinates, offset, end, stride) {
|
||||
var chunkStart = offset;
|
||||
var chunkEnd = offset;
|
||||
var chunkM = 0;
|
||||
var m = 0;
|
||||
var start = offset;
|
||||
var acos, i, m12, m23, x1, y1, x12, y12, x23, y23;
|
||||
let chunkStart = offset;
|
||||
let chunkEnd = offset;
|
||||
let chunkM = 0;
|
||||
let m = 0;
|
||||
let start = offset;
|
||||
let acos, i, m12, m23, x1, y1, x12, y12, x23, y23;
|
||||
for (i = offset; i < end; i += stride) {
|
||||
var x2 = flatCoordinates[i];
|
||||
var y2 = flatCoordinates[i + 1];
|
||||
const x2 = flatCoordinates[i];
|
||||
const y2 = flatCoordinates[i + 1];
|
||||
if (x1 !== undefined) {
|
||||
x23 = x2 - x1;
|
||||
y23 = y2 - y1;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/textpath
|
||||
*/
|
||||
import {lerp} from '../../math.js';
|
||||
var _ol_geom_flat_textpath_ = {};
|
||||
const _ol_geom_flat_textpath_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,32 +19,32 @@ var _ol_geom_flat_textpath_ = {};
|
||||
* exceeded. Entries of the array are x, y, anchorX, angle, chunk.
|
||||
*/
|
||||
_ol_geom_flat_textpath_.lineString = function(
|
||||
flatCoordinates, offset, end, stride, text, measure, startM, maxAngle) {
|
||||
var result = [];
|
||||
flatCoordinates, offset, end, stride, text, measure, startM, maxAngle) {
|
||||
const result = [];
|
||||
|
||||
// Keep text upright
|
||||
var reverse = flatCoordinates[offset] > flatCoordinates[end - stride];
|
||||
const reverse = flatCoordinates[offset] > flatCoordinates[end - stride];
|
||||
|
||||
var numChars = text.length;
|
||||
const numChars = text.length;
|
||||
|
||||
var x1 = flatCoordinates[offset];
|
||||
var y1 = flatCoordinates[offset + 1];
|
||||
let x1 = flatCoordinates[offset];
|
||||
let y1 = flatCoordinates[offset + 1];
|
||||
offset += stride;
|
||||
var x2 = flatCoordinates[offset];
|
||||
var y2 = flatCoordinates[offset + 1];
|
||||
var segmentM = 0;
|
||||
var segmentLength = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
||||
let x2 = flatCoordinates[offset];
|
||||
let y2 = flatCoordinates[offset + 1];
|
||||
let segmentM = 0;
|
||||
let segmentLength = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
||||
|
||||
var chunk = '';
|
||||
var chunkLength = 0;
|
||||
var data, index, previousAngle;
|
||||
for (var i = 0; i < numChars; ++i) {
|
||||
let chunk = '';
|
||||
let chunkLength = 0;
|
||||
let data, index, previousAngle;
|
||||
for (let i = 0; i < numChars; ++i) {
|
||||
index = reverse ? numChars - i - 1 : i;
|
||||
var char = text.charAt(index);
|
||||
const char = text.charAt(index);
|
||||
chunk = reverse ? char + chunk : chunk + char;
|
||||
var charLength = measure(chunk) - chunkLength;
|
||||
const charLength = measure(chunk) - chunkLength;
|
||||
chunkLength += charLength;
|
||||
var charM = startM + charLength / 2;
|
||||
const charM = startM + charLength / 2;
|
||||
while (offset < end - stride && segmentM + segmentLength < charM) {
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
@@ -54,21 +54,21 @@ _ol_geom_flat_textpath_.lineString = function(
|
||||
segmentM += segmentLength;
|
||||
segmentLength = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
||||
}
|
||||
var segmentPos = charM - segmentM;
|
||||
var angle = Math.atan2(y2 - y1, x2 - x1);
|
||||
const segmentPos = charM - segmentM;
|
||||
let angle = Math.atan2(y2 - y1, x2 - x1);
|
||||
if (reverse) {
|
||||
angle += angle > 0 ? -Math.PI : Math.PI;
|
||||
}
|
||||
if (previousAngle !== undefined) {
|
||||
var delta = angle - previousAngle;
|
||||
let delta = angle - previousAngle;
|
||||
delta += (delta > Math.PI) ? -2 * Math.PI : (delta < -Math.PI) ? 2 * Math.PI : 0;
|
||||
if (Math.abs(delta) > maxAngle) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
var interpolate = segmentPos / segmentLength;
|
||||
var x = lerp(x1, x2, interpolate);
|
||||
var y = lerp(y1, y2, interpolate);
|
||||
const interpolate = segmentPos / segmentLength;
|
||||
const x = lerp(x1, x2, interpolate);
|
||||
const y = lerp(y1, y2, interpolate);
|
||||
if (previousAngle == angle) {
|
||||
if (reverse) {
|
||||
data[0] = x;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/topology
|
||||
*/
|
||||
import _ol_geom_flat_area_ from '../flat/area.js';
|
||||
var _ol_geom_flat_topology_ = {};
|
||||
const _ol_geom_flat_topology_ = {};
|
||||
|
||||
/**
|
||||
* Check if the linestring is a boundary.
|
||||
@@ -13,7 +13,7 @@ var _ol_geom_flat_topology_ = {};
|
||||
* @return {boolean} The linestring is a boundary.
|
||||
*/
|
||||
_ol_geom_flat_topology_.lineStringIsClosed = function(flatCoordinates, offset, end, stride) {
|
||||
var lastCoord = end - stride;
|
||||
const lastCoord = end - stride;
|
||||
if (flatCoordinates[offset] === flatCoordinates[lastCoord] &&
|
||||
flatCoordinates[offset + 1] === flatCoordinates[lastCoord + 1] && (end - offset) / stride > 3) {
|
||||
return !!_ol_geom_flat_area_.linearRing(flatCoordinates, offset, end, stride);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/transform
|
||||
*/
|
||||
var _ol_geom_flat_transform_ = {};
|
||||
const _ol_geom_flat_transform_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,12 +14,12 @@ var _ol_geom_flat_transform_ = {};
|
||||
* @return {Array.<number>} Transformed coordinates.
|
||||
*/
|
||||
_ol_geom_flat_transform_.transform2D = function(flatCoordinates, offset, end, stride, transform, opt_dest) {
|
||||
var dest = opt_dest ? opt_dest : [];
|
||||
var i = 0;
|
||||
var j;
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
let i = 0;
|
||||
let j;
|
||||
for (j = offset; j < end; j += stride) {
|
||||
var x = flatCoordinates[j];
|
||||
var y = flatCoordinates[j + 1];
|
||||
const x = flatCoordinates[j];
|
||||
const y = flatCoordinates[j + 1];
|
||||
dest[i++] = transform[0] * x + transform[2] * y + transform[4];
|
||||
dest[i++] = transform[1] * x + transform[3] * y + transform[5];
|
||||
}
|
||||
@@ -41,18 +41,18 @@ _ol_geom_flat_transform_.transform2D = function(flatCoordinates, offset, end, st
|
||||
* @return {Array.<number>} Transformed coordinates.
|
||||
*/
|
||||
_ol_geom_flat_transform_.rotate = function(flatCoordinates, offset, end, stride, angle, anchor, opt_dest) {
|
||||
var dest = opt_dest ? opt_dest : [];
|
||||
var cos = Math.cos(angle);
|
||||
var sin = Math.sin(angle);
|
||||
var anchorX = anchor[0];
|
||||
var anchorY = anchor[1];
|
||||
var i = 0;
|
||||
for (var j = offset; j < end; j += stride) {
|
||||
var deltaX = flatCoordinates[j] - anchorX;
|
||||
var deltaY = flatCoordinates[j + 1] - anchorY;
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
const cos = Math.cos(angle);
|
||||
const sin = Math.sin(angle);
|
||||
const anchorX = anchor[0];
|
||||
const anchorY = anchor[1];
|
||||
let i = 0;
|
||||
for (let j = offset; j < end; j += stride) {
|
||||
const deltaX = flatCoordinates[j] - anchorX;
|
||||
const deltaY = flatCoordinates[j + 1] - anchorY;
|
||||
dest[i++] = anchorX + deltaX * cos - deltaY * sin;
|
||||
dest[i++] = anchorY + deltaX * sin + deltaY * cos;
|
||||
for (var k = j + 2; k < j + stride; ++k) {
|
||||
for (let k = j + 2; k < j + stride; ++k) {
|
||||
dest[i++] = flatCoordinates[k];
|
||||
}
|
||||
}
|
||||
@@ -76,16 +76,16 @@ _ol_geom_flat_transform_.rotate = function(flatCoordinates, offset, end, stride,
|
||||
* @return {Array.<number>} Transformed coordinates.
|
||||
*/
|
||||
_ol_geom_flat_transform_.scale = function(flatCoordinates, offset, end, stride, sx, sy, anchor, opt_dest) {
|
||||
var dest = opt_dest ? opt_dest : [];
|
||||
var anchorX = anchor[0];
|
||||
var anchorY = anchor[1];
|
||||
var i = 0;
|
||||
for (var j = offset; j < end; j += stride) {
|
||||
var deltaX = flatCoordinates[j] - anchorX;
|
||||
var deltaY = flatCoordinates[j + 1] - anchorY;
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
const anchorX = anchor[0];
|
||||
const anchorY = anchor[1];
|
||||
let i = 0;
|
||||
for (let j = offset; j < end; j += stride) {
|
||||
const deltaX = flatCoordinates[j] - anchorX;
|
||||
const deltaY = flatCoordinates[j + 1] - anchorY;
|
||||
dest[i++] = anchorX + sx * deltaX;
|
||||
dest[i++] = anchorY + sy * deltaY;
|
||||
for (var k = j + 2; k < j + stride; ++k) {
|
||||
for (let k = j + 2; k < j + stride; ++k) {
|
||||
dest[i++] = flatCoordinates[k];
|
||||
}
|
||||
}
|
||||
@@ -107,9 +107,9 @@ _ol_geom_flat_transform_.scale = function(flatCoordinates, offset, end, stride,
|
||||
* @return {Array.<number>} Transformed coordinates.
|
||||
*/
|
||||
_ol_geom_flat_transform_.translate = function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) {
|
||||
var dest = opt_dest ? opt_dest : [];
|
||||
var i = 0;
|
||||
var j, k;
|
||||
const dest = opt_dest ? opt_dest : [];
|
||||
let i = 0;
|
||||
let j, k;
|
||||
for (j = offset; j < end; j += stride) {
|
||||
dest[i++] = flatCoordinates[j] + deltaX;
|
||||
dest[i++] = flatCoordinates[j + 1] + deltaY;
|
||||
|
||||
Reference in New Issue
Block a user