Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (operation.type === 'intersection') {
// TODO: this is O(n^2) in number of polygons. By sorting the bboxes,
// it could be optimized to O(n * ln(n))
for (var _i2 = 0, _iMax = multipolys.length; _i2 < _iMax; _i2++) {
var mpA = multipolys[_i2];
for (var j = _i2 + 1, jMax = multipolys.length; j < jMax; j++) {
if (getBboxOverlap(mpA.bbox, multipolys[j].bbox) === null) return [];
}
}
}
/* Put segment endpoints in a priority queue */
var queue = new SplayTree(SweepEvent.compare);
for (var _i3 = 0, _iMax2 = multipolys.length; _i3 < _iMax2; _i3++) {
var sweepEvents = multipolys[_i3].getSweepEvents();
for (var _j = 0, _jMax = sweepEvents.length; _j < _jMax; _j++) {
queue.insert(sweepEvents[_j]);
}
}
/* Pass the sweep line over those endpoints */
var sweepLine = new SweepLine(queue);
var prevQueueSize = queue.size;
var node = queue.pop();
while (node) {
constructor () {
this.tree = new SplayTree()
// preseed with 0 so we don't end up with values < Number.EPSILON
this.round(0)
}
/* BBox optimization for intersection operation
* If we can find any pair of multipolygons whose bbox does not overlap,
* then the result will be empty. */
if (operation.type === 'intersection') {
// TODO: this is O(n^2) in number of polygons. By sorting the bboxes,
// it could be optimized to O(n * ln(n))
for (let i = 0, iMax = multipolys.length; i < iMax; i++) {
const mpA = multipolys[i]
for (let j = i + 1, jMax = multipolys.length; j < jMax; j++) {
if (getBboxOverlap(mpA.bbox, multipolys[j].bbox) === null) return []
}
}
}
/* Put segment endpoints in a priority queue */
const queue = new SplayTree(SweepEvent.compare)
for (let i = 0, iMax = multipolys.length; i < iMax; i++) {
const sweepEvents = multipolys[i].getSweepEvents()
for (let j = 0, jMax = sweepEvents.length; j < jMax; j++) {
queue.insert(sweepEvents[j])
}
}
/* Pass the sweep line over those endpoints */
const sweepLine = new SweepLine(queue)
let prevQueueSize = queue.size
let node = queue.pop()
while (node) {
const evt = node.key
if (queue.size === prevQueueSize) {
// prevents an infinite loop, an otherwise common manifestation of bugs
const seg = evt.segment
function CoordRounder() {
_classCallCheck(this, CoordRounder);
this.tree = new SplayTree(); // preseed with 0 so we don't end up with values < Number.EPSILON
this.round(0);
} // Note: this can rounds input values backwards or forwards.
// You might ask, why not restrict this to just rounding
export default function createSweepStatus(onError, EPS) {
var lastPointY, prevY;
var lastPointX, prevX;
var useBelow = false;
var status = new SplayTree(compareSegments);
// To save on GC we return mutable object.
var currentBoundary = {
beforeLeft: null,
left: null,
right: null,
afterRight: null,
}
var currentLeftRight = {left: null, right: null};
return {
/**
* Add new segments into the status tree.
*/
insertSegments,
constructor () {
this.tree = new SplayTree(compareSegments)
}
function SweepLine(queue) {
var comparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Segment.compare;
_classCallCheck(this, SweepLine);
this.queue = queue;
this.tree = new SplayTree(comparator);
this.segments = [];
}
export default function createEventQueue(byY) {
const q = new SplayTree(byY);
return {
isEmpty: isEmpty,
size: size,
pop: pop,
find: find,
insert: insert
}
function find(p) {
return q.find(p);
}
function size() {
return q.size;
}
constructor (queue, comparator = Segment.compare) {
this.queue = queue
this.tree = new SplayTree(comparator)
this.segments = []
}