@@ -6,7 +6,7 @@ import {intersects, getCenter} from './extent.js';
|
||||
import GeometryLayout from './geom/GeometryLayout.js';
|
||||
import LineString from './geom/LineString.js';
|
||||
import Point from './geom/Point.js';
|
||||
import _ol_geom_flat_geodesic_ from './geom/flat/geodesic.js';
|
||||
import {meridian, parallel} from './geom/flat/geodesic.js';
|
||||
import {clamp} from './math.js';
|
||||
import {get as getProjection, equivalent as equivalentProjection, getTransform, transformExtent} from './proj.js';
|
||||
import RenderEventType from './render/EventType.js';
|
||||
@@ -565,9 +565,8 @@ Graticule.prototype.getMap = function() {
|
||||
* @param {number} index Index.
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
||||
squaredTolerance, index) {
|
||||
const flatCoordinates = _ol_geom_flat_geodesic_.meridian(lon,
|
||||
Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, squaredTolerance, index) {
|
||||
const flatCoordinates = meridian(lon,
|
||||
minLat, maxLat, this.projection_, squaredTolerance);
|
||||
const lineString = this.meridians_[index] !== undefined ?
|
||||
this.meridians_[index] : new LineString(null);
|
||||
@@ -595,9 +594,8 @@ Graticule.prototype.getMeridians = function() {
|
||||
* @param {number} index Index.
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
||||
squaredTolerance, index) {
|
||||
const flatCoordinates = _ol_geom_flat_geodesic_.parallel(lat,
|
||||
Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, squaredTolerance, index) {
|
||||
const flatCoordinates = parallel(lat,
|
||||
minLon, maxLon, this.projection_, squaredTolerance);
|
||||
const lineString = this.parallels_[index] !== undefined ?
|
||||
this.parallels_[index] : new LineString(null);
|
||||
|
||||
@@ -9,7 +9,7 @@ import TextFeature from '../format/TextFeature.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_flip_ from '../geom/flat/flip.js';
|
||||
import {flipXY} from '../geom/flat/flip.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
@@ -326,8 +326,7 @@ Polyline.prototype.readGeometry;
|
||||
Polyline.prototype.readGeometryFromText = function(text, opt_options) {
|
||||
const stride = getStrideForLayout(this.geometryLayout_);
|
||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||
_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
const coordinates = _ol_geom_flat_inflate_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
|
||||
@@ -392,8 +391,7 @@ Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
|
||||
(transformWithOptions(geometry, true, this.adaptOptions(opt_options)));
|
||||
const flatCoordinates = geometry.getFlatCoordinates();
|
||||
const stride = geometry.getStride();
|
||||
_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
return encodeDeltas(flatCoordinates, stride, this.factor_);
|
||||
};
|
||||
export default Polyline;
|
||||
|
||||
@@ -13,7 +13,7 @@ import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
||||
import _ol_geom_flat_length_ from '../geom/flat/length.js';
|
||||
import _ol_geom_flat_segments_ from '../geom/flat/segments.js';
|
||||
import {forEach as forEachSegment} from '../geom/flat/segments.js';
|
||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
|
||||
/**
|
||||
@@ -119,8 +119,7 @@ LineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
* @api
|
||||
*/
|
||||
LineString.prototype.forEachSegment = function(callback) {
|
||||
return _ol_geom_flat_segments_.forEach(this.flatCoordinates, 0,
|
||||
this.flatCoordinates.length, this.stride, callback);
|
||||
return forEachSegment(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, callback);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_area_ from '../geom/flat/area.js';
|
||||
import {linearRing as linearRingArea} from '../geom/flat/area.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
@@ -83,8 +83,7 @@ LinearRing.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
* @api
|
||||
*/
|
||||
LinearRing.prototype.getArea = function() {
|
||||
return _ol_geom_flat_area_.linearRing(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
return linearRingArea(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import GeometryType from '../geom/GeometryType.js';
|
||||
import MultiPoint from '../geom/MultiPoint.js';
|
||||
import Polygon from '../geom/Polygon.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_area_ from '../geom/flat/area.js';
|
||||
import _ol_geom_flat_center_ from '../geom/flat/center.js';
|
||||
import {linearRingss as linearRingssArea} from '../geom/flat/area.js';
|
||||
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import _ol_geom_flat_contains_ from '../geom/flat/contains.js';
|
||||
import {linearRingssContainsXY} from '../geom/flat/contains.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
||||
@@ -151,8 +151,7 @@ MultiPolygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredD
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiPolygon.prototype.containsXY = function(x, y) {
|
||||
return _ol_geom_flat_contains_.linearRingssContainsXY(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, x, y);
|
||||
return linearRingssContainsXY(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, x, y);
|
||||
};
|
||||
|
||||
|
||||
@@ -162,8 +161,7 @@ MultiPolygon.prototype.containsXY = function(x, y) {
|
||||
* @api
|
||||
*/
|
||||
MultiPolygon.prototype.getArea = function() {
|
||||
return _ol_geom_flat_area_.linearRingss(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride);
|
||||
return linearRingssArea(this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -209,7 +207,7 @@ MultiPolygon.prototype.getEndss = function() {
|
||||
*/
|
||||
MultiPolygon.prototype.getFlatInteriorPoints = function() {
|
||||
if (this.flatInteriorPointsRevision_ != this.getRevision()) {
|
||||
const flatCenters = _ol_geom_flat_center_.linearRingss(
|
||||
const flatCenters = linearRingssCenter(
|
||||
this.flatCoordinates, 0, this.endss_, this.stride);
|
||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
|
||||
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
|
||||
|
||||
@@ -10,9 +10,9 @@ import LinearRing from '../geom/LinearRing.js';
|
||||
import Point from '../geom/Point.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import {offset as sphereOffset} from '../sphere.js';
|
||||
import _ol_geom_flat_area_ from '../geom/flat/area.js';
|
||||
import {linearRings as linearRingsArea} from '../geom/flat/area.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import _ol_geom_flat_contains_ from '../geom/flat/contains.js';
|
||||
import {linearRingsContainsXY} from '../geom/flat/contains.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
||||
@@ -141,8 +141,7 @@ Polygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistan
|
||||
* @inheritDoc
|
||||
*/
|
||||
Polygon.prototype.containsXY = function(x, y) {
|
||||
return _ol_geom_flat_contains_.linearRingsContainsXY(
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, x, y);
|
||||
return linearRingsContainsXY(this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, x, y);
|
||||
};
|
||||
|
||||
|
||||
@@ -152,8 +151,7 @@ Polygon.prototype.containsXY = function(x, y) {
|
||||
* @api
|
||||
*/
|
||||
Polygon.prototype.getArea = function() {
|
||||
return _ol_geom_flat_area_.linearRings(
|
||||
this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride);
|
||||
return linearRingsArea(this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/area
|
||||
*/
|
||||
const _ol_geom_flat_area_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -11,7 +10,7 @@ const _ol_geom_flat_area_ = {};
|
||||
* @param {number} stride Stride.
|
||||
* @return {number} Area.
|
||||
*/
|
||||
_ol_geom_flat_area_.linearRing = function(flatCoordinates, offset, end, stride) {
|
||||
export function linearRing(flatCoordinates, offset, end, stride) {
|
||||
let twiceArea = 0;
|
||||
let x1 = flatCoordinates[end - stride];
|
||||
let y1 = flatCoordinates[end - stride + 1];
|
||||
@@ -23,7 +22,7 @@ _ol_geom_flat_area_.linearRing = function(flatCoordinates, offset, end, stride)
|
||||
y1 = y2;
|
||||
}
|
||||
return twiceArea / 2;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,15 +32,15 @@ _ol_geom_flat_area_.linearRing = function(flatCoordinates, offset, end, stride)
|
||||
* @param {number} stride Stride.
|
||||
* @return {number} Area.
|
||||
*/
|
||||
_ol_geom_flat_area_.linearRings = function(flatCoordinates, offset, ends, stride) {
|
||||
export function linearRings(flatCoordinates, offset, ends, stride) {
|
||||
let area = 0;
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
area += _ol_geom_flat_area_.linearRing(flatCoordinates, offset, end, stride);
|
||||
area += linearRing(flatCoordinates, offset, end, stride);
|
||||
offset = end;
|
||||
}
|
||||
return area;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -51,13 +50,12 @@ _ol_geom_flat_area_.linearRings = function(flatCoordinates, offset, ends, stride
|
||||
* @param {number} stride Stride.
|
||||
* @return {number} Area.
|
||||
*/
|
||||
_ol_geom_flat_area_.linearRingss = function(flatCoordinates, offset, endss, stride) {
|
||||
export function linearRingss(flatCoordinates, offset, endss, stride) {
|
||||
let area = 0;
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
const ends = endss[i];
|
||||
area += _ol_geom_flat_area_.linearRings(flatCoordinates, offset, ends, stride);
|
||||
area += linearRings(flatCoordinates, offset, ends, stride);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
return area;
|
||||
};
|
||||
export default _ol_geom_flat_area_;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/flat/center
|
||||
*/
|
||||
import {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js';
|
||||
const _ol_geom_flat_center_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,7 +11,7 @@ const _ol_geom_flat_center_ = {};
|
||||
* @param {number} stride Stride.
|
||||
* @return {Array.<number>} Flat centers.
|
||||
*/
|
||||
_ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, stride) {
|
||||
export function linearRingss(flatCoordinates, offset, endss, stride) {
|
||||
const flatCenters = [];
|
||||
let extent = createEmpty();
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
@@ -22,5 +21,4 @@ _ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, st
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
return flatCenters;
|
||||
};
|
||||
export default _ol_geom_flat_center_;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/geom/flat/contains
|
||||
*/
|
||||
import {forEachCorner} from '../../extent.js';
|
||||
const _ol_geom_flat_contains_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,18 +12,17 @@ const _ol_geom_flat_contains_ = {};
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {boolean} Contains extent.
|
||||
*/
|
||||
_ol_geom_flat_contains_.linearRingContainsExtent = function(flatCoordinates, offset, end, stride, extent) {
|
||||
export function linearRingContainsExtent(flatCoordinates, offset, end, stride, extent) {
|
||||
const outside = forEachCorner(extent,
|
||||
/**
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {boolean} Contains (x, y).
|
||||
*/
|
||||
* @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]);
|
||||
return !linearRingContainsXY(flatCoordinates, offset, end, stride, coordinate[0], coordinate[1]);
|
||||
});
|
||||
return !outside;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,7 +34,7 @@ _ol_geom_flat_contains_.linearRingContainsExtent = function(flatCoordinates, off
|
||||
* @param {number} y Y.
|
||||
* @return {boolean} Contains (x, y).
|
||||
*/
|
||||
_ol_geom_flat_contains_.linearRingContainsXY = function(flatCoordinates, offset, end, stride, x, y) {
|
||||
export function linearRingContainsXY(flatCoordinates, offset, end, stride, x, y) {
|
||||
// http://geomalgorithms.com/a03-_inclusion.html
|
||||
// Copyright 2000 softSurfer, 2012 Dan Sunday
|
||||
// This code may be freely used and modified for any purpose
|
||||
@@ -61,7 +59,7 @@ _ol_geom_flat_contains_.linearRingContainsXY = function(flatCoordinates, offset,
|
||||
y1 = y2;
|
||||
}
|
||||
return wn !== 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -73,22 +71,20 @@ _ol_geom_flat_contains_.linearRingContainsXY = function(flatCoordinates, offset,
|
||||
* @param {number} y Y.
|
||||
* @return {boolean} Contains (x, y).
|
||||
*/
|
||||
_ol_geom_flat_contains_.linearRingsContainsXY = function(flatCoordinates, offset, ends, stride, x, y) {
|
||||
export function linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y) {
|
||||
if (ends.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (!_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, ends[0], stride, x, y)) {
|
||||
if (!linearRingContainsXY(flatCoordinates, offset, ends[0], stride, x, y)) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 1, ii = ends.length; i < ii; ++i) {
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, ends[i - 1], ends[i], stride, x, y)) {
|
||||
if (linearRingContainsXY(flatCoordinates, ends[i - 1], ends[i], stride, x, y)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -100,18 +96,16 @@ _ol_geom_flat_contains_.linearRingsContainsXY = function(flatCoordinates, offset
|
||||
* @param {number} y Y.
|
||||
* @return {boolean} Contains (x, y).
|
||||
*/
|
||||
_ol_geom_flat_contains_.linearRingssContainsXY = function(flatCoordinates, offset, endss, stride, x, y) {
|
||||
export function linearRingssContainsXY(flatCoordinates, offset, endss, stride, x, y) {
|
||||
if (endss.length === 0) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
const ends = endss[i];
|
||||
if (_ol_geom_flat_contains_.linearRingsContainsXY(
|
||||
flatCoordinates, offset, ends, stride, x, y)) {
|
||||
if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {
|
||||
return true;
|
||||
}
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export default _ol_geom_flat_contains_;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/flip
|
||||
*/
|
||||
const _ol_geom_flat_flip_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +12,7 @@ const _ol_geom_flat_flip_ = {};
|
||||
* @param {number=} opt_destOffset Destination offset.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) {
|
||||
export function flipXY(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) {
|
||||
let dest, destOffset;
|
||||
if (opt_dest !== undefined) {
|
||||
dest = opt_dest;
|
||||
@@ -33,5 +32,4 @@ _ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_
|
||||
}
|
||||
dest.length = destOffset;
|
||||
return dest;
|
||||
};
|
||||
export default _ol_geom_flat_flip_;
|
||||
}
|
||||
|
||||
@@ -3,18 +3,16 @@
|
||||
*/
|
||||
import {squaredSegmentDistance, toRadians, toDegrees} from '../../math.js';
|
||||
import {get as getProjection, getTransform} from '../../proj.js';
|
||||
const _ol_geom_flat_geodesic_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {function(number): ol.Coordinate} interpolate Interpolate function.
|
||||
* @param {ol.TransformFunction} transform Transform from longitude/latitude to
|
||||
* projected coordinates.
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredTolerance) {
|
||||
function line(interpolate, transform, squaredTolerance) {
|
||||
// FIXME reduce garbage generation
|
||||
// FIXME optimize stack operations
|
||||
|
||||
@@ -77,22 +75,20 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
|
||||
}
|
||||
|
||||
return flatCoordinates;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a great-circle arcs between two lat/lon points.
|
||||
* @param {number} lon1 Longitude 1 in degrees.
|
||||
* @param {number} lat1 Latitude 1 in degrees.
|
||||
* @param {number} lon2 Longitude 2 in degrees.
|
||||
* @param {number} lat2 Latitude 2 in degrees.
|
||||
* Generate a great-circle arcs between two lat/lon points.
|
||||
* @param {number} lon1 Longitude 1 in degrees.
|
||||
* @param {number} lat1 Latitude 1 in degrees.
|
||||
* @param {number} lon2 Longitude 2 in degrees.
|
||||
* @param {number} lat2 Latitude 2 in degrees.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
||||
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
export function greatCircleArc(lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
||||
const geoProjection = getProjection('EPSG:4326');
|
||||
|
||||
const cosLat1 = Math.cos(toRadians(lat1));
|
||||
@@ -103,11 +99,11 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
const sinDeltaLon = Math.sin(toRadians(lon2 - lon1));
|
||||
const d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
|
||||
|
||||
return _ol_geom_flat_geodesic_.line_(
|
||||
return line(
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
function(frac) {
|
||||
if (1 <= d) {
|
||||
return [lon2, lat2];
|
||||
@@ -124,7 +120,7 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
cosD - sinLat1 * Math.sin(lat));
|
||||
return [toDegrees(lon), toDegrees(lat)];
|
||||
}, getTransform(geoProjection, projection), squaredTolerance);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -136,18 +132,18 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squaredTolerance) {
|
||||
export function meridian(lon, lat1, lat2, projection, squaredTolerance) {
|
||||
const epsg4326Projection = getProjection('EPSG:4326');
|
||||
return _ol_geom_flat_geodesic_.line_(
|
||||
return line(
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
function(frac) {
|
||||
return [lon, lat1 + ((lat2 - lat1) * frac)];
|
||||
},
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -159,16 +155,15 @@ _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squared
|
||||
* @param {number} squaredTolerance Squared tolerance.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squaredTolerance) {
|
||||
export function parallel(lat, lon1, lon2, projection, squaredTolerance) {
|
||||
const epsg4326Projection = getProjection('EPSG:4326');
|
||||
return _ol_geom_flat_geodesic_.line_(
|
||||
return line(
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
* @param {number} frac Fraction.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
function(frac) {
|
||||
return [lon1 + ((lon2 - lon1) * frac), lat];
|
||||
},
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
};
|
||||
export default _ol_geom_flat_geodesic_;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/interiorpoint
|
||||
*/
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import _ol_geom_flat_contains_ from '../flat/contains.js';
|
||||
import {linearRingsContainsXY} from '../flat/contains.js';
|
||||
const _ol_geom_flat_interiorpoint_ = {};
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ _ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset,
|
||||
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)) {
|
||||
if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {
|
||||
pointX = x;
|
||||
maxSegmentLength = segmentLength;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* @module ol/geom/flat/intersectsextent
|
||||
*/
|
||||
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';
|
||||
import {linearRingContainsXY, linearRingContainsExtent} from '../flat/contains.js';
|
||||
import {forEach as forEachSegment} from '../flat/segments.js';
|
||||
const _ol_geom_flat_intersectsextent_ = {};
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ _ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, e
|
||||
coordinatesExtent[3] <= extent[3]) {
|
||||
return true;
|
||||
}
|
||||
return _ol_geom_flat_segments_.forEach(flatCoordinates, offset, end, stride,
|
||||
return forEachSegment(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.
|
||||
*/
|
||||
* @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);
|
||||
});
|
||||
@@ -78,20 +78,16 @@ _ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, e
|
||||
flatCoordinates, offset, end, stride, extent)) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[0], extent[1])) {
|
||||
if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[0], extent[1])) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[0], extent[3])) {
|
||||
if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[0], extent[3])) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[2], extent[1])) {
|
||||
if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[2], extent[1])) {
|
||||
return true;
|
||||
}
|
||||
if (_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
flatCoordinates, offset, end, stride, extent[2], extent[3])) {
|
||||
if (linearRingContainsXY(flatCoordinates, offset, end, stride, extent[2], extent[3])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -115,8 +111,7 @@ _ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset,
|
||||
return true;
|
||||
}
|
||||
for (let i = 1, ii = ends.length; i < ii; ++i) {
|
||||
if (_ol_geom_flat_contains_.linearRingContainsExtent(
|
||||
flatCoordinates, ends[i - 1], ends[i], stride, extent)) {
|
||||
if (linearRingContainsExtent(flatCoordinates, ends[i - 1], ends[i], stride, extent)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/orient
|
||||
*/
|
||||
import _ol_geom_flat_reverse_ from '../flat/reverse.js';
|
||||
import {coordinates as reverseCoordinates} from '../flat/reverse.js';
|
||||
const _ol_geom_flat_orient_ = {};
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ _ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends
|
||||
(right && isClockwise) || (!right && !isClockwise) :
|
||||
(right && !isClockwise) || (!right && isClockwise);
|
||||
if (reverse) {
|
||||
_ol_geom_flat_reverse_.coordinates(flatCoordinates, offset, end, stride);
|
||||
reverseCoordinates(flatCoordinates, offset, end, stride);
|
||||
}
|
||||
offset = end;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/reverse
|
||||
*/
|
||||
const _ol_geom_flat_reverse_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,7 +9,7 @@ const _ol_geom_flat_reverse_ = {};
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
*/
|
||||
_ol_geom_flat_reverse_.coordinates = function(flatCoordinates, offset, end, stride) {
|
||||
export function coordinates(flatCoordinates, offset, end, stride) {
|
||||
while (offset < end - stride) {
|
||||
for (let i = 0; i < stride; ++i) {
|
||||
const tmp = flatCoordinates[offset + i];
|
||||
@@ -20,5 +19,4 @@ _ol_geom_flat_reverse_.coordinates = function(flatCoordinates, offset, end, stri
|
||||
offset += stride;
|
||||
end -= stride;
|
||||
}
|
||||
};
|
||||
export default _ol_geom_flat_reverse_;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/segments
|
||||
*/
|
||||
const _ol_geom_flat_segments_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ const _ol_geom_flat_segments_ = {};
|
||||
* @return {T|boolean} Value.
|
||||
* @template T,S
|
||||
*/
|
||||
_ol_geom_flat_segments_.forEach = function(flatCoordinates, offset, end, stride, callback, opt_this) {
|
||||
export function forEach(flatCoordinates, offset, end, stride, callback, opt_this) {
|
||||
const point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]];
|
||||
const point2 = [];
|
||||
let ret;
|
||||
@@ -34,5 +33,4 @@ _ol_geom_flat_segments_.forEach = function(flatCoordinates, offset, end, stride,
|
||||
point1[1] = point2[1];
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export default _ol_geom_flat_segments_;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* @module ol/geom/flat/topology
|
||||
*/
|
||||
import _ol_geom_flat_area_ from '../flat/area.js';
|
||||
const _ol_geom_flat_topology_ = {};
|
||||
import {linearRing as linearRingArea} from '../flat/area.js';
|
||||
|
||||
/**
|
||||
* Check if the linestring is a boundary.
|
||||
@@ -12,12 +11,11 @@ const _ol_geom_flat_topology_ = {};
|
||||
* @param {number} stride Stride.
|
||||
* @return {boolean} The linestring is a boundary.
|
||||
*/
|
||||
_ol_geom_flat_topology_.lineStringIsClosed = function(flatCoordinates, offset, end, stride) {
|
||||
export function lineStringIsClosed(flatCoordinates, offset, 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);
|
||||
return !!linearRingArea(flatCoordinates, offset, end, stride);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export default _ol_geom_flat_topology_;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import _ol_events_KeyCode_ from '../events/KeyCode.js';
|
||||
import KeyCode from '../events/KeyCode.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
|
||||
@@ -82,19 +82,19 @@ KeyboardPan.handleEvent = function(mapBrowserEvent) {
|
||||
const keyEvent = mapBrowserEvent.originalEvent;
|
||||
const keyCode = keyEvent.keyCode;
|
||||
if (this.condition_(mapBrowserEvent) &&
|
||||
(keyCode == _ol_events_KeyCode_.DOWN ||
|
||||
keyCode == _ol_events_KeyCode_.LEFT ||
|
||||
keyCode == _ol_events_KeyCode_.RIGHT ||
|
||||
keyCode == _ol_events_KeyCode_.UP)) {
|
||||
(keyCode == KeyCode.DOWN ||
|
||||
keyCode == KeyCode.LEFT ||
|
||||
keyCode == KeyCode.RIGHT ||
|
||||
keyCode == KeyCode.UP)) {
|
||||
const map = mapBrowserEvent.map;
|
||||
const view = map.getView();
|
||||
const mapUnitsDelta = view.getResolution() * this.pixelDelta_;
|
||||
let deltaX = 0, deltaY = 0;
|
||||
if (keyCode == _ol_events_KeyCode_.DOWN) {
|
||||
if (keyCode == KeyCode.DOWN) {
|
||||
deltaY = -mapUnitsDelta;
|
||||
} else if (keyCode == _ol_events_KeyCode_.LEFT) {
|
||||
} else if (keyCode == KeyCode.LEFT) {
|
||||
deltaX = -mapUnitsDelta;
|
||||
} else if (keyCode == _ol_events_KeyCode_.RIGHT) {
|
||||
} else if (keyCode == KeyCode.RIGHT) {
|
||||
deltaX = mapUnitsDelta;
|
||||
} else {
|
||||
deltaY = mapUnitsDelta;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {nullFunction} from '../index.js';
|
||||
import {extend} from '../array.js';
|
||||
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import _ol_geom_flat_center_ from '../geom/flat/center.js';
|
||||
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
||||
import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
|
||||
@@ -137,7 +137,7 @@ RenderFeature.prototype.getFlatInteriorPoint = function() {
|
||||
*/
|
||||
RenderFeature.prototype.getFlatInteriorPoints = function() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
const flatCenters = _ol_geom_flat_center_.linearRingss(
|
||||
const flatCenters = linearRingssCenter(
|
||||
this.flatCoordinates_, 0, this.ends_, 2);
|
||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {asArray} from '../../color.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_geom_flat_topology_ from '../../geom/flat/topology.js';
|
||||
import {lineStringIsClosed} from '../../geom/flat/topology.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import WebGLReplay from '../webgl/Replay.js';
|
||||
@@ -91,7 +91,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
||||
this.state_.lineJoin === 'miter' ? 1 : 2;
|
||||
const lineCap = this.state_.lineCap === 'butt' ? 0 :
|
||||
this.state_.lineCap === 'square' ? 1 : 2;
|
||||
const closed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, offset, end, stride);
|
||||
const closed = lineStringIsClosed(flatCoordinates, offset, end, stride);
|
||||
let startCoords, sign, n;
|
||||
let lastIndex = numIndices;
|
||||
let lastSign = 1;
|
||||
@@ -357,8 +357,7 @@ WebGLLineStringReplay.prototype.drawMultiLineString = function(multiLineStringGe
|
||||
*/
|
||||
WebGLLineStringReplay.prototype.drawPolygonCoordinates = function(
|
||||
flatCoordinates, holeFlatCoordinates, stride) {
|
||||
if (!_ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0,
|
||||
flatCoordinates.length, stride)) {
|
||||
if (!lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
||||
flatCoordinates.push(flatCoordinates[0]);
|
||||
flatCoordinates.push(flatCoordinates[1]);
|
||||
}
|
||||
@@ -366,8 +365,7 @@ WebGLLineStringReplay.prototype.drawPolygonCoordinates = function(
|
||||
if (holeFlatCoordinates.length) {
|
||||
let i, ii;
|
||||
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
|
||||
if (!_ol_geom_flat_topology_.lineStringIsClosed(holeFlatCoordinates[i], 0,
|
||||
holeFlatCoordinates[i].length, stride)) {
|
||||
if (!lineStringIsClosed(holeFlatCoordinates[i], 0, holeFlatCoordinates[i].length, stride)) {
|
||||
holeFlatCoordinates[i].push(holeFlatCoordinates[i][0]);
|
||||
holeFlatCoordinates[i].push(holeFlatCoordinates[i][1]);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {equals} from '../../array.js';
|
||||
import {asArray} from '../../color.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import _ol_geom_flat_contains_ from '../../geom/flat/contains.js';
|
||||
import {linearRingContainsXY} from '../../geom/flat/contains.js';
|
||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_render_webgl_polygonreplay_defaultshader_ from '../webgl/polygonreplay/defaultshader.js';
|
||||
@@ -663,8 +663,7 @@ WebGLPolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, p2, rtree,
|
||||
if (typeof p === 'object' && (!opt_reflex || p.reflex)) {
|
||||
if ((p.x !== p0.x || p.y !== p0.y) && (p.x !== p1.x || p.y !== p1.y) &&
|
||||
(p.x !== p2.x || p.y !== p2.y) && result.indexOf(p) === -1 &&
|
||||
_ol_geom_flat_contains_.linearRingContainsXY([p0.x, p0.y, p1.x, p1.y,
|
||||
p2.x, p2.y], 0, 6, 2, p.x, p.y)) {
|
||||
linearRingContainsXY([p0.x, p0.y, p1.x, p1.y, p2.x, p2.y], 0, 6, 2, p.x, p.y)) {
|
||||
result.push(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import _ol_geom_flat_area_ from '../../../../../src/ol/geom/flat/area.js';
|
||||
import {linearRing, linearRings} from '../../../../../src/ol/geom/flat/area.js';
|
||||
|
||||
describe('ol.geom.flat.area', function() {
|
||||
|
||||
describe('ol.geom.flat.area.linearRing', function() {
|
||||
|
||||
it('calculates the area of a triangle', function() {
|
||||
const area = _ol_geom_flat_area_.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2);
|
||||
const area = linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2);
|
||||
expect(area).to.be(0.5);
|
||||
});
|
||||
|
||||
it('calculates the area of a unit square', function() {
|
||||
const area =
|
||||
_ol_geom_flat_area_.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
|
||||
const area = linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
|
||||
expect(area).to.be(1);
|
||||
});
|
||||
|
||||
@@ -20,7 +19,7 @@ describe('ol.geom.flat.area', function() {
|
||||
describe('ol.geom.flat.area.linearRings', function() {
|
||||
|
||||
it('calculates the area with holes', function() {
|
||||
const area = _ol_geom_flat_area_.linearRings(
|
||||
const area = linearRings(
|
||||
[0, 0, 0, 3, 3, 3, 3, 0, 1, 1, 2, 1, 2, 2, 1, 2], 0, [8, 16], 2);
|
||||
expect(area).to.be(8);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_center_ from '../../../../../src/ol/geom/flat/center.js';
|
||||
import {linearRingss as linearRingssCenter} from '../../../../../src/ol/geom/flat/center.js';
|
||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('ol.geom.flat.center', function() {
|
||||
const squareMultiPoly = new MultiPolygon([[
|
||||
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
|
||||
]]);
|
||||
const got = _ol_geom_flat_center_.linearRingss(
|
||||
const got = linearRingssCenter(
|
||||
squareMultiPoly.flatCoordinates,
|
||||
0,
|
||||
squareMultiPoly.endss_,
|
||||
@@ -28,7 +28,7 @@ describe('ol.geom.flat.center', function() {
|
||||
[[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]]
|
||||
]
|
||||
]);
|
||||
const got = _ol_geom_flat_center_.linearRingss(
|
||||
const got = linearRingssCenter(
|
||||
squareMultiPoly.flatCoordinates,
|
||||
0,
|
||||
squareMultiPoly.endss_,
|
||||
@@ -42,7 +42,7 @@ describe('ol.geom.flat.center', function() {
|
||||
[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]],
|
||||
[[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]]
|
||||
]]);
|
||||
const got = _ol_geom_flat_center_.linearRingss(
|
||||
const got = linearRingssCenter(
|
||||
polywithHole.flatCoordinates,
|
||||
0,
|
||||
polywithHole.endss_,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_contains_ from '../../../../../src/ol/geom/flat/contains.js';
|
||||
import {linearRingContainsXY} from '../../../../../src/ol/geom/flat/contains.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.contains', function() {
|
||||
@@ -11,27 +11,27 @@ describe('ol.geom.flat.contains', function() {
|
||||
describe('ol.geom.flat.contains.linearRingContainsXY', function() {
|
||||
|
||||
it('returns true for point inside a simple polygon', function() {
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
expect(linearRingContainsXY(
|
||||
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 0.5, 0.5)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for point outside a simple polygon', function() {
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
expect(linearRingContainsXY(
|
||||
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 1.5, 1.5)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns true for point inside a non-simple polygon', function() {
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
expect(linearRingContainsXY(
|
||||
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1, 1)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns true for point inside an overlap of a non-simple polygon', function() {
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
expect(linearRingContainsXY(
|
||||
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1.5, 2.5)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for a point inside a hole of a non-simple polygon', function() {
|
||||
expect(_ol_geom_flat_contains_.linearRingContainsXY(
|
||||
expect(linearRingContainsXY(
|
||||
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 2.5, 1.5)).to.be(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_flip_ from '../../../../../src/ol/geom/flat/flip.js';
|
||||
import {flipXY} from '../../../../../src/ol/geom/flat/flip.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.flip', function() {
|
||||
@@ -6,29 +6,25 @@ describe('ol.geom.flat.flip', function() {
|
||||
describe('ol.geom.flat.flip.flipXY', function() {
|
||||
|
||||
it('can flip XY coordinates', function() {
|
||||
const flatCoordinates = _ol_geom_flat_flip_.flipXY([1, 2, 3, 4], 0, 4, 2);
|
||||
const flatCoordinates = flipXY([1, 2, 3, 4], 0, 4, 2);
|
||||
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates while preserving other dimensions', function() {
|
||||
const flatCoordinates = _ol_geom_flat_flip_.flipXY(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4);
|
||||
const flatCoordinates = flipXY([1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4);
|
||||
expect(flatCoordinates).to.eql([2, 1, 3, 4, 6, 5, 7, 8]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates in place', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4];
|
||||
expect(_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flipXY(flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates in place while preserving other dimensions',
|
||||
function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
expect(_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, 9, 3, flatCoordinates)).
|
||||
to.be(flatCoordinates);
|
||||
expect(flipXY(flatCoordinates, 0, 9, 3, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([2, 1, 3, 5, 4, 6, 8, 7, 9]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_reverse_ from '../../../../../src/ol/geom/flat/reverse.js';
|
||||
import {coordinates as reverseCoordinates} from '../../../../../src/ol/geom/flat/reverse.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.reverse', function() {
|
||||
@@ -9,36 +9,31 @@ describe('ol.geom.flat.reverse', function() {
|
||||
|
||||
it('can reverse empty flat coordinates', function() {
|
||||
const flatCoordinates = [];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('can reverse one flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('can reverse two flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([3, 4, 1, 2]);
|
||||
});
|
||||
|
||||
it('can reverse three flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([5, 6, 3, 4, 1, 2]);
|
||||
});
|
||||
|
||||
it('can reverse four flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]);
|
||||
});
|
||||
|
||||
@@ -48,36 +43,31 @@ describe('ol.geom.flat.reverse', function() {
|
||||
|
||||
it('can reverse empty flat coordinates', function() {
|
||||
const flatCoordinates = [];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('can reverse one flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('can reverse two flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([4, 5, 6, 1, 2, 3]);
|
||||
});
|
||||
|
||||
it('can reverse three flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
||||
});
|
||||
|
||||
it('can reverse four flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||
expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
||||
});
|
||||
|
||||
@@ -87,37 +77,32 @@ describe('ol.geom.flat.reverse', function() {
|
||||
|
||||
it('can reverse empty flat coordinates', function() {
|
||||
const flatCoordinates = [];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.be.empty();
|
||||
});
|
||||
|
||||
it('can reverse one flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('can reverse two flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql([5, 6, 7, 8, 1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('can reverse three flat coordinates', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('can reverse four flat coordinates', function() {
|
||||
const flatCoordinates =
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
|
||||
_ol_geom_flat_reverse_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||
expect(flatCoordinates).to.eql(
|
||||
[13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_segments_ from '../../../../../src/ol/geom/flat/segments.js';
|
||||
import {forEach as forEachSegment} from '../../../../../src/ol/geom/flat/segments.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.segments', function() {
|
||||
@@ -17,8 +17,7 @@ describe('ol.geom.flat.segments', function() {
|
||||
const spy = sinon.spy(function(point1, point2) {
|
||||
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
||||
});
|
||||
const ret = _ol_geom_flat_segments_.forEach(
|
||||
flatCoordinates, offset, end, stride, spy);
|
||||
const ret = forEachSegment(flatCoordinates, offset, end, stride, spy);
|
||||
expect(spy.callCount).to.be(3);
|
||||
expect(args[0][0]).to.be(0);
|
||||
expect(args[0][1]).to.be(0);
|
||||
@@ -42,8 +41,7 @@ describe('ol.geom.flat.segments', function() {
|
||||
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
||||
return true;
|
||||
});
|
||||
const ret = _ol_geom_flat_segments_.forEach(
|
||||
flatCoordinates, offset, end, stride, spy);
|
||||
const ret = forEachSegment(flatCoordinates, offset, end, stride, spy);
|
||||
expect(spy.callCount).to.be(1);
|
||||
expect(args[0][0]).to.be(0);
|
||||
expect(args[0][1]).to.be(0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_topology_ from '../../../../../src/ol/geom/flat/topology.js';
|
||||
import {lineStringIsClosed} from '../../../../../src/ol/geom/flat/topology.js';
|
||||
|
||||
describe('ol.geom.flat.topology', function() {
|
||||
|
||||
@@ -6,23 +6,23 @@ describe('ol.geom.flat.topology', function() {
|
||||
|
||||
it('identifies closed lines aka boundaries', function() {
|
||||
const flatCoordinates = [0, 0, 3, 0, 0, 3, 0, 0];
|
||||
const isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
const isClosed = lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(true);
|
||||
});
|
||||
|
||||
it('identifies regular linestrings', function() {
|
||||
const flatCoordinates = [0, 0, 3, 0, 0, 3, 5, 2];
|
||||
const isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
const isClosed = lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(false);
|
||||
});
|
||||
|
||||
it('identifies degenerate boundaries', function() {
|
||||
let flatCoordinates = [0, 0, 3, 0, 0, 0];
|
||||
let isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
let isClosed = lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(false);
|
||||
|
||||
flatCoordinates = [0, 0, 1, 1, 3, 3, 5, 5, 0, 0];
|
||||
isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
isClosed = lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
expect(isClosed).to.be(false);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user