Named exports from ol/geom/flat/segments
This commit is contained in:
@@ -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_interpolate_ from '../geom/flat/interpolate.js';
|
||||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.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_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';
|
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,8 +119,7 @@ LineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
LineString.prototype.forEachSegment = function(callback) {
|
LineString.prototype.forEachSegment = function(callback) {
|
||||||
return _ol_geom_flat_segments_.forEach(this.flatCoordinates, 0,
|
return forEachSegment(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, callback);
|
||||||
this.flatCoordinates.length, this.stride, callback);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import {containsExtent, createEmpty, extendFlatCoordinates, intersects, intersectsSegment} from '../../extent.js';
|
import {containsExtent, createEmpty, extendFlatCoordinates, intersects, intersectsSegment} from '../../extent.js';
|
||||||
import {linearRingContainsXY, linearRingContainsExtent} from '../flat/contains.js';
|
import {linearRingContainsXY, linearRingContainsExtent} from '../flat/contains.js';
|
||||||
import _ol_geom_flat_segments_ from '../flat/segments.js';
|
import {forEach as forEachSegment} from '../flat/segments.js';
|
||||||
const _ol_geom_flat_intersectsextent_ = {};
|
const _ol_geom_flat_intersectsextent_ = {};
|
||||||
|
|
||||||
|
|
||||||
@@ -32,13 +32,13 @@ _ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, e
|
|||||||
coordinatesExtent[3] <= extent[3]) {
|
coordinatesExtent[3] <= extent[3]) {
|
||||||
return true;
|
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} point1 Start point.
|
||||||
* @param {ol.Coordinate} point2 End point.
|
* @param {ol.Coordinate} point2 End point.
|
||||||
* @return {boolean} `true` if the segment and the extent intersect,
|
* @return {boolean} `true` if the segment and the extent intersect,
|
||||||
* `false` otherwise.
|
* `false` otherwise.
|
||||||
*/
|
*/
|
||||||
function(point1, point2) {
|
function(point1, point2) {
|
||||||
return intersectsSegment(extent, point1, point2);
|
return intersectsSegment(extent, point1, point2);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/segments
|
* @module ol/geom/flat/segments
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_segments_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +18,7 @@ const _ol_geom_flat_segments_ = {};
|
|||||||
* @return {T|boolean} Value.
|
* @return {T|boolean} Value.
|
||||||
* @template T,S
|
* @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 point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]];
|
||||||
const point2 = [];
|
const point2 = [];
|
||||||
let ret;
|
let ret;
|
||||||
@@ -34,5 +33,4 @@ _ol_geom_flat_segments_.forEach = function(flatCoordinates, offset, end, stride,
|
|||||||
point1[1] = point2[1];
|
point1[1] = point2[1];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_segments_;
|
|
||||||
|
|||||||
@@ -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() {
|
describe('ol.geom.flat.segments', function() {
|
||||||
@@ -17,8 +17,7 @@ describe('ol.geom.flat.segments', function() {
|
|||||||
const spy = sinon.spy(function(point1, point2) {
|
const spy = sinon.spy(function(point1, point2) {
|
||||||
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
||||||
});
|
});
|
||||||
const ret = _ol_geom_flat_segments_.forEach(
|
const ret = forEachSegment(flatCoordinates, offset, end, stride, spy);
|
||||||
flatCoordinates, offset, end, stride, spy);
|
|
||||||
expect(spy.callCount).to.be(3);
|
expect(spy.callCount).to.be(3);
|
||||||
expect(args[0][0]).to.be(0);
|
expect(args[0][0]).to.be(0);
|
||||||
expect(args[0][1]).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]]);
|
args.push([point1[0], point1[1], point2[0], point2[1]]);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
const ret = _ol_geom_flat_segments_.forEach(
|
const ret = forEachSegment(flatCoordinates, offset, end, stride, spy);
|
||||||
flatCoordinates, offset, end, stride, spy);
|
|
||||||
expect(spy.callCount).to.be(1);
|
expect(spy.callCount).to.be(1);
|
||||||
expect(args[0][0]).to.be(0);
|
expect(args[0][0]).to.be(0);
|
||||||
expect(args[0][1]).to.be(0);
|
expect(args[0][1]).to.be(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user