/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 175);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function (target, source) {
for (let key in source) {
if (source.hasOwnProperty(key)) target[key] = source[key]
}
});
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ArrayList;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Collection__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__IndexOutOfBoundsException__ = __webpack_require__(208);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Iterator__ = __webpack_require__(49);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__List__ = __webpack_require__(33);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NoSuchElementException__ = __webpack_require__(71);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__OperationNotSupported__ = __webpack_require__(86);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/ArrayList.html
*
* @extends List
* @private
*/
function ArrayList () {
/**
* @type {Array}
* @private
*/
this.array_ = [];
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Collection__["a" /* default */]) {
this.addAll(arguments[0]);
}
};
ArrayList.prototype = Object.create(__WEBPACK_IMPORTED_MODULE_3__List__["a" /* default */].prototype)
ArrayList.prototype.constructor = ArrayList;
ArrayList.prototype.ensureCapacity = function () {}
ArrayList.prototype.interfaces_ = function () { return [__WEBPACK_IMPORTED_MODULE_3__List__["a" /* default */], __WEBPACK_IMPORTED_MODULE_0__Collection__["a" /* default */]] }
/**
* @override
*/
ArrayList.prototype.add = function(e) {
if (arguments.length === 1) {
this.array_.push(e)
} else {
this.array_.splice(arguments[0], arguments[1])
}
return true
};
ArrayList.prototype.clear = function() {
this.array_ = []
}
/**
* @override
*/
ArrayList.prototype.addAll = function(c) {
for (var i = c.iterator(); i.hasNext();) {
this.add(i.next());
}
return true;
};
/**
* @override
*/
ArrayList.prototype.set = function(index, element) {
var oldElement = this.array_[index];
this.array_[index] = element;
return oldElement;
};
/**
* @override
*/
ArrayList.prototype.iterator = function() {
return new Iterator_(this);
};
/**
* @override
*/
ArrayList.prototype.get = function(index) {
if (index < 0 || index >= this.size()) {
throw new __WEBPACK_IMPORTED_MODULE_1__IndexOutOfBoundsException__["a" /* default */]();
}
return this.array_[index];
};
/**
* @override
*/
ArrayList.prototype.isEmpty = function() {
return this.array_.length === 0;
};
/**
* @override
*/
ArrayList.prototype.size = function() {
return this.array_.length;
};
/**
* @override
*/
ArrayList.prototype.toArray = function() {
var array = [];
for (var i = 0, len = this.array_.length; i < len; i++) {
array.push(this.array_[i]);
}
return array;
};
/**
* @override
*/
ArrayList.prototype.remove = function(o) {
var found = false;
for (var i = 0, len = this.array_.length; i < len; i++) {
if (this.array_[i] === o) {
this.array_.splice(i, 1);
found = true;
break;
}
}
return found;
};
/**
* @extends {Iterator}
* @param {ArrayList} arrayList
* @constructor
* @private
*/
var Iterator_ = function(arrayList) {
/**
* @type {ArrayList}
* @private
*/
this.arrayList_ = arrayList;
/**
* @type {number}
* @private
*/
this.position_ = 0;
};
/**
* @override
*/
Iterator_.prototype.next = function() {
if (this.position_ === this.arrayList_.size()) {
throw new __WEBPACK_IMPORTED_MODULE_4__NoSuchElementException__["a" /* default */]();
}
return this.arrayList_.get(this.position_++);
};
/**
* @override
*/
Iterator_.prototype.hasNext = function() {
if (this.position_ < this.arrayList_.size()) {
return true;
} else {
return false;
}
};
/**
* TODO: should be in ListIterator
* @override
*/
Iterator_.prototype.set = function(element) {
return this.arrayList_.set(this.position_ - 1, element);
};
/**
* @override
*/
Iterator_.prototype.remove = function() {
this.arrayList_.remove(this.arrayList_.get(this.position_));
};
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Coordinate;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_NumberUtil__ = __webpack_require__(206);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_Cloneable__ = __webpack_require__(53);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_util_Comparator__ = __webpack_require__(48);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_io_Serializable__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_Assert__ = __webpack_require__(4);
function Coordinate() {
this.x = null;
this.y = null;
this.z = null;
if (arguments.length === 0) {
Coordinate.call(this, 0.0, 0.0);
} else if (arguments.length === 1) {
let c = arguments[0];
Coordinate.call(this, c.x, c.y, c.z);
} else if (arguments.length === 2) {
let x = arguments[0], y = arguments[1];
Coordinate.call(this, x, y, Coordinate.NULL_ORDINATE);
} else if (arguments.length === 3) {
let x = arguments[0], y = arguments[1], z = arguments[2];
this.x = x;
this.y = y;
this.z = z;
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(Coordinate.prototype, {
setOrdinate: function (ordinateIndex, value) {
switch (ordinateIndex) {
case Coordinate.X:
this.x = value;
break;
case Coordinate.Y:
this.y = value;
break;
case Coordinate.Z:
this.z = value;
break;
default:
throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Invalid ordinate index: " + ordinateIndex);
}
},
equals2D: function () {
if (arguments.length === 1) {
let other = arguments[0];
if (this.x !== other.x) {
return false;
}
if (this.y !== other.y) {
return false;
}
return true;
} else if (arguments.length === 2) {
let c = arguments[0], tolerance = arguments[1];
if (!__WEBPACK_IMPORTED_MODULE_0__util_NumberUtil__["a" /* default */].equalsWithTolerance(this.x, c.x, tolerance)) {
return false;
}
if (!__WEBPACK_IMPORTED_MODULE_0__util_NumberUtil__["a" /* default */].equalsWithTolerance(this.y, c.y, tolerance)) {
return false;
}
return true;
}
},
getOrdinate: function (ordinateIndex) {
switch (ordinateIndex) {
case Coordinate.X:
return this.x;
case Coordinate.Y:
return this.y;
case Coordinate.Z:
return this.z;
}
throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Invalid ordinate index: " + ordinateIndex);
},
equals3D: function (other) {
return this.x === other.x && this.y === other.y && (this.z === other.z || __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(this.z) && __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(other.z));
},
equals: function (other) {
if (!(other instanceof Coordinate)) {
return false;
}
return this.equals2D(other);
},
equalInZ: function (c, tolerance) {
return __WEBPACK_IMPORTED_MODULE_0__util_NumberUtil__["a" /* default */].equalsWithTolerance(this.z, c.z, tolerance);
},
compareTo: function (o) {
var other = o;
if (this.x < other.x) return -1;
if (this.x > other.x) return 1;
if (this.y < other.y) return -1;
if (this.y > other.y) return 1;
return 0;
},
clone: function () {
try {
var coord = null;
return coord;
} catch (e) {
if (e instanceof CloneNotSupportedException) {
__WEBPACK_IMPORTED_MODULE_8__util_Assert__["a" /* default */].shouldNeverReachHere("this shouldn't happen because this class is Cloneable");
return null;
} else throw e;
} finally {}
},
copy: function () {
return new Coordinate(this);
},
toString: function () {
return "(" + this.x + ", " + this.y + ", " + this.z + ")";
},
distance3D: function (c) {
var dx = this.x - c.x;
var dy = this.y - c.y;
var dz = this.z - c.z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
},
distance: function (c) {
var dx = this.x - c.x;
var dy = this.y - c.y;
return Math.sqrt(dx * dx + dy * dy);
},
hashCode: function () {
var result = 17;
result = 37 * result + Coordinate.hashCode(this.x);
result = 37 * result + Coordinate.hashCode(this.y);
return result;
},
setCoordinate: function (other) {
this.x = other.x;
this.y = other.y;
this.z = other.z;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_4__java_lang_Comparable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_5__java_lang_Cloneable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_7__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return Coordinate;
}
});
Coordinate.hashCode = function () {
if (arguments.length === 1) {
let x = arguments[0];
var f = __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].doubleToLongBits(x);
return Math.trunc(f ^ f >>> 32);
}
};
function DimensionalComparator() {
this._dimensionsToTest = 2;
if (arguments.length === 0) {
DimensionalComparator.call(this, 2);
} else if (arguments.length === 1) {
let dimensionsToTest = arguments[0];
if (dimensionsToTest !== 2 && dimensionsToTest !== 3) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("only 2 or 3 dimensions may be specified");
this._dimensionsToTest = dimensionsToTest;
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(DimensionalComparator.prototype, {
compare: function (o1, o2) {
var c1 = o1;
var c2 = o2;
var compX = DimensionalComparator.compare(c1.x, c2.x);
if (compX !== 0) return compX;
var compY = DimensionalComparator.compare(c1.y, c2.y);
if (compY !== 0) return compY;
if (this._dimensionsToTest <= 2) return 0;
var compZ = DimensionalComparator.compare(c1.z, c2.z);
return compZ;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_6__java_util_Comparator__["a" /* default */]];
},
getClass: function () {
return DimensionalComparator;
}
});
DimensionalComparator.compare = function (a, b) {
if (a < b) return -1;
if (a > b) return 1;
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(a)) {
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(b)) return 0;
return -1;
}
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(b)) return 1;
return 0;
};
Coordinate.DimensionalComparator = DimensionalComparator;
Coordinate.serialVersionUID = 6683108902428366910;
Coordinate.NULL_ORDINATE = __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].NaN;
Coordinate.X = 0;
Coordinate.Y = 1;
Coordinate.Z = 2;
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function (c, p) {
c.prototype = Object.create(p.prototype)
c.prototype.constructor = c
});
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Assert;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__AssertionFailedException__ = __webpack_require__(207);
function Assert() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Assert.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Assert;
}
});
Assert.shouldNeverReachHere = function () {
if (arguments.length === 0) {
Assert.shouldNeverReachHere(null);
} else if (arguments.length === 1) {
let message = arguments[0];
throw new __WEBPACK_IMPORTED_MODULE_1__AssertionFailedException__["a" /* default */]("Should never reach here" + (message !== null ? ": " + message : ""));
}
};
Assert.isTrue = function () {
if (arguments.length === 1) {
let assertion = arguments[0];
Assert.isTrue(assertion, null);
} else if (arguments.length === 2) {
let assertion = arguments[0], message = arguments[1];
if (!assertion) {
if (message === null) {
throw new __WEBPACK_IMPORTED_MODULE_1__AssertionFailedException__["a" /* default */]();
} else {
throw new __WEBPACK_IMPORTED_MODULE_1__AssertionFailedException__["a" /* default */](message);
}
}
}
};
Assert.equals = function () {
if (arguments.length === 2) {
let expectedValue = arguments[0], actualValue = arguments[1];
Assert.equals(expectedValue, actualValue, null);
} else if (arguments.length === 3) {
let expectedValue = arguments[0], actualValue = arguments[1], message = arguments[2];
if (!actualValue.equals(expectedValue)) {
throw new __WEBPACK_IMPORTED_MODULE_1__AssertionFailedException__["a" /* default */]("Expected " + expectedValue + " but encountered " + actualValue + (message !== null ? ": " + message : ""));
}
}
};
/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function (o, i) {
return o.interfaces_ && o.interfaces_().indexOf(i) > -1
});
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = IllegalArgumentException;
function IllegalArgumentException () {}
/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Envelope;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_io_Serializable__ = __webpack_require__(21);
function Envelope() {
this._minx = null;
this._maxx = null;
this._miny = null;
this._maxy = null;
if (arguments.length === 0) {
this.init();
} else if (arguments.length === 1) {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]) {
let p = arguments[0];
this.init(p.x, p.x, p.y, p.y);
} else if (arguments[0] instanceof Envelope) {
let env = arguments[0];
this.init(env);
}
} else if (arguments.length === 2) {
let p1 = arguments[0], p2 = arguments[1];
this.init(p1.x, p2.x, p1.y, p2.y);
} else if (arguments.length === 4) {
let x1 = arguments[0], x2 = arguments[1], y1 = arguments[2], y2 = arguments[3];
this.init(x1, x2, y1, y2);
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Envelope.prototype, {
getArea: function () {
return this.getWidth() * this.getHeight();
},
equals: function (other) {
if (!(other instanceof Envelope)) {
return false;
}
var otherEnvelope = other;
if (this.isNull()) {
return otherEnvelope.isNull();
}
return this._maxx === otherEnvelope.getMaxX() && this._maxy === otherEnvelope.getMaxY() && this._minx === otherEnvelope.getMinX() && this._miny === otherEnvelope.getMinY();
},
intersection: function (env) {
if (this.isNull() || env.isNull() || !this.intersects(env)) return new Envelope();
var intMinX = this._minx > env._minx ? this._minx : env._minx;
var intMinY = this._miny > env._miny ? this._miny : env._miny;
var intMaxX = this._maxx < env._maxx ? this._maxx : env._maxx;
var intMaxY = this._maxy < env._maxy ? this._maxy : env._maxy;
return new Envelope(intMinX, intMaxX, intMinY, intMaxY);
},
isNull: function () {
return this._maxx < this._minx;
},
getMaxX: function () {
return this._maxx;
},
covers: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]) {
let p = arguments[0];
return this.covers(p.x, p.y);
} else if (arguments[0] instanceof Envelope) {
let other = arguments[0];
if (this.isNull() || other.isNull()) {
return false;
}
return other.getMinX() >= this._minx && other.getMaxX() <= this._maxx && other.getMinY() >= this._miny && other.getMaxY() <= this._maxy;
}
} else if (arguments.length === 2) {
let x = arguments[0], y = arguments[1];
if (this.isNull()) return false;
return x >= this._minx && x <= this._maxx && y >= this._miny && y <= this._maxy;
}
},
intersects: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof Envelope) {
let other = arguments[0];
if (this.isNull() || other.isNull()) {
return false;
}
return !(other._minx > this._maxx || other._maxx < this._minx || other._miny > this._maxy || other._maxy < this._miny);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]) {
let p = arguments[0];
return this.intersects(p.x, p.y);
}
} else if (arguments.length === 2) {
let x = arguments[0], y = arguments[1];
if (this.isNull()) return false;
return !(x > this._maxx || x < this._minx || y > this._maxy || y < this._miny);
}
},
getMinY: function () {
return this._miny;
},
getMinX: function () {
return this._minx;
},
expandToInclude: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]) {
let p = arguments[0];
this.expandToInclude(p.x, p.y);
} else if (arguments[0] instanceof Envelope) {
let other = arguments[0];
if (other.isNull()) {
return null;
}
if (this.isNull()) {
this._minx = other.getMinX();
this._maxx = other.getMaxX();
this._miny = other.getMinY();
this._maxy = other.getMaxY();
} else {
if (other._minx < this._minx) {
this._minx = other._minx;
}
if (other._maxx > this._maxx) {
this._maxx = other._maxx;
}
if (other._miny < this._miny) {
this._miny = other._miny;
}
if (other._maxy > this._maxy) {
this._maxy = other._maxy;
}
}
}
} else if (arguments.length === 2) {
let x = arguments[0], y = arguments[1];
if (this.isNull()) {
this._minx = x;
this._maxx = x;
this._miny = y;
this._maxy = y;
} else {
if (x < this._minx) {
this._minx = x;
}
if (x > this._maxx) {
this._maxx = x;
}
if (y < this._miny) {
this._miny = y;
}
if (y > this._maxy) {
this._maxy = y;
}
}
}
},
minExtent: function () {
if (this.isNull()) return 0.0;
var w = this.getWidth();
var h = this.getHeight();
if (w < h) return w;
return h;
},
getWidth: function () {
if (this.isNull()) {
return 0;
}
return this._maxx - this._minx;
},
compareTo: function (o) {
var env = o;
if (this.isNull()) {
if (env.isNull()) return 0;
return -1;
} else {
if (env.isNull()) return 1;
}
if (this._minx < env._minx) return -1;
if (this._minx > env._minx) return 1;
if (this._miny < env._miny) return -1;
if (this._miny > env._miny) return 1;
if (this._maxx < env._maxx) return -1;
if (this._maxx > env._maxx) return 1;
if (this._maxy < env._maxy) return -1;
if (this._maxy > env._maxy) return 1;
return 0;
},
translate: function (transX, transY) {
if (this.isNull()) {
return null;
}
this.init(this.getMinX() + transX, this.getMaxX() + transX, this.getMinY() + transY, this.getMaxY() + transY);
},
toString: function () {
return "Env[" + this._minx + " : " + this._maxx + ", " + this._miny + " : " + this._maxy + "]";
},
setToNull: function () {
this._minx = 0;
this._maxx = -1;
this._miny = 0;
this._maxy = -1;
},
getHeight: function () {
if (this.isNull()) {
return 0;
}
return this._maxy - this._miny;
},
maxExtent: function () {
if (this.isNull()) return 0.0;
var w = this.getWidth();
var h = this.getHeight();
if (w > h) return w;
return h;
},
expandBy: function () {
if (arguments.length === 1) {
let distance = arguments[0];
this.expandBy(distance, distance);
} else if (arguments.length === 2) {
let deltaX = arguments[0], deltaY = arguments[1];
if (this.isNull()) return null;
this._minx -= deltaX;
this._maxx += deltaX;
this._miny -= deltaY;
this._maxy += deltaY;
if (this._minx > this._maxx || this._miny > this._maxy) this.setToNull();
}
},
contains: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof Envelope) {
let other = arguments[0];
return this.covers(other);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]) {
let p = arguments[0];
return this.covers(p);
}
} else if (arguments.length === 2) {
let x = arguments[0], y = arguments[1];
return this.covers(x, y);
}
},
centre: function () {
if (this.isNull()) return null;
return new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]((this.getMinX() + this.getMaxX()) / 2.0, (this.getMinY() + this.getMaxY()) / 2.0);
},
init: function () {
if (arguments.length === 0) {
this.setToNull();
} else if (arguments.length === 1) {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */]) {
let p = arguments[0];
this.init(p.x, p.x, p.y, p.y);
} else if (arguments[0] instanceof Envelope) {
let env = arguments[0];
this._minx = env._minx;
this._maxx = env._maxx;
this._miny = env._miny;
this._maxy = env._maxy;
}
} else if (arguments.length === 2) {
let p1 = arguments[0], p2 = arguments[1];
this.init(p1.x, p2.x, p1.y, p2.y);
} else if (arguments.length === 4) {
let x1 = arguments[0], x2 = arguments[1], y1 = arguments[2], y2 = arguments[3];
if (x1 < x2) {
this._minx = x1;
this._maxx = x2;
} else {
this._minx = x2;
this._maxx = x1;
}
if (y1 < y2) {
this._miny = y1;
this._maxy = y2;
} else {
this._miny = y2;
this._maxy = y1;
}
}
},
getMaxY: function () {
return this._maxy;
},
distance: function (env) {
if (this.intersects(env)) return 0;
var dx = 0.0;
if (this._maxx < env._minx) dx = env._minx - this._maxx; else if (this._minx > env._maxx) dx = this._minx - env._maxx;
var dy = 0.0;
if (this._maxy < env._miny) dy = env._miny - this._maxy; else if (this._miny > env._maxy) dy = this._miny - env._maxy;
if (dx === 0.0) return dy;
if (dy === 0.0) return dx;
return Math.sqrt(dx * dx + dy * dy);
},
hashCode: function () {
var result = 17;
result = 37 * result + __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */].hashCode(this._minx);
result = 37 * result + __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */].hashCode(this._maxx);
result = 37 * result + __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */].hashCode(this._miny);
result = 37 * result + __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */].hashCode(this._maxy);
return result;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_2__java_lang_Comparable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_3__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return Envelope;
}
});
Envelope.intersects = function () {
if (arguments.length === 3) {
let p1 = arguments[0], p2 = arguments[1], q = arguments[2];
if (q.x >= (p1.x < p2.x ? p1.x : p2.x) && q.x <= (p1.x > p2.x ? p1.x : p2.x) && (q.y >= (p1.y < p2.y ? p1.y : p2.y) && q.y <= (p1.y > p2.y ? p1.y : p2.y))) {
return true;
}
return false;
} else if (arguments.length === 4) {
let p1 = arguments[0], p2 = arguments[1], q1 = arguments[2], q2 = arguments[3];
var minq = Math.min(q1.x, q2.x);
var maxq = Math.max(q1.x, q2.x);
var minp = Math.min(p1.x, p2.x);
var maxp = Math.max(p1.x, p2.x);
if (minp > maxq) return false;
if (maxp < minq) return false;
minq = Math.min(q1.y, q2.y);
maxq = Math.max(q1.y, q2.y);
minp = Math.min(p1.y, p2.y);
maxp = Math.max(p1.y, p2.y);
if (minp > maxq) return false;
if (maxp < minq) return false;
return true;
}
};
Envelope.serialVersionUID = 5873921885273102420;
/***/ }),
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CGAlgorithms;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_MathUtil__ = __webpack_require__(88);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CGAlgorithmsDD__ = __webpack_require__(115);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_CoordinateSequence__ = __webpack_require__(37);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__RobustLineIntersector__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__RayCrossingCounter__ = __webpack_require__(123);
function CGAlgorithms() {}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(CGAlgorithms.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return CGAlgorithms;
}
});
CGAlgorithms.orientationIndex = function (p1, p2, q) {
return __WEBPACK_IMPORTED_MODULE_6__CGAlgorithmsDD__["a" /* default */].orientationIndex(p1, p2, q);
};
CGAlgorithms.signedArea = function () {
if (arguments[0] instanceof Array) {
let ring = arguments[0];
if (ring.length < 3) return 0.0;
var sum = 0.0;
var x0 = ring[0].x;
for (var i = 1; i < ring.length - 1; i++) {
var x = ring[i].x - x0;
var y1 = ring[i + 1].y;
var y2 = ring[i - 1].y;
sum += x * (y2 - y1);
}
return sum / 2.0;
} else if (Object(__WEBPACK_IMPORTED_MODULE_1__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_7__geom_CoordinateSequence__["a" /* default */])) {
let ring = arguments[0];
var n = ring.size();
if (n < 3) return 0.0;
var p0 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
var p1 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
var p2 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
ring.getCoordinate(0, p1);
ring.getCoordinate(1, p2);
var x0 = p1.x;
p2.x -= x0;
var sum = 0.0;
for (var i = 1; i < n - 1; i++) {
p0.y = p1.y;
p1.x = p2.x;
p1.y = p2.y;
ring.getCoordinate(i + 1, p2);
p2.x -= x0;
sum += p1.x * (p0.y - p2.y);
}
return sum / 2.0;
}
};
CGAlgorithms.distanceLineLine = function (A, B, C, D) {
if (A.equals(B)) return CGAlgorithms.distancePointLine(A, C, D);
if (C.equals(D)) return CGAlgorithms.distancePointLine(D, A, B);
var noIntersection = false;
if (!__WEBPACK_IMPORTED_MODULE_9__geom_Envelope__["a" /* default */].intersects(A, B, C, D)) {
noIntersection = true;
} else {
var denom = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
if (denom === 0) {
noIntersection = true;
} else {
var r_num = (A.y - C.y) * (D.x - C.x) - (A.x - C.x) * (D.y - C.y);
var s_num = (A.y - C.y) * (B.x - A.x) - (A.x - C.x) * (B.y - A.y);
var s = s_num / denom;
var r = r_num / denom;
if (r < 0 || r > 1 || s < 0 || s > 1) {
noIntersection = true;
}
}
}
if (noIntersection) {
return __WEBPACK_IMPORTED_MODULE_5__math_MathUtil__["a" /* default */].min(CGAlgorithms.distancePointLine(A, C, D), CGAlgorithms.distancePointLine(B, C, D), CGAlgorithms.distancePointLine(C, A, B), CGAlgorithms.distancePointLine(D, A, B));
}
return 0.0;
};
CGAlgorithms.isPointInRing = function (p, ring) {
return CGAlgorithms.locatePointInRing(p, ring) !== __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
};
CGAlgorithms.computeLength = function (pts) {
var n = pts.size();
if (n <= 1) return 0.0;
var len = 0.0;
var p = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
pts.getCoordinate(0, p);
var x0 = p.x;
var y0 = p.y;
for (var i = 1; i < n; i++) {
pts.getCoordinate(i, p);
var x1 = p.x;
var y1 = p.y;
var dx = x1 - x0;
var dy = y1 - y0;
len += Math.sqrt(dx * dx + dy * dy);
x0 = x1;
y0 = y1;
}
return len;
};
CGAlgorithms.isCCW = function (ring) {
var nPts = ring.length - 1;
if (nPts < 3) throw new __WEBPACK_IMPORTED_MODULE_3__java_lang_IllegalArgumentException__["a" /* default */]("Ring has fewer than 4 points, so orientation cannot be determined");
var hiPt = ring[0];
var hiIndex = 0;
for (var i = 1; i <= nPts; i++) {
var p = ring[i];
if (p.y > hiPt.y) {
hiPt = p;
hiIndex = i;
}
}
var iPrev = hiIndex;
do {
iPrev = iPrev - 1;
if (iPrev < 0) iPrev = nPts;
} while (ring[iPrev].equals2D(hiPt) && iPrev !== hiIndex);
var iNext = hiIndex;
do {
iNext = (iNext + 1) % nPts;
} while (ring[iNext].equals2D(hiPt) && iNext !== hiIndex);
var prev = ring[iPrev];
var next = ring[iNext];
if (prev.equals2D(hiPt) || next.equals2D(hiPt) || prev.equals2D(next)) return false;
var disc = CGAlgorithms.computeOrientation(prev, hiPt, next);
var isCCW = false;
if (disc === 0) {
isCCW = prev.x > next.x;
} else {
isCCW = disc > 0;
}
return isCCW;
};
CGAlgorithms.locatePointInRing = function (p, ring) {
return __WEBPACK_IMPORTED_MODULE_10__RayCrossingCounter__["a" /* default */].locatePointInRing(p, ring);
};
CGAlgorithms.distancePointLinePerpendicular = function (p, A, B) {
var len2 = (B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y);
var s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y)) / len2;
return Math.abs(s) * Math.sqrt(len2);
};
CGAlgorithms.computeOrientation = function (p1, p2, q) {
return CGAlgorithms.orientationIndex(p1, p2, q);
};
CGAlgorithms.distancePointLine = function () {
if (arguments.length === 2) {
let p = arguments[0], line = arguments[1];
if (line.length === 0) throw new __WEBPACK_IMPORTED_MODULE_3__java_lang_IllegalArgumentException__["a" /* default */]("Line array must contain at least one vertex");
var minDistance = p.distance(line[0]);
for (var i = 0; i < line.length - 1; i++) {
var dist = CGAlgorithms.distancePointLine(p, line[i], line[i + 1]);
if (dist < minDistance) {
minDistance = dist;
}
}
return minDistance;
} else if (arguments.length === 3) {
let p = arguments[0], A = arguments[1], B = arguments[2];
if (A.x === B.x && A.y === B.y) return p.distance(A);
var len2 = (B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y);
var r = ((p.x - A.x) * (B.x - A.x) + (p.y - A.y) * (B.y - A.y)) / len2;
if (r <= 0.0) return p.distance(A);
if (r >= 1.0) return p.distance(B);
var s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y)) / len2;
return Math.abs(s) * Math.sqrt(len2);
}
};
CGAlgorithms.isOnLine = function (p, pt) {
var lineIntersector = new __WEBPACK_IMPORTED_MODULE_8__RobustLineIntersector__["a" /* default */]();
for (var i = 1; i < pt.length; i++) {
var p0 = pt[i - 1];
var p1 = pt[i];
lineIntersector.computeIntersection(p, p0, p1);
if (lineIntersector.hasIntersection()) {
return true;
}
}
return false;
};
CGAlgorithms.CLOCKWISE = -1;
CGAlgorithms.RIGHT = CGAlgorithms.CLOCKWISE;
CGAlgorithms.COUNTERCLOCKWISE = 1;
CGAlgorithms.LEFT = CGAlgorithms.COUNTERCLOCKWISE;
CGAlgorithms.COLLINEAR = 0;
CGAlgorithms.STRAIGHT = CGAlgorithms.COLLINEAR;
/***/ }),
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LineString;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CoordinateFilter__ = __webpack_require__(50);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__operation_BoundaryOp__ = __webpack_require__(89);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Lineal__ = __webpack_require__(90);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__CoordinateSequences__ = __webpack_require__(91);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__GeometryComponentFilter__ = __webpack_require__(31);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__GeometryFilter__ = __webpack_require__(39);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__CoordinateSequenceFilter__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__inherits__ = __webpack_require__(3);
function LineString() {
this._points = null;
let points = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].call(this, factory);
this.init(points);
}
Object(__WEBPACK_IMPORTED_MODULE_14__inherits__["a" /* default */])(LineString, __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_6__extend__["a" /* default */])(LineString.prototype, {
computeEnvelopeInternal: function () {
if (this.isEmpty()) {
return new __WEBPACK_IMPORTED_MODULE_13__Envelope__["a" /* default */]();
}
return this._points.expandEnvelope(new __WEBPACK_IMPORTED_MODULE_13__Envelope__["a" /* default */]());
},
isRing: function () {
return this.isClosed() && this.isSimple();
},
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].SORTINDEX_LINESTRING;
},
getCoordinates: function () {
return this._points.toCoordinateArray();
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
var otherLineString = other;
if (this._points.size() !== otherLineString._points.size()) {
return false;
}
for (var i = 0; i < this._points.size(); i++) {
if (!this.equal(this._points.getCoordinate(i), otherLineString._points.getCoordinate(i), tolerance)) {
return false;
}
}
return true;
} else return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
normalize: function () {
for (var i = 0; i < Math.trunc(this._points.size() / 2); i++) {
var j = this._points.size() - 1 - i;
if (!this._points.getCoordinate(i).equals(this._points.getCoordinate(j))) {
if (this._points.getCoordinate(i).compareTo(this._points.getCoordinate(j)) > 0) {
__WEBPACK_IMPORTED_MODULE_8__CoordinateSequences__["a" /* default */].reverse(this._points);
}
return null;
}
}
},
getCoordinate: function () {
if (this.isEmpty()) return null;
return this._points.getCoordinate(0);
},
getBoundaryDimension: function () {
if (this.isClosed()) {
return __WEBPACK_IMPORTED_MODULE_10__Dimension__["a" /* default */].FALSE;
}
return 0;
},
isClosed: function () {
if (this.isEmpty()) {
return false;
}
return this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints() - 1));
},
getEndPoint: function () {
if (this.isEmpty()) {
return null;
}
return this.getPointN(this.getNumPoints() - 1);
},
getDimension: function () {
return 1;
},
getLength: function () {
return __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].computeLength(this._points);
},
getNumPoints: function () {
return this._points.size();
},
reverse: function () {
var seq = this._points.copy();
__WEBPACK_IMPORTED_MODULE_8__CoordinateSequences__["a" /* default */].reverse(seq);
var revLine = this.getFactory().createLineString(seq);
return revLine;
},
compareToSameClass: function () {
if (arguments.length === 1) {
let o = arguments[0];
var line = o;
var i = 0;
var j = 0;
while (i < this._points.size() && j < line._points.size()) {
var comparison = this._points.getCoordinate(i).compareTo(line._points.getCoordinate(j));
if (comparison !== 0) {
return comparison;
}
i++;
j++;
}
if (i < this._points.size()) {
return 1;
}
if (j < line._points.size()) {
return -1;
}
return 0;
} else if (arguments.length === 2) {
let o = arguments[0], comp = arguments[1];
var line = o;
return comp.compare(this._points, line._points);
}
},
apply: function () {
if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_2__CoordinateFilter__["a" /* default */])) {
let filter = arguments[0];
for (var i = 0; i < this._points.size(); i++) {
filter.filter(this._points.getCoordinate(i));
}
} else if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_12__CoordinateSequenceFilter__["a" /* default */])) {
let filter = arguments[0];
if (this._points.size() === 0) return null;
for (var i = 0; i < this._points.size(); i++) {
filter.filter(this._points, i);
if (filter.isDone()) break;
}
if (filter.isGeometryChanged()) this.geometryChanged();
} else if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_11__GeometryFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
} else if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_9__GeometryComponentFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
}
},
getBoundary: function () {
return new __WEBPACK_IMPORTED_MODULE_4__operation_BoundaryOp__["a" /* default */](this).getBoundary();
},
isEquivalentClass: function (other) {
return other instanceof LineString;
},
clone: function () {
var ls = __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].prototype.clone.call(this);
ls._points = this._points.clone();
return ls;
},
getCoordinateN: function (n) {
return this._points.getCoordinate(n);
},
getGeometryType: function () {
return "LineString";
},
copy: function () {
return new LineString(this._points.copy(), this._factory);
},
getCoordinateSequence: function () {
return this._points;
},
isEmpty: function () {
return this._points.size() === 0;
},
init: function (points) {
if (points === null) {
points = this.getFactory().getCoordinateSequenceFactory().create([]);
}
if (points.size() === 1) {
throw new __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__["a" /* default */]("Invalid number of points in LineString (found " + points.size() + " - must be 0 or >= 2)");
}
this._points = points;
},
isCoordinate: function (pt) {
for (var i = 0; i < this._points.size(); i++) {
if (this._points.getCoordinate(i).equals(pt)) {
return true;
}
}
return false;
},
getStartPoint: function () {
if (this.isEmpty()) {
return null;
}
return this.getPointN(0);
},
getPointN: function (n) {
return this.getFactory().createPoint(this._points.getCoordinate(n));
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_7__Lineal__["a" /* default */]];
},
getClass: function () {
return LineString;
}
});
LineString.serialVersionUID = 3110669828065365560;
/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Location;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
function Location() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Location.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Location;
}
});
Location.toLocationSymbol = function (locationValue) {
switch (locationValue) {
case Location.EXTERIOR:
return 'e';
case Location.BOUNDARY:
return 'b';
case Location.INTERIOR:
return 'i';
case Location.NONE:
return '-';
}
throw new __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__["a" /* default */]("Unknown location value: " + locationValue);
};
Location.INTERIOR = 0;
Location.BOUNDARY = 1;
Location.EXTERIOR = 2;
Location.NONE = -1;
/***/ }),
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Double;
function Double () {}
Double.isNaN = n => Number.isNaN(n)
Double.doubleToLongBits = n => n
Double.longBitsToDouble = n => n
Double.isInfinite = n => !Number.isFinite(n)
Double.MAX_VALUE = Number.MAX_VALUE
/***/ }),
/* 12 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Geometry;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__GeometryComponentFilter__ = __webpack_require__(31);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_Cloneable__ = __webpack_require__(53);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_io_Serializable__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_Assert__ = __webpack_require__(4);
function Geometry() {
this._envelope = null;
this._factory = null;
this._SRID = null;
this._userData = null;
let factory = arguments[0];
this._factory = factory;
this._SRID = factory.getSRID();
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Geometry.prototype, {
isGeometryCollection: function () {
return this.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION;
},
getFactory: function () {
return this._factory;
},
getGeometryN: function (n) {
return this;
},
getArea: function () {
return 0.0;
},
isRectangle: function () {
return false;
},
equals: function () {
if (arguments[0] instanceof Geometry) {
let g = arguments[0];
if (g === null) return false;
return this.equalsTopo(g);
} else if (arguments[0] instanceof Object) {
let o = arguments[0];
if (!(o instanceof Geometry)) return false;
var g = o;
return this.equalsExact(g);
}
},
equalsExact: function (other) {
return this === other || this.equalsExact(other, 0);
},
geometryChanged: function () {
this.apply(Geometry.geometryChangedFilter);
},
geometryChangedAction: function () {
this._envelope = null;
},
equalsNorm: function (g) {
if (g === null) return false;
return this.norm().equalsExact(g.norm());
},
getLength: function () {
return 0.0;
},
getNumGeometries: function () {
return 1;
},
compareTo: function () {
if (arguments.length === 1) {
let o = arguments[0];
var other = o;
if (this.getSortIndex() !== other.getSortIndex()) {
return this.getSortIndex() - other.getSortIndex();
}
if (this.isEmpty() && other.isEmpty()) {
return 0;
}
if (this.isEmpty()) {
return -1;
}
if (other.isEmpty()) {
return 1;
}
return this.compareToSameClass(o);
} else if (arguments.length === 2) {
let o = arguments[0], comp = arguments[1];
var other = o;
if (this.getSortIndex() !== other.getSortIndex()) {
return this.getSortIndex() - other.getSortIndex();
}
if (this.isEmpty() && other.isEmpty()) {
return 0;
}
if (this.isEmpty()) {
return -1;
}
if (other.isEmpty()) {
return 1;
}
return this.compareToSameClass(o, comp);
}
},
getUserData: function () {
return this._userData;
},
getSRID: function () {
return this._SRID;
},
getEnvelope: function () {
return this.getFactory().toGeometry(this.getEnvelopeInternal());
},
checkNotGeometryCollection: function (g) {
if (g.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION) {
throw new __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__["a" /* default */]("This method does not support GeometryCollection arguments");
}
},
equal: function (a, b, tolerance) {
if (tolerance === 0) {
return a.equals(b);
}
return a.distance(b) <= tolerance;
},
norm: function () {
var copy = this.copy();
copy.normalize();
return copy;
},
getPrecisionModel: function () {
return this._factory.getPrecisionModel();
},
getEnvelopeInternal: function () {
if (this._envelope === null) {
this._envelope = this.computeEnvelopeInternal();
}
return new __WEBPACK_IMPORTED_MODULE_6__Envelope__["a" /* default */](this._envelope);
},
setSRID: function (SRID) {
this._SRID = SRID;
},
setUserData: function (userData) {
this._userData = userData;
},
compare: function (a, b) {
var i = a.iterator();
var j = b.iterator();
while (i.hasNext() && j.hasNext()) {
var aElement = i.next();
var bElement = j.next();
var comparison = aElement.compareTo(bElement);
if (comparison !== 0) {
return comparison;
}
}
if (i.hasNext()) {
return 1;
}
if (j.hasNext()) {
return -1;
}
return 0;
},
hashCode: function () {
return this.getEnvelopeInternal().hashCode();
},
isGeometryCollectionOrDerived: function () {
if (this.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION || this.getSortIndex() === Geometry.SORTINDEX_MULTIPOINT || this.getSortIndex() === Geometry.SORTINDEX_MULTILINESTRING || this.getSortIndex() === Geometry.SORTINDEX_MULTIPOLYGON) {
return true;
}
return false;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_4__java_lang_Cloneable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_3__java_lang_Comparable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_5__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return Geometry;
}
});
Geometry.hasNonEmptyElements = function (geometries) {
for (var i = 0; i < geometries.length; i++) {
if (!geometries[i].isEmpty()) {
return true;
}
}
return false;
};
Geometry.hasNullElements = function (array) {
for (var i = 0; i < array.length; i++) {
if (array[i] === null) {
return true;
}
}
return false;
};
Geometry.serialVersionUID = 8763622679187376702;
Geometry.SORTINDEX_POINT = 0;
Geometry.SORTINDEX_MULTIPOINT = 1;
Geometry.SORTINDEX_LINESTRING = 2;
Geometry.SORTINDEX_LINEARRING = 3;
Geometry.SORTINDEX_MULTILINESTRING = 4;
Geometry.SORTINDEX_POLYGON = 5;
Geometry.SORTINDEX_MULTIPOLYGON = 6;
Geometry.SORTINDEX_GEOMETRYCOLLECTION = 7;
Geometry.geometryChangedFilter = {
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_2__GeometryComponentFilter__["a" /* default */]];
},
filter: function (geom) {
geom.geometryChangedAction();
}
};
/***/ }),
/* 13 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryCollection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__ = __webpack_require__(46);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__ = __webpack_require__(58);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__CoordinateFilter__ = __webpack_require__(50);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__GeometryComponentFilter__ = __webpack_require__(31);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__GeometryFilter__ = __webpack_require__(39);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__CoordinateSequenceFilter__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__inherits__ = __webpack_require__(3);
function GeometryCollection() {
this._geometries = null;
let geometries = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].call(this, factory);
if (geometries === null) {
geometries = [];
}
if (__WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].hasNullElements(geometries)) {
throw new __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__["a" /* default */]("geometries must not contain null elements");
}
this._geometries = geometries;
}
Object(__WEBPACK_IMPORTED_MODULE_13__inherits__["a" /* default */])(GeometryCollection, __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_6__extend__["a" /* default */])(GeometryCollection.prototype, {
computeEnvelopeInternal: function () {
var envelope = new __WEBPACK_IMPORTED_MODULE_11__Envelope__["a" /* default */]();
for (var i = 0; i < this._geometries.length; i++) {
envelope.expandToInclude(this._geometries[i].getEnvelopeInternal());
}
return envelope;
},
getGeometryN: function (n) {
return this._geometries[n];
},
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].SORTINDEX_GEOMETRYCOLLECTION;
},
getCoordinates: function () {
var coordinates = new Array(this.getNumPoints()).fill(null);
var k = -1;
for (var i = 0; i < this._geometries.length; i++) {
var childCoordinates = this._geometries[i].getCoordinates();
for (var j = 0; j < childCoordinates.length; j++) {
k++;
coordinates[k] = childCoordinates[j];
}
}
return coordinates;
},
getArea: function () {
var area = 0.0;
for (var i = 0; i < this._geometries.length; i++) {
area += this._geometries[i].getArea();
}
return area;
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
var otherCollection = other;
if (this._geometries.length !== otherCollection._geometries.length) {
return false;
}
for (var i = 0; i < this._geometries.length; i++) {
if (!this._geometries[i].equalsExact(otherCollection._geometries[i], tolerance)) {
return false;
}
}
return true;
} else return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
normalize: function () {
for (var i = 0; i < this._geometries.length; i++) {
this._geometries[i].normalize();
}
__WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__["a" /* default */].sort(this._geometries);
},
getCoordinate: function () {
if (this.isEmpty()) return null;
return this._geometries[0].getCoordinate();
},
getBoundaryDimension: function () {
var dimension = __WEBPACK_IMPORTED_MODULE_8__Dimension__["a" /* default */].FALSE;
for (var i = 0; i < this._geometries.length; i++) {
dimension = Math.max(dimension, this._geometries[i].getBoundaryDimension());
}
return dimension;
},
getDimension: function () {
var dimension = __WEBPACK_IMPORTED_MODULE_8__Dimension__["a" /* default */].FALSE;
for (var i = 0; i < this._geometries.length; i++) {
dimension = Math.max(dimension, this._geometries[i].getDimension());
}
return dimension;
},
getLength: function () {
var sum = 0.0;
for (var i = 0; i < this._geometries.length; i++) {
sum += this._geometries[i].getLength();
}
return sum;
},
getNumPoints: function () {
var numPoints = 0;
for (var i = 0; i < this._geometries.length; i++) {
numPoints += this._geometries[i].getNumPoints();
}
return numPoints;
},
getNumGeometries: function () {
return this._geometries.length;
},
reverse: function () {
var n = this._geometries.length;
var revGeoms = new Array(n).fill(null);
for (var i = 0; i < this._geometries.length; i++) {
revGeoms[i] = this._geometries[i].reverse();
}
return this.getFactory().createGeometryCollection(revGeoms);
},
compareToSameClass: function () {
if (arguments.length === 1) {
let o = arguments[0];
var theseElements = new __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__["a" /* default */](__WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__["a" /* default */].asList(this._geometries));
var otherElements = new __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__["a" /* default */](__WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__["a" /* default */].asList(o._geometries));
return this.compare(theseElements, otherElements);
} else if (arguments.length === 2) {
let o = arguments[0], comp = arguments[1];
var gc = o;
var n1 = this.getNumGeometries();
var n2 = gc.getNumGeometries();
var i = 0;
while (i < n1 && i < n2) {
var thisGeom = this.getGeometryN(i);
var otherGeom = gc.getGeometryN(i);
var holeComp = thisGeom.compareToSameClass(otherGeom, comp);
if (holeComp !== 0) return holeComp;
i++;
}
if (i < n1) return 1;
if (i < n2) return -1;
return 0;
}
},
apply: function () {
if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_3__CoordinateFilter__["a" /* default */])) {
let filter = arguments[0];
for (var i = 0; i < this._geometries.length; i++) {
this._geometries[i].apply(filter);
}
} else if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_10__CoordinateSequenceFilter__["a" /* default */])) {
let filter = arguments[0];
if (this._geometries.length === 0) return null;
for (var i = 0; i < this._geometries.length; i++) {
this._geometries[i].apply(filter);
if (filter.isDone()) {
break;
}
}
if (filter.isGeometryChanged()) this.geometryChanged();
} else if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_9__GeometryFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
for (var i = 0; i < this._geometries.length; i++) {
this._geometries[i].apply(filter);
}
} else if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_7__GeometryComponentFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
for (var i = 0; i < this._geometries.length; i++) {
this._geometries[i].apply(filter);
}
}
},
getBoundary: function () {
this.checkNotGeometryCollection(this);
__WEBPACK_IMPORTED_MODULE_12__util_Assert__["a" /* default */].shouldNeverReachHere();
return null;
},
clone: function () {
var gc = __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].prototype.clone.call(this);
gc._geometries = new Array(this._geometries.length).fill(null);
for (var i = 0; i < this._geometries.length; i++) {
gc._geometries[i] = this._geometries[i].clone();
}
return gc;
},
getGeometryType: function () {
return "GeometryCollection";
},
copy: function () {
var geometries = new Array(this._geometries.length).fill(null);
for (var i = 0; i < geometries.length; i++) {
geometries[i] = this._geometries[i].copy();
}
return new GeometryCollection(geometries, this._factory);
},
isEmpty: function () {
for (var i = 0; i < this._geometries.length; i++) {
if (!this._geometries[i].isEmpty()) {
return false;
}
}
return true;
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryCollection;
}
});
GeometryCollection.serialVersionUID = -5694727726395021467;
/***/ }),
/* 14 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LineSegment;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_NotRepresentableException__ = __webpack_require__(54);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__algorithm_RobustLineIntersector__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__algorithm_HCoordinate__ = __webpack_require__(56);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_io_Serializable__ = __webpack_require__(21);
function LineSegment() {
this.p0 = null;
this.p1 = null;
if (arguments.length === 0) {
LineSegment.call(this, new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */](), new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]());
} else if (arguments.length === 1) {
let ls = arguments[0];
LineSegment.call(this, ls.p0, ls.p1);
} else if (arguments.length === 2) {
let p0 = arguments[0], p1 = arguments[1];
this.p0 = p0;
this.p1 = p1;
} else if (arguments.length === 4) {
let x0 = arguments[0], y0 = arguments[1], x1 = arguments[2], y1 = arguments[3];
LineSegment.call(this, new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */](x0, y0), new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */](x1, y1));
}
}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(LineSegment.prototype, {
minX: function () {
return Math.min(this.p0.x, this.p1.x);
},
orientationIndex: function () {
if (arguments[0] instanceof LineSegment) {
let seg = arguments[0];
var orient0 = __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].orientationIndex(this.p0, this.p1, seg.p0);
var orient1 = __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].orientationIndex(this.p0, this.p1, seg.p1);
if (orient0 >= 0 && orient1 >= 0) return Math.max(orient0, orient1);
if (orient0 <= 0 && orient1 <= 0) return Math.max(orient0, orient1);
return 0;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]) {
let p = arguments[0];
return __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].orientationIndex(this.p0, this.p1, p);
}
},
toGeometry: function (geomFactory) {
return geomFactory.createLineString([this.p0, this.p1]);
},
isVertical: function () {
return this.p0.x === this.p1.x;
},
equals: function (o) {
if (!(o instanceof LineSegment)) {
return false;
}
var other = o;
return this.p0.equals(other.p0) && this.p1.equals(other.p1);
},
intersection: function (line) {
var li = new __WEBPACK_IMPORTED_MODULE_6__algorithm_RobustLineIntersector__["a" /* default */]();
li.computeIntersection(this.p0, this.p1, line.p0, line.p1);
if (li.hasIntersection()) return li.getIntersection(0);
return null;
},
project: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]) {
let p = arguments[0];
if (p.equals(this.p0) || p.equals(this.p1)) return new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */](p);
var r = this.projectionFactor(p);
var coord = new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]();
coord.x = this.p0.x + r * (this.p1.x - this.p0.x);
coord.y = this.p0.y + r * (this.p1.y - this.p0.y);
return coord;
} else if (arguments[0] instanceof LineSegment) {
let seg = arguments[0];
var pf0 = this.projectionFactor(seg.p0);
var pf1 = this.projectionFactor(seg.p1);
if (pf0 >= 1.0 && pf1 >= 1.0) return null;
if (pf0 <= 0.0 && pf1 <= 0.0) return null;
var newp0 = this.project(seg.p0);
if (pf0 < 0.0) newp0 = this.p0;
if (pf0 > 1.0) newp0 = this.p1;
var newp1 = this.project(seg.p1);
if (pf1 < 0.0) newp1 = this.p0;
if (pf1 > 1.0) newp1 = this.p1;
return new LineSegment(newp0, newp1);
}
},
normalize: function () {
if (this.p1.compareTo(this.p0) < 0) this.reverse();
},
angle: function () {
return Math.atan2(this.p1.y - this.p0.y, this.p1.x - this.p0.x);
},
getCoordinate: function (i) {
if (i === 0) return this.p0;
return this.p1;
},
distancePerpendicular: function (p) {
return __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].distancePointLinePerpendicular(p, this.p0, this.p1);
},
minY: function () {
return Math.min(this.p0.y, this.p1.y);
},
midPoint: function () {
return LineSegment.midPoint(this.p0, this.p1);
},
projectionFactor: function (p) {
if (p.equals(this.p0)) return 0.0;
if (p.equals(this.p1)) return 1.0;
var dx = this.p1.x - this.p0.x;
var dy = this.p1.y - this.p0.y;
var len = dx * dx + dy * dy;
if (len <= 0.0) return __WEBPACK_IMPORTED_MODULE_3__java_lang_Double__["a" /* default */].NaN;
var r = ((p.x - this.p0.x) * dx + (p.y - this.p0.y) * dy) / len;
return r;
},
closestPoints: function (line) {
var intPt = this.intersection(line);
if (intPt !== null) {
return [intPt, intPt];
}
var closestPt = new Array(2).fill(null);
var minDistance = __WEBPACK_IMPORTED_MODULE_3__java_lang_Double__["a" /* default */].MAX_VALUE;
var dist = null;
var close00 = this.closestPoint(line.p0);
minDistance = close00.distance(line.p0);
closestPt[0] = close00;
closestPt[1] = line.p0;
var close01 = this.closestPoint(line.p1);
dist = close01.distance(line.p1);
if (dist < minDistance) {
minDistance = dist;
closestPt[0] = close01;
closestPt[1] = line.p1;
}
var close10 = line.closestPoint(this.p0);
dist = close10.distance(this.p0);
if (dist < minDistance) {
minDistance = dist;
closestPt[0] = this.p0;
closestPt[1] = close10;
}
var close11 = line.closestPoint(this.p1);
dist = close11.distance(this.p1);
if (dist < minDistance) {
minDistance = dist;
closestPt[0] = this.p1;
closestPt[1] = close11;
}
return closestPt;
},
closestPoint: function (p) {
var factor = this.projectionFactor(p);
if (factor > 0 && factor < 1) {
return this.project(p);
}
var dist0 = this.p0.distance(p);
var dist1 = this.p1.distance(p);
if (dist0 < dist1) return this.p0;
return this.p1;
},
maxX: function () {
return Math.max(this.p0.x, this.p1.x);
},
getLength: function () {
return this.p0.distance(this.p1);
},
compareTo: function (o) {
var other = o;
var comp0 = this.p0.compareTo(other.p0);
if (comp0 !== 0) return comp0;
return this.p1.compareTo(other.p1);
},
reverse: function () {
var temp = this.p0;
this.p0 = this.p1;
this.p1 = temp;
},
equalsTopo: function (other) {
return this.p0.equals(other.p0) && this.p1.equals(other.p1) || this.p0.equals(other.p1) && this.p1.equals(other.p0);
},
lineIntersection: function (line) {
try {
var intPt = __WEBPACK_IMPORTED_MODULE_7__algorithm_HCoordinate__["a" /* default */].intersection(this.p0, this.p1, line.p0, line.p1);
return intPt;
} catch (ex) {
if (ex instanceof __WEBPACK_IMPORTED_MODULE_0__algorithm_NotRepresentableException__["a" /* default */]) {} else throw ex;
} finally {}
return null;
},
maxY: function () {
return Math.max(this.p0.y, this.p1.y);
},
pointAlongOffset: function (segmentLengthFraction, offsetDistance) {
var segx = this.p0.x + segmentLengthFraction * (this.p1.x - this.p0.x);
var segy = this.p0.y + segmentLengthFraction * (this.p1.y - this.p0.y);
var dx = this.p1.x - this.p0.x;
var dy = this.p1.y - this.p0.y;
var len = Math.sqrt(dx * dx + dy * dy);
var ux = 0.0;
var uy = 0.0;
if (offsetDistance !== 0.0) {
if (len <= 0.0) throw new IllegalStateException("Cannot compute offset from zero-length line segment");
ux = offsetDistance * dx / len;
uy = offsetDistance * dy / len;
}
var offsetx = segx - uy;
var offsety = segy + ux;
var coord = new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */](offsetx, offsety);
return coord;
},
setCoordinates: function () {
if (arguments.length === 1) {
let ls = arguments[0];
this.setCoordinates(ls.p0, ls.p1);
} else if (arguments.length === 2) {
let p0 = arguments[0], p1 = arguments[1];
this.p0.x = p0.x;
this.p0.y = p0.y;
this.p1.x = p1.x;
this.p1.y = p1.y;
}
},
segmentFraction: function (inputPt) {
var segFrac = this.projectionFactor(inputPt);
if (segFrac < 0.0) segFrac = 0.0; else if (segFrac > 1.0 || __WEBPACK_IMPORTED_MODULE_3__java_lang_Double__["a" /* default */].isNaN(segFrac)) segFrac = 1.0;
return segFrac;
},
toString: function () {
return "LINESTRING( " + this.p0.x + " " + this.p0.y + ", " + this.p1.x + " " + this.p1.y + ")";
},
isHorizontal: function () {
return this.p0.y === this.p1.y;
},
distance: function () {
if (arguments[0] instanceof LineSegment) {
let ls = arguments[0];
return __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].distanceLineLine(this.p0, this.p1, ls.p0, ls.p1);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]) {
let p = arguments[0];
return __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].distancePointLine(p, this.p0, this.p1);
}
},
pointAlong: function (segmentLengthFraction) {
var coord = new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]();
coord.x = this.p0.x + segmentLengthFraction * (this.p1.x - this.p0.x);
coord.y = this.p0.y + segmentLengthFraction * (this.p1.y - this.p0.y);
return coord;
},
hashCode: function () {
var bits0 = java.lang.Double.doubleToLongBits(this.p0.x);
bits0 ^= java.lang.Double.doubleToLongBits(this.p0.y) * 31;
var hash0 = Math.trunc(bits0) ^ Math.trunc(bits0 >> 32);
var bits1 = java.lang.Double.doubleToLongBits(this.p1.x);
bits1 ^= java.lang.Double.doubleToLongBits(this.p1.y) * 31;
var hash1 = Math.trunc(bits1) ^ Math.trunc(bits1 >> 32);
return hash0 ^ hash1;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_5__java_lang_Comparable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_8__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return LineSegment;
}
});
LineSegment.midPoint = function (p0, p1) {
return new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]((p0.x + p1.x) / 2, (p0.y + p1.y) / 2);
};
LineSegment.serialVersionUID = 3252005833466256227;
/***/ }),
/* 15 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryFactory;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CoordinateSequenceFactory__ = __webpack_require__(119);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Point__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__MultiPoint__ = __webpack_require__(41);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_GeometryEditor__ = __webpack_require__(92);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__impl_CoordinateArraySequenceFactory__ = __webpack_require__(219);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__MultiPolygon__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__CoordinateSequences__ = __webpack_require__(91);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__CoordinateSequence__ = __webpack_require__(37);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__PrecisionModel__ = __webpack_require__(51);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__java_io_Serializable__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__MultiLineString__ = __webpack_require__(28);
function GeometryFactory() {
this._precisionModel = null;
this._coordinateSequenceFactory = null;
this._SRID = null;
if (arguments.length === 0) {
GeometryFactory.call(this, new __WEBPACK_IMPORTED_MODULE_15__PrecisionModel__["a" /* default */](), 0);
} else if (arguments.length === 1) {
if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_0__CoordinateSequenceFactory__["a" /* default */])) {
let coordinateSequenceFactory = arguments[0];
GeometryFactory.call(this, new __WEBPACK_IMPORTED_MODULE_15__PrecisionModel__["a" /* default */](), 0, coordinateSequenceFactory);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_15__PrecisionModel__["a" /* default */]) {
let precisionModel = arguments[0];
GeometryFactory.call(this, precisionModel, 0, GeometryFactory.getDefaultCoordinateSequenceFactory());
}
} else if (arguments.length === 2) {
let precisionModel = arguments[0], SRID = arguments[1];
GeometryFactory.call(this, precisionModel, SRID, GeometryFactory.getDefaultCoordinateSequenceFactory());
} else if (arguments.length === 3) {
let precisionModel = arguments[0], SRID = arguments[1], coordinateSequenceFactory = arguments[2];
this._precisionModel = precisionModel;
this._coordinateSequenceFactory = coordinateSequenceFactory;
this._SRID = SRID;
}
}
Object(__WEBPACK_IMPORTED_MODULE_9__extend__["a" /* default */])(GeometryFactory.prototype, {
toGeometry: function (envelope) {
if (envelope.isNull()) {
return this.createPoint(null);
}
if (envelope.getMinX() === envelope.getMaxX() && envelope.getMinY() === envelope.getMaxY()) {
return this.createPoint(new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMinX(), envelope.getMinY()));
}
if (envelope.getMinX() === envelope.getMaxX() || envelope.getMinY() === envelope.getMaxY()) {
return this.createLineString([new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMinX(), envelope.getMinY()), new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMaxX(), envelope.getMaxY())]);
}
return this.createPolygon(this.createLinearRing([new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMinX(), envelope.getMinY()), new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMinX(), envelope.getMaxY()), new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMaxX(), envelope.getMaxY()), new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMaxX(), envelope.getMinY()), new __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */](envelope.getMinX(), envelope.getMinY())]), null);
},
createLineString: function () {
if (arguments.length === 0) {
return this.createLineString(this.getCoordinateSequenceFactory().create([]));
} else if (arguments.length === 1) {
if (arguments[0] instanceof Array) {
let coordinates = arguments[0];
return this.createLineString(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_13__CoordinateSequence__["a" /* default */])) {
let coordinates = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_1__LineString__["a" /* default */](coordinates, this);
}
}
},
createMultiLineString: function () {
if (arguments.length === 0) {
return new __WEBPACK_IMPORTED_MODULE_18__MultiLineString__["a" /* default */](null, this);
} else if (arguments.length === 1) {
let lineStrings = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_18__MultiLineString__["a" /* default */](lineStrings, this);
}
},
buildGeometry: function (geomList) {
var geomClass = null;
var isHeterogeneous = false;
var hasGeometryCollection = false;
for (var i = geomList.iterator(); i.hasNext(); ) {
var geom = i.next();
var partClass = geom.getClass();
if (geomClass === null) {
geomClass = partClass;
}
if (partClass !== geomClass) {
isHeterogeneous = true;
}
if (geom.isGeometryCollectionOrDerived()) hasGeometryCollection = true;
}
if (geomClass === null) {
return this.createGeometryCollection();
}
if (isHeterogeneous || hasGeometryCollection) {
return this.createGeometryCollection(GeometryFactory.toGeometryArray(geomList));
}
var geom0 = geomList.iterator().next();
var isCollection = geomList.size() > 1;
if (isCollection) {
if (geom0 instanceof __WEBPACK_IMPORTED_MODULE_5__Polygon__["a" /* default */]) {
return this.createMultiPolygon(GeometryFactory.toPolygonArray(geomList));
} else if (geom0 instanceof __WEBPACK_IMPORTED_MODULE_1__LineString__["a" /* default */]) {
return this.createMultiLineString(GeometryFactory.toLineStringArray(geomList));
} else if (geom0 instanceof __WEBPACK_IMPORTED_MODULE_4__Point__["a" /* default */]) {
return this.createMultiPoint(GeometryFactory.toPointArray(geomList));
}
__WEBPACK_IMPORTED_MODULE_17__util_Assert__["a" /* default */].shouldNeverReachHere("Unhandled class: " + geom0.getClass().getName());
}
return geom0;
},
createMultiPointFromCoords: function (coordinates) {
return this.createMultiPoint(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
},
createPoint: function () {
if (arguments.length === 0) {
return this.createPoint(this.getCoordinateSequenceFactory().create([]));
} else if (arguments.length === 1) {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__Coordinate__["a" /* default */]) {
let coordinate = arguments[0];
return this.createPoint(coordinate !== null ? this.getCoordinateSequenceFactory().create([coordinate]) : null);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_13__CoordinateSequence__["a" /* default */])) {
let coordinates = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_4__Point__["a" /* default */](coordinates, this);
}
}
},
getCoordinateSequenceFactory: function () {
return this._coordinateSequenceFactory;
},
createPolygon: function () {
if (arguments.length === 0) {
return new __WEBPACK_IMPORTED_MODULE_5__Polygon__["a" /* default */](null, null, this);
} else if (arguments.length === 1) {
if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_13__CoordinateSequence__["a" /* default */])) {
let coordinates = arguments[0];
return this.createPolygon(this.createLinearRing(coordinates));
} else if (arguments[0] instanceof Array) {
let coordinates = arguments[0];
return this.createPolygon(this.createLinearRing(coordinates));
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_8__LinearRing__["a" /* default */]) {
let shell = arguments[0];
return this.createPolygon(shell, null);
}
} else if (arguments.length === 2) {
let shell = arguments[0], holes = arguments[1];
return new __WEBPACK_IMPORTED_MODULE_5__Polygon__["a" /* default */](shell, holes, this);
}
},
getSRID: function () {
return this._SRID;
},
createGeometryCollection: function () {
if (arguments.length === 0) {
return new __WEBPACK_IMPORTED_MODULE_14__GeometryCollection__["a" /* default */](null, this);
} else if (arguments.length === 1) {
let geometries = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_14__GeometryCollection__["a" /* default */](geometries, this);
}
},
createGeometry: function (g) {
var editor = new __WEBPACK_IMPORTED_MODULE_7__util_GeometryEditor__["a" /* default */](this);
return editor.edit(g, {
edit: function () {
if (arguments.length === 2) {
let coordSeq = arguments[0], geometry = arguments[1];
return this._coordinateSequenceFactory.create(coordSeq);
}
}
});
},
getPrecisionModel: function () {
return this._precisionModel;
},
createLinearRing: function () {
if (arguments.length === 0) {
return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));
} else if (arguments.length === 1) {
if (arguments[0] instanceof Array) {
let coordinates = arguments[0];
return this.createLinearRing(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_13__CoordinateSequence__["a" /* default */])) {
let coordinates = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_8__LinearRing__["a" /* default */](coordinates, this);
}
}
},
createMultiPolygon: function () {
if (arguments.length === 0) {
return new __WEBPACK_IMPORTED_MODULE_11__MultiPolygon__["a" /* default */](null, this);
} else if (arguments.length === 1) {
let polygons = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_11__MultiPolygon__["a" /* default */](polygons, this);
}
},
createMultiPoint: function () {
if (arguments.length === 0) {
return new __WEBPACK_IMPORTED_MODULE_6__MultiPoint__["a" /* default */](null, this);
} else if (arguments.length === 1) {
if (arguments[0] instanceof Array) {
let point = arguments[0];
return new __WEBPACK_IMPORTED_MODULE_6__MultiPoint__["a" /* default */](point, this);
} else if (arguments[0] instanceof Array) {
let coordinates = arguments[0];
return this.createMultiPoint(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_13__CoordinateSequence__["a" /* default */])) {
let coordinates = arguments[0];
if (coordinates === null) {
return this.createMultiPoint(new Array(0).fill(null));
}
var points = new Array(coordinates.size()).fill(null);
for (var i = 0; i < coordinates.size(); i++) {
var ptSeq = this.getCoordinateSequenceFactory().create(1, coordinates.getDimension());
__WEBPACK_IMPORTED_MODULE_12__CoordinateSequences__["a" /* default */].copy(coordinates, i, ptSeq, 0, 1);
points[i] = this.createPoint(ptSeq);
}
return this.createMultiPoint(points);
}
}
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_16__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return GeometryFactory;
}
});
GeometryFactory.toMultiPolygonArray = function (multiPolygons) {
var multiPolygonArray = new Array(multiPolygons.size()).fill(null);
return multiPolygons.toArray(multiPolygonArray);
};
GeometryFactory.toGeometryArray = function (geometries) {
if (geometries === null) return null;
var geometryArray = new Array(geometries.size()).fill(null);
return geometries.toArray(geometryArray);
};
GeometryFactory.getDefaultCoordinateSequenceFactory = function () {
return __WEBPACK_IMPORTED_MODULE_10__impl_CoordinateArraySequenceFactory__["a" /* default */].instance();
};
GeometryFactory.toMultiLineStringArray = function (multiLineStrings) {
var multiLineStringArray = new Array(multiLineStrings.size()).fill(null);
return multiLineStrings.toArray(multiLineStringArray);
};
GeometryFactory.toLineStringArray = function (lineStrings) {
var lineStringArray = new Array(lineStrings.size()).fill(null);
return lineStrings.toArray(lineStringArray);
};
GeometryFactory.toMultiPointArray = function (multiPoints) {
var multiPointArray = new Array(multiPoints.size()).fill(null);
return multiPoints.toArray(multiPointArray);
};
GeometryFactory.toLinearRingArray = function (linearRings) {
var linearRingArray = new Array(linearRings.size()).fill(null);
return linearRings.toArray(linearRingArray);
};
GeometryFactory.toPointArray = function (points) {
var pointArray = new Array(points.size()).fill(null);
return points.toArray(pointArray);
};
GeometryFactory.toPolygonArray = function (polygons) {
var polygonArray = new Array(polygons.size()).fill(null);
return polygons.toArray(polygonArray);
};
GeometryFactory.createPointFromInternalCoord = function (coord, exemplar) {
exemplar.getPrecisionModel().makePrecise(coord);
return exemplar.getFactory().createPoint(coord);
};
GeometryFactory.serialVersionUID = -6820524753094095635;
/***/ }),
/* 16 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Polygon;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__ = __webpack_require__(58);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__CoordinateFilter__ = __webpack_require__(50);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__GeometryComponentFilter__ = __webpack_require__(31);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Polygonal__ = __webpack_require__(40);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__GeometryFilter__ = __webpack_require__(39);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__CoordinateSequenceFilter__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__inherits__ = __webpack_require__(3);
function Polygon() {
this._shell = null;
this._holes = null;
let shell = arguments[0], holes = arguments[1], factory = arguments[2];
__WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].call(this, factory);
if (shell === null) {
shell = this.getFactory().createLinearRing();
}
if (holes === null) {
holes = [];
}
if (__WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].hasNullElements(holes)) {
throw new __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__["a" /* default */]("holes must not contain null elements");
}
if (shell.isEmpty() && __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].hasNonEmptyElements(holes)) {
throw new __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__["a" /* default */]("shell is empty but holes are not");
}
this._shell = shell;
this._holes = holes;
}
Object(__WEBPACK_IMPORTED_MODULE_13__inherits__["a" /* default */])(Polygon, __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_6__extend__["a" /* default */])(Polygon.prototype, {
computeEnvelopeInternal: function () {
return this._shell.getEnvelopeInternal();
},
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].SORTINDEX_POLYGON;
},
getCoordinates: function () {
if (this.isEmpty()) {
return [];
}
var coordinates = new Array(this.getNumPoints()).fill(null);
var k = -1;
var shellCoordinates = this._shell.getCoordinates();
for (var x = 0; x < shellCoordinates.length; x++) {
k++;
coordinates[k] = shellCoordinates[x];
}
for (var i = 0; i < this._holes.length; i++) {
var childCoordinates = this._holes[i].getCoordinates();
for (var j = 0; j < childCoordinates.length; j++) {
k++;
coordinates[k] = childCoordinates[j];
}
}
return coordinates;
},
getArea: function () {
var area = 0.0;
area += Math.abs(__WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].signedArea(this._shell.getCoordinateSequence()));
for (var i = 0; i < this._holes.length; i++) {
area -= Math.abs(__WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].signedArea(this._holes[i].getCoordinateSequence()));
}
return area;
},
isRectangle: function () {
if (this.getNumInteriorRing() !== 0) return false;
if (this._shell === null) return false;
if (this._shell.getNumPoints() !== 5) return false;
var seq = this._shell.getCoordinateSequence();
var env = this.getEnvelopeInternal();
for (var i = 0; i < 5; i++) {
var x = seq.getX(i);
if (!(x === env.getMinX() || x === env.getMaxX())) return false;
var y = seq.getY(i);
if (!(y === env.getMinY() || y === env.getMaxY())) return false;
}
var prevX = seq.getX(0);
var prevY = seq.getY(0);
for (var i = 1; i <= 4; i++) {
var x = seq.getX(i);
var y = seq.getY(i);
var xChanged = x !== prevX;
var yChanged = y !== prevY;
if (xChanged === yChanged) return false;
prevX = x;
prevY = y;
}
return true;
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
var otherPolygon = other;
var thisShell = this._shell;
var otherPolygonShell = otherPolygon._shell;
if (!thisShell.equalsExact(otherPolygonShell, tolerance)) {
return false;
}
if (this._holes.length !== otherPolygon._holes.length) {
return false;
}
for (var i = 0; i < this._holes.length; i++) {
if (!this._holes[i].equalsExact(otherPolygon._holes[i], tolerance)) {
return false;
}
}
return true;
} else return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
normalize: function () {
if (arguments.length === 0) {
this.normalize(this._shell, true);
for (var i = 0; i < this._holes.length; i++) {
this.normalize(this._holes[i], false);
}
__WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__["a" /* default */].sort(this._holes);
} else if (arguments.length === 2) {
let ring = arguments[0], clockwise = arguments[1];
if (ring.isEmpty()) {
return null;
}
var uniqueCoordinates = new Array(ring.getCoordinates().length - 1).fill(null);
__WEBPACK_IMPORTED_MODULE_7__java_lang_System__["a" /* default */].arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length);
var minCoordinate = __WEBPACK_IMPORTED_MODULE_9__CoordinateArrays__["a" /* default */].minCoordinate(ring.getCoordinates());
__WEBPACK_IMPORTED_MODULE_9__CoordinateArrays__["a" /* default */].scroll(uniqueCoordinates, minCoordinate);
__WEBPACK_IMPORTED_MODULE_7__java_lang_System__["a" /* default */].arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length);
ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0];
if (__WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].isCCW(ring.getCoordinates()) === clockwise) {
__WEBPACK_IMPORTED_MODULE_9__CoordinateArrays__["a" /* default */].reverse(ring.getCoordinates());
}
}
},
getCoordinate: function () {
return this._shell.getCoordinate();
},
getNumInteriorRing: function () {
return this._holes.length;
},
getBoundaryDimension: function () {
return 1;
},
getDimension: function () {
return 2;
},
getLength: function () {
var len = 0.0;
len += this._shell.getLength();
for (var i = 0; i < this._holes.length; i++) {
len += this._holes[i].getLength();
}
return len;
},
getNumPoints: function () {
var numPoints = this._shell.getNumPoints();
for (var i = 0; i < this._holes.length; i++) {
numPoints += this._holes[i].getNumPoints();
}
return numPoints;
},
reverse: function () {
var poly = this.copy();
poly._shell = this._shell.copy().reverse();
poly._holes = new Array(this._holes.length).fill(null);
for (var i = 0; i < this._holes.length; i++) {
poly._holes[i] = this._holes[i].copy().reverse();
}
return poly;
},
convexHull: function () {
return this.getExteriorRing().convexHull();
},
compareToSameClass: function () {
if (arguments.length === 1) {
let o = arguments[0];
var thisShell = this._shell;
var otherShell = o._shell;
return thisShell.compareToSameClass(otherShell);
} else if (arguments.length === 2) {
let o = arguments[0], comp = arguments[1];
var poly = o;
var thisShell = this._shell;
var otherShell = poly._shell;
var shellComp = thisShell.compareToSameClass(otherShell, comp);
if (shellComp !== 0) return shellComp;
var nHole1 = this.getNumInteriorRing();
var nHole2 = poly.getNumInteriorRing();
var i = 0;
while (i < nHole1 && i < nHole2) {
var thisHole = this.getInteriorRingN(i);
var otherHole = poly.getInteriorRingN(i);
var holeComp = thisHole.compareToSameClass(otherHole, comp);
if (holeComp !== 0) return holeComp;
i++;
}
if (i < nHole1) return 1;
if (i < nHole2) return -1;
return 0;
}
},
apply: function () {
if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_3__CoordinateFilter__["a" /* default */])) {
let filter = arguments[0];
this._shell.apply(filter);
for (var i = 0; i < this._holes.length; i++) {
this._holes[i].apply(filter);
}
} else if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_12__CoordinateSequenceFilter__["a" /* default */])) {
let filter = arguments[0];
this._shell.apply(filter);
if (!filter.isDone()) {
for (var i = 0; i < this._holes.length; i++) {
this._holes[i].apply(filter);
if (filter.isDone()) break;
}
}
if (filter.isGeometryChanged()) this.geometryChanged();
} else if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_11__GeometryFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
} else if (Object(__WEBPACK_IMPORTED_MODULE_4__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_8__GeometryComponentFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
this._shell.apply(filter);
for (var i = 0; i < this._holes.length; i++) {
this._holes[i].apply(filter);
}
}
},
getBoundary: function () {
if (this.isEmpty()) {
return this.getFactory().createMultiLineString();
}
var rings = new Array(this._holes.length + 1).fill(null);
rings[0] = this._shell;
for (var i = 0; i < this._holes.length; i++) {
rings[i + 1] = this._holes[i];
}
if (rings.length <= 1) return this.getFactory().createLinearRing(rings[0].getCoordinateSequence());
return this.getFactory().createMultiLineString(rings);
},
clone: function () {
var poly = __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].prototype.clone.call(this);
poly._shell = this._shell.clone();
poly._holes = new Array(this._holes.length).fill(null);
for (var i = 0; i < this._holes.length; i++) {
poly._holes[i] = this._holes[i].clone();
}
return poly;
},
getGeometryType: function () {
return "Polygon";
},
copy: function () {
var shell = this._shell.copy();
var holes = new Array(this._holes.length).fill(null);
for (var i = 0; i < holes.length; i++) {
holes[i] = this._holes[i].copy();
}
return new Polygon(shell, holes, this._factory);
},
getExteriorRing: function () {
return this._shell;
},
isEmpty: function () {
return this._shell.isEmpty();
},
getInteriorRingN: function (n) {
return this._holes[n];
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_10__Polygonal__["a" /* default */]];
},
getClass: function () {
return Polygon;
}
});
Polygon.serialVersionUID = -3494792200821764533;
/***/ }),
/* 17 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Position;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Position() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Position.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Position;
}
});
Position.opposite = function (position) {
if (position === Position.LEFT) return Position.RIGHT;
if (position === Position.RIGHT) return Position.LEFT;
return position;
};
Position.ON = 0;
Position.LEFT = 1;
Position.RIGHT = 2;
/***/ }),
/* 18 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateList;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__inherits__ = __webpack_require__(3);
function CoordinateList() {
__WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */].apply(this);
if (arguments.length === 0) {} else if (arguments.length === 1) {
let coord = arguments[0];
this.ensureCapacity(coord.length);
this.add(coord, true);
} else if (arguments.length === 2) {
let coord = arguments[0], allowRepeated = arguments[1];
this.ensureCapacity(coord.length);
this.add(coord, allowRepeated);
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__inherits__["a" /* default */])(CoordinateList, __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(CoordinateList.prototype, {
getCoordinate: function (i) {
return this.get(i);
},
addAll: function () {
if (arguments.length === 2) {
let coll = arguments[0], allowRepeated = arguments[1];
var isChanged = false;
for (var i = coll.iterator(); i.hasNext(); ) {
this.add(i.next(), allowRepeated);
isChanged = true;
}
return isChanged;
} else return __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */].prototype.addAll.apply(this, arguments);
},
clone: function () {
var clone = __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */].prototype.clone.call(this);
for (var i = 0; i < this.size(); i++) {
clone.add(i, this.get(i).copy());
}
return clone;
},
toCoordinateArray: function () {
return this.toArray(CoordinateList.coordArrayType);
},
add: function () {
if (arguments.length === 1) {
let coord = arguments[0];
__WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */].prototype.add.call(this, coord);
} else if (arguments.length === 2) {
if (arguments[0] instanceof Array && typeof arguments[1] === "boolean") {
let coord = arguments[0], allowRepeated = arguments[1];
this.add(coord, allowRepeated, true);
return true;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */] && typeof arguments[1] === "boolean") {
let coord = arguments[0], allowRepeated = arguments[1];
if (!allowRepeated) {
if (this.size() >= 1) {
var last = this.get(this.size() - 1);
if (last.equals2D(coord)) return null;
}
}
__WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */].prototype.add.call(this, coord);
} else if (arguments[0] instanceof Object && typeof arguments[1] === "boolean") {
let obj = arguments[0], allowRepeated = arguments[1];
this.add(obj, allowRepeated);
return true;
}
} else if (arguments.length === 3) {
if (typeof arguments[2] === "boolean" && (arguments[0] instanceof Array && typeof arguments[1] === "boolean")) {
let coord = arguments[0], allowRepeated = arguments[1], direction = arguments[2];
if (direction) {
for (var i = 0; i < coord.length; i++) {
this.add(coord[i], allowRepeated);
}
} else {
for (var i = coord.length - 1; i >= 0; i--) {
this.add(coord[i], allowRepeated);
}
}
return true;
} else if (typeof arguments[2] === "boolean" && (Number.isInteger(arguments[0]) && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */])) {
let i = arguments[0], coord = arguments[1], allowRepeated = arguments[2];
if (!allowRepeated) {
var size = this.size();
if (size > 0) {
if (i > 0) {
var prev = this.get(i - 1);
if (prev.equals2D(coord)) return null;
}
if (i < size) {
var next = this.get(i);
if (next.equals2D(coord)) return null;
}
}
}
__WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */].prototype.add.call(this, i, coord);
}
} else if (arguments.length === 4) {
let coord = arguments[0], allowRepeated = arguments[1], start = arguments[2], end = arguments[3];
var inc = 1;
if (start > end) inc = -1;
for (var i = start; i !== end; i += inc) {
this.add(coord[i], allowRepeated);
}
return true;
}
},
closeRing: function () {
if (this.size() > 0) this.add(new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */](this.get(0)), false);
},
interfaces_: function () {
return [];
},
getClass: function () {
return CoordinateList;
}
});
CoordinateList.coordArrayType = new Array(0).fill(null);
/***/ }),
/* 19 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateArrays;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_MathUtil__ = __webpack_require__(88);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_util_Comparator__ = __webpack_require__(48);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Envelope__ = __webpack_require__(7);
function CoordinateArrays() {}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(CoordinateArrays.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return CoordinateArrays;
}
});
CoordinateArrays.isRing = function (pts) {
if (pts.length < 4) return false;
if (!pts[0].equals2D(pts[pts.length - 1])) return false;
return true;
};
CoordinateArrays.ptNotInList = function (testPts, pts) {
for (var i = 0; i < testPts.length; i++) {
var testPt = testPts[i];
if (CoordinateArrays.indexOf(testPt, pts) < 0) return testPt;
}
return null;
};
CoordinateArrays.scroll = function (coordinates, firstCoordinate) {
var i = CoordinateArrays.indexOf(firstCoordinate, coordinates);
if (i < 0) return null;
var newCoordinates = new Array(coordinates.length).fill(null);
__WEBPACK_IMPORTED_MODULE_4__java_lang_System__["a" /* default */].arraycopy(coordinates, i, newCoordinates, 0, coordinates.length - i);
__WEBPACK_IMPORTED_MODULE_4__java_lang_System__["a" /* default */].arraycopy(coordinates, 0, newCoordinates, coordinates.length - i, i);
__WEBPACK_IMPORTED_MODULE_4__java_lang_System__["a" /* default */].arraycopy(newCoordinates, 0, coordinates, 0, coordinates.length);
};
CoordinateArrays.equals = function () {
if (arguments.length === 2) {
let coord1 = arguments[0], coord2 = arguments[1];
if (coord1 === coord2) return true;
if (coord1 === null || coord2 === null) return false;
if (coord1.length !== coord2.length) return false;
for (var i = 0; i < coord1.length; i++) {
if (!coord1[i].equals(coord2[i])) return false;
}
return true;
} else if (arguments.length === 3) {
let coord1 = arguments[0], coord2 = arguments[1], coordinateComparator = arguments[2];
if (coord1 === coord2) return true;
if (coord1 === null || coord2 === null) return false;
if (coord1.length !== coord2.length) return false;
for (var i = 0; i < coord1.length; i++) {
if (coordinateComparator.compare(coord1[i], coord2[i]) !== 0) return false;
}
return true;
}
};
CoordinateArrays.intersection = function (coordinates, env) {
var coordList = new __WEBPACK_IMPORTED_MODULE_0__CoordinateList__["a" /* default */]();
for (var i = 0; i < coordinates.length; i++) {
if (env.intersects(coordinates[i])) coordList.add(coordinates[i], true);
}
return coordList.toCoordinateArray();
};
CoordinateArrays.hasRepeatedPoints = function (coord) {
for (var i = 1; i < coord.length; i++) {
if (coord[i - 1].equals(coord[i])) {
return true;
}
}
return false;
};
CoordinateArrays.removeRepeatedPoints = function (coord) {
if (!CoordinateArrays.hasRepeatedPoints(coord)) return coord;
var coordList = new __WEBPACK_IMPORTED_MODULE_0__CoordinateList__["a" /* default */](coord, false);
return coordList.toCoordinateArray();
};
CoordinateArrays.reverse = function (coord) {
var last = coord.length - 1;
var mid = Math.trunc(last / 2);
for (var i = 0; i <= mid; i++) {
var tmp = coord[i];
coord[i] = coord[last - i];
coord[last - i] = tmp;
}
};
CoordinateArrays.removeNull = function (coord) {
var nonNull = 0;
for (var i = 0; i < coord.length; i++) {
if (coord[i] !== null) nonNull++;
}
var newCoord = new Array(nonNull).fill(null);
if (nonNull === 0) return newCoord;
var j = 0;
for (var i = 0; i < coord.length; i++) {
if (coord[i] !== null) newCoord[j++] = coord[i];
}
return newCoord;
};
CoordinateArrays.copyDeep = function () {
if (arguments.length === 1) {
let coordinates = arguments[0];
var copy = new Array(coordinates.length).fill(null);
for (var i = 0; i < coordinates.length; i++) {
copy[i] = new __WEBPACK_IMPORTED_MODULE_1__Coordinate__["a" /* default */](coordinates[i]);
}
return copy;
} else if (arguments.length === 5) {
let src = arguments[0], srcStart = arguments[1], dest = arguments[2], destStart = arguments[3], length = arguments[4];
for (var i = 0; i < length; i++) {
dest[destStart + i] = new __WEBPACK_IMPORTED_MODULE_1__Coordinate__["a" /* default */](src[srcStart + i]);
}
}
};
CoordinateArrays.isEqualReversed = function (pts1, pts2) {
for (var i = 0; i < pts1.length; i++) {
var p1 = pts1[i];
var p2 = pts2[pts1.length - i - 1];
if (p1.compareTo(p2) !== 0) return false;
}
return true;
};
CoordinateArrays.envelope = function (coordinates) {
var env = new __WEBPACK_IMPORTED_MODULE_6__Envelope__["a" /* default */]();
for (var i = 0; i < coordinates.length; i++) {
env.expandToInclude(coordinates[i]);
}
return env;
};
CoordinateArrays.toCoordinateArray = function (coordList) {
return coordList.toArray(CoordinateArrays.coordArrayType);
};
CoordinateArrays.atLeastNCoordinatesOrNothing = function (n, c) {
return c.length >= n ? c : [];
};
CoordinateArrays.indexOf = function (coordinate, coordinates) {
for (var i = 0; i < coordinates.length; i++) {
if (coordinate.equals(coordinates[i])) {
return i;
}
}
return -1;
};
CoordinateArrays.increasingDirection = function (pts) {
for (var i = 0; i < Math.trunc(pts.length / 2); i++) {
var j = pts.length - 1 - i;
var comp = pts[i].compareTo(pts[j]);
if (comp !== 0) return comp;
}
return 1;
};
CoordinateArrays.compare = function (pts1, pts2) {
var i = 0;
while (i < pts1.length && i < pts2.length) {
var compare = pts1[i].compareTo(pts2[i]);
if (compare !== 0) return compare;
i++;
}
if (i < pts2.length) return -1;
if (i < pts1.length) return 1;
return 0;
};
CoordinateArrays.minCoordinate = function (coordinates) {
var minCoord = null;
for (var i = 0; i < coordinates.length; i++) {
if (minCoord === null || minCoord.compareTo(coordinates[i]) > 0) {
minCoord = coordinates[i];
}
}
return minCoord;
};
CoordinateArrays.extract = function (pts, start, end) {
start = __WEBPACK_IMPORTED_MODULE_3__math_MathUtil__["a" /* default */].clamp(start, 0, pts.length);
end = __WEBPACK_IMPORTED_MODULE_3__math_MathUtil__["a" /* default */].clamp(end, -1, pts.length);
var npts = end - start + 1;
if (end < 0) npts = 0;
if (start >= pts.length) npts = 0;
if (end < start) npts = 0;
var extractPts = new Array(npts).fill(null);
if (npts === 0) return extractPts;
var iPts = 0;
for (var i = start; i <= end; i++) {
extractPts[iPts++] = pts[i];
}
return extractPts;
};
function ForwardComparator() {}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(ForwardComparator.prototype, {
compare: function (o1, o2) {
var pts1 = o1;
var pts2 = o2;
return CoordinateArrays.compare(pts1, pts2);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_5__java_util_Comparator__["a" /* default */]];
},
getClass: function () {
return ForwardComparator;
}
});
function BidirectionalComparator() {}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(BidirectionalComparator.prototype, {
compare: function (o1, o2) {
var pts1 = o1;
var pts2 = o2;
if (pts1.length < pts2.length) return -1;
if (pts1.length > pts2.length) return 1;
if (pts1.length === 0) return 0;
var forwardComp = CoordinateArrays.compare(pts1, pts2);
var isEqualRev = CoordinateArrays.isEqualReversed(pts1, pts2);
if (isEqualRev) return 0;
return forwardComp;
},
OLDcompare: function (o1, o2) {
var pts1 = o1;
var pts2 = o2;
if (pts1.length < pts2.length) return -1;
if (pts1.length > pts2.length) return 1;
if (pts1.length === 0) return 0;
var dir1 = CoordinateArrays.increasingDirection(pts1);
var dir2 = CoordinateArrays.increasingDirection(pts2);
var i1 = dir1 > 0 ? 0 : pts1.length - 1;
var i2 = dir2 > 0 ? 0 : pts1.length - 1;
for (var i = 0; i < pts1.length; i++) {
var comparePt = pts1[i1].compareTo(pts2[i2]);
if (comparePt !== 0) return comparePt;
i1 += dir1;
i2 += dir2;
}
return 0;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_5__java_util_Comparator__["a" /* default */]];
},
getClass: function () {
return BidirectionalComparator;
}
});
CoordinateArrays.ForwardComparator = ForwardComparator;
CoordinateArrays.BidirectionalComparator = BidirectionalComparator;
CoordinateArrays.coordArrayType = new Array(0).fill(null);
/***/ }),
/* 20 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Comparable;
function Comparable () {}
/***/ }),
/* 21 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Serializable;
function Serializable () {}
/***/ }),
/* 22 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = RobustLineIntersector;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__NotRepresentableException__ = __webpack_require__(54);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CGAlgorithmsDD__ = __webpack_require__(115);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__HCoordinate__ = __webpack_require__(56);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__LineIntersector__ = __webpack_require__(209);
function RobustLineIntersector() {
__WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].apply(this);
}
Object(__WEBPACK_IMPORTED_MODULE_8__inherits__["a" /* default */])(RobustLineIntersector, __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(RobustLineIntersector.prototype, {
isInSegmentEnvelopes: function (intPt) {
var env0 = new __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */](this._inputLines[0][0], this._inputLines[0][1]);
var env1 = new __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */](this._inputLines[1][0], this._inputLines[1][1]);
return env0.contains(intPt) && env1.contains(intPt);
},
computeIntersection: function () {
if (arguments.length === 3) {
let p = arguments[0], p1 = arguments[1], p2 = arguments[2];
this._isProper = false;
if (__WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */].intersects(p1, p2, p)) {
if (__WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].orientationIndex(p1, p2, p) === 0 && __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].orientationIndex(p2, p1, p) === 0) {
this._isProper = true;
if (p.equals(p1) || p.equals(p2)) {
this._isProper = false;
}
this._result = __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].POINT_INTERSECTION;
return null;
}
}
this._result = __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].NO_INTERSECTION;
} else return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].prototype.computeIntersection.apply(this, arguments);
},
normalizeToMinimum: function (n1, n2, n3, n4, normPt) {
normPt.x = this.smallestInAbsValue(n1.x, n2.x, n3.x, n4.x);
normPt.y = this.smallestInAbsValue(n1.y, n2.y, n3.y, n4.y);
n1.x -= normPt.x;
n1.y -= normPt.y;
n2.x -= normPt.x;
n2.y -= normPt.y;
n3.x -= normPt.x;
n3.y -= normPt.y;
n4.x -= normPt.x;
n4.y -= normPt.y;
},
safeHCoordinateIntersection: function (p1, p2, q1, q2) {
var intPt = null;
try {
intPt = __WEBPACK_IMPORTED_MODULE_6__HCoordinate__["a" /* default */].intersection(p1, p2, q1, q2);
} catch (e) {
if (e instanceof __WEBPACK_IMPORTED_MODULE_0__NotRepresentableException__["a" /* default */]) {
intPt = RobustLineIntersector.nearestEndpoint(p1, p2, q1, q2);
} else throw e;
} finally {}
return intPt;
},
intersection: function (p1, p2, q1, q2) {
var intPt = this.intersectionWithNormalization(p1, p2, q1, q2);
if (!this.isInSegmentEnvelopes(intPt)) {
intPt = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](RobustLineIntersector.nearestEndpoint(p1, p2, q1, q2));
}
if (this._precisionModel !== null) {
this._precisionModel.makePrecise(intPt);
}
return intPt;
},
smallestInAbsValue: function (x1, x2, x3, x4) {
var x = x1;
var xabs = Math.abs(x);
if (Math.abs(x2) < xabs) {
x = x2;
xabs = Math.abs(x2);
}
if (Math.abs(x3) < xabs) {
x = x3;
xabs = Math.abs(x3);
}
if (Math.abs(x4) < xabs) {
x = x4;
}
return x;
},
checkDD: function (p1, p2, q1, q2, intPt) {
var intPtDD = __WEBPACK_IMPORTED_MODULE_4__CGAlgorithmsDD__["a" /* default */].intersection(p1, p2, q1, q2);
var isIn = this.isInSegmentEnvelopes(intPtDD);
__WEBPACK_IMPORTED_MODULE_5__java_lang_System__["a" /* default */].out.println("DD in env = " + isIn + " --------------------- " + intPtDD);
if (intPt.distance(intPtDD) > 0.0001) {
__WEBPACK_IMPORTED_MODULE_5__java_lang_System__["a" /* default */].out.println("Distance = " + intPt.distance(intPtDD));
}
},
intersectionWithNormalization: function (p1, p2, q1, q2) {
var n1 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](p1);
var n2 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](p2);
var n3 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](q1);
var n4 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](q2);
var normPt = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
this.normalizeToEnvCentre(n1, n2, n3, n4, normPt);
var intPt = this.safeHCoordinateIntersection(n1, n2, n3, n4);
intPt.x += normPt.x;
intPt.y += normPt.y;
return intPt;
},
computeCollinearIntersection: function (p1, p2, q1, q2) {
var p1q1p2 = __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */].intersects(p1, p2, q1);
var p1q2p2 = __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */].intersects(p1, p2, q2);
var q1p1q2 = __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */].intersects(q1, q2, p1);
var q1p2q2 = __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */].intersects(q1, q2, p2);
if (p1q1p2 && p1q2p2) {
this._intPt[0] = q1;
this._intPt[1] = q2;
return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].COLLINEAR_INTERSECTION;
}
if (q1p1q2 && q1p2q2) {
this._intPt[0] = p1;
this._intPt[1] = p2;
return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].COLLINEAR_INTERSECTION;
}
if (p1q1p2 && q1p1q2) {
this._intPt[0] = q1;
this._intPt[1] = p1;
return q1.equals(p1) && !p1q2p2 && !q1p2q2 ? __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].POINT_INTERSECTION : __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].COLLINEAR_INTERSECTION;
}
if (p1q1p2 && q1p2q2) {
this._intPt[0] = q1;
this._intPt[1] = p2;
return q1.equals(p2) && !p1q2p2 && !q1p1q2 ? __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].POINT_INTERSECTION : __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].COLLINEAR_INTERSECTION;
}
if (p1q2p2 && q1p1q2) {
this._intPt[0] = q2;
this._intPt[1] = p1;
return q2.equals(p1) && !p1q1p2 && !q1p2q2 ? __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].POINT_INTERSECTION : __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].COLLINEAR_INTERSECTION;
}
if (p1q2p2 && q1p2q2) {
this._intPt[0] = q2;
this._intPt[1] = p2;
return q2.equals(p2) && !p1q1p2 && !q1p1q2 ? __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].POINT_INTERSECTION : __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].COLLINEAR_INTERSECTION;
}
return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].NO_INTERSECTION;
},
normalizeToEnvCentre: function (n00, n01, n10, n11, normPt) {
var minX0 = n00.x < n01.x ? n00.x : n01.x;
var minY0 = n00.y < n01.y ? n00.y : n01.y;
var maxX0 = n00.x > n01.x ? n00.x : n01.x;
var maxY0 = n00.y > n01.y ? n00.y : n01.y;
var minX1 = n10.x < n11.x ? n10.x : n11.x;
var minY1 = n10.y < n11.y ? n10.y : n11.y;
var maxX1 = n10.x > n11.x ? n10.x : n11.x;
var maxY1 = n10.y > n11.y ? n10.y : n11.y;
var intMinX = minX0 > minX1 ? minX0 : minX1;
var intMaxX = maxX0 < maxX1 ? maxX0 : maxX1;
var intMinY = minY0 > minY1 ? minY0 : minY1;
var intMaxY = maxY0 < maxY1 ? maxY0 : maxY1;
var intMidX = (intMinX + intMaxX) / 2.0;
var intMidY = (intMinY + intMaxY) / 2.0;
normPt.x = intMidX;
normPt.y = intMidY;
n00.x -= normPt.x;
n00.y -= normPt.y;
n01.x -= normPt.x;
n01.y -= normPt.y;
n10.x -= normPt.x;
n10.y -= normPt.y;
n11.x -= normPt.x;
n11.y -= normPt.y;
},
computeIntersect: function (p1, p2, q1, q2) {
this._isProper = false;
if (!__WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */].intersects(p1, p2, q1, q2)) return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].NO_INTERSECTION;
var Pq1 = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].orientationIndex(p1, p2, q1);
var Pq2 = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].orientationIndex(p1, p2, q2);
if (Pq1 > 0 && Pq2 > 0 || Pq1 < 0 && Pq2 < 0) {
return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].NO_INTERSECTION;
}
var Qp1 = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].orientationIndex(q1, q2, p1);
var Qp2 = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].orientationIndex(q1, q2, p2);
if (Qp1 > 0 && Qp2 > 0 || Qp1 < 0 && Qp2 < 0) {
return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].NO_INTERSECTION;
}
var collinear = Pq1 === 0 && Pq2 === 0 && Qp1 === 0 && Qp2 === 0;
if (collinear) {
return this.computeCollinearIntersection(p1, p2, q1, q2);
}
if (Pq1 === 0 || Pq2 === 0 || Qp1 === 0 || Qp2 === 0) {
this._isProper = false;
if (p1.equals2D(q1) || p1.equals2D(q2)) {
this._intPt[0] = p1;
} else if (p2.equals2D(q1) || p2.equals2D(q2)) {
this._intPt[0] = p2;
} else if (Pq1 === 0) {
this._intPt[0] = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](q1);
} else if (Pq2 === 0) {
this._intPt[0] = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](q2);
} else if (Qp1 === 0) {
this._intPt[0] = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](p1);
} else if (Qp2 === 0) {
this._intPt[0] = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */](p2);
}
} else {
this._isProper = true;
this._intPt[0] = this.intersection(p1, p2, q1, q2);
}
return __WEBPACK_IMPORTED_MODULE_9__LineIntersector__["a" /* default */].POINT_INTERSECTION;
},
interfaces_: function () {
return [];
},
getClass: function () {
return RobustLineIntersector;
}
});
RobustLineIntersector.nearestEndpoint = function (p1, p2, q1, q2) {
var nearestPt = p1;
var minDist = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].distancePointLine(p1, q1, q2);
var dist = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].distancePointLine(p2, q1, q2);
if (dist < minDist) {
minDist = dist;
nearestPt = p2;
}
dist = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].distancePointLine(q1, p1, p2);
if (dist < minDist) {
minDist = dist;
nearestPt = q1;
}
dist = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].distancePointLine(q2, p1, p2);
if (dist < minDist) {
minDist = dist;
nearestPt = q2;
}
return nearestPt;
};
/***/ }),
/* 23 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = System;
function System () { }
System.arraycopy = (src, srcPos, dest, destPos, len) => {
let c = 0
for (let i = srcPos; i < srcPos + len; i++) {
dest[destPos + c] = src[i]
c++
}
}
System.getProperty = (name) => {
return {
'line.separator': '\n'
}[name]
}
/***/ }),
/* 24 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Collection;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Iterator__ = __webpack_require__(49);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/Collection.html
*
* @constructor
* @private
*/
function Collection() {};
/**
* Ensures that this collection contains the specified element (optional
* operation).
* @param {Object} e
* @return {boolean}
*/
Collection.prototype.add = function() {};
/**
* Appends all of the elements in the specified collection to the end of this
* list, in the order that they are returned by the specified collection's
* iterator (optional operation).
* @param {javascript.util.Collection} c
* @return {boolean}
*/
Collection.prototype.addAll = function() {};
/**
* Returns true if this collection contains no elements.
* @return {boolean}
*/
Collection.prototype.isEmpty = function() {};
/**
* Returns an iterator over the elements in this collection.
* @return {javascript.util.Iterator}
*/
Collection.prototype.iterator = function() {};
/**
* Returns an iterator over the elements in this collection.
* @return {number}
*/
Collection.prototype.size = function() {};
/**
* Returns an array containing all of the elements in this collection.
* @return {Array}
*/
Collection.prototype.toArray = function() {};
/**
* Removes a single instance of the specified element from this collection if it
* is present. (optional)
* @param {Object} e
* @return {boolean}
*/
Collection.prototype.remove = function() {};
/***/ }),
/* 25 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Point;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CoordinateFilter__ = __webpack_require__(50);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__GeometryComponentFilter__ = __webpack_require__(31);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__GeometryFilter__ = __webpack_require__(39);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__CoordinateSequenceFilter__ = __webpack_require__(59);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Puntal__ = __webpack_require__(122);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__inherits__ = __webpack_require__(3);
function Point() {
this._coordinates = null;
let coordinates = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].call(this, factory);
this.init(coordinates);
}
Object(__WEBPACK_IMPORTED_MODULE_11__inherits__["a" /* default */])(Point, __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(Point.prototype, {
computeEnvelopeInternal: function () {
if (this.isEmpty()) {
return new __WEBPACK_IMPORTED_MODULE_9__Envelope__["a" /* default */]();
}
var env = new __WEBPACK_IMPORTED_MODULE_9__Envelope__["a" /* default */]();
env.expandToInclude(this._coordinates.getX(0), this._coordinates.getY(0));
return env;
},
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].SORTINDEX_POINT;
},
getCoordinates: function () {
return this.isEmpty() ? [] : [this.getCoordinate()];
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
if (this.isEmpty() && other.isEmpty()) {
return true;
}
if (this.isEmpty() !== other.isEmpty()) {
return false;
}
return this.equal(other.getCoordinate(), this.getCoordinate(), tolerance);
} else return __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
normalize: function () {},
getCoordinate: function () {
return this._coordinates.size() !== 0 ? this._coordinates.getCoordinate(0) : null;
},
getBoundaryDimension: function () {
return __WEBPACK_IMPORTED_MODULE_5__Dimension__["a" /* default */].FALSE;
},
getDimension: function () {
return 0;
},
getNumPoints: function () {
return this.isEmpty() ? 0 : 1;
},
reverse: function () {
return this.copy();
},
getX: function () {
if (this.getCoordinate() === null) {
throw new IllegalStateException("getX called on empty Point");
}
return this.getCoordinate().x;
},
compareToSameClass: function () {
if (arguments.length === 1) {
let other = arguments[0];
var point = other;
return this.getCoordinate().compareTo(point.getCoordinate());
} else if (arguments.length === 2) {
let other = arguments[0], comp = arguments[1];
var point = other;
return comp.compare(this._coordinates, point._coordinates);
}
},
apply: function () {
if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_1__CoordinateFilter__["a" /* default */])) {
let filter = arguments[0];
if (this.isEmpty()) {
return null;
}
filter.filter(this.getCoordinate());
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_7__CoordinateSequenceFilter__["a" /* default */])) {
let filter = arguments[0];
if (this.isEmpty()) return null;
filter.filter(this._coordinates, 0);
if (filter.isGeometryChanged()) this.geometryChanged();
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_6__GeometryFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_4__GeometryComponentFilter__["a" /* default */])) {
let filter = arguments[0];
filter.filter(this);
}
},
getBoundary: function () {
return this.getFactory().createGeometryCollection(null);
},
clone: function () {
var p = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].prototype.clone.call(this);
p._coordinates = this._coordinates.clone();
return p;
},
getGeometryType: function () {
return "Point";
},
copy: function () {
return new Point(this._coordinates.copy(), this._factory);
},
getCoordinateSequence: function () {
return this._coordinates;
},
getY: function () {
if (this.getCoordinate() === null) {
throw new IllegalStateException("getY called on empty Point");
}
return this.getCoordinate().y;
},
isEmpty: function () {
return this._coordinates.size() === 0;
},
init: function (coordinates) {
if (coordinates === null) {
coordinates = this.getFactory().getCoordinateSequenceFactory().create([]);
}
__WEBPACK_IMPORTED_MODULE_10__util_Assert__["a" /* default */].isTrue(coordinates.size() <= 1);
this._coordinates = coordinates;
},
isSimple: function () {
return true;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_8__Puntal__["a" /* default */]];
},
getClass: function () {
return Point;
}
});
Point.serialVersionUID = 4902022702746614570;
/***/ }),
/* 26 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Label;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__ = __webpack_require__(248);
function Label() {
this.elt = new Array(2).fill(null);
if (arguments.length === 1) {
if (Number.isInteger(arguments[0])) {
let onLoc = arguments[0];
this.elt[0] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](onLoc);
this.elt[1] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](onLoc);
} else if (arguments[0] instanceof Label) {
let lbl = arguments[0];
this.elt[0] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](lbl.elt[0]);
this.elt[1] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](lbl.elt[1]);
}
} else if (arguments.length === 2) {
let geomIndex = arguments[0], onLoc = arguments[1];
this.elt[0] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](__WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE);
this.elt[1] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](__WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE);
this.elt[geomIndex].setLocation(onLoc);
} else if (arguments.length === 3) {
let onLoc = arguments[0], leftLoc = arguments[1], rightLoc = arguments[2];
this.elt[0] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](onLoc, leftLoc, rightLoc);
this.elt[1] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](onLoc, leftLoc, rightLoc);
} else if (arguments.length === 4) {
let geomIndex = arguments[0], onLoc = arguments[1], leftLoc = arguments[2], rightLoc = arguments[3];
this.elt[0] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](__WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE);
this.elt[1] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](__WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE);
this.elt[geomIndex].setLocations(onLoc, leftLoc, rightLoc);
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(Label.prototype, {
getGeometryCount: function () {
var count = 0;
if (!this.elt[0].isNull()) count++;
if (!this.elt[1].isNull()) count++;
return count;
},
setAllLocations: function (geomIndex, location) {
this.elt[geomIndex].setAllLocations(location);
},
isNull: function (geomIndex) {
return this.elt[geomIndex].isNull();
},
setAllLocationsIfNull: function () {
if (arguments.length === 1) {
let location = arguments[0];
this.setAllLocationsIfNull(0, location);
this.setAllLocationsIfNull(1, location);
} else if (arguments.length === 2) {
let geomIndex = arguments[0], location = arguments[1];
this.elt[geomIndex].setAllLocationsIfNull(location);
}
},
isLine: function (geomIndex) {
return this.elt[geomIndex].isLine();
},
merge: function (lbl) {
for (var i = 0; i < 2; i++) {
if (this.elt[i] === null && lbl.elt[i] !== null) {
this.elt[i] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](lbl.elt[i]);
} else {
this.elt[i].merge(lbl.elt[i]);
}
}
},
flip: function () {
this.elt[0].flip();
this.elt[1].flip();
},
getLocation: function () {
if (arguments.length === 1) {
let geomIndex = arguments[0];
return this.elt[geomIndex].get(__WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].ON);
} else if (arguments.length === 2) {
let geomIndex = arguments[0], posIndex = arguments[1];
return this.elt[geomIndex].get(posIndex);
}
},
toString: function () {
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]();
if (this.elt[0] !== null) {
buf.append("A:");
buf.append(this.elt[0].toString());
}
if (this.elt[1] !== null) {
buf.append(" B:");
buf.append(this.elt[1].toString());
}
return buf.toString();
},
isArea: function () {
if (arguments.length === 0) {
return this.elt[0].isArea() || this.elt[1].isArea();
} else if (arguments.length === 1) {
let geomIndex = arguments[0];
return this.elt[geomIndex].isArea();
}
},
isAnyNull: function (geomIndex) {
return this.elt[geomIndex].isAnyNull();
},
setLocation: function () {
if (arguments.length === 2) {
let geomIndex = arguments[0], location = arguments[1];
this.elt[geomIndex].setLocation(__WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].ON, location);
} else if (arguments.length === 3) {
let geomIndex = arguments[0], posIndex = arguments[1], location = arguments[2];
this.elt[geomIndex].setLocation(posIndex, location);
}
},
isEqualOnSide: function (lbl, side) {
return this.elt[0].isEqualOnSide(lbl.elt[0], side) && this.elt[1].isEqualOnSide(lbl.elt[1], side);
},
allPositionsEqual: function (geomIndex, loc) {
return this.elt[geomIndex].allPositionsEqual(loc);
},
toLine: function (geomIndex) {
if (this.elt[geomIndex].isArea()) this.elt[geomIndex] = new __WEBPACK_IMPORTED_MODULE_4__TopologyLocation__["a" /* default */](this.elt[geomIndex].location[0]);
},
interfaces_: function () {
return [];
},
getClass: function () {
return Label;
}
});
Label.toLineLabel = function (label) {
var lineLabel = new Label(__WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE);
for (var i = 0; i < 2; i++) {
lineLabel.setLocation(i, label.getLocation(i));
}
return lineLabel;
};
/***/ }),
/* 27 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = WKTWriter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__WKTParser__ = __webpack_require__(118);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/**
* Writes the Well-Known Text representation of a {@link Geometry}. The
* Well-Known Text format is defined in the OGC Simple Features
* Specification for SQL.
*
* The WKTWriter
outputs coordinates rounded to the precision
* model. Only the maximum number of decimal places necessary to represent the
* ordinates to the required precision will be output.
*
* The SFS WKT spec does not define a special tag for {@link LinearRing}s.
* Under the spec, rings are output as LINESTRING
s.
*/
/**
* @param {GeometryFactory} geometryFactory
* @constructor
*/
function WKTWriter (geometryFactory) {
this.parser = new __WEBPACK_IMPORTED_MODULE_0__WKTParser__["a" /* default */](geometryFactory)
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(WKTWriter.prototype, {
/**
* Converts a Geometry
to its Well-known Text representation.
*
* @param {Geometry} geometry a Geometry
to process.
* @return {string} a string (see the OpenGIS Simple
* Features Specification).
* @memberof WKTWriter
*/
write (geometry) {
return this.parser.write(geometry)
}
})
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(WKTWriter, {
/**
* Generates the WKT for a LINESTRING specified by two
* {@link Coordinate}s.
*
* @param p0 the first coordinate.
* @param p1 the second coordinate.
*
* @return the WKT.
* @private
*/
toLineString (p0, p1) {
if (arguments.length !== 2) {
throw new Error('Not implemented')
}
return 'LINESTRING ( ' + p0.x + ' ' + p0.y + ', ' + p1.x + ' ' + p1.y + ' )'
}
})
/***/ }),
/* 28 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MultiLineString;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__operation_BoundaryOp__ = __webpack_require__(89);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Lineal__ = __webpack_require__(90);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__inherits__ = __webpack_require__(3);
function MultiLineString() {
let lineStrings = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_4__GeometryCollection__["a" /* default */].call(this, lineStrings, factory);
}
Object(__WEBPACK_IMPORTED_MODULE_6__inherits__["a" /* default */])(MultiLineString, __WEBPACK_IMPORTED_MODULE_4__GeometryCollection__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(MultiLineString.prototype, {
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].SORTINDEX_MULTILINESTRING;
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
return __WEBPACK_IMPORTED_MODULE_4__GeometryCollection__["a" /* default */].prototype.equalsExact.call(this, other, tolerance);
} else return __WEBPACK_IMPORTED_MODULE_4__GeometryCollection__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
getBoundaryDimension: function () {
if (this.isClosed()) {
return __WEBPACK_IMPORTED_MODULE_5__Dimension__["a" /* default */].FALSE;
}
return 0;
},
isClosed: function () {
if (this.isEmpty()) {
return false;
}
for (var i = 0; i < this._geometries.length; i++) {
if (!this._geometries[i].isClosed()) {
return false;
}
}
return true;
},
getDimension: function () {
return 1;
},
reverse: function () {
var nLines = this._geometries.length;
var revLines = new Array(nLines).fill(null);
for (var i = 0; i < this._geometries.length; i++) {
revLines[nLines - 1 - i] = this._geometries[i].reverse();
}
return this.getFactory().createMultiLineString(revLines);
},
getBoundary: function () {
return new __WEBPACK_IMPORTED_MODULE_1__operation_BoundaryOp__["a" /* default */](this).getBoundary();
},
getGeometryType: function () {
return "MultiLineString";
},
copy: function () {
var lineStrings = new Array(this._geometries.length).fill(null);
for (var i = 0; i < lineStrings.length; i++) {
lineStrings[i] = this._geometries[i].copy();
}
return new MultiLineString(lineStrings, this._factory);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_3__Lineal__["a" /* default */]];
},
getClass: function () {
return MultiLineString;
}
});
MultiLineString.serialVersionUID = 8166665132445433741;
/***/ }),
/* 29 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LinearRing;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__GeometryFactory__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__CoordinateSequences__ = __webpack_require__(91);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__CoordinateSequence__ = __webpack_require__(37);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__inherits__ = __webpack_require__(3);
function LinearRing() {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_4__Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_3__GeometryFactory__["a" /* default */]) {
let points = arguments[0], factory = arguments[1];
LinearRing.call(this, factory.getCoordinateSequenceFactory().create(points), factory);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_8__CoordinateSequence__["a" /* default */]) && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_3__GeometryFactory__["a" /* default */]) {
let points = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */].call(this, points, factory);
this.validateConstruction();
}
}
Object(__WEBPACK_IMPORTED_MODULE_10__inherits__["a" /* default */])(LinearRing, __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_6__extend__["a" /* default */])(LinearRing.prototype, {
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */].SORTINDEX_LINEARRING;
},
getBoundaryDimension: function () {
return __WEBPACK_IMPORTED_MODULE_9__Dimension__["a" /* default */].FALSE;
},
isClosed: function () {
if (this.isEmpty()) {
return true;
}
return __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */].prototype.isClosed.call(this);
},
reverse: function () {
var seq = this._points.copy();
__WEBPACK_IMPORTED_MODULE_7__CoordinateSequences__["a" /* default */].reverse(seq);
var rev = this.getFactory().createLinearRing(seq);
return rev;
},
validateConstruction: function () {
if (!this.isEmpty() && !__WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */].prototype.isClosed.call(this)) {
throw new __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__["a" /* default */]("Points of LinearRing do not form a closed linestring");
}
if (this.getCoordinateSequence().size() >= 1 && this.getCoordinateSequence().size() < LinearRing.MINIMUM_VALID_SIZE) {
throw new __WEBPACK_IMPORTED_MODULE_5__java_lang_IllegalArgumentException__["a" /* default */]("Invalid number of points in LinearRing (found " + this.getCoordinateSequence().size() + " - must be 0 or >= 4)");
}
},
getGeometryType: function () {
return "LinearRing";
},
copy: function () {
return new LinearRing(this._points.copy(), this._factory);
},
interfaces_: function () {
return [];
},
getClass: function () {
return LinearRing;
}
});
LinearRing.MINIMUM_VALID_SIZE = 4;
LinearRing.serialVersionUID = -4261142084085851829;
/***/ }),
/* 30 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MultiPolygon;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Polygonal__ = __webpack_require__(40);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__inherits__ = __webpack_require__(3);
function MultiPolygon() {
let polygons = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].call(this, polygons, factory);
}
Object(__WEBPACK_IMPORTED_MODULE_5__inherits__["a" /* default */])(MultiPolygon, __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(MultiPolygon.prototype, {
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].SORTINDEX_MULTIPOLYGON;
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
return __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].prototype.equalsExact.call(this, other, tolerance);
} else return __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
getBoundaryDimension: function () {
return 1;
},
getDimension: function () {
return 2;
},
reverse: function () {
var n = this._geometries.length;
var revGeoms = new Array(n).fill(null);
for (var i = 0; i < this._geometries.length; i++) {
revGeoms[i] = this._geometries[i].reverse();
}
return this.getFactory().createMultiPolygon(revGeoms);
},
getBoundary: function () {
if (this.isEmpty()) {
return this.getFactory().createMultiLineString();
}
var allRings = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < this._geometries.length; i++) {
var polygon = this._geometries[i];
var rings = polygon.getBoundary();
for (var j = 0; j < rings.getNumGeometries(); j++) {
allRings.add(rings.getGeometryN(j));
}
}
var allRingsArray = new Array(allRings.size()).fill(null);
return this.getFactory().createMultiLineString(allRings.toArray(allRingsArray));
},
getGeometryType: function () {
return "MultiPolygon";
},
copy: function () {
var polygons = new Array(this._geometries.length).fill(null);
for (var i = 0; i < polygons.length; i++) {
polygons[i] = this._geometries[i].copy();
}
return new MultiPolygon(polygons, this._factory);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_3__Polygonal__["a" /* default */]];
},
getClass: function () {
return MultiPolygon;
}
});
MultiPolygon.serialVersionUID = -551033529766975875;
/***/ }),
/* 31 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryComponentFilter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function GeometryComponentFilter() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(GeometryComponentFilter.prototype, {
filter: function (geom) {},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryComponentFilter;
}
});
/***/ }),
/* 32 */
/***/ (function(module, exports) {
/**
* Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
*
* @name getCoord
* @param {Array|Geometry|Feature} obj Object
* @returns {Array} coordinates
* @example
* var pt = turf.point([10, 10]);
*
* var coord = turf.getCoord(pt);
* //= [10, 10]
*/
function getCoord(obj) {
if (!obj) throw new Error('obj is required');
var coordinates = getCoords(obj);
// getCoord() must contain at least two numbers (Point)
if (coordinates.length > 1 &&
typeof coordinates[0] === 'number' &&
typeof coordinates[1] === 'number') {
return coordinates;
} else {
throw new Error('Coordinate is not a valid Point');
}
}
/**
* Unwrap coordinates from a Feature, Geometry Object or an Array of numbers
*
* @name getCoords
* @param {Array|Geometry|Feature} obj Object
* @returns {Array} coordinates
* @example
* var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);
*
* var coord = turf.getCoords(poly);
* //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]
*/
function getCoords(obj) {
if (!obj) throw new Error('obj is required');
var coordinates;
// Array of numbers
if (obj.length) {
coordinates = obj;
// Geometry Object
} else if (obj.coordinates) {
coordinates = obj.coordinates;
// Feature
} else if (obj.geometry && obj.geometry.coordinates) {
coordinates = obj.geometry.coordinates;
}
// Checks if coordinates contains a number
if (coordinates) {
containsNumber(coordinates);
return coordinates;
}
throw new Error('No valid coordinates');
}
/**
* Checks if coordinates contains a number
*
* @name containsNumber
* @param {Array} coordinates GeoJSON Coordinates
* @returns {boolean} true if Array contains a number
*/
function containsNumber(coordinates) {
if (coordinates.length > 1 &&
typeof coordinates[0] === 'number' &&
typeof coordinates[1] === 'number') {
return true;
}
if (Array.isArray(coordinates[0]) && coordinates[0].length) {
return containsNumber(coordinates[0]);
}
throw new Error('coordinates must only contain numbers');
}
/**
* Enforce expectations about types of GeoJSON objects for Turf.
*
* @name geojsonType
* @param {GeoJSON} value any GeoJSON object
* @param {string} type expected GeoJSON type
* @param {string} name name of calling function
* @throws {Error} if value is not the expected type.
*/
function geojsonType(value, type, name) {
if (!type || !name) throw new Error('type and name required');
if (!value || value.type !== type) {
throw new Error('Invalid input to ' + name + ': must be a ' + type + ', given ' + value.type);
}
}
/**
* Enforce expectations about types of {@link Feature} inputs for Turf.
* Internally this uses {@link geojsonType} to judge geometry types.
*
* @name featureOf
* @param {Feature} feature a feature with an expected geometry type
* @param {string} type expected GeoJSON type
* @param {string} name name of calling function
* @throws {Error} error if value is not the expected type.
*/
function featureOf(feature, type, name) {
if (!feature) throw new Error('No feature passed');
if (!name) throw new Error('.featureOf() requires a name');
if (!feature || feature.type !== 'Feature' || !feature.geometry) {
throw new Error('Invalid input to ' + name + ', Feature with geometry required');
}
if (!feature.geometry || feature.geometry.type !== type) {
throw new Error('Invalid input to ' + name + ': must be a ' + type + ', given ' + feature.geometry.type);
}
}
/**
* Enforce expectations about types of {@link FeatureCollection} inputs for Turf.
* Internally this uses {@link geojsonType} to judge geometry types.
*
* @name collectionOf
* @param {FeatureCollection} featureCollection a FeatureCollection for which features will be judged
* @param {string} type expected GeoJSON type
* @param {string} name name of calling function
* @throws {Error} if value is not the expected type.
*/
function collectionOf(featureCollection, type, name) {
if (!featureCollection) throw new Error('No featureCollection passed');
if (!name) throw new Error('.collectionOf() requires a name');
if (!featureCollection || featureCollection.type !== 'FeatureCollection') {
throw new Error('Invalid input to ' + name + ', FeatureCollection required');
}
for (var i = 0; i < featureCollection.features.length; i++) {
var feature = featureCollection.features[i];
if (!feature || feature.type !== 'Feature' || !feature.geometry) {
throw new Error('Invalid input to ' + name + ', Feature with geometry required');
}
if (!feature.geometry || feature.geometry.type !== type) {
throw new Error('Invalid input to ' + name + ': must be a ' + type + ', given ' + feature.geometry.type);
}
}
}
/**
* Get Geometry from Feature or Geometry Object
*
* @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
* @returns {Geometry|null} GeoJSON Geometry Object
* @throws {Error} if geojson is not a Feature or Geometry Object
* @example
* var point = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [110, 40]
* }
* }
* var geom = turf.getGeom(point)
* //={"type": "Point", "coordinates": [110, 40]}
*/
function getGeom(geojson) {
if (!geojson) throw new Error('geojson is required');
if (geojson.geometry !== undefined) return geojson.geometry;
if (geojson.coordinates || geojson.geometries) return geojson;
throw new Error('geojson must be a valid Feature or Geometry Object');
}
/**
* Get Geometry Type from Feature or Geometry Object
*
* @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
* @returns {string} GeoJSON Geometry Type
* @throws {Error} if geojson is not a Feature or Geometry Object
* @example
* var point = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [110, 40]
* }
* }
* var geom = turf.getGeomType(point)
* //="Point"
*/
function getGeomType(geojson) {
if (!geojson) throw new Error('geojson is required');
var geom = getGeom(geojson);
if (geom) return geom.type;
}
module.exports = {
geojsonType: geojsonType,
collectionOf: collectionOf,
featureOf: featureOf,
getCoord: getCoord,
getCoords: getCoords,
containsNumber: containsNumber,
getGeom: getGeom,
getGeomType: getGeomType
};
/***/ }),
/* 33 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = List;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Collection__ = __webpack_require__(24);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/List.html
*
* @extends {javascript.util.Collection}
* @constructor
* @private
*/
function List() { };
List.prototype = Object.create(__WEBPACK_IMPORTED_MODULE_0__Collection__["a" /* default */].prototype);
List.prototype.constructor = List
/**
* Returns the element at the specified position in this list.
* @param {number} index
* @return {Object}
*/
List.prototype.get = function() { };
/**
* Replaces the element at the specified position in this list with the
* specified element (optional operation).
* @param {number} index
* @param {Object} e
* @return {Object}
*/
List.prototype.set = function() { };
/**
* Returns true if this collection contains no elements.
* @return {boolean}
*/
List.prototype.isEmpty = function() { };
/***/ }),
/* 34 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = StringBuffer;
function StringBuffer (str) {
this.str = str
}
StringBuffer.prototype.append = function (e) {
this.str += e
}
StringBuffer.prototype.setCharAt = function (i, c) {
this.str = this.str.substr(0, i) + c + this.str.substr(i + 1)
}
StringBuffer.prototype.toString = function (e) {
return this.str
}
/***/ }),
/* 35 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = TreeMap;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__SortedMap__ = __webpack_require__(210);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__HashSet__ = __webpack_require__(45);
const BLACK = 0
const RED = 1
function colorOf (p) { return (p == null ? BLACK : p.color) }
function parentOf (p) { return (p == null ? null : p.parent) }
function setColor (p, c) { if (p !== null) p.color = c }
function leftOf (p) { return (p == null ? null : p.left) }
function rightOf (p) { return (p == null ? null : p.right) }
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/TreeMap.html
*
* @extends {SortedMap}
* @constructor
* @private
*/
function TreeMap() {
/**
* @type {Object}
* @private
*/
this.root_ = null;
/**
* @type {number}
* @private
*/
this.size_ = 0;
};
TreeMap.prototype = new __WEBPACK_IMPORTED_MODULE_1__SortedMap__["a" /* default */]();
/**
* @override
*/
TreeMap.prototype.get = function(key) {
var p = this.root_;
while (p !== null) {
var cmp = key['compareTo'](p.key);
if (cmp < 0) {
p = p.left;
} else if (cmp > 0) {
p = p.right;
} else {
return p.value;
}
}
return null;
};
/**
* @override
*/
TreeMap.prototype.put = function(key, value) {
if (this.root_ === null) {
this.root_ = {
key: key,
value: value,
left: null,
right: null,
parent: null,
color: BLACK,
getValue() { return this.value },
getKey() { return this.key }
};
this.size_ = 1;
return null;
}
var t = this.root_, parent, cmp;
do {
parent = t;
cmp = key['compareTo'](t.key);
if (cmp < 0) {
t = t.left;
} else if (cmp > 0) {
t = t.right;
} else {
var oldValue = t.value;
t.value = value;
return oldValue;
}
} while (t !== null);
var e = {
key: key,
left: null,
right: null,
value: value,
parent: parent,
color: BLACK,
getValue() { return this.value },
getKey() { return this.key }
};
if (cmp < 0) {
parent.left = e;
} else {
parent.right = e;
}
this.fixAfterInsertion(e);
this.size_++;
return null;
};
/**
* @param {Object} x
*/
TreeMap.prototype.fixAfterInsertion = function(x) {
x.color = RED;
while (x != null && x != this.root_ && x.parent.color == RED) {
if (parentOf(x) == leftOf(parentOf(parentOf(x)))) {
var y = rightOf(parentOf(parentOf(x)));
if (colorOf(y) == RED) {
setColor(parentOf(x), BLACK);
setColor(y, BLACK);
setColor(parentOf(parentOf(x)), RED);
x = parentOf(parentOf(x));
} else {
if (x == rightOf(parentOf(x))) {
x = parentOf(x);
this.rotateLeft(x);
}
setColor(parentOf(x), BLACK);
setColor(parentOf(parentOf(x)), RED);
this.rotateRight(parentOf(parentOf(x)));
}
} else {
var y = leftOf(parentOf(parentOf(x)));
if (colorOf(y) == RED) {
setColor(parentOf(x), BLACK);
setColor(y, BLACK);
setColor(parentOf(parentOf(x)), RED);
x = parentOf(parentOf(x));
} else {
if (x == leftOf(parentOf(x))) {
x = parentOf(x);
this.rotateRight(x);
}
setColor(parentOf(x), BLACK);
setColor(parentOf(parentOf(x)), RED);
this.rotateLeft(parentOf(parentOf(x)));
}
}
}
this.root_.color = BLACK;
};
/**
* @override
*/
TreeMap.prototype.values = function() {
var arrayList = new __WEBPACK_IMPORTED_MODULE_0__ArrayList__["a" /* default */]();
var p = this.getFirstEntry();
if (p !== null) {
arrayList.add(p.value);
while ((p = TreeMap.successor(p)) !== null) {
arrayList.add(p.value);
}
}
return arrayList;
};
/**
* @override
*/
TreeMap.prototype.entrySet = function() {
var hashSet = new __WEBPACK_IMPORTED_MODULE_2__HashSet__["a" /* default */]();
var p = this.getFirstEntry();
if (p !== null) {
hashSet.add(p);
while ((p = TreeMap.successor(p)) !== null) {
hashSet.add(p);
}
}
return hashSet;
};
/**
* @param {Object} p
*/
TreeMap.prototype.rotateLeft = function(p) {
if (p != null) {
var r = p.right;
p.right = r.left;
if (r.left != null)
r.left.parent = p;
r.parent = p.parent;
if (p.parent == null)
this.root_ = r;
else if (p.parent.left == p)
p.parent.left = r;
else
p.parent.right = r;
r.left = p;
p.parent = r;
}
};
/**
* @param {Object} p
*/
TreeMap.prototype.rotateRight = function(p) {
if (p != null) {
var l = p.left;
p.left = l.right;
if (l.right != null) l.right.parent = p;
l.parent = p.parent;
if (p.parent == null)
this.root_ = l;
else if (p.parent.right == p)
p.parent.right = l;
else p.parent.left = l;
l.right = p;
p.parent = l;
}
};
/**
* @return {Object}
*/
TreeMap.prototype.getFirstEntry = function() {
var p = this.root_;
if (p != null) {
while (p.left != null) {
p = p.left;
}
}
return p;
};
/**
* @param {Object} t
* @return {Object}
* @private
*/
TreeMap.successor = function(t) {
if (t === null)
return null;
else if (t.right !== null) {
var p = t.right;
while (p.left !== null) {
p = p.left;
}
return p;
} else {
var p = t.parent;
var ch = t;
while (p !== null && ch === p.right) {
ch = p;
p = p.parent;
}
return p;
}
};
/**
* @override
*/
TreeMap.prototype.size = function() {
return this.size_;
};
/***/ }),
/* 36 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Arrays__ = __webpack_require__(58);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ArrayList__ = __webpack_require__(1);
const Collections = {
reverseOrder: function () {
return {
compare (a, b) {
return b.compareTo(a)
}
}
},
min: function (l) {
Collections.sort(l)
return l.get(0)
},
sort: function (l, c) {
const a = l.toArray()
if (c) {
__WEBPACK_IMPORTED_MODULE_0__Arrays__["a" /* default */].sort(a, c)
} else {
__WEBPACK_IMPORTED_MODULE_0__Arrays__["a" /* default */].sort(a)
}
const i = l.iterator()
for (let pos = 0, alen = a.length; pos < alen; pos++) {
i.next()
i.set(a[pos])
}
},
singletonList: function (o) {
const arrayList = new __WEBPACK_IMPORTED_MODULE_1__ArrayList__["a" /* default */]()
arrayList.add(o)
return arrayList
}
}
/* harmony default export */ __webpack_exports__["a"] = (Collections);
/***/ }),
/* 37 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateSequence;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_Cloneable__ = __webpack_require__(53);
function CoordinateSequence() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(CoordinateSequence.prototype, {
setOrdinate: function (index, ordinateIndex, value) {},
size: function () {},
getOrdinate: function (index, ordinateIndex) {},
getCoordinate: function () {
if (arguments.length === 1) {
let i = arguments[0];
} else if (arguments.length === 2) {
let index = arguments[0], coord = arguments[1];
}
},
getCoordinateCopy: function (i) {},
getDimension: function () {},
getX: function (index) {},
clone: function () {},
expandEnvelope: function (env) {},
copy: function () {},
getY: function (index) {},
toCoordinateArray: function () {},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_1__java_lang_Cloneable__["a" /* default */]];
},
getClass: function () {
return CoordinateSequence;
}
});
CoordinateSequence.X = 0;
CoordinateSequence.Y = 1;
CoordinateSequence.Z = 2;
CoordinateSequence.M = 3;
/***/ }),
/* 38 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Dimension;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Character__ = __webpack_require__(117);
function Dimension() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Dimension.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Dimension;
}
});
Dimension.toDimensionSymbol = function (dimensionValue) {
switch (dimensionValue) {
case Dimension.FALSE:
return Dimension.SYM_FALSE;
case Dimension.TRUE:
return Dimension.SYM_TRUE;
case Dimension.DONTCARE:
return Dimension.SYM_DONTCARE;
case Dimension.P:
return Dimension.SYM_P;
case Dimension.L:
return Dimension.SYM_L;
case Dimension.A:
return Dimension.SYM_A;
}
throw new __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__["a" /* default */]("Unknown dimension value: " + dimensionValue);
};
Dimension.toDimensionValue = function (dimensionSymbol) {
switch (__WEBPACK_IMPORTED_MODULE_2__java_lang_Character__["a" /* default */].toUpperCase(dimensionSymbol)) {
case Dimension.SYM_FALSE:
return Dimension.FALSE;
case Dimension.SYM_TRUE:
return Dimension.TRUE;
case Dimension.SYM_DONTCARE:
return Dimension.DONTCARE;
case Dimension.SYM_P:
return Dimension.P;
case Dimension.SYM_L:
return Dimension.L;
case Dimension.SYM_A:
return Dimension.A;
}
throw new __WEBPACK_IMPORTED_MODULE_0__java_lang_IllegalArgumentException__["a" /* default */]("Unknown dimension symbol: " + dimensionSymbol);
};
Dimension.P = 0;
Dimension.L = 1;
Dimension.A = 2;
Dimension.FALSE = -1;
Dimension.TRUE = -2;
Dimension.DONTCARE = -3;
Dimension.SYM_FALSE = 'F';
Dimension.SYM_TRUE = 'T';
Dimension.SYM_DONTCARE = '*';
Dimension.SYM_P = '0';
Dimension.SYM_L = '1';
Dimension.SYM_A = '2';
/***/ }),
/* 39 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryFilter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function GeometryFilter() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(GeometryFilter.prototype, {
filter: function (geom) {},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryFilter;
}
});
/***/ }),
/* 40 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Polygonal;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Polygonal() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Polygonal.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Polygonal;
}
});
/***/ }),
/* 41 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MultiPoint;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Puntal__ = __webpack_require__(122);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__inherits__ = __webpack_require__(3);
function MultiPoint() {
let points = arguments[0], factory = arguments[1];
__WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].call(this, points, factory);
}
Object(__WEBPACK_IMPORTED_MODULE_5__inherits__["a" /* default */])(MultiPoint, __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(MultiPoint.prototype, {
getSortIndex: function () {
return __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].SORTINDEX_MULTIPOINT;
},
isValid: function () {
return true;
},
equalsExact: function () {
if (arguments.length === 2) {
let other = arguments[0], tolerance = arguments[1];
if (!this.isEquivalentClass(other)) {
return false;
}
return __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].prototype.equalsExact.call(this, other, tolerance);
} else return __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].prototype.equalsExact.apply(this, arguments);
},
getCoordinate: function () {
if (arguments.length === 1) {
let n = arguments[0];
return this._geometries[n].getCoordinate();
} else return __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */].prototype.getCoordinate.apply(this, arguments);
},
getBoundaryDimension: function () {
return __WEBPACK_IMPORTED_MODULE_3__Dimension__["a" /* default */].FALSE;
},
getDimension: function () {
return 0;
},
getBoundary: function () {
return this.getFactory().createGeometryCollection(null);
},
getGeometryType: function () {
return "MultiPoint";
},
copy: function () {
var points = new Array(this._geometries.length).fill(null);
for (var i = 0; i < points.length; i++) {
points[i] = this._geometries[i].copy();
}
return new MultiPoint(points, this._factory);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_4__Puntal__["a" /* default */]];
},
getClass: function () {
return MultiPoint;
}
});
MultiPoint.serialVersionUID = -8048474874175355449;
/***/ }),
/* 42 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = OverlayOp;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_PointLocator__ = __webpack_require__(62);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geomgraph_EdgeNodingValidator__ = __webpack_require__(231);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_util_GeometryCollectionMapper__ = __webpack_require__(246);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__PolygonBuilder__ = __webpack_require__(132);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__LineBuilder__ = __webpack_require__(249);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__PointBuilder__ = __webpack_require__(250);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__snap_SnapIfNeededOverlayOp__ = __webpack_require__(73);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__geomgraph_Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__OverlayNodeFactory__ = __webpack_require__(101);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__GeometryGraphOperation__ = __webpack_require__(102);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__geomgraph_EdgeList__ = __webpack_require__(143);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__geomgraph_PlanarGraph__ = __webpack_require__(64);
function OverlayOp() {
this._ptLocator = new __WEBPACK_IMPORTED_MODULE_0__algorithm_PointLocator__["a" /* default */]();
this._geomFact = null;
this._resultGeom = null;
this._graph = null;
this._edgeList = new __WEBPACK_IMPORTED_MODULE_13__geomgraph_EdgeList__["a" /* default */]();
this._resultPolyList = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
this._resultLineList = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
this._resultPointList = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
let g0 = arguments[0], g1 = arguments[1];
__WEBPACK_IMPORTED_MODULE_12__GeometryGraphOperation__["a" /* default */].call(this, g0, g1);
this._graph = new __WEBPACK_IMPORTED_MODULE_17__geomgraph_PlanarGraph__["a" /* default */](new __WEBPACK_IMPORTED_MODULE_11__OverlayNodeFactory__["a" /* default */]());
this._geomFact = g0.getFactory();
}
Object(__WEBPACK_IMPORTED_MODULE_16__inherits__["a" /* default */])(OverlayOp, __WEBPACK_IMPORTED_MODULE_12__GeometryGraphOperation__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_9__extend__["a" /* default */])(OverlayOp.prototype, {
insertUniqueEdge: function (e) {
var existingEdge = this._edgeList.findEqualEdge(e);
if (existingEdge !== null) {
var existingLabel = existingEdge.getLabel();
var labelToMerge = e.getLabel();
if (!existingEdge.isPointwiseEqual(e)) {
labelToMerge = new __WEBPACK_IMPORTED_MODULE_10__geomgraph_Label__["a" /* default */](e.getLabel());
labelToMerge.flip();
}
var depth = existingEdge.getDepth();
if (depth.isNull()) {
depth.add(existingLabel);
}
depth.add(labelToMerge);
existingLabel.merge(labelToMerge);
} else {
this._edgeList.add(e);
}
},
getGraph: function () {
return this._graph;
},
cancelDuplicateResultEdges: function () {
for (var it = this._graph.getEdgeEnds().iterator(); it.hasNext(); ) {
var de = it.next();
var sym = de.getSym();
if (de.isInResult() && sym.isInResult()) {
de.setInResult(false);
sym.setInResult(false);
}
}
},
isCoveredByLA: function (coord) {
if (this.isCovered(coord, this._resultLineList)) return true;
if (this.isCovered(coord, this._resultPolyList)) return true;
return false;
},
computeGeometry: function (resultPointList, resultLineList, resultPolyList, opcode) {
var geomList = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
geomList.addAll(resultPointList);
geomList.addAll(resultLineList);
geomList.addAll(resultPolyList);
if (geomList.isEmpty()) return OverlayOp.createEmptyResult(opcode, this._arg[0].getGeometry(), this._arg[1].getGeometry(), this._geomFact);
return this._geomFact.buildGeometry(geomList);
},
mergeSymLabels: function () {
for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext(); ) {
var node = nodeit.next();
node.getEdges().mergeSymLabels();
}
},
isCovered: function (coord, geomList) {
for (var it = geomList.iterator(); it.hasNext(); ) {
var geom = it.next();
var loc = this._ptLocator.locate(coord, geom);
if (loc !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].EXTERIOR) return true;
}
return false;
},
replaceCollapsedEdges: function () {
var newEdges = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
for (var it = this._edgeList.iterator(); it.hasNext(); ) {
var e = it.next();
if (e.isCollapsed()) {
it.remove();
newEdges.add(e.getCollapsedEdge());
}
}
this._edgeList.addAll(newEdges);
},
updateNodeLabelling: function () {
for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext(); ) {
var node = nodeit.next();
var lbl = node.getEdges().getLabel();
node.getLabel().merge(lbl);
}
},
getResultGeometry: function (overlayOpCode) {
this.computeOverlay(overlayOpCode);
return this._resultGeom;
},
insertUniqueEdges: function (edges) {
for (var i = edges.iterator(); i.hasNext(); ) {
var e = i.next();
this.insertUniqueEdge(e);
}
},
computeOverlay: function (opCode) {
this.copyPoints(0);
this.copyPoints(1);
this._arg[0].computeSelfNodes(this._li, false);
this._arg[1].computeSelfNodes(this._li, false);
this._arg[0].computeEdgeIntersections(this._arg[1], this._li, true);
var baseSplitEdges = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
this._arg[0].computeSplitEdges(baseSplitEdges);
this._arg[1].computeSplitEdges(baseSplitEdges);
var splitEdges = baseSplitEdges;
this.insertUniqueEdges(baseSplitEdges);
this.computeLabelsFromDepths();
this.replaceCollapsedEdges();
__WEBPACK_IMPORTED_MODULE_2__geomgraph_EdgeNodingValidator__["a" /* default */].checkValid(this._edgeList.getEdges());
this._graph.addEdges(this._edgeList.getEdges());
this.computeLabelling();
this.labelIncompleteNodes();
this.findResultAreaEdges(opCode);
this.cancelDuplicateResultEdges();
var polyBuilder = new __WEBPACK_IMPORTED_MODULE_4__PolygonBuilder__["a" /* default */](this._geomFact);
polyBuilder.add(this._graph);
this._resultPolyList = polyBuilder.getPolygons();
var lineBuilder = new __WEBPACK_IMPORTED_MODULE_6__LineBuilder__["a" /* default */](this, this._geomFact, this._ptLocator);
this._resultLineList = lineBuilder.build(opCode);
var pointBuilder = new __WEBPACK_IMPORTED_MODULE_7__PointBuilder__["a" /* default */](this, this._geomFact, this._ptLocator);
this._resultPointList = pointBuilder.build(opCode);
this._resultGeom = this.computeGeometry(this._resultPointList, this._resultLineList, this._resultPolyList, opCode);
},
labelIncompleteNode: function (n, targetIndex) {
var loc = this._ptLocator.locate(n.getCoordinate(), this._arg[targetIndex].getGeometry());
n.getLabel().setLocation(targetIndex, loc);
},
copyPoints: function (argIndex) {
for (var i = this._arg[argIndex].getNodeIterator(); i.hasNext(); ) {
var graphNode = i.next();
var newNode = this._graph.addNode(graphNode.getCoordinate());
newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
}
},
findResultAreaEdges: function (opCode) {
for (var it = this._graph.getEdgeEnds().iterator(); it.hasNext(); ) {
var de = it.next();
var label = de.getLabel();
if (label.isArea() && !de.isInteriorAreaEdge() && OverlayOp.isResultOfOp(label.getLocation(0, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].RIGHT), label.getLocation(1, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].RIGHT), opCode)) {
de.setInResult(true);
}
}
},
computeLabelsFromDepths: function () {
for (var it = this._edgeList.iterator(); it.hasNext(); ) {
var e = it.next();
var lbl = e.getLabel();
var depth = e.getDepth();
if (!depth.isNull()) {
depth.normalize();
for (var i = 0; i < 2; i++) {
if (!lbl.isNull(i) && lbl.isArea() && !depth.isNull(i)) {
if (depth.getDelta(i) === 0) {
lbl.toLine(i);
} else {
__WEBPACK_IMPORTED_MODULE_15__util_Assert__["a" /* default */].isTrue(!depth.isNull(i, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].LEFT), "depth of LEFT side has not been initialized");
lbl.setLocation(i, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].LEFT, depth.getLocation(i, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].LEFT));
__WEBPACK_IMPORTED_MODULE_15__util_Assert__["a" /* default */].isTrue(!depth.isNull(i, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].RIGHT), "depth of RIGHT side has not been initialized");
lbl.setLocation(i, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].RIGHT, depth.getLocation(i, __WEBPACK_IMPORTED_MODULE_5__geomgraph_Position__["a" /* default */].RIGHT));
}
}
}
}
}
},
computeLabelling: function () {
for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext(); ) {
var node = nodeit.next();
node.getEdges().computeLabelling(this._arg);
}
this.mergeSymLabels();
this.updateNodeLabelling();
},
labelIncompleteNodes: function () {
var nodeCount = 0;
for (var ni = this._graph.getNodes().iterator(); ni.hasNext(); ) {
var n = ni.next();
var label = n.getLabel();
if (n.isIsolated()) {
nodeCount++;
if (label.isNull(0)) this.labelIncompleteNode(n, 0); else this.labelIncompleteNode(n, 1);
}
n.getEdges().updateLabelling(label);
}
},
isCoveredByA: function (coord) {
if (this.isCovered(coord, this._resultPolyList)) return true;
return false;
},
interfaces_: function () {
return [];
},
getClass: function () {
return OverlayOp;
}
});
OverlayOp.overlayOp = function (geom0, geom1, opCode) {
var gov = new OverlayOp(geom0, geom1);
var geomOv = gov.getResultGeometry(opCode);
return geomOv;
};
OverlayOp.intersection = function (g, other) {
if (g.isEmpty() || other.isEmpty()) return OverlayOp.createEmptyResult(OverlayOp.INTERSECTION, g, other, g.getFactory());
if (g.isGeometryCollection()) {
var g2 = other;
return __WEBPACK_IMPORTED_MODULE_3__geom_util_GeometryCollectionMapper__["a" /* default */].map(g, {
interfaces_: function () {
return [MapOp];
},
map: function (g) {
return g.intersection(g2);
}
});
}
g.checkNotGeometryCollection(g);
g.checkNotGeometryCollection(other);
return __WEBPACK_IMPORTED_MODULE_8__snap_SnapIfNeededOverlayOp__["a" /* default */].overlayOp(g, other, OverlayOp.INTERSECTION);
};
OverlayOp.symDifference = function (g, other) {
if (g.isEmpty() || other.isEmpty()) {
if (g.isEmpty() && other.isEmpty()) return OverlayOp.createEmptyResult(OverlayOp.SYMDIFFERENCE, g, other, g.getFactory());
if (g.isEmpty()) return other.copy();
if (other.isEmpty()) return g.copy();
}
g.checkNotGeometryCollection(g);
g.checkNotGeometryCollection(other);
return __WEBPACK_IMPORTED_MODULE_8__snap_SnapIfNeededOverlayOp__["a" /* default */].overlayOp(g, other, OverlayOp.SYMDIFFERENCE);
};
OverlayOp.resultDimension = function (opCode, g0, g1) {
var dim0 = g0.getDimension();
var dim1 = g1.getDimension();
var resultDimension = -1;
switch (opCode) {
case OverlayOp.INTERSECTION:
resultDimension = Math.min(dim0, dim1);
break;
case OverlayOp.UNION:
resultDimension = Math.max(dim0, dim1);
break;
case OverlayOp.DIFFERENCE:
resultDimension = dim0;
break;
case OverlayOp.SYMDIFFERENCE:
resultDimension = Math.max(dim0, dim1);
break;
}
return resultDimension;
};
OverlayOp.createEmptyResult = function (overlayOpCode, a, b, geomFact) {
var result = null;
switch (OverlayOp.resultDimension(overlayOpCode, a, b)) {
case -1:
result = geomFact.createGeometryCollection(new Array(0).fill(null));
break;
case 0:
result = geomFact.createPoint();
break;
case 1:
result = geomFact.createLineString();
break;
case 2:
result = geomFact.createPolygon();
break;
}
return result;
};
OverlayOp.difference = function (g, other) {
if (g.isEmpty()) return OverlayOp.createEmptyResult(OverlayOp.DIFFERENCE, g, other, g.getFactory());
if (other.isEmpty()) return g.copy();
g.checkNotGeometryCollection(g);
g.checkNotGeometryCollection(other);
return __WEBPACK_IMPORTED_MODULE_8__snap_SnapIfNeededOverlayOp__["a" /* default */].overlayOp(g, other, OverlayOp.DIFFERENCE);
};
OverlayOp.isResultOfOp = function () {
if (arguments.length === 2) {
let label = arguments[0], opCode = arguments[1];
var loc0 = label.getLocation(0);
var loc1 = label.getLocation(1);
return OverlayOp.isResultOfOp(loc0, loc1, opCode);
} else if (arguments.length === 3) {
let loc0 = arguments[0], loc1 = arguments[1], overlayOpCode = arguments[2];
if (loc0 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY) loc0 = __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
if (loc1 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY) loc1 = __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
switch (overlayOpCode) {
case OverlayOp.INTERSECTION:
return loc0 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR && loc1 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
case OverlayOp.UNION:
return loc0 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR || loc1 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
case OverlayOp.DIFFERENCE:
return loc0 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR && loc1 !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
case OverlayOp.SYMDIFFERENCE:
return loc0 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR && loc1 !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR || loc0 !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR && loc1 === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
}
return false;
}
};
OverlayOp.INTERSECTION = 1;
OverlayOp.UNION = 2;
OverlayOp.DIFFERENCE = 3;
OverlayOp.SYMDIFFERENCE = 4;
/***/ }),
/* 43 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = TopologyException;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__ = __webpack_require__(44);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__inherits__ = __webpack_require__(3);
function TopologyException() {
this.pt = null;
if (arguments.length === 1) {
let msg = arguments[0];
__WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__["a" /* default */].call(this, msg);
} else if (arguments.length === 2) {
let msg = arguments[0], pt = arguments[1];
__WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__["a" /* default */].call(this, TopologyException.msgWithCoord(msg, pt));
this.name = 'TopologyException';
this.pt = new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */](pt);
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__inherits__["a" /* default */])(TopologyException, __WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(TopologyException.prototype, {
getCoordinate: function () {
return this.pt;
},
interfaces_: function () {
return [];
},
getClass: function () {
return TopologyException;
}
});
TopologyException.msgWithCoord = function (msg, pt) {
if (pt !== null) return msg + " [ " + pt + " ]";
return msg;
};
/***/ }),
/* 44 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = RuntimeException;
function RuntimeException (message) {
this.name = 'RuntimeException'
this.message = message
this.stack = (new Error()).stack
Error.call(this, message)
}
RuntimeException.prototype = Object.create(Error.prototype)
RuntimeException.prototype.constructor = Error
/***/ }),
/* 45 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = HashSet;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Collection__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Iterator__ = __webpack_require__(49);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__NoSuchElementException__ = __webpack_require__(71);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__OperationNotSupported__ = __webpack_require__(86);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Set__ = __webpack_require__(121);
/**
* @see http://docs.oracle.com/javase/6/docs/api/java/util/HashSet.html
*
* @extends {javascript.util.Set}
* @constructor
* @private
*/
function HashSet() {
/**
* @type {Array}
* @private
*/
this.array_ = [];
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Collection__["a" /* default */]) {
this.addAll(arguments[0]);
}
};
HashSet.prototype = new __WEBPACK_IMPORTED_MODULE_4__Set__["a" /* default */]();
/**
* @override
*/
HashSet.prototype.contains = function(o) {
for (var i = 0, len = this.array_.length; i < len; i++) {
var e = this.array_[i];
if (e === o) {
return true;
}
}
return false;
};
/**
* @override
*/
HashSet.prototype.add = function(o) {
if (this.contains(o)) {
return false;
}
this.array_.push(o);
return true;
};
/**
* @override
*/
HashSet.prototype.addAll = function(c) {
for (var i = c.iterator(); i.hasNext();) {
this.add(i.next());
}
return true;
};
/**
* @override
*/
HashSet.prototype.remove = function(o) {
throw new javascript.util.OperationNotSupported();
};
/**
* @override
*/
HashSet.prototype.size = function() {
return this.array_.length;
};
/**
* @override
*/
HashSet.prototype.isEmpty = function() {
return this.array_.length === 0;
};
/**
* @override
*/
HashSet.prototype.toArray = function() {
var array = [];
for (var i = 0, len = this.array_.length; i < len; i++) {
array.push(this.array_[i]);
}
return array;
};
/**
* @override
*/
HashSet.prototype.iterator = function() {
return new Iterator_(this);
};
/**
* @extends {Iterator}
* @param {HashSet} hashSet
* @constructor
* @private
*/
var Iterator_ = function(hashSet) {
/**
* @type {HashSet}
* @private
*/
this.hashSet_ = hashSet;
/**
* @type {number}
* @private
*/
this.position_ = 0;
};
/**
* @override
*/
Iterator_.prototype.next = function() {
if (this.position_ === this.hashSet_.size()) {
throw new __WEBPACK_IMPORTED_MODULE_2__NoSuchElementException__["a" /* default */]();
}
return this.hashSet_.array_[this.position_++];
};
/**
* @override
*/
Iterator_.prototype.hasNext = function() {
if (this.position_ < this.hashSet_.size()) {
return true;
} else {
return false;
}
};
/**
* @override
*/
Iterator_.prototype.remove = function() {
throw new __WEBPACK_IMPORTED_MODULE_3__OperationNotSupported__["a" /* default */]();
};
/***/ }),
/* 46 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = TreeSet;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Collection__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Iterator__ = __webpack_require__(49);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__NoSuchElementException__ = __webpack_require__(71);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__OperationNotSupported__ = __webpack_require__(86);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SortedSet__ = __webpack_require__(211);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/TreeSet.html
*
* @extends {SortedSet}
* @constructor
* @private
*/
function TreeSet() {
/**
* @type {Array}
* @private
*/
this.array_ = [];
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Collection__["a" /* default */]) {
this.addAll(arguments[0]);
}
};
TreeSet.prototype = new __WEBPACK_IMPORTED_MODULE_4__SortedSet__["a" /* default */]();
/**
* @override
*/
TreeSet.prototype.contains = function(o) {
for (var i = 0, len = this.array_.length; i < len; i++) {
var e = this.array_[i];
if (e['compareTo'](o) === 0) {
return true;
}
}
return false;
};
/**
* @override
*/
TreeSet.prototype.add = function(o) {
if (this.contains(o)) {
return false;
}
for (var i = 0, len = this.array_.length; i < len; i++) {
var e = this.array_[i];
if (e['compareTo'](o) === 1) {
this.array_.splice(i, 0, o);
return true;
}
}
this.array_.push(o);
return true;
};
/**
* @override
*/
TreeSet.prototype.addAll = function(c) {
for (var i = c.iterator(); i.hasNext();) {
this.add(i.next());
}
return true;
};
/**
* @override
*/
TreeSet.prototype.remove = function(e) {
throw new __WEBPACK_IMPORTED_MODULE_3__OperationNotSupported__["a" /* default */]();
};
/**
* @override
*/
TreeSet.prototype.size = function() {
return this.array_.length;
};
/**
* @override
*/
TreeSet.prototype.isEmpty = function() {
return this.array_.length === 0;
};
/**
* @override
*/
TreeSet.prototype.toArray = function() {
var array = [];
for (var i = 0, len = this.array_.length; i < len; i++) {
array.push(this.array_[i]);
}
return array;
};
/**
* @override
*/
TreeSet.prototype.iterator = function() {
return new Iterator_(this);
};
/**
* @extends {javascript.util.Iterator}
* @param {javascript.util.TreeSet} treeSet
* @constructor
* @private
*/
var Iterator_ = function(treeSet) {
/**
* @type {javascript.util.TreeSet}
* @private
*/
this.treeSet_ = treeSet;
/**
* @type {number}
* @private
*/
this.position_ = 0;
};
/**
* @override
*/
Iterator_.prototype.next = function() {
if (this.position_ === this.treeSet_.size()) {
throw new __WEBPACK_IMPORTED_MODULE_2__NoSuchElementException__["a" /* default */]();
}
return this.treeSet_.array_[this.position_++];
};
/**
* @override
*/
Iterator_.prototype.hasNext = function() {
if (this.position_ < this.treeSet_.size()) {
return true;
} else {
return false;
}
};
/**
* @override
*/
Iterator_.prototype.remove = function() {
throw new __WEBPACK_IMPORTED_MODULE_3__OperationNotSupported__["a" /* default */]();
};
/***/ }),
/* 47 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Quadrant;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
function Quadrant() {}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(Quadrant.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Quadrant;
}
});
Quadrant.isNorthern = function (quad) {
return quad === Quadrant.NE || quad === Quadrant.NW;
};
Quadrant.isOpposite = function (quad1, quad2) {
if (quad1 === quad2) return false;
var diff = (quad1 - quad2 + 4) % 4;
if (diff === 2) return true;
return false;
};
Quadrant.commonHalfPlane = function (quad1, quad2) {
if (quad1 === quad2) return quad1;
var diff = (quad1 - quad2 + 4) % 4;
if (diff === 2) return -1;
var min = quad1 < quad2 ? quad1 : quad2;
var max = quad1 > quad2 ? quad1 : quad2;
if (min === 0 && max === 3) return 3;
return min;
};
Quadrant.isInHalfPlane = function (quad, halfPlane) {
if (halfPlane === Quadrant.SE) {
return quad === Quadrant.SE || quad === Quadrant.SW;
}
return quad === halfPlane || quad === halfPlane + 1;
};
Quadrant.quadrant = function () {
if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
let dx = arguments[0], dy = arguments[1];
if (dx === 0.0 && dy === 0.0) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Cannot compute the quadrant for point ( " + dx + ", " + dy + " )");
if (dx >= 0.0) {
if (dy >= 0.0) return Quadrant.NE; else return Quadrant.SE;
} else {
if (dy >= 0.0) return Quadrant.NW; else return Quadrant.SW;
}
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */]) {
let p0 = arguments[0], p1 = arguments[1];
if (p1.x === p0.x && p1.y === p0.y) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Cannot compute the quadrant for two identical points " + p0);
if (p1.x >= p0.x) {
if (p1.y >= p0.y) return Quadrant.NE; else return Quadrant.SE;
} else {
if (p1.y >= p0.y) return Quadrant.NW; else return Quadrant.SW;
}
}
};
Quadrant.NE = 0;
Quadrant.NW = 1;
Quadrant.SW = 2;
Quadrant.SE = 3;
/***/ }),
/* 48 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Comparator;
function Comparator () {}
/***/ }),
/* 49 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Iterator;
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/Iterator.html
* @constructor
* @private
*/
function Iterator() {};
/**
* Returns true if the iteration has more elements.
* @return {boolean}
*/
Iterator.prototype.hasNext = function() {};
/**
* Returns the next element in the iteration.
* @return {Object}
*/
Iterator.prototype.next = function() {};
/**
* Removes from the underlying collection the last element returned by the
* iterator (optional operation).
*/
Iterator.prototype.remove = function() {};
/***/ }),
/* 50 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateFilter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function CoordinateFilter() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(CoordinateFilter.prototype, {
filter: function (coord) {},
interfaces_: function () {
return [];
},
getClass: function () {
return CoordinateFilter;
}
});
/***/ }),
/* 51 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PrecisionModel;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_util_HashMap__ = __webpack_require__(72);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_Integer__ = __webpack_require__(55);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_io_Serializable__ = __webpack_require__(21);
function PrecisionModel() {
this._modelType = null;
this._scale = null;
if (arguments.length === 0) {
this._modelType = PrecisionModel.FLOATING;
} else if (arguments.length === 1) {
if (arguments[0] instanceof Type) {
let modelType = arguments[0];
this._modelType = modelType;
if (modelType === PrecisionModel.FIXED) {
this.setScale(1.0);
}
} else if (typeof arguments[0] === "number") {
let scale = arguments[0];
this._modelType = PrecisionModel.FIXED;
this.setScale(scale);
} else if (arguments[0] instanceof PrecisionModel) {
let pm = arguments[0];
this._modelType = pm._modelType;
this._scale = pm._scale;
}
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(PrecisionModel.prototype, {
equals: function (other) {
if (!(other instanceof PrecisionModel)) {
return false;
}
var otherPrecisionModel = other;
return this._modelType === otherPrecisionModel._modelType && this._scale === otherPrecisionModel._scale;
},
compareTo: function (o) {
var other = o;
var sigDigits = this.getMaximumSignificantDigits();
var otherSigDigits = other.getMaximumSignificantDigits();
return new __WEBPACK_IMPORTED_MODULE_4__java_lang_Integer__["a" /* default */](sigDigits).compareTo(new __WEBPACK_IMPORTED_MODULE_4__java_lang_Integer__["a" /* default */](otherSigDigits));
},
getScale: function () {
return this._scale;
},
isFloating: function () {
return this._modelType === PrecisionModel.FLOATING || this._modelType === PrecisionModel.FLOATING_SINGLE;
},
getType: function () {
return this._modelType;
},
toString: function () {
var description = "UNKNOWN";
if (this._modelType === PrecisionModel.FLOATING) {
description = "Floating";
} else if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
description = "Floating-Single";
} else if (this._modelType === PrecisionModel.FIXED) {
description = "Fixed (Scale=" + this.getScale() + ")";
}
return description;
},
makePrecise: function () {
if (typeof arguments[0] === "number") {
let val = arguments[0];
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(val)) return val;
if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
var floatSingleVal = val;
return floatSingleVal;
}
if (this._modelType === PrecisionModel.FIXED) {
return Math.round(val * this._scale) / this._scale;
}
return val;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__Coordinate__["a" /* default */]) {
let coord = arguments[0];
if (this._modelType === PrecisionModel.FLOATING) return null;
coord.x = this.makePrecise(coord.x);
coord.y = this.makePrecise(coord.y);
}
},
getMaximumSignificantDigits: function () {
var maxSigDigits = 16;
if (this._modelType === PrecisionModel.FLOATING) {
maxSigDigits = 16;
} else if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
maxSigDigits = 6;
} else if (this._modelType === PrecisionModel.FIXED) {
maxSigDigits = 1 + Math.trunc(Math.ceil(Math.log(this.getScale()) / Math.log(10)));
}
return maxSigDigits;
},
setScale: function (scale) {
this._scale = Math.abs(scale);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_6__java_io_Serializable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_5__java_lang_Comparable__["a" /* default */]];
},
getClass: function () {
return PrecisionModel;
}
});
PrecisionModel.mostPrecise = function (pm1, pm2) {
if (pm1.compareTo(pm2) >= 0) return pm1;
return pm2;
};
function Type() {
this._name = null;
let name = arguments[0];
this._name = name;
Type.nameToTypeMap.put(name, this);
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(Type.prototype, {
readResolve: function () {
return Type.nameToTypeMap.get(this._name);
},
toString: function () {
return this._name;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_6__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return Type;
}
});
Type.serialVersionUID = -5528602631731589822;
Type.nameToTypeMap = new __WEBPACK_IMPORTED_MODULE_0__java_util_HashMap__["a" /* default */]();
PrecisionModel.Type = Type;
PrecisionModel.serialVersionUID = 7777263578777803835;
PrecisionModel.FIXED = new Type("FIXED");
PrecisionModel.FLOATING = new Type("FLOATING");
PrecisionModel.FLOATING_SINGLE = new Type("FLOATING SINGLE");
PrecisionModel.maximumPreciseValue = 9007199254740992.0;
/***/ }),
/* 52 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ItemVisitor;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function ItemVisitor() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(ItemVisitor.prototype, {
visitItem: function (item) {},
interfaces_: function () {
return [];
},
getClass: function () {
return ItemVisitor;
}
});
/***/ }),
/* 53 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Clonable;
function Clonable () {}
/***/ }),
/* 54 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NotRepresentableException;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_Exception__ = __webpack_require__(87);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__inherits__ = __webpack_require__(3);
function NotRepresentableException() {
__WEBPACK_IMPORTED_MODULE_1__java_lang_Exception__["a" /* default */].call(this, "Projective point not representable on the Cartesian plane.");
}
Object(__WEBPACK_IMPORTED_MODULE_2__inherits__["a" /* default */])(NotRepresentableException, __WEBPACK_IMPORTED_MODULE_1__java_lang_Exception__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(NotRepresentableException.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return NotRepresentableException;
}
});
/***/ }),
/* 55 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Integer;
function Integer (value) {
this.value = value
}
Integer.prototype.intValue = function () {
return this.value
}
Integer.prototype.compareTo = function (o) {
if (this.value < o) return -1
if (this.value > o) return 1
return 0
}
Integer.isNaN = n => Number.isNaN(n)
/***/ }),
/* 56 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = HCoordinate;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__NotRepresentableException__ = __webpack_require__(54);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
function HCoordinate() {
this.x = null;
this.y = null;
this.w = null;
if (arguments.length === 0) {
this.x = 0.0;
this.y = 0.0;
this.w = 1.0;
} else if (arguments.length === 1) {
let p = arguments[0];
this.x = p.x;
this.y = p.y;
this.w = 1.0;
} else if (arguments.length === 2) {
if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
let _x = arguments[0], _y = arguments[1];
this.x = _x;
this.y = _y;
this.w = 1.0;
} else if (arguments[0] instanceof HCoordinate && arguments[1] instanceof HCoordinate) {
let p1 = arguments[0], p2 = arguments[1];
this.x = p1.y * p2.w - p2.y * p1.w;
this.y = p2.x * p1.w - p1.x * p2.w;
this.w = p1.x * p2.y - p2.x * p1.y;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */]) {
let p1 = arguments[0], p2 = arguments[1];
this.x = p1.y - p2.y;
this.y = p2.x - p1.x;
this.w = p1.x * p2.y - p2.x * p1.y;
}
} else if (arguments.length === 3) {
let _x = arguments[0], _y = arguments[1], _w = arguments[2];
this.x = _x;
this.y = _y;
this.w = _w;
} else if (arguments.length === 4) {
let p1 = arguments[0], p2 = arguments[1], q1 = arguments[2], q2 = arguments[3];
var px = p1.y - p2.y;
var py = p2.x - p1.x;
var pw = p1.x * p2.y - p2.x * p1.y;
var qx = q1.y - q2.y;
var qy = q2.x - q1.x;
var qw = q1.x * q2.y - q2.x * q1.y;
this.x = py * qw - qy * pw;
this.y = qx * pw - px * qw;
this.w = px * qy - qx * py;
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(HCoordinate.prototype, {
getY: function () {
var a = this.y / this.w;
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(a) || __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isInfinite(a)) {
throw new __WEBPACK_IMPORTED_MODULE_0__NotRepresentableException__["a" /* default */]();
}
return a;
},
getX: function () {
var a = this.x / this.w;
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(a) || __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isInfinite(a)) {
throw new __WEBPACK_IMPORTED_MODULE_0__NotRepresentableException__["a" /* default */]();
}
return a;
},
getCoordinate: function () {
var p = new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */]();
p.x = this.getX();
p.y = this.getY();
return p;
},
interfaces_: function () {
return [];
},
getClass: function () {
return HCoordinate;
}
});
HCoordinate.intersection = function (p1, p2, q1, q2) {
var px = p1.y - p2.y;
var py = p2.x - p1.x;
var pw = p1.x * p2.y - p2.x * p1.y;
var qx = q1.y - q2.y;
var qy = q2.x - q1.x;
var qw = q1.x * q2.y - q2.x * q1.y;
var x = py * qw - qy * pw;
var y = qx * pw - px * qw;
var w = px * qy - qx * py;
var xInt = x / w;
var yInt = y / w;
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(xInt) || (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isInfinite(xInt) || __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(yInt)) || __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isInfinite(yInt)) {
throw new __WEBPACK_IMPORTED_MODULE_0__NotRepresentableException__["a" /* default */]();
}
return new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */](xInt, yInt);
};
/***/ }),
/* 57 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = BoundaryNodeRule;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function BoundaryNodeRule() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(BoundaryNodeRule.prototype, {
isInBoundary: function (boundaryCount) {},
interfaces_: function () {
return [];
},
getClass: function () {
return BoundaryNodeRule;
}
});
function Mod2BoundaryNodeRule() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Mod2BoundaryNodeRule.prototype, {
isInBoundary: function (boundaryCount) {
return boundaryCount % 2 === 1;
},
interfaces_: function () {
return [BoundaryNodeRule];
},
getClass: function () {
return Mod2BoundaryNodeRule;
}
});
function EndPointBoundaryNodeRule() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(EndPointBoundaryNodeRule.prototype, {
isInBoundary: function (boundaryCount) {
return boundaryCount > 0;
},
interfaces_: function () {
return [BoundaryNodeRule];
},
getClass: function () {
return EndPointBoundaryNodeRule;
}
});
function MultiValentEndPointBoundaryNodeRule() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(MultiValentEndPointBoundaryNodeRule.prototype, {
isInBoundary: function (boundaryCount) {
return boundaryCount > 1;
},
interfaces_: function () {
return [BoundaryNodeRule];
},
getClass: function () {
return MultiValentEndPointBoundaryNodeRule;
}
});
function MonoValentEndPointBoundaryNodeRule() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(MonoValentEndPointBoundaryNodeRule.prototype, {
isInBoundary: function (boundaryCount) {
return boundaryCount === 1;
},
interfaces_: function () {
return [BoundaryNodeRule];
},
getClass: function () {
return MonoValentEndPointBoundaryNodeRule;
}
});
BoundaryNodeRule.Mod2BoundaryNodeRule = Mod2BoundaryNodeRule;
BoundaryNodeRule.EndPointBoundaryNodeRule = EndPointBoundaryNodeRule;
BoundaryNodeRule.MultiValentEndPointBoundaryNodeRule = MultiValentEndPointBoundaryNodeRule;
BoundaryNodeRule.MonoValentEndPointBoundaryNodeRule = MonoValentEndPointBoundaryNodeRule;
BoundaryNodeRule.MOD2_BOUNDARY_RULE = new Mod2BoundaryNodeRule();
BoundaryNodeRule.ENDPOINT_BOUNDARY_RULE = new EndPointBoundaryNodeRule();
BoundaryNodeRule.MULTIVALENT_ENDPOINT_BOUNDARY_RULE = new MultiValentEndPointBoundaryNodeRule();
BoundaryNodeRule.MONOVALENT_ENDPOINT_BOUNDARY_RULE = new MonoValentEndPointBoundaryNodeRule();
BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE = BoundaryNodeRule.MOD2_BOUNDARY_RULE;
/***/ }),
/* 58 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Arrays;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ArrayList__ = __webpack_require__(1);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/Arrays.html
*
* @constructor
* @private
*/
function Arrays() {};
/**
*/
Arrays.sort = function() {
var a = arguments[0], i, t, comparator, compare;
if (arguments.length === 1) {
compare = function(a, b) {
return a.compareTo(b);
}
a.sort(compare);
return;
} else if (arguments.length === 2) {
comparator = arguments[1];
compare = function(a, b) {
return comparator['compare'](a, b);
};
a.sort(compare);
} else if (arguments.length === 3) {
t = a.slice(arguments[1], arguments[2]);
t.sort();
var r = a.slice(0, arguments[1]).concat(t, a.slice(arguments[2], a.length));
a.splice(0, a.length);
for (i = 0; i < r.length; i++) {
a.push(r[i]);
}
return;
} else if (arguments.length === 4) {
t = a.slice(arguments[1], arguments[2]);
comparator = arguments[3];
compare = function(a, b) {
return comparator['compare'](a, b);
};
t.sort(compare);
r = a.slice(0, arguments[1]).concat(t, a.slice(arguments[2], a.length));
a.splice(0, a.length);
for (i = 0; i < r.length; i++) {
a.push(r[i]);
}
return;
}
};
/**
* @param {Array} array
* @return {ArrayList}
*/
Arrays.asList = function(array) {
var arrayList = new __WEBPACK_IMPORTED_MODULE_0__ArrayList__["a" /* default */]();
for (var i = 0, len = array.length; i < len; i++) {
arrayList.add(array[i]);
}
return arrayList;
};
/***/ }),
/* 59 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateSequenceFilter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function CoordinateSequenceFilter() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(CoordinateSequenceFilter.prototype, {
filter: function (seq, i) {},
isDone: function () {},
isGeometryChanged: function () {},
interfaces_: function () {
return [];
},
getClass: function () {
return CoordinateSequenceFilter;
}
});
/***/ }),
/* 60 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateArraySequence;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__ = __webpack_require__(37);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_io_Serializable__ = __webpack_require__(21);
function CoordinateArraySequence() {
this._dimension = 3;
this._coordinates = null;
if (arguments.length === 1) {
if (arguments[0] instanceof Array) {
let coordinates = arguments[0];
CoordinateArraySequence.call(this, coordinates, 3);
} else if (Number.isInteger(arguments[0])) {
let size = arguments[0];
this._coordinates = new Array(size).fill(null);
for (var i = 0; i < size; i++) {
this._coordinates[i] = new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]();
}
} else if (Object(__WEBPACK_IMPORTED_MODULE_1__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */])) {
let coordSeq = arguments[0];
if (coordSeq === null) {
this._coordinates = new Array(0).fill(null);
return null;
}
this._dimension = coordSeq.getDimension();
this._coordinates = new Array(coordSeq.size()).fill(null);
for (var i = 0; i < this._coordinates.length; i++) {
this._coordinates[i] = coordSeq.getCoordinateCopy(i);
}
}
} else if (arguments.length === 2) {
if (arguments[0] instanceof Array && Number.isInteger(arguments[1])) {
let coordinates = arguments[0], dimension = arguments[1];
this._coordinates = coordinates;
this._dimension = dimension;
if (coordinates === null) this._coordinates = new Array(0).fill(null);
} else if (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1])) {
let size = arguments[0], dimension = arguments[1];
this._coordinates = new Array(size).fill(null);
this._dimension = dimension;
for (var i = 0; i < size; i++) {
this._coordinates[i] = new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */]();
}
}
}
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(CoordinateArraySequence.prototype, {
setOrdinate: function (index, ordinateIndex, value) {
switch (ordinateIndex) {
case __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */].X:
this._coordinates[index].x = value;
break;
case __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */].Y:
this._coordinates[index].y = value;
break;
case __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */].Z:
this._coordinates[index].z = value;
break;
default:
throw new __WEBPACK_IMPORTED_MODULE_3__java_lang_IllegalArgumentException__["a" /* default */]("invalid ordinateIndex");
}
},
size: function () {
return this._coordinates.length;
},
getOrdinate: function (index, ordinateIndex) {
switch (ordinateIndex) {
case __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */].X:
return this._coordinates[index].x;
case __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */].Y:
return this._coordinates[index].y;
case __WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */].Z:
return this._coordinates[index].z;
}
return __WEBPACK_IMPORTED_MODULE_4__java_lang_Double__["a" /* default */].NaN;
},
getCoordinate: function () {
if (arguments.length === 1) {
let i = arguments[0];
return this._coordinates[i];
} else if (arguments.length === 2) {
let index = arguments[0], coord = arguments[1];
coord.x = this._coordinates[index].x;
coord.y = this._coordinates[index].y;
coord.z = this._coordinates[index].z;
}
},
getCoordinateCopy: function (i) {
return new __WEBPACK_IMPORTED_MODULE_2__Coordinate__["a" /* default */](this._coordinates[i]);
},
getDimension: function () {
return this._dimension;
},
getX: function (index) {
return this._coordinates[index].x;
},
clone: function () {
var cloneCoordinates = new Array(this.size()).fill(null);
for (var i = 0; i < this._coordinates.length; i++) {
cloneCoordinates[i] = this._coordinates[i].clone();
}
return new CoordinateArraySequence(cloneCoordinates, this._dimension);
},
expandEnvelope: function (env) {
for (var i = 0; i < this._coordinates.length; i++) {
env.expandToInclude(this._coordinates[i]);
}
return env;
},
copy: function () {
var cloneCoordinates = new Array(this.size()).fill(null);
for (var i = 0; i < this._coordinates.length; i++) {
cloneCoordinates[i] = this._coordinates[i].copy();
}
return new CoordinateArraySequence(cloneCoordinates, this._dimension);
},
toString: function () {
if (this._coordinates.length > 0) {
var strBuf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */](17 * this._coordinates.length);
strBuf.append('(');
strBuf.append(this._coordinates[0]);
for (var i = 1; i < this._coordinates.length; i++) {
strBuf.append(", ");
strBuf.append(this._coordinates[i]);
}
strBuf.append(')');
return strBuf.toString();
} else {
return "()";
}
},
getY: function (index) {
return this._coordinates[index].y;
},
toCoordinateArray: function () {
return this._coordinates;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_6__CoordinateSequence__["a" /* default */], __WEBPACK_IMPORTED_MODULE_7__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return CoordinateArraySequence;
}
});
CoordinateArraySequence.serialVersionUID = -915438501601840650;
/***/ }),
/* 61 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Stack;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__EmptyStackException__ = __webpack_require__(223);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__List__ = __webpack_require__(33);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/Stack.html
*
* @extends {List}
* @constructor
* @private
*/
function Stack() {
/**
* @type {Array}
* @private
*/
this.array_ = [];
};
Stack.prototype = new __WEBPACK_IMPORTED_MODULE_1__List__["a" /* default */]();
/**
* @override
*/
Stack.prototype.add = function(e) {
this.array_.push(e);
return true;
};
/**
* @override
*/
Stack.prototype.get = function(index) {
if (index < 0 || index >= this.size()) {
throw new IndexOutOfBoundsException();
}
return this.array_[index];
};
/**
* Pushes an item onto the top of this stack.
* @param {Object} e
* @return {Object}
*/
Stack.prototype.push = function(e) {
this.array_.push(e);
return e;
};
/**
* Pushes an item onto the top of this stack.
* @param {Object} e
* @return {Object}
*/
Stack.prototype.pop = function(e) {
if (this.array_.length === 0) {
throw new __WEBPACK_IMPORTED_MODULE_0__EmptyStackException__["a" /* default */]();
}
return this.array_.pop();
};
/**
* Looks at the object at the top of this stack without removing it from the
* stack.
* @return {Object}
*/
Stack.prototype.peek = function() {
if (this.array_.length === 0) {
throw new __WEBPACK_IMPORTED_MODULE_0__EmptyStackException__["a" /* default */]();
}
return this.array_[this.array_.length - 1];
};
/**
* Tests if this stack is empty.
* @return {boolean} true if and only if this stack contains no items; false
* otherwise.
*/
Stack.prototype.empty = function() {
if (this.array_.length === 0) {
return true;
} else {
return false;
}
};
/**
* @return {boolean}
*/
Stack.prototype.isEmpty = function() {
return this.empty();
};
/**
* Returns the 1-based position where an object is on this stack. If the object
* o occurs as an item in this stack, this method returns the distance from the
* top of the stack of the occurrence nearest the top of the stack; the topmost
* item on the stack is considered to be at distance 1. The equals method is
* used to compare o to the items in this stack.
*
* NOTE: does not currently actually use equals. (=== is used)
*
* @param {Object} o
* @return {number} the 1-based position from the top of the stack where the
* object is located; the return value -1 indicates that the object is
* not on the stack.
*/
Stack.prototype.search = function(o) {
return this.array_.indexOf(o);
};
/**
* @return {number}
* @export
*/
Stack.prototype.size = function() {
return this.array_.length;
};
/**
* @return {Array}
*/
Stack.prototype.toArray = function() {
var array = [];
for (var i = 0, len = this.array_.length; i < len; i++) {
array.push(this.array_[i]);
}
return array;
};
/***/ }),
/* 62 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PointLocator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_Point__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__BoundaryNodeRule__ = __webpack_require__(57);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__geom_MultiPolygon__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__geom_GeometryCollectionIterator__ = __webpack_require__(126);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__geom_GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__geom_MultiLineString__ = __webpack_require__(28);
function PointLocator() {
this._boundaryRule = __WEBPACK_IMPORTED_MODULE_7__BoundaryNodeRule__["a" /* default */].OGC_SFS_BOUNDARY_RULE;
this._isIn = null;
this._numBoundaries = null;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let boundaryRule = arguments[0];
if (boundaryRule === null) throw new __WEBPACK_IMPORTED_MODULE_4__java_lang_IllegalArgumentException__["a" /* default */]("Rule must be non-null");
this._boundaryRule = boundaryRule;
}
}
Object(__WEBPACK_IMPORTED_MODULE_8__extend__["a" /* default */])(PointLocator.prototype, {
locateInternal: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_6__geom_Polygon__["a" /* default */]) {
let p = arguments[0], poly = arguments[1];
if (poly.isEmpty()) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
var shell = poly.getExteriorRing();
var shellLoc = this.locateInPolygonRing(p, shell);
if (shellLoc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
if (shellLoc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
for (var i = 0; i < poly.getNumInteriorRing(); i++) {
var hole = poly.getInteriorRingN(i);
var holeLoc = this.locateInPolygonRing(p, hole);
if (holeLoc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
if (holeLoc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
}
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_1__geom_LineString__["a" /* default */]) {
let p = arguments[0], l = arguments[1];
if (!l.getEnvelopeInternal().intersects(p)) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
var pt = l.getCoordinates();
if (!l.isClosed()) {
if (p.equals(pt[0]) || p.equals(pt[pt.length - 1])) {
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
}
}
if (__WEBPACK_IMPORTED_MODULE_2__CGAlgorithms__["a" /* default */].isOnLine(p, pt)) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_5__geom_Point__["a" /* default */]) {
let p = arguments[0], pt = arguments[1];
var ptCoord = pt.getCoordinate();
if (ptCoord.equals2D(p)) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
}
},
locateInPolygonRing: function (p, ring) {
if (!ring.getEnvelopeInternal().intersects(p)) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
return __WEBPACK_IMPORTED_MODULE_2__CGAlgorithms__["a" /* default */].locatePointInRing(p, ring.getCoordinates());
},
intersects: function (p, geom) {
return this.locate(p, geom) !== __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
},
updateLocationInfo: function (loc) {
if (loc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR) this._isIn = true;
if (loc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY) this._numBoundaries++;
},
computeLocation: function (p, geom) {
if (geom instanceof __WEBPACK_IMPORTED_MODULE_5__geom_Point__["a" /* default */]) {
this.updateLocationInfo(this.locateInternal(p, geom));
}
if (geom instanceof __WEBPACK_IMPORTED_MODULE_1__geom_LineString__["a" /* default */]) {
this.updateLocationInfo(this.locateInternal(p, geom));
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_6__geom_Polygon__["a" /* default */]) {
this.updateLocationInfo(this.locateInternal(p, geom));
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_12__geom_MultiLineString__["a" /* default */]) {
var ml = geom;
for (var i = 0; i < ml.getNumGeometries(); i++) {
var l = ml.getGeometryN(i);
this.updateLocationInfo(this.locateInternal(p, l));
}
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_9__geom_MultiPolygon__["a" /* default */]) {
var mpoly = geom;
for (var i = 0; i < mpoly.getNumGeometries(); i++) {
var poly = mpoly.getGeometryN(i);
this.updateLocationInfo(this.locateInternal(p, poly));
}
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_11__geom_GeometryCollection__["a" /* default */]) {
var geomi = new __WEBPACK_IMPORTED_MODULE_10__geom_GeometryCollectionIterator__["a" /* default */](geom);
while (geomi.hasNext()) {
var g2 = geomi.next();
if (g2 !== geom) this.computeLocation(p, g2);
}
}
},
locate: function (p, geom) {
if (geom.isEmpty()) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
if (geom instanceof __WEBPACK_IMPORTED_MODULE_1__geom_LineString__["a" /* default */]) {
return this.locateInternal(p, geom);
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_6__geom_Polygon__["a" /* default */]) {
return this.locateInternal(p, geom);
}
this._isIn = false;
this._numBoundaries = 0;
this.computeLocation(p, geom);
if (this._boundaryRule.isInBoundary(this._numBoundaries)) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
if (this._numBoundaries > 0 || this._isIn) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
},
interfaces_: function () {
return [];
},
getClass: function () {
return PointLocator;
}
});
/***/ }),
/* 63 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NodedSegmentString;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__SegmentNodeList__ = __webpack_require__(238);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__io_WKTWriter__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_impl_CoordinateArraySequence__ = __webpack_require__(60);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Octant__ = __webpack_require__(127);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__NodableSegmentString__ = __webpack_require__(241);
function NodedSegmentString() {
this._nodeList = new __WEBPACK_IMPORTED_MODULE_0__SegmentNodeList__["a" /* default */](this);
this._pts = null;
this._data = null;
let pts = arguments[0], data = arguments[1];
this._pts = pts;
this._data = data;
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(NodedSegmentString.prototype, {
getCoordinates: function () {
return this._pts;
},
size: function () {
return this._pts.length;
},
getCoordinate: function (i) {
return this._pts[i];
},
isClosed: function () {
return this._pts[0].equals(this._pts[this._pts.length - 1]);
},
getSegmentOctant: function (index) {
if (index === this._pts.length - 1) return -1;
return this.safeOctant(this.getCoordinate(index), this.getCoordinate(index + 1));
},
setData: function (data) {
this._data = data;
},
safeOctant: function (p0, p1) {
if (p0.equals2D(p1)) return 0;
return __WEBPACK_IMPORTED_MODULE_4__Octant__["a" /* default */].octant(p0, p1);
},
getData: function () {
return this._data;
},
addIntersection: function () {
if (arguments.length === 2) {
let intPt = arguments[0], segmentIndex = arguments[1];
this.addIntersectionNode(intPt, segmentIndex);
} else if (arguments.length === 4) {
let li = arguments[0], segmentIndex = arguments[1], geomIndex = arguments[2], intIndex = arguments[3];
var intPt = new __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */](li.getIntersection(intIndex));
this.addIntersection(intPt, segmentIndex);
}
},
toString: function () {
return __WEBPACK_IMPORTED_MODULE_1__io_WKTWriter__["a" /* default */].toLineString(new __WEBPACK_IMPORTED_MODULE_2__geom_impl_CoordinateArraySequence__["a" /* default */](this._pts));
},
getNodeList: function () {
return this._nodeList;
},
addIntersectionNode: function (intPt, segmentIndex) {
var normalizedSegmentIndex = segmentIndex;
var nextSegIndex = normalizedSegmentIndex + 1;
if (nextSegIndex < this._pts.length) {
var nextPt = this._pts[nextSegIndex];
if (intPt.equals2D(nextPt)) {
normalizedSegmentIndex = nextSegIndex;
}
}
var ei = this._nodeList.add(intPt, normalizedSegmentIndex);
return ei;
},
addIntersections: function (li, segmentIndex, geomIndex) {
for (var i = 0; i < li.getIntersectionNum(); i++) {
this.addIntersection(li, segmentIndex, geomIndex, i);
}
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_7__NodableSegmentString__["a" /* default */]];
},
getClass: function () {
return NodedSegmentString;
}
});
NodedSegmentString.getNodedSubstrings = function () {
if (arguments.length === 1) {
let segStrings = arguments[0];
var resultEdgelist = new __WEBPACK_IMPORTED_MODULE_6__java_util_ArrayList__["a" /* default */]();
NodedSegmentString.getNodedSubstrings(segStrings, resultEdgelist);
return resultEdgelist;
} else if (arguments.length === 2) {
let segStrings = arguments[0], resultEdgelist = arguments[1];
for (var i = segStrings.iterator(); i.hasNext(); ) {
var ss = i.next();
ss.getNodeList().addSplitEdges(resultEdgelist);
}
}
};
/***/ }),
/* 64 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PlanarGraph;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Node__ = __webpack_require__(65);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__NodeMap__ = __webpack_require__(98);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__DirectedEdge__ = __webpack_require__(136);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Quadrant__ = __webpack_require__(47);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NodeFactory__ = __webpack_require__(100);
function PlanarGraph() {
this._edges = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
this._nodes = null;
this._edgeEndList = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
if (arguments.length === 0) {
this._nodes = new __WEBPACK_IMPORTED_MODULE_5__NodeMap__["a" /* default */](new __WEBPACK_IMPORTED_MODULE_10__NodeFactory__["a" /* default */]());
} else if (arguments.length === 1) {
let nodeFact = arguments[0];
this._nodes = new __WEBPACK_IMPORTED_MODULE_5__NodeMap__["a" /* default */](nodeFact);
}
}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(PlanarGraph.prototype, {
printEdges: function (out) {
out.println("Edges:");
for (var i = 0; i < this._edges.size(); i++) {
out.println("edge " + i + ":");
var e = this._edges.get(i);
e.print(out);
e.eiList.print(out);
}
},
find: function (coord) {
return this._nodes.find(coord);
},
addNode: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__Node__["a" /* default */]) {
let node = arguments[0];
return this._nodes.addNode(node);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]) {
let coord = arguments[0];
return this._nodes.addNode(coord);
}
},
getNodeIterator: function () {
return this._nodes.iterator();
},
linkResultDirectedEdges: function () {
for (var nodeit = this._nodes.iterator(); nodeit.hasNext(); ) {
var node = nodeit.next();
node.getEdges().linkResultDirectedEdges();
}
},
debugPrintln: function (o) {
__WEBPACK_IMPORTED_MODULE_7__java_lang_System__["a" /* default */].out.println(o);
},
isBoundaryNode: function (geomIndex, coord) {
var node = this._nodes.find(coord);
if (node === null) return false;
var label = node.getLabel();
if (label !== null && label.getLocation(geomIndex) === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY) return true;
return false;
},
linkAllDirectedEdges: function () {
for (var nodeit = this._nodes.iterator(); nodeit.hasNext(); ) {
var node = nodeit.next();
node.getEdges().linkAllDirectedEdges();
}
},
matchInSameDirection: function (p0, p1, ep0, ep1) {
if (!p0.equals(ep0)) return false;
if (__WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].computeOrientation(p0, p1, ep1) === __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].COLLINEAR && __WEBPACK_IMPORTED_MODULE_9__Quadrant__["a" /* default */].quadrant(p0, p1) === __WEBPACK_IMPORTED_MODULE_9__Quadrant__["a" /* default */].quadrant(ep0, ep1)) return true;
return false;
},
getEdgeEnds: function () {
return this._edgeEndList;
},
debugPrint: function (o) {
__WEBPACK_IMPORTED_MODULE_7__java_lang_System__["a" /* default */].out.print(o);
},
getEdgeIterator: function () {
return this._edges.iterator();
},
findEdgeInSameDirection: function (p0, p1) {
for (var i = 0; i < this._edges.size(); i++) {
var e = this._edges.get(i);
var eCoord = e.getCoordinates();
if (this.matchInSameDirection(p0, p1, eCoord[0], eCoord[1])) return e;
if (this.matchInSameDirection(p0, p1, eCoord[eCoord.length - 1], eCoord[eCoord.length - 2])) return e;
}
return null;
},
insertEdge: function (e) {
this._edges.add(e);
},
findEdgeEnd: function (e) {
for (var i = this.getEdgeEnds().iterator(); i.hasNext(); ) {
var ee = i.next();
if (ee.getEdge() === e) return ee;
}
return null;
},
addEdges: function (edgesToAdd) {
for (var it = edgesToAdd.iterator(); it.hasNext(); ) {
var e = it.next();
this._edges.add(e);
var de1 = new __WEBPACK_IMPORTED_MODULE_6__DirectedEdge__["a" /* default */](e, true);
var de2 = new __WEBPACK_IMPORTED_MODULE_6__DirectedEdge__["a" /* default */](e, false);
de1.setSym(de2);
de2.setSym(de1);
this.add(de1);
this.add(de2);
}
},
add: function (e) {
this._nodes.add(e);
this._edgeEndList.add(e);
},
getNodes: function () {
return this._nodes.values();
},
findEdge: function (p0, p1) {
for (var i = 0; i < this._edges.size(); i++) {
var e = this._edges.get(i);
var eCoord = e.getCoordinates();
if (p0.equals(eCoord[0]) && p1.equals(eCoord[1])) return e;
}
return null;
},
interfaces_: function () {
return [];
},
getClass: function () {
return PlanarGraph;
}
});
PlanarGraph.linkResultDirectedEdges = function (nodes) {
for (var nodeit = nodes.iterator(); nodeit.hasNext(); ) {
var node = nodeit.next();
node.getEdges().linkResultDirectedEdges();
}
};
/***/ }),
/* 65 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Node;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__GraphComponent__ = __webpack_require__(135);
function Node() {
__WEBPACK_IMPORTED_MODULE_4__GraphComponent__["a" /* default */].apply(this);
this._coord = null;
this._edges = null;
let coord = arguments[0], edges = arguments[1];
this._coord = coord;
this._edges = edges;
this._label = new __WEBPACK_IMPORTED_MODULE_2__Label__["a" /* default */](0, __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE);
}
Object(__WEBPACK_IMPORTED_MODULE_3__inherits__["a" /* default */])(Node, __WEBPACK_IMPORTED_MODULE_4__GraphComponent__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Node.prototype, {
isIncidentEdgeInResult: function () {
for (var it = this.getEdges().getEdges().iterator(); it.hasNext(); ) {
var de = it.next();
if (de.getEdge().isInResult()) return true;
}
return false;
},
isIsolated: function () {
return this._label.getGeometryCount() === 1;
},
getCoordinate: function () {
return this._coord;
},
print: function (out) {
out.println("node " + this._coord + " lbl: " + this._label);
},
computeIM: function (im) {},
computeMergedLocation: function (label2, eltIndex) {
var loc = __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE;
loc = this._label.getLocation(eltIndex);
if (!label2.isNull(eltIndex)) {
var nLoc = label2.getLocation(eltIndex);
if (loc !== __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY) loc = nLoc;
}
return loc;
},
setLabel: function () {
if (arguments.length === 2) {
let argIndex = arguments[0], onLocation = arguments[1];
if (this._label === null) {
this._label = new __WEBPACK_IMPORTED_MODULE_2__Label__["a" /* default */](argIndex, onLocation);
} else this._label.setLocation(argIndex, onLocation);
} else return __WEBPACK_IMPORTED_MODULE_4__GraphComponent__["a" /* default */].prototype.setLabel.apply(this, arguments);
},
getEdges: function () {
return this._edges;
},
mergeLabel: function () {
if (arguments[0] instanceof Node) {
let n = arguments[0];
this.mergeLabel(n._label);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__Label__["a" /* default */]) {
let label2 = arguments[0];
for (var i = 0; i < 2; i++) {
var loc = this.computeMergedLocation(label2, i);
var thisLoc = this._label.getLocation(i);
if (thisLoc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE) this._label.setLocation(i, loc);
}
}
},
add: function (e) {
this._edges.insert(e);
e.setNode(this);
},
setLabelBoundary: function (argIndex) {
if (this._label === null) return null;
var loc = __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE;
if (this._label !== null) loc = this._label.getLocation(argIndex);
var newLoc = null;
switch (loc) {
case __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY:
newLoc = __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
break;
case __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR:
newLoc = __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
break;
default:
newLoc = __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
break;
}
this._label.setLocation(argIndex, newLoc);
},
interfaces_: function () {
return [];
},
getClass: function () {
return Node;
}
});
/***/ }),
/* 66 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryGraph;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_PointLocator__ = __webpack_require__(62);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_HashMap__ = __webpack_require__(72);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__geom_Point__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__geom_Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__geom_MultiPoint__ = __webpack_require__(41);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__index_SimpleMCSweepLineIntersector__ = __webpack_require__(252);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__geom_LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__algorithm_BoundaryNodeRule__ = __webpack_require__(57);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__index_SegmentIntersector__ = __webpack_require__(140);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__geom_MultiPolygon__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__geom_GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__geom_Polygonal__ = __webpack_require__(40);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__algorithm_locate_IndexedPointInAreaLocator__ = __webpack_require__(256);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__Edge__ = __webpack_require__(77);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__geom_MultiLineString__ = __webpack_require__(28);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__PlanarGraph__ = __webpack_require__(64);
function GeometryGraph() {
__WEBPACK_IMPORTED_MODULE_26__PlanarGraph__["a" /* default */].apply(this);
this._parentGeom = null;
this._lineEdgeMap = new __WEBPACK_IMPORTED_MODULE_3__java_util_HashMap__["a" /* default */]();
this._boundaryNodeRule = null;
this._useBoundaryDeterminationRule = true;
this._argIndex = null;
this._boundaryNodes = null;
this._hasTooFewPoints = false;
this._invalidPoint = null;
this._areaPtLocator = null;
this._ptLocator = new __WEBPACK_IMPORTED_MODULE_0__algorithm_PointLocator__["a" /* default */]();
if (arguments.length === 2) {
let argIndex = arguments[0], parentGeom = arguments[1];
GeometryGraph.call(this, argIndex, parentGeom, __WEBPACK_IMPORTED_MODULE_13__algorithm_BoundaryNodeRule__["a" /* default */].OGC_SFS_BOUNDARY_RULE);
} else if (arguments.length === 3) {
let argIndex = arguments[0], parentGeom = arguments[1], boundaryNodeRule = arguments[2];
this._argIndex = argIndex;
this._parentGeom = parentGeom;
this._boundaryNodeRule = boundaryNodeRule;
if (parentGeom !== null) {
this.add(parentGeom);
}
}
}
Object(__WEBPACK_IMPORTED_MODULE_24__inherits__["a" /* default */])(GeometryGraph, __WEBPACK_IMPORTED_MODULE_26__PlanarGraph__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_14__extend__["a" /* default */])(GeometryGraph.prototype, {
insertBoundaryPoint: function (argIndex, coord) {
var n = this._nodes.addNode(coord);
var lbl = n.getLabel();
var boundaryCount = 1;
var loc = __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE;
loc = lbl.getLocation(argIndex, __WEBPACK_IMPORTED_MODULE_6__Position__["a" /* default */].ON);
if (loc === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY) boundaryCount++;
var newLoc = GeometryGraph.determineBoundary(this._boundaryNodeRule, boundaryCount);
lbl.setLocation(argIndex, newLoc);
},
computeSelfNodes: function () {
if (arguments.length === 2) {
let li = arguments[0], computeRingSelfNodes = arguments[1];
return this.computeSelfNodes(li, computeRingSelfNodes, false);
} else if (arguments.length === 3) {
let li = arguments[0], computeRingSelfNodes = arguments[1], isDoneIfProperInt = arguments[2];
var si = new __WEBPACK_IMPORTED_MODULE_15__index_SegmentIntersector__["a" /* default */](li, true, false);
si.setIsDoneIfProperInt(isDoneIfProperInt);
var esi = this.createEdgeSetIntersector();
var isRings = this._parentGeom instanceof __WEBPACK_IMPORTED_MODULE_12__geom_LinearRing__["a" /* default */] || this._parentGeom instanceof __WEBPACK_IMPORTED_MODULE_9__geom_Polygon__["a" /* default */] || this._parentGeom instanceof __WEBPACK_IMPORTED_MODULE_16__geom_MultiPolygon__["a" /* default */];
var computeAllSegments = computeRingSelfNodes || !isRings;
esi.computeIntersections(this._edges, si, computeAllSegments);
this.addSelfIntersectionNodes(this._argIndex);
return si;
}
},
computeSplitEdges: function (edgelist) {
for (var i = this._edges.iterator(); i.hasNext(); ) {
var e = i.next();
e.eiList.addSplitEdges(edgelist);
}
},
computeEdgeIntersections: function (g, li, includeProper) {
var si = new __WEBPACK_IMPORTED_MODULE_15__index_SegmentIntersector__["a" /* default */](li, includeProper, true);
si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());
var esi = this.createEdgeSetIntersector();
esi.computeIntersections(this._edges, g._edges, si);
return si;
},
getGeometry: function () {
return this._parentGeom;
},
getBoundaryNodeRule: function () {
return this._boundaryNodeRule;
},
hasTooFewPoints: function () {
return this._hasTooFewPoints;
},
addPoint: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_8__geom_Point__["a" /* default */]) {
let p = arguments[0];
var coord = p.getCoordinate();
this.insertPoint(this._argIndex, coord, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_7__geom_Coordinate__["a" /* default */]) {
let pt = arguments[0];
this.insertPoint(this._argIndex, pt, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR);
}
},
addPolygon: function (p) {
this.addPolygonRing(p.getExteriorRing(), __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].EXTERIOR, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR);
for (var i = 0; i < p.getNumInteriorRing(); i++) {
var hole = p.getInteriorRingN(i);
this.addPolygonRing(hole, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].EXTERIOR);
}
},
addEdge: function (e) {
this.insertEdge(e);
var coord = e.getCoordinates();
this.insertPoint(this._argIndex, coord[0], __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY);
this.insertPoint(this._argIndex, coord[coord.length - 1], __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY);
},
addLineString: function (line) {
var coord = __WEBPACK_IMPORTED_MODULE_19__geom_CoordinateArrays__["a" /* default */].removeRepeatedPoints(line.getCoordinates());
if (coord.length < 2) {
this._hasTooFewPoints = true;
this._invalidPoint = coord[0];
return null;
}
var e = new __WEBPACK_IMPORTED_MODULE_23__Edge__["a" /* default */](coord, new __WEBPACK_IMPORTED_MODULE_17__Label__["a" /* default */](this._argIndex, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR));
this._lineEdgeMap.put(line, e);
this.insertEdge(e);
__WEBPACK_IMPORTED_MODULE_22__util_Assert__["a" /* default */].isTrue(coord.length >= 2, "found LineString with single point");
this.insertBoundaryPoint(this._argIndex, coord[0]);
this.insertBoundaryPoint(this._argIndex, coord[coord.length - 1]);
},
getInvalidPoint: function () {
return this._invalidPoint;
},
getBoundaryPoints: function () {
var coll = this.getBoundaryNodes();
var pts = new Array(coll.size()).fill(null);
var i = 0;
for (var it = coll.iterator(); it.hasNext(); ) {
var node = it.next();
pts[i++] = node.getCoordinate().copy();
}
return pts;
},
getBoundaryNodes: function () {
if (this._boundaryNodes === null) this._boundaryNodes = this._nodes.getBoundaryNodes(this._argIndex);
return this._boundaryNodes;
},
addSelfIntersectionNode: function (argIndex, coord, loc) {
if (this.isBoundaryNode(argIndex, coord)) return null;
if (loc === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY && this._useBoundaryDeterminationRule) this.insertBoundaryPoint(argIndex, coord); else this.insertPoint(argIndex, coord, loc);
},
addPolygonRing: function (lr, cwLeft, cwRight) {
if (lr.isEmpty()) return null;
var coord = __WEBPACK_IMPORTED_MODULE_19__geom_CoordinateArrays__["a" /* default */].removeRepeatedPoints(lr.getCoordinates());
if (coord.length < 4) {
this._hasTooFewPoints = true;
this._invalidPoint = coord[0];
return null;
}
var left = cwLeft;
var right = cwRight;
if (__WEBPACK_IMPORTED_MODULE_4__algorithm_CGAlgorithms__["a" /* default */].isCCW(coord)) {
left = cwRight;
right = cwLeft;
}
var e = new __WEBPACK_IMPORTED_MODULE_23__Edge__["a" /* default */](coord, new __WEBPACK_IMPORTED_MODULE_17__Label__["a" /* default */](this._argIndex, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY, left, right));
this._lineEdgeMap.put(lr, e);
this.insertEdge(e);
this.insertPoint(this._argIndex, coord[0], __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY);
},
insertPoint: function (argIndex, coord, onLocation) {
var n = this._nodes.addNode(coord);
var lbl = n.getLabel();
if (lbl === null) {
n._label = new __WEBPACK_IMPORTED_MODULE_17__Label__["a" /* default */](argIndex, onLocation);
} else lbl.setLocation(argIndex, onLocation);
},
createEdgeSetIntersector: function () {
return new __WEBPACK_IMPORTED_MODULE_11__index_SimpleMCSweepLineIntersector__["a" /* default */]();
},
addSelfIntersectionNodes: function (argIndex) {
for (var i = this._edges.iterator(); i.hasNext(); ) {
var e = i.next();
var eLoc = e.getLabel().getLocation(argIndex);
for (var eiIt = e.eiList.iterator(); eiIt.hasNext(); ) {
var ei = eiIt.next();
this.addSelfIntersectionNode(argIndex, ei.coord, eLoc);
}
}
},
add: function () {
if (arguments.length === 1) {
let g = arguments[0];
if (g.isEmpty()) return null;
if (g instanceof __WEBPACK_IMPORTED_MODULE_16__geom_MultiPolygon__["a" /* default */]) this._useBoundaryDeterminationRule = false;
if (g instanceof __WEBPACK_IMPORTED_MODULE_9__geom_Polygon__["a" /* default */]) this.addPolygon(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_2__geom_LineString__["a" /* default */]) this.addLineString(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_8__geom_Point__["a" /* default */]) this.addPoint(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_10__geom_MultiPoint__["a" /* default */]) this.addCollection(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_25__geom_MultiLineString__["a" /* default */]) this.addCollection(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_16__geom_MultiPolygon__["a" /* default */]) this.addCollection(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_18__geom_GeometryCollection__["a" /* default */]) this.addCollection(g); else throw new UnsupportedOperationException(g.getClass().getName());
} else return __WEBPACK_IMPORTED_MODULE_26__PlanarGraph__["a" /* default */].prototype.add.apply(this, arguments);
},
addCollection: function (gc) {
for (var i = 0; i < gc.getNumGeometries(); i++) {
var g = gc.getGeometryN(i);
this.add(g);
}
},
locate: function (pt) {
if (Object(__WEBPACK_IMPORTED_MODULE_5__hasInterface__["a" /* default */])(this._parentGeom, __WEBPACK_IMPORTED_MODULE_20__geom_Polygonal__["a" /* default */]) && this._parentGeom.getNumGeometries() > 50) {
if (this._areaPtLocator === null) {
this._areaPtLocator = new __WEBPACK_IMPORTED_MODULE_21__algorithm_locate_IndexedPointInAreaLocator__["a" /* default */](this._parentGeom);
}
return this._areaPtLocator.locate(pt);
}
return this._ptLocator.locate(pt, this._parentGeom);
},
findEdge: function () {
if (arguments.length === 1) {
let line = arguments[0];
return this._lineEdgeMap.get(line);
} else return __WEBPACK_IMPORTED_MODULE_26__PlanarGraph__["a" /* default */].prototype.findEdge.apply(this, arguments);
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryGraph;
}
});
GeometryGraph.determineBoundary = function (boundaryNodeRule, boundaryCount) {
return boundaryNodeRule.isInBoundary(boundaryCount) ? __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY : __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].INTERIOR;
};
/***/ }),
/* 67 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LinearComponentExtracter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__GeometryComponentFilter__ = __webpack_require__(31);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_util_ArrayList__ = __webpack_require__(1);
function LinearComponentExtracter() {
this._lines = null;
this._isForcedToLineString = false;
if (arguments.length === 1) {
let lines = arguments[0];
this._lines = lines;
} else if (arguments.length === 2) {
let lines = arguments[0], isForcedToLineString = arguments[1];
this._lines = lines;
this._isForcedToLineString = isForcedToLineString;
}
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(LinearComponentExtracter.prototype, {
filter: function (geom) {
if (this._isForcedToLineString && geom instanceof __WEBPACK_IMPORTED_MODULE_4__LinearRing__["a" /* default */]) {
var line = geom.getFactory().createLineString(geom.getCoordinateSequence());
this._lines.add(line);
return null;
}
if (geom instanceof __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]) this._lines.add(geom);
},
setForceToLineString: function (isForcedToLineString) {
this._isForcedToLineString = isForcedToLineString;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_6__GeometryComponentFilter__["a" /* default */]];
},
getClass: function () {
return LinearComponentExtracter;
}
});
LinearComponentExtracter.getGeometry = function () {
if (arguments.length === 1) {
let geom = arguments[0];
return geom.getFactory().buildGeometry(LinearComponentExtracter.getLines(geom));
} else if (arguments.length === 2) {
let geom = arguments[0], forceToLineString = arguments[1];
return geom.getFactory().buildGeometry(LinearComponentExtracter.getLines(geom, forceToLineString));
}
};
LinearComponentExtracter.getLines = function () {
if (arguments.length === 1) {
let geom = arguments[0];
return LinearComponentExtracter.getLines(geom, false);
} else if (arguments.length === 2) {
if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__["a" /* default */]) && Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[1], __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__["a" /* default */])) {
let geoms = arguments[0], lines = arguments[1];
for (var i = geoms.iterator(); i.hasNext(); ) {
var g = i.next();
LinearComponentExtracter.getLines(g, lines);
}
return lines;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */] && typeof arguments[1] === "boolean") {
let geom = arguments[0], forceToLineString = arguments[1];
var lines = new __WEBPACK_IMPORTED_MODULE_7__java_util_ArrayList__["a" /* default */]();
geom.apply(new LinearComponentExtracter(lines, forceToLineString));
return lines;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */] && Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[1], __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__["a" /* default */])) {
let geom = arguments[0], lines = arguments[1];
if (geom instanceof __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]) {
lines.add(geom);
} else {
geom.apply(new LinearComponentExtracter(lines));
}
return lines;
}
} else if (arguments.length === 3) {
if (typeof arguments[2] === "boolean" && (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__["a" /* default */]) && Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[1], __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__["a" /* default */]))) {
let geoms = arguments[0], lines = arguments[1], forceToLineString = arguments[2];
for (var i = geoms.iterator(); i.hasNext(); ) {
var g = i.next();
LinearComponentExtracter.getLines(g, lines, forceToLineString);
}
return lines;
} else if (typeof arguments[2] === "boolean" && (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__Geometry__["a" /* default */] && Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[1], __WEBPACK_IMPORTED_MODULE_3__java_util_Collection__["a" /* default */]))) {
let geom = arguments[0], lines = arguments[1], forceToLineString = arguments[2];
geom.apply(new LinearComponentExtracter(lines, forceToLineString));
return lines;
}
}
};
/***/ }),
/* 68 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = DirectedEdge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geomgraph_Quadrant__ = __webpack_require__(47);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__GraphComponent__ = __webpack_require__(81);
function DirectedEdge() {
__WEBPACK_IMPORTED_MODULE_6__GraphComponent__["a" /* default */].apply(this);
this._parentEdge = null;
this._from = null;
this._to = null;
this._p0 = null;
this._p1 = null;
this._sym = null;
this._edgeDirection = null;
this._quadrant = null;
this._angle = null;
let from = arguments[0], to = arguments[1], directionPt = arguments[2], edgeDirection = arguments[3];
this._from = from;
this._to = to;
this._edgeDirection = edgeDirection;
this._p0 = from.getCoordinate();
this._p1 = directionPt;
var dx = this._p1.x - this._p0.x;
var dy = this._p1.y - this._p0.y;
this._quadrant = __WEBPACK_IMPORTED_MODULE_4__geomgraph_Quadrant__["a" /* default */].quadrant(dx, dy);
this._angle = Math.atan2(dy, dx);
}
Object(__WEBPACK_IMPORTED_MODULE_5__inherits__["a" /* default */])(DirectedEdge, __WEBPACK_IMPORTED_MODULE_6__GraphComponent__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(DirectedEdge.prototype, {
isRemoved: function () {
return this._parentEdge === null;
},
compareDirection: function (e) {
if (this._quadrant > e._quadrant) return 1;
if (this._quadrant < e._quadrant) return -1;
return __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].computeOrientation(e._p0, e._p1, this._p1);
},
getCoordinate: function () {
return this._from.getCoordinate();
},
print: function (out) {
var className = this.getClass().getName();
var lastDotPos = className.lastIndexOf('.');
var name = className.substring(lastDotPos + 1);
out.print(" " + name + ": " + this._p0 + " - " + this._p1 + " " + this._quadrant + ":" + this._angle);
},
getDirectionPt: function () {
return this._p1;
},
getAngle: function () {
return this._angle;
},
compareTo: function (obj) {
var de = obj;
return this.compareDirection(de);
},
getFromNode: function () {
return this._from;
},
getSym: function () {
return this._sym;
},
setEdge: function (parentEdge) {
this._parentEdge = parentEdge;
},
remove: function () {
this._sym = null;
this._parentEdge = null;
},
getEdge: function () {
return this._parentEdge;
},
getQuadrant: function () {
return this._quadrant;
},
setSym: function (sym) {
this._sym = sym;
},
getToNode: function () {
return this._to;
},
getEdgeDirection: function () {
return this._edgeDirection;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_2__java_lang_Comparable__["a" /* default */]];
},
getClass: function () {
return DirectedEdge;
}
});
DirectedEdge.toEdges = function (dirEdges) {
var edges = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
for (var i = dirEdges.iterator(); i.hasNext(); ) {
edges.add(i.next()._parentEdge);
}
return edges;
};
/***/ }),
/* 69 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LinearIterator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_Lineal__ = __webpack_require__(90);
function LinearIterator() {
this._linearGeom = null;
this._numLines = null;
this._currentLine = null;
this._componentIndex = 0;
this._vertexIndex = 0;
if (arguments.length === 1) {
let linear = arguments[0];
LinearIterator.call(this, linear, 0, 0);
} else if (arguments.length === 2) {
let linear = arguments[0], start = arguments[1];
LinearIterator.call(this, linear, start.getComponentIndex(), LinearIterator.segmentEndVertexIndex(start));
} else if (arguments.length === 3) {
let linearGeom = arguments[0], componentIndex = arguments[1], vertexIndex = arguments[2];
if (!Object(__WEBPACK_IMPORTED_MODULE_0__hasInterface__["a" /* default */])(linearGeom, __WEBPACK_IMPORTED_MODULE_3__geom_Lineal__["a" /* default */])) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Lineal geometry is required");
this._linearGeom = linearGeom;
this._numLines = linearGeom.getNumGeometries();
this._componentIndex = componentIndex;
this._vertexIndex = vertexIndex;
this.loadCurrentLine();
}
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(LinearIterator.prototype, {
getComponentIndex: function () {
return this._componentIndex;
},
getLine: function () {
return this._currentLine;
},
getVertexIndex: function () {
return this._vertexIndex;
},
getSegmentEnd: function () {
if (this._vertexIndex < this.getLine().getNumPoints() - 1) return this._currentLine.getCoordinateN(this._vertexIndex + 1);
return null;
},
next: function () {
if (!this.hasNext()) return null;
this._vertexIndex++;
if (this._vertexIndex >= this._currentLine.getNumPoints()) {
this._componentIndex++;
this.loadCurrentLine();
this._vertexIndex = 0;
}
},
loadCurrentLine: function () {
if (this._componentIndex >= this._numLines) {
this._currentLine = null;
return null;
}
this._currentLine = this._linearGeom.getGeometryN(this._componentIndex);
},
getSegmentStart: function () {
return this._currentLine.getCoordinateN(this._vertexIndex);
},
isEndOfLine: function () {
if (this._componentIndex >= this._numLines) return false;
if (this._vertexIndex < this._currentLine.getNumPoints() - 1) return false;
return true;
},
hasNext: function () {
if (this._componentIndex >= this._numLines) return false;
if (this._componentIndex === this._numLines - 1 && this._vertexIndex >= this._currentLine.getNumPoints()) return false;
return true;
},
interfaces_: function () {
return [];
},
getClass: function () {
return LinearIterator;
}
});
LinearIterator.segmentEndVertexIndex = function (loc) {
if (loc.getSegmentFraction() > 0.0) return loc.getSegmentIndex() + 1;
return loc.getSegmentIndex();
};
/***/ }),
/* 70 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "earthRadius", function() { return earthRadius; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factors", function() { return factors; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unitsFactors", function() { return unitsFactors; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "areaFactors", function() { return areaFactors; });
/* harmony export (immutable) */ __webpack_exports__["feature"] = feature;
/* harmony export (immutable) */ __webpack_exports__["geometry"] = geometry;
/* harmony export (immutable) */ __webpack_exports__["point"] = point;
/* harmony export (immutable) */ __webpack_exports__["polygon"] = polygon;
/* harmony export (immutable) */ __webpack_exports__["lineString"] = lineString;
/* harmony export (immutable) */ __webpack_exports__["featureCollection"] = featureCollection;
/* harmony export (immutable) */ __webpack_exports__["multiLineString"] = multiLineString;
/* harmony export (immutable) */ __webpack_exports__["multiPoint"] = multiPoint;
/* harmony export (immutable) */ __webpack_exports__["multiPolygon"] = multiPolygon;
/* harmony export (immutable) */ __webpack_exports__["geometryCollection"] = geometryCollection;
/* harmony export (immutable) */ __webpack_exports__["round"] = round;
/* harmony export (immutable) */ __webpack_exports__["radiansToDistance"] = radiansToDistance;
/* harmony export (immutable) */ __webpack_exports__["distanceToRadians"] = distanceToRadians;
/* harmony export (immutable) */ __webpack_exports__["distanceToDegrees"] = distanceToDegrees;
/* harmony export (immutable) */ __webpack_exports__["bearingToAngle"] = bearingToAngle;
/* harmony export (immutable) */ __webpack_exports__["radians2degrees"] = radians2degrees;
/* harmony export (immutable) */ __webpack_exports__["degrees2radians"] = degrees2radians;
/* harmony export (immutable) */ __webpack_exports__["convertDistance"] = convertDistance;
/* harmony export (immutable) */ __webpack_exports__["convertArea"] = convertArea;
/* harmony export (immutable) */ __webpack_exports__["isNumber"] = isNumber;
/* harmony export (immutable) */ __webpack_exports__["isObject"] = isObject;
/**
* Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
*/
var earthRadius = 6371008.8;
/**
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
*/
var factors = {
meters: earthRadius,
metres: earthRadius,
millimeters: earthRadius * 1000,
millimetres: earthRadius * 1000,
centimeters: earthRadius * 100,
centimetres: earthRadius * 100,
kilometers: earthRadius / 1000,
kilometres: earthRadius / 1000,
miles: earthRadius / 1609.344,
nauticalmiles: earthRadius / 1852,
inches: earthRadius * 39.370,
yards: earthRadius / 1.0936,
feet: earthRadius * 3.28084,
radians: 1,
degrees: earthRadius / 111325,
};
/**
* Units of measurement factors based on 1 meter.
*/
var unitsFactors = {
meters: 1,
metres: 1,
millimeters: 1000,
millimetres: 1000,
centimeters: 100,
centimetres: 100,
kilometers: 1 / 1000,
kilometres: 1 / 1000,
miles: 1 / 1609.344,
nauticalmiles: 1 / 1852,
inches: 39.370,
yards: 1 / 1.0936,
feet: 3.28084,
radians: 1 / earthRadius,
degrees: 1 / 111325,
};
/**
* Area of measurement factors based on 1 square meter.
*/
var areaFactors = {
meters: 1,
metres: 1,
millimeters: 1000000,
millimetres: 1000000,
centimeters: 10000,
centimetres: 10000,
kilometers: 0.000001,
kilometres: 0.000001,
acres: 0.000247105,
miles: 3.86e-7,
yards: 1.195990046,
feet: 10.763910417,
inches: 1550.003100006
};
/**
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
*
* @name feature
* @param {Geometry} geometry input geometry
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON Feature
* @example
* var geometry = {
* "type": "Point",
* "coordinates": [110, 50]
* };
*
* var feature = turf.feature(geometry);
*
* //=feature
*/
function feature(geometry, properties, bbox, id) {
if (geometry === undefined) throw new Error('geometry is required');
if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var feat = {type: 'Feature'};
if (id) feat.id = id;
if (bbox) feat.bbox = bbox;
feat.properties = properties || {};
feat.geometry = geometry;
return feat;
}
/**
* Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
* For GeometryCollection type use `helpers.geometryCollection`
*
* @name geometry
* @param {string} type Geometry Type
* @param {Array} coordinates Coordinates
* @param {Array} [bbox] BBox [west, south, east, north]
* @returns {Geometry} a GeoJSON Geometry
* @example
* var type = 'Point';
* var coordinates = [110, 50];
*
* var geometry = turf.geometry(type, coordinates);
*
* //=geometry
*/
function geometry(type, coordinates, bbox) {
// Validation
if (!type) throw new Error('type is required');
if (!coordinates) throw new Error('coordinates is required');
if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
var geom;
switch (type) {
case 'Point': geom = point(coordinates).geometry; break;
case 'LineString': geom = lineString(coordinates).geometry; break;
case 'Polygon': geom = polygon(coordinates).geometry; break;
case 'MultiPoint': geom = multiPoint(coordinates).geometry; break;
case 'MultiLineString': geom = multiLineString(coordinates).geometry; break;
case 'MultiPolygon': geom = multiPolygon(coordinates).geometry; break;
default: throw new Error(type + ' is invalid');
}
if (bbox) geom.bbox = bbox;
return geom;
}
/**
* Takes coordinates and properties (optional) and returns a new {@link Point} feature.
*
* @name point
* @param {Array} coordinates longitude, latitude position (each in decimal degrees)
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Point feature
* @example
* var point = turf.point([-75.343, 39.984]);
*
* //=point
*/
function point(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'Point',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes an array of LinearRings and optionally an {@link Object} with properties and returns a {@link Polygon} feature.
*
* @name polygon
* @param {Array>>} coordinates an array of LinearRings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Polygon feature
* @throws {Error} throw an error if a LinearRing of the polygon has too few positions
* or if a LinearRing of the Polygon does not have matching Positions at the beginning & end.
* @example
* var polygon = turf.polygon([[
* [-2.275543, 53.464547],
* [-2.275543, 53.489271],
* [-2.215118, 53.489271],
* [-2.215118, 53.464547],
* [-2.275543, 53.464547]
* ]], { name: 'poly1', population: 400});
*
* //=polygon
*/
function polygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
for (var i = 0; i < coordinates.length; i++) {
var ring = coordinates[i];
if (ring.length < 4) {
throw new Error('Each LinearRing of a Polygon must have 4 or more Positions.');
}
for (var j = 0; j < ring[ring.length - 1].length; j++) {
// Check if first point of Polygon contains two numbers
if (i === 0 && j === 0 && !isNumber(ring[0][0]) || !isNumber(ring[0][1])) throw new Error('Coordinates must contain numbers');
if (ring[ring.length - 1][j] !== ring[0][j]) {
throw new Error('First and last Position are not equivalent.');
}
}
}
return feature({
type: 'Polygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link LineString} based on a
* coordinate array. Properties can be added optionally.
*
* @name lineString
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a LineString feature
* @throws {Error} if no coordinates are passed
* @example
* var linestring1 = turf.lineString([
* [-21.964416, 64.148203],
* [-21.956176, 64.141316],
* [-21.93901, 64.135924],
* [-21.927337, 64.136673]
* ]);
* var linestring2 = turf.lineString([
* [-21.929054, 64.127985],
* [-21.912918, 64.134726],
* [-21.916007, 64.141016],
* [-21.930084, 64.14446]
* ], {name: 'line 1', distance: 145});
*
* //=linestring1
*
* //=linestring2
*/
function lineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
// Check if first point of LineString contains two numbers
if (!isNumber(coordinates[0][1]) || !isNumber(coordinates[0][1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'LineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
*
* @name featureCollection
* @param {Feature[]} features input features
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {FeatureCollection} a FeatureCollection of input features
* @example
* var features = [
* turf.point([-75.343, 39.984], {name: 'Location A'}),
* turf.point([-75.833, 39.284], {name: 'Location B'}),
* turf.point([-75.534, 39.123], {name: 'Location C'})
* ];
*
* var collection = turf.featureCollection(features);
*
* //=collection
*/
function featureCollection(features, bbox, id) {
if (!features) throw new Error('No features passed');
if (!Array.isArray(features)) throw new Error('features must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var fc = {type: 'FeatureCollection'};
if (id) fc.id = id;
if (bbox) fc.bbox = bbox;
fc.features = features;
return fc;
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiLineString
* @param {Array>>} coordinates an array of LineStrings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiLineString feature
* @throws {Error} if no coordinates are passed
* @example
* var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
*
* //=multiLine
*/
function multiLineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiLineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPoint
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiPoint feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPt = turf.multiPoint([[0,0],[10,10]]);
*
* //=multiPt
*/
function multiPoint(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPoint',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPolygon
* @param {Array>>>} coordinates an array of Polygons
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a multipolygon feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
*
* //=multiPoly
*
*/
function multiPolygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPolygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name geometryCollection
* @param {Array} geometries an array of GeoJSON Geometries
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON GeometryCollection Feature
* @example
* var pt = {
* "type": "Point",
* "coordinates": [100, 0]
* };
* var line = {
* "type": "LineString",
* "coordinates": [ [101, 0], [102, 1] ]
* };
* var collection = turf.geometryCollection([pt, line]);
*
* //=collection
*/
function geometryCollection(geometries, properties, bbox, id) {
if (!geometries) throw new Error('geometries is required');
if (!Array.isArray(geometries)) throw new Error('geometries must be an Array');
return feature({
type: 'GeometryCollection',
geometries: geometries
}, properties, bbox, id);
}
/**
* Round number to precision
*
* @param {number} num Number
* @param {number} [precision=0] Precision
* @returns {number} rounded number
* @example
* turf.round(120.4321)
* //=120
*
* turf.round(120.4321, 2)
* //=120.43
*/
function round(num, precision) {
if (num === undefined || num === null || isNaN(num)) throw new Error('num is required');
if (precision && !(precision >= 0)) throw new Error('precision must be a positive number');
var multiplier = Math.pow(10, precision || 0);
return Math.round(num * multiplier) / multiplier;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name radiansToDistance
* @param {number} radians in radians across the sphere
* @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} distance
*/
function radiansToDistance(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');
if (units && typeof units !== 'string') throw new Error('units must be a string');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error(units + ' units is invalid');
return radians * factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name distanceToRadians
* @param {number} distance in real units
* @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} radians
*/
function distanceToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');
if (units && typeof units !== 'string') throw new Error('units must be a string');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error(units + ' units is invalid');
return distance / factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
*
* @name distanceToDegrees
* @param {number} distance in real units
* @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} degrees
*/
function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));
}
/**
* Converts any bearing angle from the north line direction (positive clockwise)
* and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
*
* @name bearingToAngle
* @param {number} bearing angle, between -180 and +180 degrees
* @returns {number} angle between 0 and 360 degrees
*/
function bearingToAngle(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');
var angle = bearing % 360;
if (angle < 0) angle += 360;
return angle;
}
/**
* Converts an angle in radians to degrees
*
* @name radians2degrees
* @param {number} radians angle in radians
* @returns {number} degrees between 0 and 360 degrees
*/
function radians2degrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');
var degrees = radians % (2 * Math.PI);
return degrees * 180 / Math.PI;
}
/**
* Converts an angle in degrees to radians
*
* @name degrees2radians
* @param {number} degrees angle between 0 and 360 degrees
* @returns {number} angle in radians
*/
function degrees2radians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');
var radians = degrees % 360;
return radians * Math.PI / 180;
}
/**
* Converts a distance to the requested unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @param {number} distance to be converted
* @param {string} originalUnit of the distance
* @param {string} [finalUnit='kilometers'] returned unit
* @returns {number} the converted distance
*/
function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');
if (!(distance >= 0)) throw new Error('distance must be a positive number');
var convertedDistance = radiansToDistance(distanceToRadians(distance, originalUnit), finalUnit || 'kilometers');
return convertedDistance;
}
/**
* Converts a area to the requested unit.
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
* @param {number} area to be converted
* @param {string} [originalUnit='meters'] of the distance
* @param {string} [finalUnit='kilometers'] returned unit
* @returns {number} the converted distance
*/
function convertArea(area, originalUnit, finalUnit) {
if (area === null || area === undefined) throw new Error('area is required');
if (!(area >= 0)) throw new Error('area must be a positive number');
var startFactor = areaFactors[originalUnit || 'meters'];
if (!startFactor) throw new Error('invalid original units');
var finalFactor = areaFactors[finalUnit || 'kilometers'];
if (!finalFactor) throw new Error('invalid final units');
return (area / startFactor) * finalFactor;
}
/**
* isNumber
*
* @param {*} num Number to validate
* @returns {boolean} true/false
* @example
* turf.isNumber(123)
* //=true
* turf.isNumber('foo')
* //=false
*/
function isNumber(num) {
return !isNaN(num) && num !== null && !Array.isArray(num);
}
/**
* isObject
*
* @param {*} input variable to validate
* @returns {boolean} true/false
* @example
* turf.isObject({elevation: 10})
* //=true
* turf.isObject('foo')
* //=false
*/
function isObject(input) {
return (!!input) && (input.constructor === Object);
}
/***/ }),
/* 71 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NoSuchElementException;
/**
* @param {string=} message Optional message
* @extends {Error}
* @constructor
* @private
*/
function NoSuchElementException(message) {
this.message = message || '';
};
NoSuchElementException.prototype = new Error();
/**
* @type {string}
*/
NoSuchElementException.prototype.name = 'NoSuchElementException';
/***/ }),
/* 72 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = HashMap;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Map__ = __webpack_require__(120);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__HashSet__ = __webpack_require__(45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Map__ = __webpack_require__(220);
let MapImpl = typeof Map === 'undefined' || !Map.prototype.values ? __WEBPACK_IMPORTED_MODULE_3__Map__["a" /* default */] : Map
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/HashMap.html
*
* @extends {javascript.util.Map}
* @constructor
* @private
*/
function HashMap () {
/**
* @type {Object}
* @private
*/
this.map_ = new MapImpl()
}
HashMap.prototype = new __WEBPACK_IMPORTED_MODULE_1__Map__["a" /* default */]()
/**
* @override
*/
HashMap.prototype.get = function (key) {
return this.map_.get(key) || null
}
/**
* @override
*/
HashMap.prototype.put = function (key, value) {
this.map_.set(key, value)
return value
}
/**
* @override
*/
HashMap.prototype.values = function () {
const arrayList = new __WEBPACK_IMPORTED_MODULE_0__ArrayList__["a" /* default */]()
const it = this.map_.values()
let o = it.next()
while (!o.done) {
arrayList.add(o.value)
o = it.next()
}
return arrayList
}
/**
* @override
*/
HashMap.prototype.entrySet = function () {
const hashSet = new __WEBPACK_IMPORTED_MODULE_2__HashSet__["a" /* default */]()
this.map_.entries().forEach(entry => hashSet.add(entry))
return hashSet
}
/**
* @override
*/
HashMap.prototype.size = function () {
return this.map_.size()
}
/***/ }),
/* 73 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = SnapIfNeededOverlayOp;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__SnapOverlayOp__ = __webpack_require__(226);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__ = __webpack_require__(44);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__OverlayOp__ = __webpack_require__(42);
function SnapIfNeededOverlayOp() {
this._geom = new Array(2).fill(null);
let g1 = arguments[0], g2 = arguments[1];
this._geom[0] = g1;
this._geom[1] = g2;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(SnapIfNeededOverlayOp.prototype, {
getResultGeometry: function (opCode) {
var result = null;
var isSuccess = false;
var savedException = null;
try {
result = __WEBPACK_IMPORTED_MODULE_3__OverlayOp__["a" /* default */].overlayOp(this._geom[0], this._geom[1], opCode);
var isValid = true;
if (isValid) isSuccess = true;
} catch (ex) {
if (ex instanceof __WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__["a" /* default */]) {
savedException = ex;
} else throw ex;
} finally {}
if (!isSuccess) {
try {
result = __WEBPACK_IMPORTED_MODULE_0__SnapOverlayOp__["a" /* default */].overlayOp(this._geom[0], this._geom[1], opCode);
} catch (ex) {
if (ex instanceof __WEBPACK_IMPORTED_MODULE_2__java_lang_RuntimeException__["a" /* default */]) {
throw savedException;
} else throw ex;
} finally {}
}
return result;
},
interfaces_: function () {
return [];
},
getClass: function () {
return SnapIfNeededOverlayOp;
}
});
SnapIfNeededOverlayOp.overlayOp = function (g0, g1, opCode) {
var op = new SnapIfNeededOverlayOp(g0, g1);
return op.getResultGeometry(opCode);
};
SnapIfNeededOverlayOp.union = function (g0, g1) {
return SnapIfNeededOverlayOp.overlayOp(g0, g1, __WEBPACK_IMPORTED_MODULE_3__OverlayOp__["a" /* default */].UNION);
};
SnapIfNeededOverlayOp.intersection = function (g0, g1) {
return SnapIfNeededOverlayOp.overlayOp(g0, g1, __WEBPACK_IMPORTED_MODULE_3__OverlayOp__["a" /* default */].INTERSECTION);
};
SnapIfNeededOverlayOp.symDifference = function (g0, g1) {
return SnapIfNeededOverlayOp.overlayOp(g0, g1, __WEBPACK_IMPORTED_MODULE_3__OverlayOp__["a" /* default */].SYMDIFFERENCE);
};
SnapIfNeededOverlayOp.difference = function (g0, g1) {
return SnapIfNeededOverlayOp.overlayOp(g0, g1, __WEBPACK_IMPORTED_MODULE_3__OverlayOp__["a" /* default */].DIFFERENCE);
};
/***/ }),
/* 74 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryTransformer;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__GeometryFactory__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Point__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__MultiPoint__ = __webpack_require__(41);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__MultiPolygon__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__MultiLineString__ = __webpack_require__(28);
function GeometryTransformer() {
this._inputGeom = null;
this._factory = null;
this._pruneEmptyGeometry = true;
this._preserveGeometryCollectionType = true;
this._preserveCollections = false;
this._preserveType = false;
}
Object(__WEBPACK_IMPORTED_MODULE_7__extend__["a" /* default */])(GeometryTransformer.prototype, {
transformPoint: function (geom, parent) {
return this._factory.createPoint(this.transformCoordinates(geom.getCoordinateSequence(), geom));
},
transformPolygon: function (geom, parent) {
var isAllValidLinearRings = true;
var shell = this.transformLinearRing(geom.getExteriorRing(), geom);
if (shell === null || !(shell instanceof __WEBPACK_IMPORTED_MODULE_6__LinearRing__["a" /* default */]) || shell.isEmpty()) isAllValidLinearRings = false;
var holes = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < geom.getNumInteriorRing(); i++) {
var hole = this.transformLinearRing(geom.getInteriorRingN(i), geom);
if (hole === null || hole.isEmpty()) {
continue;
}
if (!(hole instanceof __WEBPACK_IMPORTED_MODULE_6__LinearRing__["a" /* default */])) isAllValidLinearRings = false;
holes.add(hole);
}
if (isAllValidLinearRings) return this._factory.createPolygon(shell, holes.toArray([])); else {
var components = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
if (shell !== null) components.add(shell);
components.addAll(holes);
return this._factory.buildGeometry(components);
}
},
createCoordinateSequence: function (coords) {
return this._factory.getCoordinateSequenceFactory().create(coords);
},
getInputGeometry: function () {
return this._inputGeom;
},
transformMultiLineString: function (geom, parent) {
var transGeomList = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < geom.getNumGeometries(); i++) {
var transformGeom = this.transformLineString(geom.getGeometryN(i), geom);
if (transformGeom === null) continue;
if (transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
return this._factory.buildGeometry(transGeomList);
},
transformCoordinates: function (coords, parent) {
return this.copy(coords);
},
transformLineString: function (geom, parent) {
return this._factory.createLineString(this.transformCoordinates(geom.getCoordinateSequence(), geom));
},
transformMultiPoint: function (geom, parent) {
var transGeomList = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < geom.getNumGeometries(); i++) {
var transformGeom = this.transformPoint(geom.getGeometryN(i), geom);
if (transformGeom === null) continue;
if (transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
return this._factory.buildGeometry(transGeomList);
},
transformMultiPolygon: function (geom, parent) {
var transGeomList = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < geom.getNumGeometries(); i++) {
var transformGeom = this.transformPolygon(geom.getGeometryN(i), geom);
if (transformGeom === null) continue;
if (transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
return this._factory.buildGeometry(transGeomList);
},
copy: function (seq) {
return seq.copy();
},
transformGeometryCollection: function (geom, parent) {
var transGeomList = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < geom.getNumGeometries(); i++) {
var transformGeom = this.transform(geom.getGeometryN(i));
if (transformGeom === null) continue;
if (this._pruneEmptyGeometry && transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
if (this._preserveGeometryCollectionType) return this._factory.createGeometryCollection(__WEBPACK_IMPORTED_MODULE_1__GeometryFactory__["a" /* default */].toGeometryArray(transGeomList));
return this._factory.buildGeometry(transGeomList);
},
transform: function (inputGeom) {
this._inputGeom = inputGeom;
this._factory = inputGeom.getFactory();
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_3__Point__["a" /* default */]) return this.transformPoint(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_5__MultiPoint__["a" /* default */]) return this.transformMultiPoint(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_6__LinearRing__["a" /* default */]) return this.transformLinearRing(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]) return this.transformLineString(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_11__MultiLineString__["a" /* default */]) return this.transformMultiLineString(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_4__Polygon__["a" /* default */]) return this.transformPolygon(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_8__MultiPolygon__["a" /* default */]) return this.transformMultiPolygon(inputGeom, null);
if (inputGeom instanceof __WEBPACK_IMPORTED_MODULE_9__GeometryCollection__["a" /* default */]) return this.transformGeometryCollection(inputGeom, null);
throw new __WEBPACK_IMPORTED_MODULE_2__java_lang_IllegalArgumentException__["a" /* default */]("Unknown Geometry subtype: " + inputGeom.getClass().getName());
},
transformLinearRing: function (geom, parent) {
var seq = this.transformCoordinates(geom.getCoordinateSequence(), geom);
if (seq === null) return this._factory.createLinearRing(null);
var seqSize = seq.size();
if (seqSize > 0 && seqSize < 4 && !this._preserveType) return this._factory.createLineString(seq);
return this._factory.createLinearRing(seq);
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryTransformer;
}
});
/***/ }),
/* 75 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MCIndexNoder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_strtree_STRtree__ = __webpack_require__(76);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__NodedSegmentString__ = __webpack_require__(63);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__index_chain_MonotoneChainOverlapAction__ = __webpack_require__(242);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__index_chain_MonotoneChainBuilder__ = __webpack_require__(131);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__SinglePassNoder__ = __webpack_require__(244);
function MCIndexNoder() {
this._monoChains = new __WEBPACK_IMPORTED_MODULE_5__java_util_ArrayList__["a" /* default */]();
this._index = new __WEBPACK_IMPORTED_MODULE_0__index_strtree_STRtree__["a" /* default */]();
this._idCounter = 0;
this._nodedSegStrings = null;
this._nOverlaps = 0;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let si = arguments[0];
__WEBPACK_IMPORTED_MODULE_7__SinglePassNoder__["a" /* default */].call(this, si);
}
}
Object(__WEBPACK_IMPORTED_MODULE_6__inherits__["a" /* default */])(MCIndexNoder, __WEBPACK_IMPORTED_MODULE_7__SinglePassNoder__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(MCIndexNoder.prototype, {
getMonotoneChains: function () {
return this._monoChains;
},
getNodedSubstrings: function () {
return __WEBPACK_IMPORTED_MODULE_1__NodedSegmentString__["a" /* default */].getNodedSubstrings(this._nodedSegStrings);
},
getIndex: function () {
return this._index;
},
add: function (segStr) {
var segChains = __WEBPACK_IMPORTED_MODULE_4__index_chain_MonotoneChainBuilder__["a" /* default */].getChains(segStr.getCoordinates(), segStr);
for (var i = segChains.iterator(); i.hasNext(); ) {
var mc = i.next();
mc.setId(this._idCounter++);
this._index.insert(mc.getEnvelope(), mc);
this._monoChains.add(mc);
}
},
computeNodes: function (inputSegStrings) {
this._nodedSegStrings = inputSegStrings;
for (var i = inputSegStrings.iterator(); i.hasNext(); ) {
this.add(i.next());
}
this.intersectChains();
},
intersectChains: function () {
var overlapAction = new SegmentOverlapAction(this._segInt);
for (var i = this._monoChains.iterator(); i.hasNext(); ) {
var queryChain = i.next();
var overlapChains = this._index.query(queryChain.getEnvelope());
for (var j = overlapChains.iterator(); j.hasNext(); ) {
var testChain = j.next();
if (testChain.getId() > queryChain.getId()) {
queryChain.computeOverlaps(testChain, overlapAction);
this._nOverlaps++;
}
if (this._segInt.isDone()) return null;
}
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return MCIndexNoder;
}
});
function SegmentOverlapAction() {
__WEBPACK_IMPORTED_MODULE_2__index_chain_MonotoneChainOverlapAction__["a" /* default */].apply(this);
this._si = null;
let si = arguments[0];
this._si = si;
}
Object(__WEBPACK_IMPORTED_MODULE_6__inherits__["a" /* default */])(SegmentOverlapAction, __WEBPACK_IMPORTED_MODULE_2__index_chain_MonotoneChainOverlapAction__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(SegmentOverlapAction.prototype, {
overlap: function () {
if (arguments.length === 4) {
let mc1 = arguments[0], start1 = arguments[1], mc2 = arguments[2], start2 = arguments[3];
var ss1 = mc1.getContext();
var ss2 = mc2.getContext();
this._si.processIntersections(ss1, start1, ss2, start2);
} else return __WEBPACK_IMPORTED_MODULE_2__index_chain_MonotoneChainOverlapAction__["a" /* default */].prototype.overlap.apply(this, arguments);
},
interfaces_: function () {
return [];
},
getClass: function () {
return SegmentOverlapAction;
}
});
MCIndexNoder.SegmentOverlapAction = SegmentOverlapAction;
/***/ }),
/* 76 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = STRtree;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ItemBoundable__ = __webpack_require__(128);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_PriorityQueue__ = __webpack_require__(234);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__ItemVisitor__ = __webpack_require__(52);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SpatialIndex__ = __webpack_require__(130);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__AbstractNode__ = __webpack_require__(95);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_util_Collections__ = __webpack_require__(36);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__BoundablePair__ = __webpack_require__(235);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__java_util_Comparator__ = __webpack_require__(48);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__java_io_Serializable__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__java_util_List__ = __webpack_require__(33);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__ = __webpack_require__(236);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__ItemDistance__ = __webpack_require__(237);
function STRtree() {
if (arguments.length === 0) {
STRtree.call(this, STRtree.DEFAULT_NODE_CAPACITY);
} else if (arguments.length === 1) {
let nodeCapacity = arguments[0];
__WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].call(this, nodeCapacity);
}
}
Object(__WEBPACK_IMPORTED_MODULE_15__inherits__["a" /* default */])(STRtree, __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_7__extend__["a" /* default */])(STRtree.prototype, {
createParentBoundablesFromVerticalSlices: function (verticalSlices, newLevel) {
__WEBPACK_IMPORTED_MODULE_14__util_Assert__["a" /* default */].isTrue(verticalSlices.length > 0);
var parentBoundables = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < verticalSlices.length; i++) {
parentBoundables.addAll(this.createParentBoundablesFromVerticalSlice(verticalSlices[i], newLevel));
}
return parentBoundables;
},
createNode: function (level) {
return new STRtreeNode(level);
},
size: function () {
if (arguments.length === 0) {
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.size.call(this);
} else return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.size.apply(this, arguments);
},
insert: function () {
if (arguments.length === 2) {
let itemEnv = arguments[0], item = arguments[1];
if (itemEnv.isNull()) {
return null;
}
__WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.insert.call(this, itemEnv, item);
} else return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.insert.apply(this, arguments);
},
getIntersectsOp: function () {
return STRtree.intersectsOp;
},
verticalSlices: function (childBoundables, sliceCount) {
var sliceCapacity = Math.trunc(Math.ceil(childBoundables.size() / sliceCount));
var slices = new Array(sliceCount).fill(null);
var i = childBoundables.iterator();
for (var j = 0; j < sliceCount; j++) {
slices[j] = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
var boundablesAddedToSlice = 0;
while (i.hasNext() && boundablesAddedToSlice < sliceCapacity) {
var childBoundable = i.next();
slices[j].add(childBoundable);
boundablesAddedToSlice++;
}
}
return slices;
},
query: function () {
if (arguments.length === 1) {
let searchEnv = arguments[0];
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.query.call(this, searchEnv);
} else if (arguments.length === 2) {
let searchEnv = arguments[0], visitor = arguments[1];
__WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.query.call(this, searchEnv, visitor);
} else if (arguments.length === 3) {
if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[2], __WEBPACK_IMPORTED_MODULE_3__ItemVisitor__["a" /* default */]) && (arguments[0] instanceof Object && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_5__AbstractNode__["a" /* default */])) {
let searchBounds = arguments[0], node = arguments[1], visitor = arguments[2];
__WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.query.call(this, searchBounds, node, visitor);
} else if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[2], __WEBPACK_IMPORTED_MODULE_16__java_util_List__["a" /* default */]) && (arguments[0] instanceof Object && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_5__AbstractNode__["a" /* default */])) {
let searchBounds = arguments[0], node = arguments[1], matches = arguments[2];
__WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.query.call(this, searchBounds, node, matches);
}
}
},
getComparator: function () {
return STRtree.yComparator;
},
createParentBoundablesFromVerticalSlice: function (childBoundables, newLevel) {
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.createParentBoundables.call(this, childBoundables, newLevel);
},
remove: function () {
if (arguments.length === 2) {
let itemEnv = arguments[0], item = arguments[1];
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.remove.call(this, itemEnv, item);
} else return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.remove.apply(this, arguments);
},
depth: function () {
if (arguments.length === 0) {
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.depth.call(this);
} else return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].prototype.depth.apply(this, arguments);
},
createParentBoundables: function (childBoundables, newLevel) {
__WEBPACK_IMPORTED_MODULE_14__util_Assert__["a" /* default */].isTrue(!childBoundables.isEmpty());
var minLeafCount = Math.trunc(Math.ceil(childBoundables.size() / this.getNodeCapacity()));
var sortedChildBoundables = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */](childBoundables);
__WEBPACK_IMPORTED_MODULE_8__java_util_Collections__["a" /* default */].sort(sortedChildBoundables, STRtree.xComparator);
var verticalSlices = this.verticalSlices(sortedChildBoundables, Math.trunc(Math.ceil(Math.sqrt(minLeafCount))));
return this.createParentBoundablesFromVerticalSlices(verticalSlices, newLevel);
},
nearestNeighbour: function () {
if (arguments.length === 1) {
if (Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_18__ItemDistance__["a" /* default */])) {
let itemDist = arguments[0];
var bp = new __WEBPACK_IMPORTED_MODULE_9__BoundablePair__["a" /* default */](this.getRoot(), this.getRoot(), itemDist);
return this.nearestNeighbour(bp);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_9__BoundablePair__["a" /* default */]) {
let initBndPair = arguments[0];
return this.nearestNeighbour(initBndPair, __WEBPACK_IMPORTED_MODULE_6__java_lang_Double__["a" /* default */].POSITIVE_INFINITY);
}
} else if (arguments.length === 2) {
if (arguments[0] instanceof STRtree && Object(__WEBPACK_IMPORTED_MODULE_2__hasInterface__["a" /* default */])(arguments[1], __WEBPACK_IMPORTED_MODULE_18__ItemDistance__["a" /* default */])) {
let tree = arguments[0], itemDist = arguments[1];
var bp = new __WEBPACK_IMPORTED_MODULE_9__BoundablePair__["a" /* default */](this.getRoot(), tree.getRoot(), itemDist);
return this.nearestNeighbour(bp);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_9__BoundablePair__["a" /* default */] && typeof arguments[1] === "number") {
let initBndPair = arguments[0], maxDistance = arguments[1];
var distanceLowerBound = maxDistance;
var minPair = null;
var priQ = new __WEBPACK_IMPORTED_MODULE_1__util_PriorityQueue__["a" /* default */]();
priQ.add(initBndPair);
while (!priQ.isEmpty() && distanceLowerBound > 0.0) {
var bndPair = priQ.poll();
var currentDistance = bndPair.getDistance();
if (currentDistance >= distanceLowerBound) break;
if (bndPair.isLeaves()) {
distanceLowerBound = currentDistance;
minPair = bndPair;
} else {
bndPair.expandToQueue(priQ, distanceLowerBound);
}
}
return [minPair.getBoundable(0).getItem(), minPair.getBoundable(1).getItem()];
}
} else if (arguments.length === 3) {
let env = arguments[0], item = arguments[1], itemDist = arguments[2];
var bnd = new __WEBPACK_IMPORTED_MODULE_0__ItemBoundable__["a" /* default */](env, item);
var bp = new __WEBPACK_IMPORTED_MODULE_9__BoundablePair__["a" /* default */](this.getRoot(), bnd, itemDist);
return this.nearestNeighbour(bp)[0];
}
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_4__SpatialIndex__["a" /* default */], __WEBPACK_IMPORTED_MODULE_12__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return STRtree;
}
});
STRtree.centreX = function (e) {
return STRtree.avg(e.getMinX(), e.getMaxX());
};
STRtree.avg = function (a, b) {
return (a + b) / 2;
};
STRtree.centreY = function (e) {
return STRtree.avg(e.getMinY(), e.getMaxY());
};
function STRtreeNode() {
let level = arguments[0];
__WEBPACK_IMPORTED_MODULE_5__AbstractNode__["a" /* default */].call(this, level);
}
Object(__WEBPACK_IMPORTED_MODULE_15__inherits__["a" /* default */])(STRtreeNode, __WEBPACK_IMPORTED_MODULE_5__AbstractNode__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_7__extend__["a" /* default */])(STRtreeNode.prototype, {
computeBounds: function () {
var bounds = null;
for (var i = this.getChildBoundables().iterator(); i.hasNext(); ) {
var childBoundable = i.next();
if (bounds === null) {
bounds = new __WEBPACK_IMPORTED_MODULE_13__geom_Envelope__["a" /* default */](childBoundable.getBounds());
} else {
bounds.expandToInclude(childBoundable.getBounds());
}
}
return bounds;
},
interfaces_: function () {
return [];
},
getClass: function () {
return STRtreeNode;
}
});
STRtree.STRtreeNode = STRtreeNode;
STRtree.serialVersionUID = 259274702368956900;
STRtree.xComparator = {
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_11__java_util_Comparator__["a" /* default */]];
},
compare: function (o1, o2) {
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].compareDoubles(STRtree.centreX(o1.getBounds()), STRtree.centreX(o2.getBounds()));
}
};
STRtree.yComparator = {
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_11__java_util_Comparator__["a" /* default */]];
},
compare: function (o1, o2) {
return __WEBPACK_IMPORTED_MODULE_17__AbstractSTRtree__["a" /* default */].compareDoubles(STRtree.centreY(o1.getBounds()), STRtree.centreY(o2.getBounds()));
}
};
STRtree.intersectsOp = {
interfaces_: function () {
return [IntersectsOp];
},
intersects: function (aBounds, bBounds) {
return aBounds.intersects(bBounds);
}
};
STRtree.DEFAULT_NODE_CAPACITY = 10;
/***/ }),
/* 77 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Edge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__EdgeIntersectionList__ = __webpack_require__(260);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__index_MonotoneChainEdge__ = __webpack_require__(262);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Depth__ = __webpack_require__(264);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__GraphComponent__ = __webpack_require__(135);
function Edge() {
__WEBPACK_IMPORTED_MODULE_10__GraphComponent__["a" /* default */].apply(this);
this.pts = null;
this._env = null;
this.eiList = new __WEBPACK_IMPORTED_MODULE_1__EdgeIntersectionList__["a" /* default */](this);
this._name = null;
this._mce = null;
this._isIsolated = true;
this._depth = new __WEBPACK_IMPORTED_MODULE_9__Depth__["a" /* default */]();
this._depthDelta = 0;
if (arguments.length === 1) {
let pts = arguments[0];
Edge.call(this, pts, null);
} else if (arguments.length === 2) {
let pts = arguments[0], label = arguments[1];
this.pts = pts;
this._label = label;
}
}
Object(__WEBPACK_IMPORTED_MODULE_8__inherits__["a" /* default */])(Edge, __WEBPACK_IMPORTED_MODULE_10__GraphComponent__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(Edge.prototype, {
getDepth: function () {
return this._depth;
},
getCollapsedEdge: function () {
var newPts = new Array(2).fill(null);
newPts[0] = this.pts[0];
newPts[1] = this.pts[1];
var newe = new Edge(newPts, __WEBPACK_IMPORTED_MODULE_6__Label__["a" /* default */].toLineLabel(this._label));
return newe;
},
isIsolated: function () {
return this._isIsolated;
},
getCoordinates: function () {
return this.pts;
},
setIsolated: function (isIsolated) {
this._isIsolated = isIsolated;
},
setName: function (name) {
this._name = name;
},
equals: function (o) {
if (!(o instanceof Edge)) return false;
var e = o;
if (this.pts.length !== e.pts.length) return false;
var isEqualForward = true;
var isEqualReverse = true;
var iRev = this.pts.length;
for (var i = 0; i < this.pts.length; i++) {
if (!this.pts[i].equals2D(e.pts[i])) {
isEqualForward = false;
}
if (!this.pts[i].equals2D(e.pts[-- iRev])) {
isEqualReverse = false;
}
if (!isEqualForward && !isEqualReverse) return false;
}
return true;
},
getCoordinate: function () {
if (arguments.length === 0) {
if (this.pts.length > 0) return this.pts[0];
return null;
} else if (arguments.length === 1) {
let i = arguments[0];
return this.pts[i];
}
},
print: function (out) {
out.print("edge " + this._name + ": ");
out.print("LINESTRING (");
for (var i = 0; i < this.pts.length; i++) {
if (i > 0) out.print(",");
out.print(this.pts[i].x + " " + this.pts[i].y);
}
out.print(") " + this._label + " " + this._depthDelta);
},
computeIM: function (im) {
Edge.updateIM(this._label, im);
},
isCollapsed: function () {
if (!this._label.isArea()) return false;
if (this.pts.length !== 3) return false;
if (this.pts[0].equals(this.pts[2])) return true;
return false;
},
isClosed: function () {
return this.pts[0].equals(this.pts[this.pts.length - 1]);
},
getMaximumSegmentIndex: function () {
return this.pts.length - 1;
},
getDepthDelta: function () {
return this._depthDelta;
},
getNumPoints: function () {
return this.pts.length;
},
printReverse: function (out) {
out.print("edge " + this._name + ": ");
for (var i = this.pts.length - 1; i >= 0; i--) {
out.print(this.pts[i] + " ");
}
out.println("");
},
getMonotoneChainEdge: function () {
if (this._mce === null) this._mce = new __WEBPACK_IMPORTED_MODULE_2__index_MonotoneChainEdge__["a" /* default */](this);
return this._mce;
},
getEnvelope: function () {
if (this._env === null) {
this._env = new __WEBPACK_IMPORTED_MODULE_7__geom_Envelope__["a" /* default */]();
for (var i = 0; i < this.pts.length; i++) {
this._env.expandToInclude(this.pts[i]);
}
}
return this._env;
},
addIntersection: function (li, segmentIndex, geomIndex, intIndex) {
var intPt = new __WEBPACK_IMPORTED_MODULE_4__geom_Coordinate__["a" /* default */](li.getIntersection(intIndex));
var normalizedSegmentIndex = segmentIndex;
var dist = li.getEdgeDistance(geomIndex, intIndex);
var nextSegIndex = normalizedSegmentIndex + 1;
if (nextSegIndex < this.pts.length) {
var nextPt = this.pts[nextSegIndex];
if (intPt.equals2D(nextPt)) {
normalizedSegmentIndex = nextSegIndex;
dist = 0.0;
}
}
var ei = this.eiList.add(intPt, normalizedSegmentIndex, dist);
},
toString: function () {
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]();
buf.append("edge " + this._name + ": ");
buf.append("LINESTRING (");
for (var i = 0; i < this.pts.length; i++) {
if (i > 0) buf.append(",");
buf.append(this.pts[i].x + " " + this.pts[i].y);
}
buf.append(") " + this._label + " " + this._depthDelta);
return buf.toString();
},
isPointwiseEqual: function (e) {
if (this.pts.length !== e.pts.length) return false;
for (var i = 0; i < this.pts.length; i++) {
if (!this.pts[i].equals2D(e.pts[i])) {
return false;
}
}
return true;
},
setDepthDelta: function (depthDelta) {
this._depthDelta = depthDelta;
},
getEdgeIntersectionList: function () {
return this.eiList;
},
addIntersections: function (li, segmentIndex, geomIndex) {
for (var i = 0; i < li.getIntersectionNum(); i++) {
this.addIntersection(li, segmentIndex, geomIndex, i);
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return Edge;
}
});
Edge.updateIM = function () {
if (arguments.length === 2) {
let label = arguments[0], im = arguments[1];
im.setAtLeastIfValid(label.getLocation(0, __WEBPACK_IMPORTED_MODULE_3__Position__["a" /* default */].ON), label.getLocation(1, __WEBPACK_IMPORTED_MODULE_3__Position__["a" /* default */].ON), 1);
if (label.isArea()) {
im.setAtLeastIfValid(label.getLocation(0, __WEBPACK_IMPORTED_MODULE_3__Position__["a" /* default */].LEFT), label.getLocation(1, __WEBPACK_IMPORTED_MODULE_3__Position__["a" /* default */].LEFT), 2);
im.setAtLeastIfValid(label.getLocation(0, __WEBPACK_IMPORTED_MODULE_3__Position__["a" /* default */].RIGHT), label.getLocation(1, __WEBPACK_IMPORTED_MODULE_3__Position__["a" /* default */].RIGHT), 2);
}
} else return __WEBPACK_IMPORTED_MODULE_10__GraphComponent__["a" /* default */].prototype.updateIM.apply(this, arguments);
};
/***/ }),
/* 78 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Interval;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Interval() {
this.min = null;
this.max = null;
if (arguments.length === 0) {
this.min = 0.0;
this.max = 0.0;
} else if (arguments.length === 1) {
let interval = arguments[0];
this.init(interval.min, interval.max);
} else if (arguments.length === 2) {
let min = arguments[0], max = arguments[1];
this.init(min, max);
}
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Interval.prototype, {
expandToInclude: function (interval) {
if (interval.max > this.max) this.max = interval.max;
if (interval.min < this.min) this.min = interval.min;
},
getWidth: function () {
return this.max - this.min;
},
overlaps: function () {
if (arguments.length === 1) {
let interval = arguments[0];
return this.overlaps(interval.min, interval.max);
} else if (arguments.length === 2) {
let min = arguments[0], max = arguments[1];
if (this.min > max || this.max < min) return false;
return true;
}
},
getMin: function () {
return this.min;
},
toString: function () {
return "[" + this.min + ", " + this.max + "]";
},
contains: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof Interval) {
let interval = arguments[0];
return this.contains(interval.min, interval.max);
} else if (typeof arguments[0] === "number") {
let p = arguments[0];
return p >= this.min && p <= this.max;
}
} else if (arguments.length === 2) {
let min = arguments[0], max = arguments[1];
return min >= this.min && max <= this.max;
}
},
init: function (min, max) {
this.min = min;
this.max = max;
if (min > max) {
this.min = max;
this.max = min;
}
},
getMax: function () {
return this.max;
},
interfaces_: function () {
return [];
},
getClass: function () {
return Interval;
}
});
/***/ }),
/* 79 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Triangle;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__algorithm_Angle__ = __webpack_require__(104);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__algorithm_HCoordinate__ = __webpack_require__(56);
function Triangle() {
this.p0 = null;
this.p1 = null;
this.p2 = null;
let p0 = arguments[0], p1 = arguments[1], p2 = arguments[2];
this.p0 = p0;
this.p1 = p1;
this.p2 = p2;
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(Triangle.prototype, {
area: function () {
return Triangle.area(this.p0, this.p1, this.p2);
},
signedArea: function () {
return Triangle.signedArea(this.p0, this.p1, this.p2);
},
interpolateZ: function (p) {
if (p === null) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Supplied point is null.");
return Triangle.interpolateZ(p, this.p0, this.p1, this.p2);
},
longestSideLength: function () {
return Triangle.longestSideLength(this.p0, this.p1, this.p2);
},
isAcute: function () {
return Triangle.isAcute(this.p0, this.p1, this.p2);
},
circumcentre: function () {
return Triangle.circumcentre(this.p0, this.p1, this.p2);
},
area3D: function () {
return Triangle.area3D(this.p0, this.p1, this.p2);
},
centroid: function () {
return Triangle.centroid(this.p0, this.p1, this.p2);
},
inCentre: function () {
return Triangle.inCentre(this.p0, this.p1, this.p2);
},
interfaces_: function () {
return [];
},
getClass: function () {
return Triangle;
}
});
Triangle.area = function (a, b, c) {
return Math.abs(((c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y)) / 2);
};
Triangle.signedArea = function (a, b, c) {
return ((c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y)) / 2;
};
Triangle.det = function (m00, m01, m10, m11) {
return m00 * m11 - m01 * m10;
};
Triangle.interpolateZ = function (p, v0, v1, v2) {
var x0 = v0.x;
var y0 = v0.y;
var a = v1.x - x0;
var b = v2.x - x0;
var c = v1.y - y0;
var d = v2.y - y0;
var det = a * d - b * c;
var dx = p.x - x0;
var dy = p.y - y0;
var t = (d * dx - b * dy) / det;
var u = (-c * dx + a * dy) / det;
var z = v0.z + t * (v1.z - v0.z) + u * (v2.z - v0.z);
return z;
};
Triangle.longestSideLength = function (a, b, c) {
var lenAB = a.distance(b);
var lenBC = b.distance(c);
var lenCA = c.distance(a);
var maxLen = lenAB;
if (lenBC > maxLen) maxLen = lenBC;
if (lenCA > maxLen) maxLen = lenCA;
return maxLen;
};
Triangle.isAcute = function (a, b, c) {
if (!__WEBPACK_IMPORTED_MODULE_3__algorithm_Angle__["a" /* default */].isAcute(a, b, c)) return false;
if (!__WEBPACK_IMPORTED_MODULE_3__algorithm_Angle__["a" /* default */].isAcute(b, c, a)) return false;
if (!__WEBPACK_IMPORTED_MODULE_3__algorithm_Angle__["a" /* default */].isAcute(c, a, b)) return false;
return true;
};
Triangle.circumcentre = function (a, b, c) {
var cx = c.x;
var cy = c.y;
var ax = a.x - cx;
var ay = a.y - cy;
var bx = b.x - cx;
var by = b.y - cy;
var denom = 2 * Triangle.det(ax, ay, bx, by);
var numx = Triangle.det(ay, ax * ax + ay * ay, by, bx * bx + by * by);
var numy = Triangle.det(ax, ax * ax + ay * ay, bx, bx * bx + by * by);
var ccx = cx - numx / denom;
var ccy = cy + numy / denom;
return new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */](ccx, ccy);
};
Triangle.perpendicularBisector = function (a, b) {
var dx = b.x - a.x;
var dy = b.y - a.y;
var l1 = new __WEBPACK_IMPORTED_MODULE_4__algorithm_HCoordinate__["a" /* default */](a.x + dx / 2.0, a.y + dy / 2.0, 1.0);
var l2 = new __WEBPACK_IMPORTED_MODULE_4__algorithm_HCoordinate__["a" /* default */](a.x - dy + dx / 2.0, a.y + dx + dy / 2.0, 1.0);
return new __WEBPACK_IMPORTED_MODULE_4__algorithm_HCoordinate__["a" /* default */](l1, l2);
};
Triangle.angleBisector = function (a, b, c) {
var len0 = b.distance(a);
var len2 = b.distance(c);
var frac = len0 / (len0 + len2);
var dx = c.x - a.x;
var dy = c.y - a.y;
var splitPt = new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */](a.x + frac * dx, a.y + frac * dy);
return splitPt;
};
Triangle.area3D = function (a, b, c) {
var ux = b.x - a.x;
var uy = b.y - a.y;
var uz = b.z - a.z;
var vx = c.x - a.x;
var vy = c.y - a.y;
var vz = c.z - a.z;
var crossx = uy * vz - uz * vy;
var crossy = uz * vx - ux * vz;
var crossz = ux * vy - uy * vx;
var absSq = crossx * crossx + crossy * crossy + crossz * crossz;
var area3D = Math.sqrt(absSq) / 2;
return area3D;
};
Triangle.centroid = function (a, b, c) {
var x = (a.x + b.x + c.x) / 3;
var y = (a.y + b.y + c.y) / 3;
return new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */](x, y);
};
Triangle.inCentre = function (a, b, c) {
var len0 = b.distance(c);
var len1 = a.distance(c);
var len2 = a.distance(b);
var circum = len0 + len1 + len2;
var inCentreX = (len0 * a.x + len1 * b.x + len2 * c.x) / circum;
var inCentreY = (len0 * a.y + len1 * b.y + len2 * c.y) / circum;
return new __WEBPACK_IMPORTED_MODULE_0__Coordinate__["a" /* default */](inCentreX, inCentreY);
};
/***/ }),
/* 80 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = BufferParameters;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function BufferParameters() {
this._quadrantSegments = BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
this._endCapStyle = BufferParameters.CAP_ROUND;
this._joinStyle = BufferParameters.JOIN_ROUND;
this._mitreLimit = BufferParameters.DEFAULT_MITRE_LIMIT;
this._isSingleSided = false;
this._simplifyFactor = BufferParameters.DEFAULT_SIMPLIFY_FACTOR;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let quadrantSegments = arguments[0];
this.setQuadrantSegments(quadrantSegments);
} else if (arguments.length === 2) {
let quadrantSegments = arguments[0], endCapStyle = arguments[1];
this.setQuadrantSegments(quadrantSegments);
this.setEndCapStyle(endCapStyle);
} else if (arguments.length === 4) {
let quadrantSegments = arguments[0], endCapStyle = arguments[1], joinStyle = arguments[2], mitreLimit = arguments[3];
this.setQuadrantSegments(quadrantSegments);
this.setEndCapStyle(endCapStyle);
this.setJoinStyle(joinStyle);
this.setMitreLimit(mitreLimit);
}
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(BufferParameters.prototype, {
getEndCapStyle: function () {
return this._endCapStyle;
},
isSingleSided: function () {
return this._isSingleSided;
},
setQuadrantSegments: function (quadSegs) {
this._quadrantSegments = quadSegs;
if (this._quadrantSegments === 0) this._joinStyle = BufferParameters.JOIN_BEVEL;
if (this._quadrantSegments < 0) {
this._joinStyle = BufferParameters.JOIN_MITRE;
this._mitreLimit = Math.abs(this._quadrantSegments);
}
if (quadSegs <= 0) {
this._quadrantSegments = 1;
}
if (this._joinStyle !== BufferParameters.JOIN_ROUND) {
this._quadrantSegments = BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
}
},
getJoinStyle: function () {
return this._joinStyle;
},
setJoinStyle: function (joinStyle) {
this._joinStyle = joinStyle;
},
setSimplifyFactor: function (simplifyFactor) {
this._simplifyFactor = simplifyFactor < 0 ? 0 : simplifyFactor;
},
getSimplifyFactor: function () {
return this._simplifyFactor;
},
getQuadrantSegments: function () {
return this._quadrantSegments;
},
setEndCapStyle: function (endCapStyle) {
this._endCapStyle = endCapStyle;
},
getMitreLimit: function () {
return this._mitreLimit;
},
setMitreLimit: function (mitreLimit) {
this._mitreLimit = mitreLimit;
},
setSingleSided: function (isSingleSided) {
this._isSingleSided = isSingleSided;
},
interfaces_: function () {
return [];
},
getClass: function () {
return BufferParameters;
}
});
BufferParameters.bufferDistanceError = function (quadSegs) {
var alpha = Math.PI / 2.0 / quadSegs;
return 1 - Math.cos(alpha / 2.0);
};
BufferParameters.CAP_ROUND = 1;
BufferParameters.CAP_FLAT = 2;
BufferParameters.CAP_SQUARE = 3;
BufferParameters.JOIN_ROUND = 1;
BufferParameters.JOIN_MITRE = 2;
BufferParameters.JOIN_BEVEL = 3;
BufferParameters.DEFAULT_QUADRANT_SEGMENTS = 8;
BufferParameters.DEFAULT_MITRE_LIMIT = 5.0;
BufferParameters.DEFAULT_SIMPLIFY_FACTOR = 0.01;
/***/ }),
/* 81 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GraphComponent;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function GraphComponent() {
this._isMarked = false;
this._isVisited = false;
this._data = null;
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(GraphComponent.prototype, {
setVisited: function (isVisited) {
this._isVisited = isVisited;
},
isMarked: function () {
return this._isMarked;
},
setData: function (data) {
this._data = data;
},
getData: function () {
return this._data;
},
setMarked: function (isMarked) {
this._isMarked = isMarked;
},
getContext: function () {
return this._data;
},
isVisited: function () {
return this._isVisited;
},
setContext: function (data) {
this._data = data;
},
interfaces_: function () {
return [];
},
getClass: function () {
return GraphComponent;
}
});
GraphComponent.getComponentWithVisitedState = function (i, visitedState) {
while (i.hasNext()) {
var comp = i.next();
if (comp.isVisited() === visitedState) return comp;
}
return null;
};
GraphComponent.setVisited = function (i, visited) {
while (i.hasNext()) {
var comp = i.next();
comp.setVisited(visited);
}
};
GraphComponent.setMarked = function (i, marked) {
while (i.hasNext()) {
var comp = i.next();
comp.setMarked(marked);
}
};
/***/ }),
/* 82 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Node;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__DirectedEdgeStar__ = __webpack_require__(324);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_util_HashSet__ = __webpack_require__(45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__DirectedEdge__ = __webpack_require__(68);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__GraphComponent__ = __webpack_require__(81);
function Node() {
__WEBPACK_IMPORTED_MODULE_5__GraphComponent__["a" /* default */].apply(this);
this._pt = null;
this._deStar = null;
if (arguments.length === 1) {
let pt = arguments[0];
Node.call(this, pt, new __WEBPACK_IMPORTED_MODULE_0__DirectedEdgeStar__["a" /* default */]());
} else if (arguments.length === 2) {
let pt = arguments[0], deStar = arguments[1];
this._pt = pt;
this._deStar = deStar;
}
}
Object(__WEBPACK_IMPORTED_MODULE_4__inherits__["a" /* default */])(Node, __WEBPACK_IMPORTED_MODULE_5__GraphComponent__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(Node.prototype, {
isRemoved: function () {
return this._pt === null;
},
addOutEdge: function (de) {
this._deStar.add(de);
},
getCoordinate: function () {
return this._pt;
},
getOutEdges: function () {
return this._deStar;
},
remove: function () {
if (arguments.length === 0) {
this._pt = null;
} else if (arguments.length === 1) {
let de = arguments[0];
this._deStar.remove(de);
}
},
getIndex: function (edge) {
return this._deStar.getIndex(edge);
},
getDegree: function () {
return this._deStar.getDegree();
},
interfaces_: function () {
return [];
},
getClass: function () {
return Node;
}
});
Node.getEdgesBetween = function (node0, node1) {
var edges0 = __WEBPACK_IMPORTED_MODULE_3__DirectedEdge__["a" /* default */].toEdges(node0.getOutEdges().getEdges());
var commonEdges = new __WEBPACK_IMPORTED_MODULE_1__java_util_HashSet__["a" /* default */](edges0);
var edges1 = __WEBPACK_IMPORTED_MODULE_3__DirectedEdge__["a" /* default */].toEdges(node1.getOutEdges().getEdges());
commonEdges.retainAll(edges1);
return commonEdges;
};
/***/ }),
/* 83 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Edge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(82);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__GraphComponent__ = __webpack_require__(81);
function Edge() {
__WEBPACK_IMPORTED_MODULE_3__GraphComponent__["a" /* default */].apply(this);
this._dirEdge = null;
if (arguments.length === 0) {} else if (arguments.length === 2) {
let de0 = arguments[0], de1 = arguments[1];
this.setDirectedEdges(de0, de1);
}
}
Object(__WEBPACK_IMPORTED_MODULE_2__inherits__["a" /* default */])(Edge, __WEBPACK_IMPORTED_MODULE_3__GraphComponent__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Edge.prototype, {
isRemoved: function () {
return this._dirEdge === null;
},
setDirectedEdges: function (de0, de1) {
this._dirEdge = [de0, de1];
de0.setEdge(this);
de1.setEdge(this);
de0.setSym(de1);
de1.setSym(de0);
de0.getFromNode().addOutEdge(de0);
de1.getFromNode().addOutEdge(de1);
},
getDirEdge: function () {
if (Number.isInteger(arguments[0])) {
let i = arguments[0];
return this._dirEdge[i];
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */]) {
let fromNode = arguments[0];
if (this._dirEdge[0].getFromNode() === fromNode) return this._dirEdge[0];
if (this._dirEdge[1].getFromNode() === fromNode) return this._dirEdge[1];
return null;
}
},
remove: function () {
this._dirEdge = null;
},
getOppositeNode: function (node) {
if (this._dirEdge[0].getFromNode() === node) return this._dirEdge[0].getToNode();
if (this._dirEdge[1].getFromNode() === node) return this._dirEdge[1].getToNode();
return null;
},
interfaces_: function () {
return [];
},
getClass: function () {
return Edge;
}
});
/***/ }),
/* 84 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Vertex;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_NotRepresentableException__ = __webpack_require__(54);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TrianglePredicate__ = __webpack_require__(369);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__algorithm_HCoordinate__ = __webpack_require__(56);
function Vertex() {
this._p = null;
if (arguments.length === 1) {
let _p = arguments[0];
this._p = new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */](_p);
} else if (arguments.length === 2) {
let _x = arguments[0], _y = arguments[1];
this._p = new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */](_x, _y);
} else if (arguments.length === 3) {
let _x = arguments[0], _y = arguments[1], _z = arguments[2];
this._p = new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */](_x, _y, _z);
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(Vertex.prototype, {
circleCenter: function (b, c) {
var a = new Vertex(this.getX(), this.getY());
var cab = this.bisector(a, b);
var cbc = this.bisector(b, c);
var hcc = new __WEBPACK_IMPORTED_MODULE_5__algorithm_HCoordinate__["a" /* default */](cab, cbc);
var cc = null;
try {
cc = new Vertex(hcc.getX(), hcc.getY());
} catch (nre) {
if (nre instanceof __WEBPACK_IMPORTED_MODULE_0__algorithm_NotRepresentableException__["a" /* default */]) {
__WEBPACK_IMPORTED_MODULE_4__java_lang_System__["a" /* default */].err.println("a: " + a + " b: " + b + " c: " + c);
__WEBPACK_IMPORTED_MODULE_4__java_lang_System__["a" /* default */].err.println(nre);
} else throw nre;
} finally {}
return cc;
},
dot: function (v) {
return this._p.x * v.getX() + this._p.y * v.getY();
},
magn: function () {
return Math.sqrt(this._p.x * this._p.x + this._p.y * this._p.y);
},
getZ: function () {
return this._p.z;
},
bisector: function (a, b) {
var dx = b.getX() - a.getX();
var dy = b.getY() - a.getY();
var l1 = new __WEBPACK_IMPORTED_MODULE_5__algorithm_HCoordinate__["a" /* default */](a.getX() + dx / 2.0, a.getY() + dy / 2.0, 1.0);
var l2 = new __WEBPACK_IMPORTED_MODULE_5__algorithm_HCoordinate__["a" /* default */](a.getX() - dy + dx / 2.0, a.getY() + dx + dy / 2.0, 1.0);
return new __WEBPACK_IMPORTED_MODULE_5__algorithm_HCoordinate__["a" /* default */](l1, l2);
},
equals: function () {
if (arguments.length === 1) {
let _x = arguments[0];
if (this._p.x === _x.getX() && this._p.y === _x.getY()) {
return true;
} else {
return false;
}
} else if (arguments.length === 2) {
let _x = arguments[0], tolerance = arguments[1];
if (this._p.distance(_x.getCoordinate()) < tolerance) {
return true;
} else {
return false;
}
}
},
getCoordinate: function () {
return this._p;
},
isInCircle: function (a, b, c) {
return __WEBPACK_IMPORTED_MODULE_2__TrianglePredicate__["a" /* default */].isInCircleRobust(a._p, b._p, c._p, this._p);
},
interpolateZValue: function (v0, v1, v2) {
var x0 = v0.getX();
var y0 = v0.getY();
var a = v1.getX() - x0;
var b = v2.getX() - x0;
var c = v1.getY() - y0;
var d = v2.getY() - y0;
var det = a * d - b * c;
var dx = this.getX() - x0;
var dy = this.getY() - y0;
var t = (d * dx - b * dy) / det;
var u = (-c * dx + a * dy) / det;
var z = v0.getZ() + t * (v1.getZ() - v0.getZ()) + u * (v2.getZ() - v0.getZ());
return z;
},
midPoint: function (a) {
var xm = (this._p.x + a.getX()) / 2.0;
var ym = (this._p.y + a.getY()) / 2.0;
var zm = (this._p.z + a.getZ()) / 2.0;
return new Vertex(xm, ym, zm);
},
rightOf: function (e) {
return this.isCCW(e.dest(), e.orig());
},
isCCW: function (b, c) {
return (b._p.x - this._p.x) * (c._p.y - this._p.y) - (b._p.y - this._p.y) * (c._p.x - this._p.x) > 0;
},
getX: function () {
return this._p.x;
},
crossProduct: function (v) {
return this._p.x * v.getY() - this._p.y * v.getX();
},
setZ: function (_z) {
this._p.z = _z;
},
times: function (c) {
return new Vertex(c * this._p.x, c * this._p.y);
},
cross: function () {
return new Vertex(this._p.y, -this._p.x);
},
leftOf: function (e) {
return this.isCCW(e.orig(), e.dest());
},
toString: function () {
return "POINT (" + this._p.x + " " + this._p.y + ")";
},
sub: function (v) {
return new Vertex(this._p.x - v.getX(), this._p.y - v.getY());
},
getY: function () {
return this._p.y;
},
classify: function (p0, p1) {
var p2 = this;
var a = p1.sub(p0);
var b = p2.sub(p0);
var sa = a.crossProduct(b);
if (sa > 0.0) return Vertex.LEFT;
if (sa < 0.0) return Vertex.RIGHT;
if (a.getX() * b.getX() < 0.0 || a.getY() * b.getY() < 0.0) return Vertex.BEHIND;
if (a.magn() < b.magn()) return Vertex.BEYOND;
if (p0.equals(p2)) return Vertex.ORIGIN;
if (p1.equals(p2)) return Vertex.DESTINATION;
return Vertex.BETWEEN;
},
sum: function (v) {
return new Vertex(this._p.x + v.getX(), this._p.y + v.getY());
},
distance: function (v1, v2) {
return Math.sqrt(Math.pow(v2.getX() - v1.getX(), 2.0) + Math.pow(v2.getY() - v1.getY(), 2.0));
},
circumRadiusRatio: function (b, c) {
var x = this.circleCenter(b, c);
var radius = this.distance(x, b);
var edgeLength = this.distance(this, b);
var el = this.distance(b, c);
if (el < edgeLength) {
edgeLength = el;
}
el = this.distance(c, this);
if (el < edgeLength) {
edgeLength = el;
}
return radius / edgeLength;
},
interfaces_: function () {
return [];
},
getClass: function () {
return Vertex;
}
});
Vertex.interpolateZ = function () {
if (arguments.length === 3) {
let p = arguments[0], p0 = arguments[1], p1 = arguments[2];
var segLen = p0.distance(p1);
var ptLen = p.distance(p0);
var dz = p1.z - p0.z;
var pz = p0.z + dz * (ptLen / segLen);
return pz;
} else if (arguments.length === 4) {
let p = arguments[0], v0 = arguments[1], v1 = arguments[2], v2 = arguments[3];
var x0 = v0.x;
var y0 = v0.y;
var a = v1.x - x0;
var b = v2.x - x0;
var c = v1.y - y0;
var d = v2.y - y0;
var det = a * d - b * c;
var dx = p.x - x0;
var dy = p.y - y0;
var t = (d * dx - b * dy) / det;
var u = (-c * dx + a * dy) / det;
var z = v0.z + t * (v1.z - v0.z) + u * (v2.z - v0.z);
return z;
}
};
Vertex.LEFT = 0;
Vertex.RIGHT = 1;
Vertex.BEYOND = 2;
Vertex.BEHIND = 3;
Vertex.BETWEEN = 4;
Vertex.ORIGIN = 5;
Vertex.DESTINATION = 6;
/***/ }),
/* 85 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LinearLocation;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_Comparable__ = __webpack_require__(20);
function LinearLocation() {
this._componentIndex = 0;
this._segmentIndex = 0;
this._segmentFraction = 0.0;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let loc = arguments[0];
this._componentIndex = loc._componentIndex;
this._segmentIndex = loc._segmentIndex;
this._segmentFraction = loc._segmentFraction;
} else if (arguments.length === 2) {
let segmentIndex = arguments[0], segmentFraction = arguments[1];
LinearLocation.call(this, 0, segmentIndex, segmentFraction);
} else if (arguments.length === 3) {
let componentIndex = arguments[0], segmentIndex = arguments[1], segmentFraction = arguments[2];
this._componentIndex = componentIndex;
this._segmentIndex = segmentIndex;
this._segmentFraction = segmentFraction;
this.normalize();
} else if (arguments.length === 4) {
let componentIndex = arguments[0], segmentIndex = arguments[1], segmentFraction = arguments[2], doNormalize = arguments[3];
this._componentIndex = componentIndex;
this._segmentIndex = segmentIndex;
this._segmentFraction = segmentFraction;
if (doNormalize) this.normalize();
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(LinearLocation.prototype, {
getSegmentIndex: function () {
return this._segmentIndex;
},
getComponentIndex: function () {
return this._componentIndex;
},
isEndpoint: function (linearGeom) {
var lineComp = linearGeom.getGeometryN(this._componentIndex);
var nseg = lineComp.getNumPoints() - 1;
return this._segmentIndex >= nseg || this._segmentIndex === nseg && this._segmentFraction >= 1.0;
},
isValid: function (linearGeom) {
if (this._componentIndex < 0 || this._componentIndex >= linearGeom.getNumGeometries()) return false;
var lineComp = linearGeom.getGeometryN(this._componentIndex);
if (this._segmentIndex < 0 || this._segmentIndex > lineComp.getNumPoints()) return false;
if (this._segmentIndex === lineComp.getNumPoints() && this._segmentFraction !== 0.0) return false;
if (this._segmentFraction < 0.0 || this._segmentFraction > 1.0) return false;
return true;
},
normalize: function () {
if (this._segmentFraction < 0.0) {
this._segmentFraction = 0.0;
}
if (this._segmentFraction > 1.0) {
this._segmentFraction = 1.0;
}
if (this._componentIndex < 0) {
this._componentIndex = 0;
this._segmentIndex = 0;
this._segmentFraction = 0.0;
}
if (this._segmentIndex < 0) {
this._segmentIndex = 0;
this._segmentFraction = 0.0;
}
if (this._segmentFraction === 1.0) {
this._segmentFraction = 0.0;
this._segmentIndex += 1;
}
},
toLowest: function (linearGeom) {
var lineComp = linearGeom.getGeometryN(this._componentIndex);
var nseg = lineComp.getNumPoints() - 1;
if (this._segmentIndex < nseg) return this;
return new LinearLocation(this._componentIndex, nseg, 1.0, false);
},
getCoordinate: function (linearGeom) {
var lineComp = linearGeom.getGeometryN(this._componentIndex);
var p0 = lineComp.getCoordinateN(this._segmentIndex);
if (this._segmentIndex >= lineComp.getNumPoints() - 1) return p0;
var p1 = lineComp.getCoordinateN(this._segmentIndex + 1);
return LinearLocation.pointAlongSegmentByFraction(p0, p1, this._segmentFraction);
},
getSegmentFraction: function () {
return this._segmentFraction;
},
getSegment: function (linearGeom) {
var lineComp = linearGeom.getGeometryN(this._componentIndex);
var p0 = lineComp.getCoordinateN(this._segmentIndex);
if (this._segmentIndex >= lineComp.getNumPoints() - 1) {
var prev = lineComp.getCoordinateN(lineComp.getNumPoints() - 2);
return new __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__["a" /* default */](prev, p0);
}
var p1 = lineComp.getCoordinateN(this._segmentIndex + 1);
return new __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__["a" /* default */](p0, p1);
},
clamp: function (linear) {
if (this._componentIndex >= linear.getNumGeometries()) {
this.setToEnd(linear);
return null;
}
if (this._segmentIndex >= linear.getNumPoints()) {
var line = linear.getGeometryN(this._componentIndex);
this._segmentIndex = line.getNumPoints() - 1;
this._segmentFraction = 1.0;
}
},
setToEnd: function (linear) {
this._componentIndex = linear.getNumGeometries() - 1;
var lastLine = linear.getGeometryN(this._componentIndex);
this._segmentIndex = lastLine.getNumPoints() - 1;
this._segmentFraction = 1.0;
},
compareTo: function (o) {
var other = o;
if (this._componentIndex < other._componentIndex) return -1;
if (this._componentIndex > other._componentIndex) return 1;
if (this._segmentIndex < other._segmentIndex) return -1;
if (this._segmentIndex > other._segmentIndex) return 1;
if (this._segmentFraction < other._segmentFraction) return -1;
if (this._segmentFraction > other._segmentFraction) return 1;
return 0;
},
clone: function () {
return new LinearLocation(this._componentIndex, this._segmentIndex, this._segmentFraction);
},
toString: function () {
return "LinearLoc[" + this._componentIndex + ", " + this._segmentIndex + ", " + this._segmentFraction + "]";
},
isOnSameSegment: function (loc) {
if (this._componentIndex !== loc._componentIndex) return false;
if (this._segmentIndex === loc._segmentIndex) return true;
if (loc._segmentIndex - this._segmentIndex === 1 && loc._segmentFraction === 0.0) return true;
if (this._segmentIndex - loc._segmentIndex === 1 && this._segmentFraction === 0.0) return true;
return false;
},
snapToVertex: function (linearGeom, minDistance) {
if (this._segmentFraction <= 0.0 || this._segmentFraction >= 1.0) return null;
var segLen = this.getSegmentLength(linearGeom);
var lenToStart = this._segmentFraction * segLen;
var lenToEnd = segLen - lenToStart;
if (lenToStart <= lenToEnd && lenToStart < minDistance) {
this._segmentFraction = 0.0;
} else if (lenToEnd <= lenToStart && lenToEnd < minDistance) {
this._segmentFraction = 1.0;
}
},
compareLocationValues: function (componentIndex1, segmentIndex1, segmentFraction1) {
if (this._componentIndex < componentIndex1) return -1;
if (this._componentIndex > componentIndex1) return 1;
if (this._segmentIndex < segmentIndex1) return -1;
if (this._segmentIndex > segmentIndex1) return 1;
if (this._segmentFraction < segmentFraction1) return -1;
if (this._segmentFraction > segmentFraction1) return 1;
return 0;
},
getSegmentLength: function (linearGeom) {
var lineComp = linearGeom.getGeometryN(this._componentIndex);
var segIndex = this._segmentIndex;
if (this._segmentIndex >= lineComp.getNumPoints() - 1) segIndex = lineComp.getNumPoints() - 2;
var p0 = lineComp.getCoordinateN(segIndex);
var p1 = lineComp.getCoordinateN(segIndex + 1);
return p0.distance(p1);
},
isVertex: function () {
return this._segmentFraction <= 0.0 || this._segmentFraction >= 1.0;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_3__java_lang_Comparable__["a" /* default */]];
},
getClass: function () {
return LinearLocation;
}
});
LinearLocation.getEndLocation = function (linear) {
var loc = new LinearLocation();
loc.setToEnd(linear);
return loc;
};
LinearLocation.pointAlongSegmentByFraction = function (p0, p1, frac) {
if (frac <= 0.0) return p0;
if (frac >= 1.0) return p1;
var x = (p1.x - p0.x) * frac + p0.x;
var y = (p1.y - p0.y) * frac + p0.y;
var z = (p1.z - p0.z) * frac + p0.z;
return new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](x, y, z);
};
LinearLocation.compareLocationValues = function (componentIndex0, segmentIndex0, segmentFraction0, componentIndex1, segmentIndex1, segmentFraction1) {
if (componentIndex0 < componentIndex1) return -1;
if (componentIndex0 > componentIndex1) return 1;
if (segmentIndex0 < segmentIndex1) return -1;
if (segmentIndex0 > segmentIndex1) return 1;
if (segmentFraction0 < segmentFraction1) return -1;
if (segmentFraction0 > segmentFraction1) return 1;
return 0;
};
/***/ }),
/* 86 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = OperationNotSupported;
/**
* @param {string=} message Optional message
* @extends {Error}
* @constructor
* @private
*/
function OperationNotSupported(message) {
this.message = message || '';
};
OperationNotSupported.prototype = new Error();
/**
* @type {string}
*/
OperationNotSupported.prototype.name = 'OperationNotSupported';
/***/ }),
/* 87 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Exception;
function Exception () {}
/***/ }),
/* 88 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MathUtil;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
function MathUtil() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(MathUtil.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return MathUtil;
}
});
MathUtil.log10 = function (x) {
var ln = Math.log(x);
if (__WEBPACK_IMPORTED_MODULE_0__java_lang_Double__["a" /* default */].isInfinite(ln)) return ln;
if (__WEBPACK_IMPORTED_MODULE_0__java_lang_Double__["a" /* default */].isNaN(ln)) return ln;
return ln / MathUtil.LOG_10;
};
MathUtil.min = function (v1, v2, v3, v4) {
var min = v1;
if (v2 < min) min = v2;
if (v3 < min) min = v3;
if (v4 < min) min = v4;
return min;
};
MathUtil.clamp = function () {
if (typeof arguments[2] === "number" && (typeof arguments[0] === "number" && typeof arguments[1] === "number")) {
let x = arguments[0], min = arguments[1], max = arguments[2];
if (x < min) return min;
if (x > max) return max;
return x;
} else if (Number.isInteger(arguments[2]) && (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1]))) {
let x = arguments[0], min = arguments[1], max = arguments[2];
if (x < min) return min;
if (x > max) return max;
return x;
}
};
MathUtil.wrap = function (index, max) {
if (index < 0) {
return max - -index % max;
}
return index % max;
};
MathUtil.max = function () {
if (arguments.length === 3) {
let v1 = arguments[0], v2 = arguments[1], v3 = arguments[2];
var max = v1;
if (v2 > max) max = v2;
if (v3 > max) max = v3;
return max;
} else if (arguments.length === 4) {
let v1 = arguments[0], v2 = arguments[1], v3 = arguments[2], v4 = arguments[3];
var max = v1;
if (v2 > max) max = v2;
if (v3 > max) max = v3;
if (v4 > max) max = v4;
return max;
}
};
MathUtil.average = function (x1, x2) {
return (x1 + x2) / 2.0;
};
MathUtil.LOG_10 = Math.log(10);
/***/ }),
/* 89 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = BoundaryOp;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__algorithm_BoundaryNodeRule__ = __webpack_require__(57);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_util_TreeMap__ = __webpack_require__(35);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_MultiLineString__ = __webpack_require__(28);
function BoundaryOp() {
this._geom = null;
this._geomFact = null;
this._bnRule = null;
this._endpointMap = null;
if (arguments.length === 1) {
let geom = arguments[0];
BoundaryOp.call(this, geom, __WEBPACK_IMPORTED_MODULE_1__algorithm_BoundaryNodeRule__["a" /* default */].MOD2_BOUNDARY_RULE);
} else if (arguments.length === 2) {
let geom = arguments[0], bnRule = arguments[1];
this._geom = geom;
this._geomFact = geom.getFactory();
this._bnRule = bnRule;
}
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(BoundaryOp.prototype, {
boundaryMultiLineString: function (mLine) {
if (this._geom.isEmpty()) {
return this.getEmptyMultiPoint();
}
var bdyPts = this.computeBoundaryCoordinates(mLine);
if (bdyPts.length === 1) {
return this._geomFact.createPoint(bdyPts[0]);
}
return this._geomFact.createMultiPointFromCoords(bdyPts);
},
getBoundary: function () {
if (this._geom instanceof __WEBPACK_IMPORTED_MODULE_0__geom_LineString__["a" /* default */]) return this.boundaryLineString(this._geom);
if (this._geom instanceof __WEBPACK_IMPORTED_MODULE_6__geom_MultiLineString__["a" /* default */]) return this.boundaryMultiLineString(this._geom);
return this._geom.getBoundary();
},
boundaryLineString: function (line) {
if (this._geom.isEmpty()) {
return this.getEmptyMultiPoint();
}
if (line.isClosed()) {
var closedEndpointOnBoundary = this._bnRule.isInBoundary(2);
if (closedEndpointOnBoundary) {
return line.getStartPoint();
} else {
return this._geomFact.createMultiPoint();
}
}
return this._geomFact.createMultiPoint([line.getStartPoint(), line.getEndPoint()]);
},
getEmptyMultiPoint: function () {
return this._geomFact.createMultiPoint();
},
computeBoundaryCoordinates: function (mLine) {
var bdyPts = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
this._endpointMap = new __WEBPACK_IMPORTED_MODULE_5__java_util_TreeMap__["a" /* default */]();
for (var i = 0; i < mLine.getNumGeometries(); i++) {
var line = mLine.getGeometryN(i);
if (line.getNumPoints() === 0) continue;
this.addEndpoint(line.getCoordinateN(0));
this.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
}
for (var it = this._endpointMap.entrySet().iterator(); it.hasNext(); ) {
var entry = it.next();
var counter = entry.getValue();
var valence = counter.count;
if (this._bnRule.isInBoundary(valence)) {
bdyPts.add(entry.getKey());
}
}
return __WEBPACK_IMPORTED_MODULE_3__geom_CoordinateArrays__["a" /* default */].toCoordinateArray(bdyPts);
},
addEndpoint: function (pt) {
var counter = this._endpointMap.get(pt);
if (counter === null) {
counter = new Counter();
this._endpointMap.put(pt, counter);
}
counter.count++;
},
interfaces_: function () {
return [];
},
getClass: function () {
return BoundaryOp;
}
});
BoundaryOp.getBoundary = function () {
if (arguments.length === 1) {
let g = arguments[0];
var bop = new BoundaryOp(g);
return bop.getBoundary();
} else if (arguments.length === 2) {
let g = arguments[0], bnRule = arguments[1];
var bop = new BoundaryOp(g, bnRule);
return bop.getBoundary();
}
};
function Counter() {
this.count = null;
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(Counter.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Counter;
}
});
/***/ }),
/* 90 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Lineal;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Lineal() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Lineal.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Lineal;
}
});
/***/ }),
/* 91 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateSequences;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_StringUtil__ = __webpack_require__(212);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__ = __webpack_require__(37);
function CoordinateSequences() {}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(CoordinateSequences.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return CoordinateSequences;
}
});
CoordinateSequences.copyCoord = function (src, srcPos, dest, destPos) {
var minDim = Math.min(src.getDimension(), dest.getDimension());
for (var dim = 0; dim < minDim; dim++) {
dest.setOrdinate(destPos, dim, src.getOrdinate(srcPos, dim));
}
};
CoordinateSequences.isRing = function (seq) {
var n = seq.size();
if (n === 0) return true;
if (n <= 3) return false;
return seq.getOrdinate(0, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].X) === seq.getOrdinate(n - 1, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].X) && seq.getOrdinate(0, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].Y) === seq.getOrdinate(n - 1, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].Y);
};
CoordinateSequences.isEqual = function (cs1, cs2) {
var cs1Size = cs1.size();
var cs2Size = cs2.size();
if (cs1Size !== cs2Size) return false;
var dim = Math.min(cs1.getDimension(), cs2.getDimension());
for (var i = 0; i < cs1Size; i++) {
for (var d = 0; d < dim; d++) {
var v1 = cs1.getOrdinate(i, d);
var v2 = cs2.getOrdinate(i, d);
if (cs1.getOrdinate(i, d) === cs2.getOrdinate(i, d)) continue;
if (__WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(v1) && __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].isNaN(v2)) continue;
return false;
}
}
return true;
};
CoordinateSequences.extend = function (fact, seq, size) {
var newseq = fact.create(size, seq.getDimension());
var n = seq.size();
CoordinateSequences.copy(seq, 0, newseq, 0, n);
if (n > 0) {
for (var i = n; i < size; i++) CoordinateSequences.copy(seq, n - 1, newseq, i, 1);
}
return newseq;
};
CoordinateSequences.reverse = function (seq) {
var last = seq.size() - 1;
var mid = Math.trunc(last / 2);
for (var i = 0; i <= mid; i++) {
CoordinateSequences.swap(seq, i, last - i);
}
};
CoordinateSequences.swap = function (seq, i, j) {
if (i === j) return null;
for (var dim = 0; dim < seq.getDimension(); dim++) {
var tmp = seq.getOrdinate(i, dim);
seq.setOrdinate(i, dim, seq.getOrdinate(j, dim));
seq.setOrdinate(j, dim, tmp);
}
};
CoordinateSequences.copy = function (src, srcPos, dest, destPos, length) {
for (var i = 0; i < length; i++) {
CoordinateSequences.copyCoord(src, srcPos + i, dest, destPos + i);
}
};
CoordinateSequences.toString = function () {
if (arguments.length === 1) {
let cs = arguments[0];
var size = cs.size();
if (size === 0) return "()";
var dim = cs.getDimension();
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]();
buf.append('(');
for (var i = 0; i < size; i++) {
if (i > 0) buf.append(" ");
for (var d = 0; d < dim; d++) {
if (d > 0) buf.append(",");
buf.append(__WEBPACK_IMPORTED_MODULE_1__util_StringUtil__["a" /* default */].toString(cs.getOrdinate(i, d)));
}
}
buf.append(')');
return buf.toString();
}
};
CoordinateSequences.ensureValidRing = function (fact, seq) {
var n = seq.size();
if (n === 0) return seq;
if (n <= 3) return CoordinateSequences.createClosedRing(fact, seq, 4);
var isClosed = seq.getOrdinate(0, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].X) === seq.getOrdinate(n - 1, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].X) && seq.getOrdinate(0, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].Y) === seq.getOrdinate(n - 1, __WEBPACK_IMPORTED_MODULE_4__CoordinateSequence__["a" /* default */].Y);
if (isClosed) return seq;
return CoordinateSequences.createClosedRing(fact, seq, n + 1);
};
CoordinateSequences.createClosedRing = function (fact, seq, size) {
var newseq = fact.create(size, seq.getDimension());
var n = seq.size();
CoordinateSequences.copy(seq, 0, newseq, 0, n);
for (var i = n; i < size; i++) CoordinateSequences.copy(seq, 0, newseq, i, 1);
return newseq;
};
/***/ }),
/* 92 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryEditor;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Point__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__MultiPoint__ = __webpack_require__(41);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__MultiPolygon__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__MultiLineString__ = __webpack_require__(28);
function GeometryEditor() {
this._factory = null;
this._isUserDataCopied = false;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let factory = arguments[0];
this._factory = factory;
}
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(GeometryEditor.prototype, {
setCopyUserData: function (isUserDataCopied) {
this._isUserDataCopied = isUserDataCopied;
},
edit: function (geometry, operation) {
if (geometry === null) return null;
var result = this.editInternal(geometry, operation);
if (this._isUserDataCopied) {
result.setUserData(geometry.getUserData());
}
return result;
},
editInternal: function (geometry, operation) {
if (this._factory === null) this._factory = geometry.getFactory();
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_7__GeometryCollection__["a" /* default */]) {
return this.editGeometryCollection(geometry, operation);
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_2__Polygon__["a" /* default */]) {
return this.editPolygon(geometry, operation);
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_1__Point__["a" /* default */]) {
return operation.edit(geometry, this._factory);
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]) {
return operation.edit(geometry, this._factory);
}
__WEBPACK_IMPORTED_MODULE_9__util_Assert__["a" /* default */].shouldNeverReachHere("Unsupported Geometry class: " + geometry.getClass().getName());
return null;
},
editGeometryCollection: function (collection, operation) {
var collectionForType = operation.edit(collection, this._factory);
var geometries = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < collectionForType.getNumGeometries(); i++) {
var geometry = this.edit(collectionForType.getGeometryN(i), operation);
if (geometry === null || geometry.isEmpty()) {
continue;
}
geometries.add(geometry);
}
if (collectionForType.getClass() === __WEBPACK_IMPORTED_MODULE_3__MultiPoint__["a" /* default */]) {
return this._factory.createMultiPoint(geometries.toArray([]));
}
if (collectionForType.getClass() === __WEBPACK_IMPORTED_MODULE_10__MultiLineString__["a" /* default */]) {
return this._factory.createMultiLineString(geometries.toArray([]));
}
if (collectionForType.getClass() === __WEBPACK_IMPORTED_MODULE_6__MultiPolygon__["a" /* default */]) {
return this._factory.createMultiPolygon(geometries.toArray([]));
}
return this._factory.createGeometryCollection(geometries.toArray([]));
},
editPolygon: function (polygon, operation) {
var newPolygon = operation.edit(polygon, this._factory);
if (newPolygon === null) newPolygon = this._factory.createPolygon(null);
if (newPolygon.isEmpty()) {
return newPolygon;
}
var shell = this.edit(newPolygon.getExteriorRing(), operation);
if (shell === null || shell.isEmpty()) {
return this._factory.createPolygon();
}
var holes = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < newPolygon.getNumInteriorRing(); i++) {
var hole = this.edit(newPolygon.getInteriorRingN(i), operation);
if (hole === null || hole.isEmpty()) {
continue;
}
holes.add(hole);
}
return this._factory.createPolygon(shell, holes.toArray([]));
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryEditor;
}
});
function GeometryEditorOperation() {}
GeometryEditor.GeometryEditorOperation = GeometryEditorOperation;
function NoOpGeometryOperation() {}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(NoOpGeometryOperation.prototype, {
edit: function (geometry, factory) {
return geometry;
},
interfaces_: function () {
return [GeometryEditorOperation];
},
getClass: function () {
return NoOpGeometryOperation;
}
});
function CoordinateOperation() {}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(CoordinateOperation.prototype, {
edit: function (geometry, factory) {
var coords = this.editCoordinates(geometry.getCoordinates(), geometry);
if (coords === null) return geometry;
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_4__LinearRing__["a" /* default */]) {
return factory.createLinearRing(coords);
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]) {
return factory.createLineString(coords);
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_1__Point__["a" /* default */]) {
if (coords.length > 0) {
return factory.createPoint(coords[0]);
} else {
return factory.createPoint();
}
}
return geometry;
},
interfaces_: function () {
return [GeometryEditorOperation];
},
getClass: function () {
return CoordinateOperation;
}
});
function CoordinateSequenceOperation() {}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(CoordinateSequenceOperation.prototype, {
edit: function (geometry, factory) {
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_4__LinearRing__["a" /* default */]) {
return factory.createLinearRing(this.edit(geometry.getCoordinateSequence(), geometry));
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_0__LineString__["a" /* default */]) {
return factory.createLineString(this.edit(geometry.getCoordinateSequence(), geometry));
}
if (geometry instanceof __WEBPACK_IMPORTED_MODULE_1__Point__["a" /* default */]) {
return factory.createPoint(this.edit(geometry.getCoordinateSequence(), geometry));
}
return geometry;
},
interfaces_: function () {
return [GeometryEditorOperation];
},
getClass: function () {
return CoordinateSequenceOperation;
}
});
GeometryEditor.NoOpGeometryOperation = NoOpGeometryOperation;
GeometryEditor.CoordinateOperation = CoordinateOperation;
GeometryEditor.CoordinateSequenceOperation = CoordinateSequenceOperation;
/***/ }),
/* 93 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ConvexHull;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__ = __webpack_require__(46);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_Arrays__ = __webpack_require__(58);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_Stack__ = __webpack_require__(61);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_util_Comparator__ = __webpack_require__(48);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__util_UniqueCoordinateArrayFilter__ = __webpack_require__(224);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_Assert__ = __webpack_require__(4);
function ConvexHull() {
this._geomFactory = null;
this._inputPts = null;
if (arguments.length === 1) {
let geometry = arguments[0];
ConvexHull.call(this, ConvexHull.extractCoordinates(geometry), geometry.getFactory());
} else if (arguments.length === 2) {
let pts = arguments[0], geomFactory = arguments[1];
this._inputPts = __WEBPACK_IMPORTED_MODULE_9__util_UniqueCoordinateArrayFilter__["a" /* default */].filterCoordinates(pts);
this._geomFactory = geomFactory;
}
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(ConvexHull.prototype, {
preSort: function (pts) {
var t = null;
for (var i = 1; i < pts.length; i++) {
if (pts[i].y < pts[0].y || pts[i].y === pts[0].y && pts[i].x < pts[0].x) {
t = pts[0];
pts[0] = pts[i];
pts[i] = t;
}
}
__WEBPACK_IMPORTED_MODULE_3__java_util_Arrays__["a" /* default */].sort(pts, 1, pts.length, new RadialComparator(pts[0]));
return pts;
},
computeOctRing: function (inputPts) {
var octPts = this.computeOctPts(inputPts);
var coordList = new __WEBPACK_IMPORTED_MODULE_2__geom_CoordinateList__["a" /* default */]();
coordList.add(octPts, false);
if (coordList.size() < 3) {
return null;
}
coordList.closeRing();
return coordList.toCoordinateArray();
},
lineOrPolygon: function (coordinates) {
coordinates = this.cleanRing(coordinates);
if (coordinates.length === 3) {
return this._geomFactory.createLineString([coordinates[0], coordinates[1]]);
}
var linearRing = this._geomFactory.createLinearRing(coordinates);
return this._geomFactory.createPolygon(linearRing, null);
},
cleanRing: function (original) {
__WEBPACK_IMPORTED_MODULE_10__util_Assert__["a" /* default */].equals(original[0], original[original.length - 1]);
var cleanedRing = new __WEBPACK_IMPORTED_MODULE_7__java_util_ArrayList__["a" /* default */]();
var previousDistinctCoordinate = null;
for (var i = 0; i <= original.length - 2; i++) {
var currentCoordinate = original[i];
var nextCoordinate = original[i + 1];
if (currentCoordinate.equals(nextCoordinate)) {
continue;
}
if (previousDistinctCoordinate !== null && this.isBetween(previousDistinctCoordinate, currentCoordinate, nextCoordinate)) {
continue;
}
cleanedRing.add(currentCoordinate);
previousDistinctCoordinate = currentCoordinate;
}
cleanedRing.add(original[original.length - 1]);
var cleanedRingCoordinates = new Array(cleanedRing.size()).fill(null);
return cleanedRing.toArray(cleanedRingCoordinates);
},
isBetween: function (c1, c2, c3) {
if (__WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].computeOrientation(c1, c2, c3) !== 0) {
return false;
}
if (c1.x !== c3.x) {
if (c1.x <= c2.x && c2.x <= c3.x) {
return true;
}
if (c3.x <= c2.x && c2.x <= c1.x) {
return true;
}
}
if (c1.y !== c3.y) {
if (c1.y <= c2.y && c2.y <= c3.y) {
return true;
}
if (c3.y <= c2.y && c2.y <= c1.y) {
return true;
}
}
return false;
},
reduce: function (inputPts) {
var polyPts = this.computeOctRing(inputPts);
if (polyPts === null) return inputPts;
var reducedSet = new __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__["a" /* default */]();
for (var i = 0; i < polyPts.length; i++) {
reducedSet.add(polyPts[i]);
}
for (var i = 0; i < inputPts.length; i++) {
if (!__WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].isPointInRing(inputPts[i], polyPts)) {
reducedSet.add(inputPts[i]);
}
}
var reducedPts = __WEBPACK_IMPORTED_MODULE_6__geom_CoordinateArrays__["a" /* default */].toCoordinateArray(reducedSet);
if (reducedPts.length < 3) return this.padArray3(reducedPts);
return reducedPts;
},
getConvexHull: function () {
if (this._inputPts.length === 0) {
return this._geomFactory.createGeometryCollection(null);
}
if (this._inputPts.length === 1) {
return this._geomFactory.createPoint(this._inputPts[0]);
}
if (this._inputPts.length === 2) {
return this._geomFactory.createLineString(this._inputPts);
}
var reducedPts = this._inputPts;
if (this._inputPts.length > 50) {
reducedPts = this.reduce(this._inputPts);
}
var sortedPts = this.preSort(reducedPts);
var cHS = this.grahamScan(sortedPts);
var cH = this.toCoordinateArray(cHS);
return this.lineOrPolygon(cH);
},
padArray3: function (pts) {
var pad = new Array(3).fill(null);
for (var i = 0; i < pad.length; i++) {
if (i < pts.length) {
pad[i] = pts[i];
} else pad[i] = pts[0];
}
return pad;
},
computeOctPts: function (inputPts) {
var pts = new Array(8).fill(null);
for (var j = 0; j < pts.length; j++) {
pts[j] = inputPts[0];
}
for (var i = 1; i < inputPts.length; i++) {
if (inputPts[i].x < pts[0].x) {
pts[0] = inputPts[i];
}
if (inputPts[i].x - inputPts[i].y < pts[1].x - pts[1].y) {
pts[1] = inputPts[i];
}
if (inputPts[i].y > pts[2].y) {
pts[2] = inputPts[i];
}
if (inputPts[i].x + inputPts[i].y > pts[3].x + pts[3].y) {
pts[3] = inputPts[i];
}
if (inputPts[i].x > pts[4].x) {
pts[4] = inputPts[i];
}
if (inputPts[i].x - inputPts[i].y > pts[5].x - pts[5].y) {
pts[5] = inputPts[i];
}
if (inputPts[i].y < pts[6].y) {
pts[6] = inputPts[i];
}
if (inputPts[i].x + inputPts[i].y < pts[7].x + pts[7].y) {
pts[7] = inputPts[i];
}
}
return pts;
},
toCoordinateArray: function (stack) {
var coordinates = new Array(stack.size()).fill(null);
for (var i = 0; i < stack.size(); i++) {
var coordinate = stack.get(i);
coordinates[i] = coordinate;
}
return coordinates;
},
grahamScan: function (c) {
var p = null;
var ps = new __WEBPACK_IMPORTED_MODULE_4__java_util_Stack__["a" /* default */]();
p = ps.push(c[0]);
p = ps.push(c[1]);
p = ps.push(c[2]);
for (var i = 3; i < c.length; i++) {
p = ps.pop();
while (!ps.empty() && __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].computeOrientation(ps.peek(), p, c[i]) > 0) {
p = ps.pop();
}
p = ps.push(p);
p = ps.push(c[i]);
}
p = ps.push(c[0]);
return ps;
},
interfaces_: function () {
return [];
},
getClass: function () {
return ConvexHull;
}
});
ConvexHull.extractCoordinates = function (geom) {
var filter = new __WEBPACK_IMPORTED_MODULE_9__util_UniqueCoordinateArrayFilter__["a" /* default */]();
geom.apply(filter);
return filter.getCoordinates();
};
function RadialComparator() {
this._origin = null;
let origin = arguments[0];
this._origin = origin;
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(RadialComparator.prototype, {
compare: function (o1, o2) {
var p1 = o1;
var p2 = o2;
return RadialComparator.polarCompare(this._origin, p1, p2);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_8__java_util_Comparator__["a" /* default */]];
},
getClass: function () {
return RadialComparator;
}
});
RadialComparator.polarCompare = function (o, p, q) {
var dxp = p.x - o.x;
var dyp = p.y - o.y;
var dxq = q.x - o.x;
var dyq = q.y - o.y;
var orient = __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].computeOrientation(o, p, q);
if (orient === __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].COUNTERCLOCKWISE) return 1;
if (orient === __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].CLOCKWISE) return -1;
var op = dxp * dxp + dyp * dyp;
var oq = dxq * dxq + dyq * dyq;
if (op < oq) {
return -1;
}
if (op > oq) {
return 1;
}
return 0;
};
ConvexHull.RadialComparator = RadialComparator;
/***/ }),
/* 94 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = SegmentString;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function SegmentString() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(SegmentString.prototype, {
getCoordinates: function () {},
size: function () {},
getCoordinate: function (i) {},
isClosed: function () {},
setData: function (data) {},
getData: function () {},
interfaces_: function () {
return [];
},
getClass: function () {
return SegmentString;
}
});
/***/ }),
/* 95 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = AbstractNode;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Boundable__ = __webpack_require__(129);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_io_Serializable__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_Assert__ = __webpack_require__(4);
function AbstractNode() {
this._childBoundables = new __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */]();
this._bounds = null;
this._level = null;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let level = arguments[0];
this._level = level;
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(AbstractNode.prototype, {
getLevel: function () {
return this._level;
},
size: function () {
return this._childBoundables.size();
},
getChildBoundables: function () {
return this._childBoundables;
},
addChildBoundable: function (childBoundable) {
__WEBPACK_IMPORTED_MODULE_4__util_Assert__["a" /* default */].isTrue(this._bounds === null);
this._childBoundables.add(childBoundable);
},
isEmpty: function () {
return this._childBoundables.isEmpty();
},
getBounds: function () {
if (this._bounds === null) {
this._bounds = this.computeBounds();
}
return this._bounds;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_0__Boundable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_3__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return AbstractNode;
}
});
AbstractNode.serialVersionUID = 6493722185909573708;
/***/ }),
/* 96 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Noder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Noder() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Noder.prototype, {
computeNodes: function (segStrings) {},
getNodedSubstrings: function () {},
interfaces_: function () {
return [];
},
getClass: function () {
return Noder;
}
});
/***/ }),
/* 97 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = SegmentIntersector;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function SegmentIntersector() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(SegmentIntersector.prototype, {
processIntersections: function (e0, segIndex0, e1, segIndex1) {},
isDone: function () {},
interfaces_: function () {
return [];
},
getClass: function () {
return SegmentIntersector;
}
});
/***/ }),
/* 98 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NodeMap;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Node__ = __webpack_require__(65);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_util_TreeMap__ = __webpack_require__(35);
function NodeMap() {
this.nodeMap = new __WEBPACK_IMPORTED_MODULE_5__java_util_TreeMap__["a" /* default */]();
this.nodeFact = null;
let nodeFact = arguments[0];
this.nodeFact = nodeFact;
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(NodeMap.prototype, {
find: function (coord) {
return this.nodeMap.get(coord);
},
addNode: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */]) {
let coord = arguments[0];
var node = this.nodeMap.get(coord);
if (node === null) {
node = this.nodeFact.createNode(coord);
this.nodeMap.put(coord, node);
}
return node;
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__Node__["a" /* default */]) {
let n = arguments[0];
var node = this.nodeMap.get(n.getCoordinate());
if (node === null) {
this.nodeMap.put(n.getCoordinate(), n);
return n;
}
node.mergeLabel(n);
return node;
}
},
print: function (out) {
for (var it = this.iterator(); it.hasNext(); ) {
var n = it.next();
n.print(out);
}
},
iterator: function () {
return this.nodeMap.values().iterator();
},
values: function () {
return this.nodeMap.values();
},
getBoundaryNodes: function (geomIndex) {
var bdyNodes = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
for (var i = this.iterator(); i.hasNext(); ) {
var node = i.next();
if (node.getLabel().getLocation(geomIndex) === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY) bdyNodes.add(node);
}
return bdyNodes;
},
add: function (e) {
var p = e.getCoordinate();
var n = this.addNode(p);
n.add(e);
},
interfaces_: function () {
return [];
},
getClass: function () {
return NodeMap;
}
});
/***/ }),
/* 99 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = EdgeEnd;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Quadrant__ = __webpack_require__(47);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_Assert__ = __webpack_require__(4);
function EdgeEnd() {
this._edge = null;
this._label = null;
this._node = null;
this._p0 = null;
this._p1 = null;
this._dx = null;
this._dy = null;
this._quadrant = null;
if (arguments.length === 1) {
let edge = arguments[0];
this._edge = edge;
} else if (arguments.length === 3) {
let edge = arguments[0], p0 = arguments[1], p1 = arguments[2];
EdgeEnd.call(this, edge, p0, p1, null);
} else if (arguments.length === 4) {
let edge = arguments[0], p0 = arguments[1], p1 = arguments[2], label = arguments[3];
EdgeEnd.call(this, edge);
this.init(p0, p1);
this._label = label;
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(EdgeEnd.prototype, {
compareDirection: function (e) {
if (this._dx === e._dx && this._dy === e._dy) return 0;
if (this._quadrant > e._quadrant) return 1;
if (this._quadrant < e._quadrant) return -1;
return __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].computeOrientation(e._p0, e._p1, this._p1);
},
getDy: function () {
return this._dy;
},
getCoordinate: function () {
return this._p0;
},
setNode: function (node) {
this._node = node;
},
print: function (out) {
var angle = Math.atan2(this._dy, this._dx);
var className = this.getClass().getName();
var lastDotPos = className.lastIndexOf('.');
var name = className.substring(lastDotPos + 1);
out.print(" " + name + ": " + this._p0 + " - " + this._p1 + " " + this._quadrant + ":" + angle + " " + this._label);
},
compareTo: function (obj) {
var e = obj;
return this.compareDirection(e);
},
getDirectedCoordinate: function () {
return this._p1;
},
getDx: function () {
return this._dx;
},
getLabel: function () {
return this._label;
},
getEdge: function () {
return this._edge;
},
getQuadrant: function () {
return this._quadrant;
},
getNode: function () {
return this._node;
},
toString: function () {
var angle = Math.atan2(this._dy, this._dx);
var className = this.getClass().getName();
var lastDotPos = className.lastIndexOf('.');
var name = className.substring(lastDotPos + 1);
return " " + name + ": " + this._p0 + " - " + this._p1 + " " + this._quadrant + ":" + angle + " " + this._label;
},
computeLabel: function (boundaryNodeRule) {},
init: function (p0, p1) {
this._p0 = p0;
this._p1 = p1;
this._dx = p1.x - p0.x;
this._dy = p1.y - p0.y;
this._quadrant = __WEBPACK_IMPORTED_MODULE_3__Quadrant__["a" /* default */].quadrant(this._dx, this._dy);
__WEBPACK_IMPORTED_MODULE_4__util_Assert__["a" /* default */].isTrue(!(this._dx === 0 && this._dy === 0), "EdgeEnd with identical endpoints found");
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_2__java_lang_Comparable__["a" /* default */]];
},
getClass: function () {
return EdgeEnd;
}
});
/***/ }),
/* 100 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NodeFactory;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(65);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
function NodeFactory() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(NodeFactory.prototype, {
createNode: function (coord) {
return new __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */](coord, null);
},
interfaces_: function () {
return [];
},
getClass: function () {
return NodeFactory;
}
});
/***/ }),
/* 101 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = OverlayNodeFactory;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geomgraph_DirectedEdgeStar__ = __webpack_require__(251);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geomgraph_Node__ = __webpack_require__(65);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geomgraph_NodeFactory__ = __webpack_require__(100);
function OverlayNodeFactory() {
__WEBPACK_IMPORTED_MODULE_4__geomgraph_NodeFactory__["a" /* default */].apply(this);
}
Object(__WEBPACK_IMPORTED_MODULE_3__inherits__["a" /* default */])(OverlayNodeFactory, __WEBPACK_IMPORTED_MODULE_4__geomgraph_NodeFactory__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(OverlayNodeFactory.prototype, {
createNode: function (coord) {
return new __WEBPACK_IMPORTED_MODULE_1__geomgraph_Node__["a" /* default */](coord, new __WEBPACK_IMPORTED_MODULE_0__geomgraph_DirectedEdgeStar__["a" /* default */]());
},
interfaces_: function () {
return [];
},
getClass: function () {
return OverlayNodeFactory;
}
});
/***/ }),
/* 102 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryGraphOperation;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_BoundaryNodeRule__ = __webpack_require__(57);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geomgraph_GeometryGraph__ = __webpack_require__(66);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__algorithm_RobustLineIntersector__ = __webpack_require__(22);
function GeometryGraphOperation() {
this._li = new __WEBPACK_IMPORTED_MODULE_3__algorithm_RobustLineIntersector__["a" /* default */]();
this._resultPrecisionModel = null;
this._arg = null;
if (arguments.length === 1) {
let g0 = arguments[0];
this.setComputationPrecision(g0.getPrecisionModel());
this._arg = new Array(1).fill(null);
this._arg[0] = new __WEBPACK_IMPORTED_MODULE_2__geomgraph_GeometryGraph__["a" /* default */](0, g0);
;
} else if (arguments.length === 2) {
let g0 = arguments[0], g1 = arguments[1];
GeometryGraphOperation.call(this, g0, g1, __WEBPACK_IMPORTED_MODULE_0__algorithm_BoundaryNodeRule__["a" /* default */].OGC_SFS_BOUNDARY_RULE);
} else if (arguments.length === 3) {
let g0 = arguments[0], g1 = arguments[1], boundaryNodeRule = arguments[2];
if (g0.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0) this.setComputationPrecision(g0.getPrecisionModel()); else this.setComputationPrecision(g1.getPrecisionModel());
this._arg = new Array(2).fill(null);
this._arg[0] = new __WEBPACK_IMPORTED_MODULE_2__geomgraph_GeometryGraph__["a" /* default */](0, g0, boundaryNodeRule);
this._arg[1] = new __WEBPACK_IMPORTED_MODULE_2__geomgraph_GeometryGraph__["a" /* default */](1, g1, boundaryNodeRule);
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(GeometryGraphOperation.prototype, {
getArgGeometry: function (i) {
return this._arg[i].getGeometry();
},
setComputationPrecision: function (pm) {
this._resultPrecisionModel = pm;
this._li.setPrecisionModel(this._resultPrecisionModel);
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryGraphOperation;
}
});
/***/ }),
/* 103 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = DoubleBits;
function DoubleBits () { }
DoubleBits.exponent = function (d) {
return CVTFWD(64, d) - 1023
}
DoubleBits.powerOf2 = function (exp) {
return Math.pow(2, exp)
}
/**
* Calculates the exponent of the bit-pattern for a number. Uses code from:
* http://www.merlyn.demon.co.uk/js-exact.htm
*
* @param {Number}
* NumW 32 or 64 to denote the number of bits.
* @param {Number}
* Qty the number to calculate the bit pattern for.
* @return {Number} The integer value of the exponent.
*/
function CVTFWD (NumW, Qty) {
var Sign
var Expo
var Mant
var Bin
var Inf = {
32: {
d: 0x7F,
c: 0x80,
b: 0,
a: 0
},
64: {
d: 0x7FF0,
c: 0,
b: 0,
a: 0
}
}
var ExW = {
32: 8,
64: 11
}[NumW]
if (!Bin) {
Sign = Qty < 0 || 1 / Qty < 0 // OK for +-0
if (!isFinite(Qty)) {
Bin = Inf[NumW]
if (Sign) {
Bin.d += 1 << (NumW / 4 - 1)
}
Expo = Math.pow(2, ExW) - 1
Mant = 0
}
}
if (!Bin) {
Expo = {
32: 127,
64: 1023
}[NumW]
Mant = Math.abs(Qty)
while (Mant >= 2) {
Expo++
Mant /= 2
}
while (Mant < 1 && Expo > 0) {
Expo--
Mant *= 2
}
if (Expo <= 0) {
Mant /= 2
}
if (NumW === 32 && Expo > 254) {
Bin = {
d: Sign ? 0xFF : 0x7F,
c: 0x80,
b: 0,
a: 0
}
Expo = Math.pow(2, ExW) - 1
Mant = 0
}
}
return Expo
}
/***/ }),
/* 104 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Angle;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
function Angle() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Angle.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Angle;
}
});
Angle.toDegrees = function (radians) {
return radians * 180 / Math.PI;
};
Angle.normalize = function (angle) {
while (angle > Math.PI) angle -= Angle.PI_TIMES_2;
while (angle <= -Math.PI) angle += Angle.PI_TIMES_2;
return angle;
};
Angle.angle = function () {
if (arguments.length === 1) {
let p = arguments[0];
return Math.atan2(p.y, p.x);
} else if (arguments.length === 2) {
let p0 = arguments[0], p1 = arguments[1];
var dx = p1.x - p0.x;
var dy = p1.y - p0.y;
return Math.atan2(dy, dx);
}
};
Angle.isAcute = function (p0, p1, p2) {
var dx0 = p0.x - p1.x;
var dy0 = p0.y - p1.y;
var dx1 = p2.x - p1.x;
var dy1 = p2.y - p1.y;
var dotprod = dx0 * dx1 + dy0 * dy1;
return dotprod > 0;
};
Angle.isObtuse = function (p0, p1, p2) {
var dx0 = p0.x - p1.x;
var dy0 = p0.y - p1.y;
var dx1 = p2.x - p1.x;
var dy1 = p2.y - p1.y;
var dotprod = dx0 * dx1 + dy0 * dy1;
return dotprod < 0;
};
Angle.interiorAngle = function (p0, p1, p2) {
var anglePrev = Angle.angle(p1, p0);
var angleNext = Angle.angle(p1, p2);
return Math.abs(angleNext - anglePrev);
};
Angle.normalizePositive = function (angle) {
if (angle < 0.0) {
while (angle < 0.0) angle += Angle.PI_TIMES_2;
if (angle >= Angle.PI_TIMES_2) angle = 0.0;
} else {
while (angle >= Angle.PI_TIMES_2) angle -= Angle.PI_TIMES_2;
if (angle < 0.0) angle = 0.0;
}
return angle;
};
Angle.angleBetween = function (tip1, tail, tip2) {
var a1 = Angle.angle(tail, tip1);
var a2 = Angle.angle(tail, tip2);
return Angle.diff(a1, a2);
};
Angle.diff = function (ang1, ang2) {
var delAngle = null;
if (ang1 < ang2) {
delAngle = ang2 - ang1;
} else {
delAngle = ang1 - ang2;
}
if (delAngle > Math.PI) {
delAngle = 2 * Math.PI - delAngle;
}
return delAngle;
};
Angle.toRadians = function (angleDegrees) {
return angleDegrees * Math.PI / 180.0;
};
Angle.getTurn = function (ang1, ang2) {
var crossproduct = Math.sin(ang2 - ang1);
if (crossproduct > 0) {
return Angle.COUNTERCLOCKWISE;
}
if (crossproduct < 0) {
return Angle.CLOCKWISE;
}
return Angle.NONE;
};
Angle.angleBetweenOriented = function (tip1, tail, tip2) {
var a1 = Angle.angle(tail, tip1);
var a2 = Angle.angle(tail, tip2);
var angDel = a2 - a1;
if (angDel <= -Math.PI) return angDel + Angle.PI_TIMES_2;
if (angDel > Math.PI) return angDel - Angle.PI_TIMES_2;
return angDel;
};
Angle.PI_TIMES_2 = 2.0 * Math.PI;
Angle.PI_OVER_2 = Math.PI / 2.0;
Angle.PI_OVER_4 = Math.PI / 4.0;
Angle.COUNTERCLOCKWISE = __WEBPACK_IMPORTED_MODULE_0__CGAlgorithms__["a" /* default */].COUNTERCLOCKWISE;
Angle.CLOCKWISE = __WEBPACK_IMPORTED_MODULE_0__CGAlgorithms__["a" /* default */].CLOCKWISE;
Angle.NONE = __WEBPACK_IMPORTED_MODULE_0__CGAlgorithms__["a" /* default */].COLLINEAR;
/***/ }),
/* 105 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = IsValidOp;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__ = __webpack_require__(46);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__ConnectedInteriorTester__ = __webpack_require__(333);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_Point__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__geom_MultiPoint__ = __webpack_require__(41);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__geom_LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__algorithm_MCPointInRing__ = __webpack_require__(144);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__geomgraph_GeometryGraph__ = __webpack_require__(66);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__geom_MultiPolygon__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__ConsistentAreaTester__ = __webpack_require__(158);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__geom_GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__IndexedNestedRingTester__ = __webpack_require__(338);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__algorithm_RobustLineIntersector__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__ = __webpack_require__(339);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__util_Assert__ = __webpack_require__(4);
function IsValidOp() {
this._parentGeometry = null;
this._isSelfTouchingRingFormingHoleValid = false;
this._validErr = null;
let parentGeometry = arguments[0];
this._parentGeometry = parentGeometry;
}
Object(__WEBPACK_IMPORTED_MODULE_11__extend__["a" /* default */])(IsValidOp.prototype, {
checkInvalidCoordinates: function () {
if (arguments[0] instanceof Array) {
let coords = arguments[0];
for (var i = 0; i < coords.length; i++) {
if (!IsValidOp.isValid(coords[i])) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].INVALID_COORDINATE, coords[i]);
return null;
}
}
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_7__geom_Polygon__["a" /* default */]) {
let poly = arguments[0];
this.checkInvalidCoordinates(poly.getExteriorRing().getCoordinates());
if (this._validErr !== null) return null;
for (var i = 0; i < poly.getNumInteriorRing(); i++) {
this.checkInvalidCoordinates(poly.getInteriorRingN(i).getCoordinates());
if (this._validErr !== null) return null;
}
}
},
checkHolesNotNested: function (p, graph) {
var nestedTester = new __WEBPACK_IMPORTED_MODULE_17__IndexedNestedRingTester__["a" /* default */](graph);
for (var i = 0; i < p.getNumInteriorRing(); i++) {
var innerHole = p.getInteriorRingN(i);
nestedTester.add(innerHole);
}
var isNonNested = nestedTester.isNonNested();
if (!isNonNested) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].NESTED_HOLES, nestedTester.getNestedPoint());
}
},
checkConsistentArea: function (graph) {
var cat = new __WEBPACK_IMPORTED_MODULE_15__ConsistentAreaTester__["a" /* default */](graph);
var isValidArea = cat.isNodeConsistentArea();
if (!isValidArea) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].SELF_INTERSECTION, cat.getInvalidPoint());
return null;
}
if (cat.hasDuplicateRings()) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].DUPLICATE_RINGS, cat.getInvalidPoint());
}
},
isValid: function () {
this.checkValid(this._parentGeometry);
return this._validErr === null;
},
checkShellInsideHole: function (shell, hole, graph) {
var shellPts = shell.getCoordinates();
var holePts = hole.getCoordinates();
var shellPt = IsValidOp.findPtNotNode(shellPts, hole, graph);
if (shellPt !== null) {
var insideHole = __WEBPACK_IMPORTED_MODULE_2__algorithm_CGAlgorithms__["a" /* default */].isPointInRing(shellPt, holePts);
if (!insideHole) {
return shellPt;
}
}
var holePt = IsValidOp.findPtNotNode(holePts, shell, graph);
if (holePt !== null) {
var insideShell = __WEBPACK_IMPORTED_MODULE_2__algorithm_CGAlgorithms__["a" /* default */].isPointInRing(holePt, shellPts);
if (insideShell) {
return holePt;
}
return null;
}
__WEBPACK_IMPORTED_MODULE_20__util_Assert__["a" /* default */].shouldNeverReachHere("points in shell and hole appear to be equal");
return null;
},
checkNoSelfIntersectingRings: function (graph) {
for (var i = graph.getEdgeIterator(); i.hasNext(); ) {
var e = i.next();
this.checkNoSelfIntersectingRing(e.getEdgeIntersectionList());
if (this._validErr !== null) return null;
}
},
checkConnectedInteriors: function (graph) {
var cit = new __WEBPACK_IMPORTED_MODULE_4__ConnectedInteriorTester__["a" /* default */](graph);
if (!cit.isInteriorsConnected()) this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].DISCONNECTED_INTERIOR, cit.getCoordinate());
},
checkNoSelfIntersectingRing: function (eiList) {
var nodeSet = new __WEBPACK_IMPORTED_MODULE_0__java_util_TreeSet__["a" /* default */]();
var isFirst = true;
for (var i = eiList.iterator(); i.hasNext(); ) {
var ei = i.next();
if (isFirst) {
isFirst = false;
continue;
}
if (nodeSet.contains(ei.coord)) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].RING_SELF_INTERSECTION, ei.coord);
return null;
} else {
nodeSet.add(ei.coord);
}
}
},
checkHolesInShell: function (p, graph) {
var shell = p.getExteriorRing();
var pir = new __WEBPACK_IMPORTED_MODULE_12__algorithm_MCPointInRing__["a" /* default */](shell);
for (var i = 0; i < p.getNumInteriorRing(); i++) {
var hole = p.getInteriorRingN(i);
var holePt = IsValidOp.findPtNotNode(hole.getCoordinates(), shell, graph);
if (holePt === null) return null;
var outside = !pir.isInside(holePt);
if (outside) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].HOLE_OUTSIDE_SHELL, holePt);
return null;
}
}
},
checkTooFewPoints: function (graph) {
if (graph.hasTooFewPoints()) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].TOO_FEW_POINTS, graph.getInvalidPoint());
return null;
}
},
getValidationError: function () {
this.checkValid(this._parentGeometry);
return this._validErr;
},
checkValid: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_6__geom_Point__["a" /* default */]) {
let g = arguments[0];
this.checkInvalidCoordinates(g.getCoordinates());
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_8__geom_MultiPoint__["a" /* default */]) {
let g = arguments[0];
this.checkInvalidCoordinates(g.getCoordinates());
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_9__geom_LinearRing__["a" /* default */]) {
let g = arguments[0];
this.checkInvalidCoordinates(g.getCoordinates());
if (this._validErr !== null) return null;
this.checkClosedRing(g);
if (this._validErr !== null) return null;
var graph = new __WEBPACK_IMPORTED_MODULE_13__geomgraph_GeometryGraph__["a" /* default */](0, g);
this.checkTooFewPoints(graph);
if (this._validErr !== null) return null;
var li = new __WEBPACK_IMPORTED_MODULE_18__algorithm_RobustLineIntersector__["a" /* default */]();
graph.computeSelfNodes(li, true, true);
this.checkNoSelfIntersectingRings(graph);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__geom_LineString__["a" /* default */]) {
let g = arguments[0];
this.checkInvalidCoordinates(g.getCoordinates());
if (this._validErr !== null) return null;
var graph = new __WEBPACK_IMPORTED_MODULE_13__geomgraph_GeometryGraph__["a" /* default */](0, g);
this.checkTooFewPoints(graph);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_7__geom_Polygon__["a" /* default */]) {
let g = arguments[0];
this.checkInvalidCoordinates(g);
if (this._validErr !== null) return null;
this.checkClosedRings(g);
if (this._validErr !== null) return null;
var graph = new __WEBPACK_IMPORTED_MODULE_13__geomgraph_GeometryGraph__["a" /* default */](0, g);
this.checkTooFewPoints(graph);
if (this._validErr !== null) return null;
this.checkConsistentArea(graph);
if (this._validErr !== null) return null;
if (!this._isSelfTouchingRingFormingHoleValid) {
this.checkNoSelfIntersectingRings(graph);
if (this._validErr !== null) return null;
}
this.checkHolesInShell(g, graph);
if (this._validErr !== null) return null;
this.checkHolesNotNested(g, graph);
if (this._validErr !== null) return null;
this.checkConnectedInteriors(graph);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_14__geom_MultiPolygon__["a" /* default */]) {
let g = arguments[0];
for (var i = 0; i < g.getNumGeometries(); i++) {
var p = g.getGeometryN(i);
this.checkInvalidCoordinates(p);
if (this._validErr !== null) return null;
this.checkClosedRings(p);
if (this._validErr !== null) return null;
}
var graph = new __WEBPACK_IMPORTED_MODULE_13__geomgraph_GeometryGraph__["a" /* default */](0, g);
this.checkTooFewPoints(graph);
if (this._validErr !== null) return null;
this.checkConsistentArea(graph);
if (this._validErr !== null) return null;
if (!this._isSelfTouchingRingFormingHoleValid) {
this.checkNoSelfIntersectingRings(graph);
if (this._validErr !== null) return null;
}
for (var i = 0; i < g.getNumGeometries(); i++) {
var p = g.getGeometryN(i);
this.checkHolesInShell(p, graph);
if (this._validErr !== null) return null;
}
for (var i = 0; i < g.getNumGeometries(); i++) {
var p = g.getGeometryN(i);
this.checkHolesNotNested(p, graph);
if (this._validErr !== null) return null;
}
this.checkShellsNotNested(g, graph);
if (this._validErr !== null) return null;
this.checkConnectedInteriors(graph);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_16__geom_GeometryCollection__["a" /* default */]) {
let gc = arguments[0];
for (var i = 0; i < gc.getNumGeometries(); i++) {
var g = gc.getGeometryN(i);
this.checkValid(g);
if (this._validErr !== null) return null;
}
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__geom_Geometry__["a" /* default */]) {
let g = arguments[0];
this._validErr = null;
if (g.isEmpty()) return null;
if (g instanceof __WEBPACK_IMPORTED_MODULE_6__geom_Point__["a" /* default */]) this.checkValid(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_8__geom_MultiPoint__["a" /* default */]) this.checkValid(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_9__geom_LinearRing__["a" /* default */]) this.checkValid(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_1__geom_LineString__["a" /* default */]) this.checkValid(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_7__geom_Polygon__["a" /* default */]) this.checkValid(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_14__geom_MultiPolygon__["a" /* default */]) this.checkValid(g); else if (g instanceof __WEBPACK_IMPORTED_MODULE_16__geom_GeometryCollection__["a" /* default */]) this.checkValid(g); else throw new UnsupportedOperationException(g.getClass().getName());
}
},
setSelfTouchingRingFormingHoleValid: function (isValid) {
this._isSelfTouchingRingFormingHoleValid = isValid;
},
checkShellNotNested: function (shell, p, graph) {
var shellPts = shell.getCoordinates();
var polyShell = p.getExteriorRing();
var polyPts = polyShell.getCoordinates();
var shellPt = IsValidOp.findPtNotNode(shellPts, polyShell, graph);
if (shellPt === null) return null;
var insidePolyShell = __WEBPACK_IMPORTED_MODULE_2__algorithm_CGAlgorithms__["a" /* default */].isPointInRing(shellPt, polyPts);
if (!insidePolyShell) return null;
if (p.getNumInteriorRing() <= 0) {
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].NESTED_SHELLS, shellPt);
return null;
}
var badNestedPt = null;
for (var i = 0; i < p.getNumInteriorRing(); i++) {
var hole = p.getInteriorRingN(i);
badNestedPt = this.checkShellInsideHole(shell, hole, graph);
if (badNestedPt === null) return null;
}
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].NESTED_SHELLS, badNestedPt);
},
checkClosedRings: function (poly) {
this.checkClosedRing(poly.getExteriorRing());
if (this._validErr !== null) return null;
for (var i = 0; i < poly.getNumInteriorRing(); i++) {
this.checkClosedRing(poly.getInteriorRingN(i));
if (this._validErr !== null) return null;
}
},
checkClosedRing: function (ring) {
if (!ring.isClosed()) {
var pt = null;
if (ring.getNumPoints() >= 1) pt = ring.getCoordinateN(0);
this._validErr = new __WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */](__WEBPACK_IMPORTED_MODULE_19__TopologyValidationError__["a" /* default */].RING_NOT_CLOSED, pt);
}
},
checkShellsNotNested: function (mp, graph) {
for (var i = 0; i < mp.getNumGeometries(); i++) {
var p = mp.getGeometryN(i);
var shell = p.getExteriorRing();
for (var j = 0; j < mp.getNumGeometries(); j++) {
if (i === j) continue;
var p2 = mp.getGeometryN(j);
this.checkShellNotNested(shell, p2, graph);
if (this._validErr !== null) return null;
}
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return IsValidOp;
}
});
IsValidOp.findPtNotNode = function (testCoords, searchRing, graph) {
var searchEdge = graph.findEdge(searchRing);
var eiList = searchEdge.getEdgeIntersectionList();
for (var i = 0; i < testCoords.length; i++) {
var pt = testCoords[i];
if (!eiList.isIntersection(pt)) return pt;
}
return null;
};
IsValidOp.isValid = function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__geom_Geometry__["a" /* default */]) {
let geom = arguments[0];
var isValidOp = new IsValidOp(geom);
return isValidOp.isValid();
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_5__geom_Coordinate__["a" /* default */]) {
let coord = arguments[0];
if (__WEBPACK_IMPORTED_MODULE_10__java_lang_Double__["a" /* default */].isNaN(coord.x)) return false;
if (__WEBPACK_IMPORTED_MODULE_10__java_lang_Double__["a" /* default */].isInfinite(coord.x)) return false;
if (__WEBPACK_IMPORTED_MODULE_10__java_lang_Double__["a" /* default */].isNaN(coord.y)) return false;
if (__WEBPACK_IMPORTED_MODULE_10__java_lang_Double__["a" /* default */].isInfinite(coord.y)) return false;
return true;
}
};
/***/ }),
/* 106 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryCombiner;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__ = __webpack_require__(1);
function GeometryCombiner() {
this._geomFactory = null;
this._skipEmpty = false;
this._inputGeoms = null;
let geoms = arguments[0];
this._geomFactory = GeometryCombiner.extractFactory(geoms);
this._inputGeoms = geoms;
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(GeometryCombiner.prototype, {
extractElements: function (geom, elems) {
if (geom === null) return null;
for (var i = 0; i < geom.getNumGeometries(); i++) {
var elemGeom = geom.getGeometryN(i);
if (this._skipEmpty && elemGeom.isEmpty()) continue;
elems.add(elemGeom);
}
},
combine: function () {
var elems = new __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__["a" /* default */]();
for (var i = this._inputGeoms.iterator(); i.hasNext(); ) {
var g = i.next();
this.extractElements(g, elems);
}
if (elems.size() === 0) {
if (this._geomFactory !== null) {
return this._geomFactory.createGeometryCollection(null);
}
return null;
}
return this._geomFactory.buildGeometry(elems);
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryCombiner;
}
});
GeometryCombiner.combine = function () {
if (arguments.length === 1) {
let geoms = arguments[0];
var combiner = new GeometryCombiner(geoms);
return combiner.combine();
} else if (arguments.length === 2) {
let g0 = arguments[0], g1 = arguments[1];
var combiner = new GeometryCombiner(GeometryCombiner.createList(g0, g1));
return combiner.combine();
} else if (arguments.length === 3) {
let g0 = arguments[0], g1 = arguments[1], g2 = arguments[2];
var combiner = new GeometryCombiner(GeometryCombiner.createList(g0, g1, g2));
return combiner.combine();
}
};
GeometryCombiner.extractFactory = function (geoms) {
if (geoms.isEmpty()) return null;
return geoms.iterator().next().getFactory();
};
GeometryCombiner.createList = function () {
if (arguments.length === 2) {
let obj0 = arguments[0], obj1 = arguments[1];
var list = new __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__["a" /* default */]();
list.add(obj0);
list.add(obj1);
return list;
} else if (arguments.length === 3) {
let obj0 = arguments[0], obj1 = arguments[1], obj2 = arguments[2];
var list = new __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__["a" /* default */]();
list.add(obj0);
list.add(obj1);
list.add(obj2);
return list;
}
};
/***/ }),
/* 107 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = IncrementalDelaunayTriangulator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__quadedge_QuadEdge__ = __webpack_require__(166);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
function IncrementalDelaunayTriangulator() {
this._subdiv = null;
this._isUsingTolerance = false;
let subdiv = arguments[0];
this._subdiv = subdiv;
this._isUsingTolerance = subdiv.getTolerance() > 0.0;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(IncrementalDelaunayTriangulator.prototype, {
insertSite: function (v) {
var e = this._subdiv.locate(v);
if (this._subdiv.isVertexOfEdge(e, v)) {
return e;
} else if (this._subdiv.isOnEdge(e, v.getCoordinate())) {
e = e.oPrev();
this._subdiv.delete(e.oNext());
}
var base = this._subdiv.makeEdge(e.orig(), v);
__WEBPACK_IMPORTED_MODULE_0__quadedge_QuadEdge__["a" /* default */].splice(base, e);
var startEdge = base;
do {
base = this._subdiv.connect(e, base.sym());
e = base.oPrev();
} while (e.lNext() !== startEdge);
do {
var t = e.oPrev();
if (t.dest().rightOf(e) && v.isInCircle(e.orig(), t.dest(), e.dest())) {
__WEBPACK_IMPORTED_MODULE_0__quadedge_QuadEdge__["a" /* default */].swap(e);
e = e.oPrev();
} else if (e.oNext() === startEdge) {
return base;
} else {
e = e.oNext().lPrev();
}
} while (true);
},
insertSites: function (vertices) {
for (var i = vertices.iterator(); i.hasNext(); ) {
var v = i.next();
this.insertSite(v);
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return IncrementalDelaunayTriangulator;
}
});
/***/ }),
/* 108 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = QuadEdgeSubdivision;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__QuadEdge__ = __webpack_require__(166);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_HashSet__ = __webpack_require__(45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__io_WKTWriter__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geom_GeometryFactory__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_util_Stack__ = __webpack_require__(61);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__LastFoundQuadEdgeLocator__ = __webpack_require__(167);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__LocateFailureException__ = __webpack_require__(371);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Vertex__ = __webpack_require__(84);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__geom_LineSegment__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__geom_Triangle__ = __webpack_require__(79);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__TriangleVisitor__ = __webpack_require__(372);
function QuadEdgeSubdivision() {
this._visitedKey = 0;
this._quadEdges = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
this._startingEdge = null;
this._tolerance = null;
this._edgeCoincidenceTolerance = null;
this._frameVertex = new Array(3).fill(null);
this._frameEnv = null;
this._locator = null;
this._seg = new __WEBPACK_IMPORTED_MODULE_13__geom_LineSegment__["a" /* default */]();
this._triEdges = new Array(3).fill(null);
let env = arguments[0], tolerance = arguments[1];
this._tolerance = tolerance;
this._edgeCoincidenceTolerance = tolerance / QuadEdgeSubdivision.EDGE_COINCIDENCE_TOL_FACTOR;
this.createFrame(env);
this._startingEdge = this.initSubdiv();
this._locator = new __WEBPACK_IMPORTED_MODULE_9__LastFoundQuadEdgeLocator__["a" /* default */](this);
}
Object(__WEBPACK_IMPORTED_MODULE_8__extend__["a" /* default */])(QuadEdgeSubdivision.prototype, {
getTriangleVertices: function (includeFrame) {
var visitor = new TriangleVertexListVisitor();
this.visitTriangles(visitor, includeFrame);
return visitor.getTriangleVertices();
},
isFrameVertex: function (v) {
if (v.equals(this._frameVertex[0])) return true;
if (v.equals(this._frameVertex[1])) return true;
if (v.equals(this._frameVertex[2])) return true;
return false;
},
isVertexOfEdge: function (e, v) {
if (v.equals(e.orig(), this._tolerance) || v.equals(e.dest(), this._tolerance)) {
return true;
}
return false;
},
connect: function (a, b) {
var q = __WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].connect(a, b);
this._quadEdges.add(q);
return q;
},
getVoronoiCellPolygon: function (qe, geomFact) {
var cellPts = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
var startQE = qe;
do {
var cc = qe.rot().orig().getCoordinate();
cellPts.add(cc);
qe = qe.oPrev();
} while (qe !== startQE);
var coordList = new __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__["a" /* default */]();
coordList.addAll(cellPts, false);
coordList.closeRing();
if (coordList.size() < 4) {
__WEBPACK_IMPORTED_MODULE_12__java_lang_System__["a" /* default */].out.println(coordList);
coordList.add(coordList.get(coordList.size() - 1), true);
}
var pts = coordList.toCoordinateArray();
var cellPoly = geomFact.createPolygon(geomFact.createLinearRing(pts), null);
var v = startQE.orig();
cellPoly.setUserData(v.getCoordinate());
return cellPoly;
},
setLocator: function (locator) {
this._locator = locator;
},
initSubdiv: function () {
var ea = this.makeEdge(this._frameVertex[0], this._frameVertex[1]);
var eb = this.makeEdge(this._frameVertex[1], this._frameVertex[2]);
__WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].splice(ea.sym(), eb);
var ec = this.makeEdge(this._frameVertex[2], this._frameVertex[0]);
__WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].splice(eb.sym(), ec);
__WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].splice(ec.sym(), ea);
return ea;
},
isFrameBorderEdge: function (e) {
var leftTri = new Array(3).fill(null);
QuadEdgeSubdivision.getTriangleEdges(e, leftTri);
var rightTri = new Array(3).fill(null);
QuadEdgeSubdivision.getTriangleEdges(e.sym(), rightTri);
var vLeftTriOther = e.lNext().dest();
if (this.isFrameVertex(vLeftTriOther)) return true;
var vRightTriOther = e.sym().lNext().dest();
if (this.isFrameVertex(vRightTriOther)) return true;
return false;
},
makeEdge: function (o, d) {
var q = __WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].makeEdge(o, d);
this._quadEdges.add(q);
return q;
},
visitTriangles: function (triVisitor, includeFrame) {
this._visitedKey++;
var edgeStack = new __WEBPACK_IMPORTED_MODULE_7__java_util_Stack__["a" /* default */]();
edgeStack.push(this._startingEdge);
var visitedEdges = new __WEBPACK_IMPORTED_MODULE_2__java_util_HashSet__["a" /* default */]();
while (!edgeStack.empty()) {
var edge = edgeStack.pop();
if (!visitedEdges.contains(edge)) {
var triEdges = this.fetchTriangleToVisit(edge, edgeStack, includeFrame, visitedEdges);
if (triEdges !== null) triVisitor.visit(triEdges);
}
}
},
isFrameEdge: function (e) {
if (this.isFrameVertex(e.orig()) || this.isFrameVertex(e.dest())) return true;
return false;
},
isOnEdge: function (e, p) {
this._seg.setCoordinates(e.orig().getCoordinate(), e.dest().getCoordinate());
var dist = this._seg.distance(p);
return dist < this._edgeCoincidenceTolerance;
},
getEnvelope: function () {
return new __WEBPACK_IMPORTED_MODULE_15__geom_Envelope__["a" /* default */](this._frameEnv);
},
createFrame: function (env) {
var deltaX = env.getWidth();
var deltaY = env.getHeight();
var offset = 0.0;
if (deltaX > deltaY) {
offset = deltaX * 10.0;
} else {
offset = deltaY * 10.0;
}
this._frameVertex[0] = new __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */]((env.getMaxX() + env.getMinX()) / 2.0, env.getMaxY() + offset);
this._frameVertex[1] = new __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */](env.getMinX() - offset, env.getMinY() - offset);
this._frameVertex[2] = new __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */](env.getMaxX() + offset, env.getMinY() - offset);
this._frameEnv = new __WEBPACK_IMPORTED_MODULE_15__geom_Envelope__["a" /* default */](this._frameVertex[0].getCoordinate(), this._frameVertex[1].getCoordinate());
this._frameEnv.expandToInclude(this._frameVertex[2].getCoordinate());
},
getTriangleCoordinates: function (includeFrame) {
var visitor = new TriangleCoordinatesVisitor();
this.visitTriangles(visitor, includeFrame);
return visitor.getTriangles();
},
getVertices: function (includeFrame) {
var vertices = new __WEBPACK_IMPORTED_MODULE_2__java_util_HashSet__["a" /* default */]();
for (var i = this._quadEdges.iterator(); i.hasNext(); ) {
var qe = i.next();
var v = qe.orig();
if (includeFrame || !this.isFrameVertex(v)) vertices.add(v);
var vd = qe.dest();
if (includeFrame || !this.isFrameVertex(vd)) vertices.add(vd);
}
return vertices;
},
fetchTriangleToVisit: function (edge, edgeStack, includeFrame, visitedEdges) {
var curr = edge;
var edgeCount = 0;
var isFrame = false;
do {
this._triEdges[edgeCount] = curr;
if (this.isFrameEdge(curr)) isFrame = true;
var sym = curr.sym();
if (!visitedEdges.contains(sym)) edgeStack.push(sym);
visitedEdges.add(curr);
edgeCount++;
curr = curr.lNext();
} while (curr !== edge);
if (isFrame && !includeFrame) return null;
return this._triEdges;
},
getEdges: function () {
if (arguments.length === 0) {
return this._quadEdges;
} else if (arguments.length === 1) {
let geomFact = arguments[0];
var quadEdges = this.getPrimaryEdges(false);
var edges = new Array(quadEdges.size()).fill(null);
var i = 0;
for (var it = quadEdges.iterator(); it.hasNext(); ) {
var qe = it.next();
edges[i++] = geomFact.createLineString([qe.orig().getCoordinate(), qe.dest().getCoordinate()]);
}
return geomFact.createMultiLineString(edges);
}
},
getVertexUniqueEdges: function (includeFrame) {
var edges = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
var visitedVertices = new __WEBPACK_IMPORTED_MODULE_2__java_util_HashSet__["a" /* default */]();
for (var i = this._quadEdges.iterator(); i.hasNext(); ) {
var qe = i.next();
var v = qe.orig();
if (!visitedVertices.contains(v)) {
visitedVertices.add(v);
if (includeFrame || !this.isFrameVertex(v)) {
edges.add(qe);
}
}
var qd = qe.sym();
var vd = qd.orig();
if (!visitedVertices.contains(vd)) {
visitedVertices.add(vd);
if (includeFrame || !this.isFrameVertex(vd)) {
edges.add(qd);
}
}
}
return edges;
},
getTriangleEdges: function (includeFrame) {
var visitor = new TriangleEdgesListVisitor();
this.visitTriangles(visitor, includeFrame);
return visitor.getTriangleEdges();
},
getPrimaryEdges: function (includeFrame) {
this._visitedKey++;
var edges = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
var edgeStack = new __WEBPACK_IMPORTED_MODULE_7__java_util_Stack__["a" /* default */]();
edgeStack.push(this._startingEdge);
var visitedEdges = new __WEBPACK_IMPORTED_MODULE_2__java_util_HashSet__["a" /* default */]();
while (!edgeStack.empty()) {
var edge = edgeStack.pop();
if (!visitedEdges.contains(edge)) {
var priQE = edge.getPrimary();
if (includeFrame || !this.isFrameEdge(priQE)) edges.add(priQE);
edgeStack.push(edge.oNext());
edgeStack.push(edge.sym().oNext());
visitedEdges.add(edge);
visitedEdges.add(edge.sym());
}
}
return edges;
},
delete: function (e) {
__WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].splice(e, e.oPrev());
__WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].splice(e.sym(), e.sym().oPrev());
var eSym = e.sym();
var eRot = e.rot();
var eRotSym = e.rot().sym();
this._quadEdges.remove(e);
this._quadEdges.remove(eSym);
this._quadEdges.remove(eRot);
this._quadEdges.remove(eRotSym);
e.delete();
eSym.delete();
eRot.delete();
eRotSym.delete();
},
locateFromEdge: function (v, startEdge) {
var iter = 0;
var maxIter = this._quadEdges.size();
var e = startEdge;
while (true) {
iter++;
if (iter > maxIter) {
throw new __WEBPACK_IMPORTED_MODULE_10__LocateFailureException__["a" /* default */](e.toLineSegment());
}
if (v.equals(e.orig()) || v.equals(e.dest())) {
break;
} else if (v.rightOf(e)) {
e = e.sym();
} else if (!v.rightOf(e.oNext())) {
e = e.oNext();
} else if (!v.rightOf(e.dPrev())) {
e = e.dPrev();
} else {
break;
}
}
return e;
},
getTolerance: function () {
return this._tolerance;
},
getVoronoiCellPolygons: function (geomFact) {
this.visitTriangles(new TriangleCircumcentreVisitor(), true);
var cells = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
var edges = this.getVertexUniqueEdges(false);
for (var i = edges.iterator(); i.hasNext(); ) {
var qe = i.next();
cells.add(this.getVoronoiCellPolygon(qe, geomFact));
}
return cells;
},
getVoronoiDiagram: function (geomFact) {
var vorCells = this.getVoronoiCellPolygons(geomFact);
return geomFact.createGeometryCollection(__WEBPACK_IMPORTED_MODULE_4__geom_GeometryFactory__["a" /* default */].toGeometryArray(vorCells));
},
getTriangles: function (geomFact) {
var triPtsList = this.getTriangleCoordinates(false);
var tris = new Array(triPtsList.size()).fill(null);
var i = 0;
for (var it = triPtsList.iterator(); it.hasNext(); ) {
var triPt = it.next();
tris[i++] = geomFact.createPolygon(geomFact.createLinearRing(triPt), null);
}
return geomFact.createGeometryCollection(tris);
},
insertSite: function (v) {
var e = this.locate(v);
if (v.equals(e.orig(), this._tolerance) || v.equals(e.dest(), this._tolerance)) {
return e;
}
var base = this.makeEdge(e.orig(), v);
__WEBPACK_IMPORTED_MODULE_0__QuadEdge__["a" /* default */].splice(base, e);
var startEdge = base;
do {
base = this.connect(e, base.sym());
e = base.oPrev();
} while (e.lNext() !== startEdge);
return startEdge;
},
locate: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */]) {
let v = arguments[0];
return this._locator.locate(v);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_5__geom_Coordinate__["a" /* default */]) {
let p = arguments[0];
return this._locator.locate(new __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */](p));
}
} else if (arguments.length === 2) {
let p0 = arguments[0], p1 = arguments[1];
var e = this._locator.locate(new __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */](p0));
if (e === null) return null;
var base = e;
if (e.dest().getCoordinate().equals2D(p0)) base = e.sym();
var locEdge = base;
do {
if (locEdge.dest().getCoordinate().equals2D(p1)) return locEdge;
locEdge = locEdge.oNext();
} while (locEdge !== base);
return null;
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return QuadEdgeSubdivision;
}
});
QuadEdgeSubdivision.getTriangleEdges = function (startQE, triEdge) {
triEdge[0] = startQE;
triEdge[1] = triEdge[0].lNext();
triEdge[2] = triEdge[1].lNext();
if (triEdge[2].lNext() !== triEdge[0]) throw new __WEBPACK_IMPORTED_MODULE_6__java_lang_IllegalArgumentException__["a" /* default */]("Edges do not form a triangle");
};
function TriangleCircumcentreVisitor() {}
Object(__WEBPACK_IMPORTED_MODULE_8__extend__["a" /* default */])(TriangleCircumcentreVisitor.prototype, {
visit: function (triEdges) {
var a = triEdges[0].orig().getCoordinate();
var b = triEdges[1].orig().getCoordinate();
var c = triEdges[2].orig().getCoordinate();
var cc = __WEBPACK_IMPORTED_MODULE_16__geom_Triangle__["a" /* default */].circumcentre(a, b, c);
var ccVertex = new __WEBPACK_IMPORTED_MODULE_11__Vertex__["a" /* default */](cc);
for (var i = 0; i < 3; i++) {
triEdges[i].rot().setOrig(ccVertex);
}
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_17__TriangleVisitor__["a" /* default */]];
},
getClass: function () {
return TriangleCircumcentreVisitor;
}
});
function TriangleEdgesListVisitor() {
this._triList = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_8__extend__["a" /* default */])(TriangleEdgesListVisitor.prototype, {
getTriangleEdges: function () {
return this._triList;
},
visit: function (triEdges) {
this._triList.add(triEdges.clone());
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_17__TriangleVisitor__["a" /* default */]];
},
getClass: function () {
return TriangleEdgesListVisitor;
}
});
function TriangleVertexListVisitor() {
this._triList = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_8__extend__["a" /* default */])(TriangleVertexListVisitor.prototype, {
visit: function (triEdges) {
this._triList.add([triEdges[0].orig(), triEdges[1].orig(), triEdges[2].orig()]);
},
getTriangleVertices: function () {
return this._triList;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_17__TriangleVisitor__["a" /* default */]];
},
getClass: function () {
return TriangleVertexListVisitor;
}
});
function TriangleCoordinatesVisitor() {
this._coordList = new __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__["a" /* default */]();
this._triCoords = new __WEBPACK_IMPORTED_MODULE_14__java_util_ArrayList__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_8__extend__["a" /* default */])(TriangleCoordinatesVisitor.prototype, {
checkTriangleSize: function (pts) {
var loc = "";
if (pts.length >= 2) loc = __WEBPACK_IMPORTED_MODULE_3__io_WKTWriter__["a" /* default */].toLineString(pts[0], pts[1]); else {
if (pts.length >= 1) loc = __WEBPACK_IMPORTED_MODULE_3__io_WKTWriter__["a" /* default */].toPoint(pts[0]);
}
},
visit: function (triEdges) {
this._coordList.clear();
for (var i = 0; i < 3; i++) {
var v = triEdges[i].orig();
this._coordList.add(v.getCoordinate());
}
if (this._coordList.size() > 0) {
this._coordList.closeRing();
var pts = this._coordList.toCoordinateArray();
if (pts.length !== 4) {
return null;
}
this._triCoords.add(pts);
}
},
getTriangles: function () {
return this._triCoords;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_17__TriangleVisitor__["a" /* default */]];
},
getClass: function () {
return TriangleCoordinatesVisitor;
}
});
QuadEdgeSubdivision.TriangleCircumcentreVisitor = TriangleCircumcentreVisitor;
QuadEdgeSubdivision.TriangleEdgesListVisitor = TriangleEdgesListVisitor;
QuadEdgeSubdivision.TriangleVertexListVisitor = TriangleVertexListVisitor;
QuadEdgeSubdivision.TriangleCoordinatesVisitor = TriangleCoordinatesVisitor;
QuadEdgeSubdivision.EDGE_COINCIDENCE_TOL_FACTOR = 1000;
/***/ }),
/* 109 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = DelaunayTriangulationBuilder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__ = __webpack_require__(58);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_Collection__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__IncrementalDelaunayTriangulator__ = __webpack_require__(107);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__quadedge_QuadEdgeSubdivision__ = __webpack_require__(108);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__quadedge_Vertex__ = __webpack_require__(84);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__geom_Envelope__ = __webpack_require__(7);
function DelaunayTriangulationBuilder() {
this._siteCoords = null;
this._tolerance = 0.0;
this._subdiv = null;
}
Object(__WEBPACK_IMPORTED_MODULE_7__extend__["a" /* default */])(DelaunayTriangulationBuilder.prototype, {
create: function () {
if (this._subdiv !== null) return null;
var siteEnv = DelaunayTriangulationBuilder.envelope(this._siteCoords);
var vertices = DelaunayTriangulationBuilder.toVertices(this._siteCoords);
this._subdiv = new __WEBPACK_IMPORTED_MODULE_6__quadedge_QuadEdgeSubdivision__["a" /* default */](siteEnv, this._tolerance);
var triangulator = new __WEBPACK_IMPORTED_MODULE_5__IncrementalDelaunayTriangulator__["a" /* default */](this._subdiv);
triangulator.insertSites(vertices);
},
setTolerance: function (tolerance) {
this._tolerance = tolerance;
},
setSites: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__geom_Geometry__["a" /* default */]) {
let geom = arguments[0];
this._siteCoords = DelaunayTriangulationBuilder.extractUniqueCoordinates(geom);
} else if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_4__java_util_Collection__["a" /* default */])) {
let coords = arguments[0];
this._siteCoords = DelaunayTriangulationBuilder.unique(__WEBPACK_IMPORTED_MODULE_9__geom_CoordinateArrays__["a" /* default */].toCoordinateArray(coords));
}
},
getEdges: function (geomFact) {
this.create();
return this._subdiv.getEdges(geomFact);
},
getSubdivision: function () {
this.create();
return this._subdiv;
},
getTriangles: function (geomFact) {
this.create();
return this._subdiv.getTriangles(geomFact);
},
interfaces_: function () {
return [];
},
getClass: function () {
return DelaunayTriangulationBuilder;
}
});
DelaunayTriangulationBuilder.extractUniqueCoordinates = function (geom) {
if (geom === null) return new __WEBPACK_IMPORTED_MODULE_0__geom_CoordinateList__["a" /* default */]();
var coords = geom.getCoordinates();
return DelaunayTriangulationBuilder.unique(coords);
};
DelaunayTriangulationBuilder.envelope = function (coords) {
var env = new __WEBPACK_IMPORTED_MODULE_11__geom_Envelope__["a" /* default */]();
for (var i = coords.iterator(); i.hasNext(); ) {
var coord = i.next();
env.expandToInclude(coord);
}
return env;
};
DelaunayTriangulationBuilder.unique = function (coords) {
var coordsCopy = __WEBPACK_IMPORTED_MODULE_9__geom_CoordinateArrays__["a" /* default */].copyDeep(coords);
__WEBPACK_IMPORTED_MODULE_2__java_util_Arrays__["a" /* default */].sort(coordsCopy);
var coordList = new __WEBPACK_IMPORTED_MODULE_0__geom_CoordinateList__["a" /* default */](coordsCopy, false);
return coordList;
};
DelaunayTriangulationBuilder.toVertices = function (coords) {
var verts = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
for (var i = coords.iterator(); i.hasNext(); ) {
var coord = i.next();
verts.add(new __WEBPACK_IMPORTED_MODULE_8__quadedge_Vertex__["a" /* default */](coord));
}
return verts;
};
/***/ }),
/* 110 */
/***/ (function(module, exports) {
module.exports = L;
/***/ }),
/* 111 */
/***/ (function(module, exports, __webpack_require__) {
var pSlice = Array.prototype.slice;
var objectKeys = __webpack_require__(183);
var isArguments = __webpack_require__(184);
var deepEqual = module.exports = function (actual, expected, opts) {
if (!opts) opts = {};
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (actual instanceof Date && expected instanceof Date) {
return actual.getTime() === expected.getTime();
// 7.3. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
return opts.strict ? actual === expected : actual == expected;
// 7.4. For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
return objEquiv(actual, expected, opts);
}
}
function isUndefinedOrNull(value) {
return value === null || value === undefined;
}
function isBuffer (x) {
if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
return false;
}
if (x.length > 0 && typeof x[0] !== 'number') return false;
return true;
}
function objEquiv(a, b, opts) {
var i, key;
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
a = pSlice.call(a);
b = pSlice.call(b);
return deepEqual(a, b, opts);
}
if (isBuffer(a)) {
if (!isBuffer(b)) {
return false;
}
if (a.length !== b.length) return false;
for (i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
}
return true;
}
try {
var ka = objectKeys(a),
kb = objectKeys(b);
} catch (e) {//happens when one is a string literal and the other isn't
return false;
}
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] != kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!deepEqual(a[key], b[key], opts)) return false;
}
return typeof a === typeof b;
}
/***/ }),
/* 112 */
/***/ (function(module, exports, __webpack_require__) {
var rbush = __webpack_require__(185);
var meta = __webpack_require__(187);
var featureEach = meta.featureEach;
var coordEach = meta.coordEach;
/**
* GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.
*
* @name rbush
* @param {number} [maxEntries=9] defines the maximum number of entries in a tree node. 9 (used by default) is a
* reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.
* @returns {RBush} GeoJSON RBush
* @example
* var rbush = require('geojson-rbush')
* var tree = rbush()
*/
module.exports = function (maxEntries) {
var tree = rbush(maxEntries);
/**
* [insert](https://github.com/mourner/rbush#data-format)
*
* @param {Feature} feature insert single GeoJSON Feature
* @returns {RBush} GeoJSON RBush
* @example
* var polygon = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]
* }
* }
* tree.insert(polygon)
*/
tree.insert = function (feature) {
if (Array.isArray(feature)) {
var bbox = feature;
feature = bboxPolygon(bbox);
feature.bbox = bbox;
} else {
feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
}
return rbush.prototype.insert.call(this, feature);
};
/**
* [load](https://github.com/mourner/rbush#bulk-inserting-data)
*
* @param {BBox[]|FeatureCollection} features load entire GeoJSON FeatureCollection
* @returns {RBush} GeoJSON RBush
* @example
* var polygons = {
* "type": "FeatureCollection",
* "features": [
* {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]
* }
* },
* {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]
* }
* }
* ]
* }
* tree.load(polygons)
*/
tree.load = function (features) {
var load = [];
// Load an Array of BBox
if (Array.isArray(features)) {
features.forEach(function (bbox) {
var feature = bboxPolygon(bbox);
feature.bbox = bbox;
load.push(feature);
});
} else {
// Load FeatureCollection
featureEach(features, function (feature) {
feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
load.push(feature);
});
}
return rbush.prototype.load.call(this, load);
};
/**
* [remove](https://github.com/mourner/rbush#removing-data)
*
* @param {BBox|Feature} feature remove single GeoJSON Feature
* @returns {RBush} GeoJSON RBush
* @example
* var polygon = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]
* }
* }
* tree.remove(polygon)
*/
tree.remove = function (feature) {
if (Array.isArray(feature)) {
var bbox = feature;
feature = bboxPolygon(bbox);
feature.bbox = bbox;
}
return rbush.prototype.remove.call(this, feature);
};
/**
* [clear](https://github.com/mourner/rbush#removing-data)
*
* @returns {RBush} GeoJSON Rbush
* @example
* tree.clear()
*/
tree.clear = function () {
return rbush.prototype.clear.call(this);
};
/**
* [search](https://github.com/mourner/rbush#search)
*
* @param {BBox|FeatureCollection|Feature} geojson search with GeoJSON
* @returns {FeatureCollection} all features that intersects with the given GeoJSON.
* @example
* var polygon = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]
* }
* }
* tree.search(polygon)
*/
tree.search = function (geojson) {
var features = rbush.prototype.search.call(this, this.toBBox(geojson));
return {
type: 'FeatureCollection',
features: features
};
};
/**
* [collides](https://github.com/mourner/rbush#collisions)
*
* @param {BBox|FeatureCollection|Feature} geojson collides with GeoJSON
* @returns {boolean} true if there are any items intersecting the given GeoJSON, otherwise false.
* @example
* var polygon = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]
* }
* }
* tree.collides(polygon)
*/
tree.collides = function (geojson) {
return rbush.prototype.collides.call(this, this.toBBox(geojson));
};
/**
* [all](https://github.com/mourner/rbush#search)
*
* @returns {FeatureCollection} all the features in RBush
* @example
* tree.all()
* //=FeatureCollection
*/
tree.all = function () {
var features = rbush.prototype.all.call(this);
return {
type: 'FeatureCollection',
features: features
};
};
/**
* [toJSON](https://github.com/mourner/rbush#export-and-import)
*
* @returns {any} export data as JSON object
* @example
* var exported = tree.toJSON()
* //=JSON object
*/
tree.toJSON = function () {
return rbush.prototype.toJSON.call(this);
};
/**
* [fromJSON](https://github.com/mourner/rbush#export-and-import)
*
* @param {any} json import previously exported data
* @returns {RBush} GeoJSON RBush
* @example
* var exported = {
* "children": [
* {
* "type": "Feature",
* "geometry": {
* "type": "Point",
* "coordinates": [110, 50]
* },
* "properties": {},
* "bbox": [110, 50, 110, 50]
* }
* ],
* "height": 1,
* "leaf": true,
* "minX": 110,
* "minY": 50,
* "maxX": 110,
* "maxY": 50
* }
* tree.fromJSON(exported)
*/
tree.fromJSON = function (json) {
return rbush.prototype.fromJSON.call(this, json);
};
/**
* Converts GeoJSON to {minX, minY, maxX, maxY} schema
*
* @private
* @param {BBox|FeatureCollectio|Feature} geojson feature(s) to retrieve BBox from
* @returns {Object} converted to {minX, minY, maxX, maxY}
*/
tree.toBBox = function (geojson) {
var bbox;
if (geojson.bbox) bbox = geojson.bbox;
else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;
else bbox = turfBBox(geojson);
return {
minX: bbox[0],
minY: bbox[1],
maxX: bbox[2],
maxY: bbox[3]
};
};
return tree;
};
/**
* Takes a bbox and returns an equivalent {@link Polygon|polygon}.
*
* @private
* @name bboxPolygon
* @param {Array} bbox extent in [minX, minY, maxX, maxY] order
* @returns {Feature} a Polygon representation of the bounding box
* @example
* var bbox = [0, 0, 10, 10];
*
* var poly = turf.bboxPolygon(bbox);
*
* //addToMap
* var addToMap = [poly]
*/
function bboxPolygon(bbox) {
var lowLeft = [bbox[0], bbox[1]];
var topLeft = [bbox[0], bbox[3]];
var topRight = [bbox[2], bbox[3]];
var lowRight = [bbox[2], bbox[1]];
var coordinates = [[lowLeft, lowRight, topRight, topLeft, lowLeft]];
return {
type: 'Feature',
bbox: bbox,
properties: {},
geometry: {
type: 'Polygon',
coordinates: coordinates
}
};
}
/**
* Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
*
* @private
* @name bbox
* @param {FeatureCollection|Feature} geojson input features
* @returns {Array} bbox extent in [minX, minY, maxX, maxY] order
* @example
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
* var bbox = turf.bbox(line);
* var bboxPolygon = turf.bboxPolygon(bbox);
*
* //addToMap
* var addToMap = [line, bboxPolygon]
*/
function turfBBox(geojson) {
var bbox = [Infinity, Infinity, -Infinity, -Infinity];
coordEach(geojson, function (coord) {
if (bbox[0] > coord[0]) bbox[0] = coord[0];
if (bbox[1] > coord[1]) bbox[1] = coord[1];
if (bbox[2] < coord[0]) bbox[2] = coord[0];
if (bbox[3] < coord[1]) bbox[3] = coord[1];
});
return bbox;
}
/***/ }),
/* 113 */
/***/ (function(module, exports, __webpack_require__) {
var helpers = __webpack_require__(188);
var getCoords = __webpack_require__(32).getCoords;
var flattenEach = __webpack_require__(189).flattenEach;
var lineString = helpers.lineString;
var featureCollection = helpers.featureCollection;
/**
* Creates a {@link FeatureCollection} of 2-vertex {@link LineString} segments from a {@link LineString|(Multi)LineString} or {@link Polygon|(Multi)Polygon}.
*
* @name lineSegment
* @param {Geometry|FeatureCollection|Feature} geojson GeoJSON Polygon or LineString
* @returns {FeatureCollection} 2-vertex line segments
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
* var segments = turf.lineSegment(polygon);
*
* //addToMap
* var addToMap = [polygon, segments]
*/
module.exports = function (geojson) {
if (!geojson) throw new Error('geojson is required');
var results = [];
flattenEach(geojson, function (feature) {
lineSegment(feature, results);
});
return featureCollection(results);
};
/**
* Line Segment
*
* @private
* @param {Feature} geojson Line or polygon feature
* @param {Array} results push to results
* @returns {void}
*/
function lineSegment(geojson, results) {
var coords = [];
var geometry = geojson.geometry;
switch (geometry.type) {
case 'Polygon':
coords = getCoords(geometry);
break;
case 'LineString':
coords = [getCoords(geometry)];
}
coords.forEach(function (coord) {
var segments = createSegments(coord, geojson.properties);
segments.forEach(function (segment) {
segment.id = results.length;
results.push(segment);
});
});
}
/**
* Create Segments from LineString coordinates
*
* @private
* @param {LineString} coords LineString coordinates
* @param {*} properties GeoJSON properties
* @returns {Array>} line segments
*/
function createSegments(coords, properties) {
var segments = [];
coords.reduce(function (previousCoords, currentCoords) {
var segment = lineString([previousCoords, currentCoords], properties);
segment.bbox = bbox(previousCoords, currentCoords);
segments.push(segment);
return currentCoords;
});
return segments;
}
/**
* Create BBox between two coordinates (faster than @turf/bbox)
*
* @private
* @param {[number, number]} coords1 Point coordinate
* @param {[number, number]} coords2 Point coordinate
* @returns {BBox} [west, south, east, north]
*/
function bbox(coords1, coords2) {
var x1 = coords1[0];
var y1 = coords1[1];
var x2 = coords2[0];
var y2 = coords2[1];
var west = (x1 < x2) ? x1 : x2;
var south = (y1 < y2) ? y1 : y2;
var east = (x1 > x2) ? x1 : x2;
var north = (y1 > y2) ? y1 : y2;
return [west, south, east, north];
}
/***/ }),
/* 114 */
/***/ (function(module, exports, __webpack_require__) {
var meta = __webpack_require__(198);
var rbush = __webpack_require__(112);
var helpers = __webpack_require__(199);
var getCoords = __webpack_require__(32).getCoords;
var lineSegment = __webpack_require__(113);
var point = helpers.point;
var featureEach = meta.featureEach;
var featureCollection = helpers.featureCollection;
/**
* Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
*
* @name lineIntersect
* @param {Geometry|FeatureCollection|Feature} line1 any LineString or Polygon
* @param {Geometry|FeatureCollection|Feature} line2 any LineString or Polygon
* @returns {FeatureCollection} point(s) that intersect both
* @example
* var line1 = turf.lineString([[126, -11], [129, -21]]);
* var line2 = turf.lineString([[123, -18], [131, -14]]);
* var intersects = turf.lineIntersect(line1, line2);
*
* //addToMap
* var addToMap = [line1, line2, intersects]
*/
module.exports = function (line1, line2) {
var unique = {};
var results = [];
// First, normalize geometries to features
// Then, handle simple 2-vertex segments
if (line1.type === 'LineString') line1 = helpers.feature(line1);
if (line2.type === 'LineString') line2 = helpers.feature(line2);
if (line1.type === 'Feature' &&
line2.type === 'Feature' &&
line1.geometry.type === 'LineString' &&
line2.geometry.type === 'LineString' &&
line1.geometry.coordinates.length === 2 &&
line2.geometry.coordinates.length === 2) {
var intersect = intersects(line1, line2);
if (intersect) results.push(intersect);
return featureCollection(results);
}
// Handles complex GeoJSON Geometries
var tree = rbush();
tree.load(lineSegment(line2));
featureEach(lineSegment(line1), function (segment) {
featureEach(tree.search(segment), function (match) {
var intersect = intersects(segment, match);
if (intersect) {
// prevent duplicate points https://github.com/Turfjs/turf/issues/688
var key = getCoords(intersect).join(',');
if (!unique[key]) {
unique[key] = true;
results.push(intersect);
}
}
});
});
return featureCollection(results);
};
/**
* Find a point that intersects LineStrings with two coordinates each
*
* @private
* @param {Feature} line1 GeoJSON LineString (Must only contain 2 coordinates)
* @param {Feature} line2 GeoJSON LineString (Must only contain 2 coordinates)
* @returns {Feature} intersecting GeoJSON Point
*/
function intersects(line1, line2) {
var coords1 = getCoords(line1);
var coords2 = getCoords(line2);
if (coords1.length !== 2) {
throw new Error(' line1 must only contain 2 coordinates');
}
if (coords2.length !== 2) {
throw new Error(' line2 must only contain 2 coordinates');
}
var x1 = coords1[0][0];
var y1 = coords1[0][1];
var x2 = coords1[1][0];
var y2 = coords1[1][1];
var x3 = coords2[0][0];
var y3 = coords2[0][1];
var x4 = coords2[1][0];
var y4 = coords2[1][1];
var denom = ((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1));
var numeA = ((x4 - x3) * (y1 - y3)) - ((y4 - y3) * (x1 - x3));
var numeB = ((x2 - x1) * (y1 - y3)) - ((y2 - y1) * (x1 - x3));
if (denom === 0) {
if (numeA === 0 && numeB === 0) {
return null;
}
return null;
}
var uA = numeA / denom;
var uB = numeB / denom;
if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) {
var x = x1 + (uA * (x2 - x1));
var y = y1 + (uA * (y2 - y1));
return point([x, y]);
}
return null;
}
/***/ }),
/* 115 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CGAlgorithmsDD;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_DD__ = __webpack_require__(116);
function CGAlgorithmsDD() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(CGAlgorithmsDD.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return CGAlgorithmsDD;
}
});
CGAlgorithmsDD.orientationIndex = function (p1, p2, q) {
var index = CGAlgorithmsDD.orientationIndexFilter(p1, p2, q);
if (index <= 1) return index;
var dx1 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.x).selfAdd(-p1.x);
var dy1 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.y).selfAdd(-p1.y);
var dx2 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q.x).selfAdd(-p2.x);
var dy2 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q.y).selfAdd(-p2.y);
return dx1.selfMultiply(dy2).selfSubtract(dy1.selfMultiply(dx2)).signum();
};
CGAlgorithmsDD.signOfDet2x2 = function (x1, y1, x2, y2) {
var det = x1.multiply(y2).selfSubtract(y1.multiply(x2));
return det.signum();
};
CGAlgorithmsDD.intersection = function (p1, p2, q1, q2) {
var denom1 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q2.y).selfSubtract(q1.y).selfMultiply(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.x).selfSubtract(p1.x));
var denom2 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q2.x).selfSubtract(q1.x).selfMultiply(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.y).selfSubtract(p1.y));
var denom = denom1.subtract(denom2);
var numx1 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q2.x).selfSubtract(q1.x).selfMultiply(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p1.y).selfSubtract(q1.y));
var numx2 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q2.y).selfSubtract(q1.y).selfMultiply(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p1.x).selfSubtract(q1.x));
var numx = numx1.subtract(numx2);
var fracP = numx.selfDivide(denom).doubleValue();
var x = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p1.x).selfAdd(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.x).selfSubtract(p1.x).selfMultiply(fracP)).doubleValue();
var numy1 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.x).selfSubtract(p1.x).selfMultiply(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p1.y).selfSubtract(q1.y));
var numy2 = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p2.y).selfSubtract(p1.y).selfMultiply(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(p1.x).selfSubtract(q1.x));
var numy = numy1.subtract(numy2);
var fracQ = numy.selfDivide(denom).doubleValue();
var y = __WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q1.y).selfAdd(__WEBPACK_IMPORTED_MODULE_2__math_DD__["a" /* default */].valueOf(q2.y).selfSubtract(q1.y).selfMultiply(fracQ)).doubleValue();
return new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](x, y);
};
CGAlgorithmsDD.orientationIndexFilter = function (pa, pb, pc) {
var detsum = null;
var detleft = (pa.x - pc.x) * (pb.y - pc.y);
var detright = (pa.y - pc.y) * (pb.x - pc.x);
var det = detleft - detright;
if (detleft > 0.0) {
if (detright <= 0.0) {
return CGAlgorithmsDD.signum(det);
} else {
detsum = detleft + detright;
}
} else if (detleft < 0.0) {
if (detright >= 0.0) {
return CGAlgorithmsDD.signum(det);
} else {
detsum = -detleft - detright;
}
} else {
return CGAlgorithmsDD.signum(det);
}
var errbound = CGAlgorithmsDD.DP_SAFE_EPSILON * detsum;
if (det >= errbound || -det >= errbound) {
return CGAlgorithmsDD.signum(det);
}
return 2;
};
CGAlgorithmsDD.signum = function (x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
};
CGAlgorithmsDD.DP_SAFE_EPSILON = 1e-15;
/***/ }),
/* 116 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = DD;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_Integer__ = __webpack_require__(55);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_lang_Character__ = __webpack_require__(117);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_Comparable__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_lang_Cloneable__ = __webpack_require__(53);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_io_Serializable__ = __webpack_require__(21);
function DD() {
this._hi = 0.0;
this._lo = 0.0;
if (arguments.length === 0) {
this.init(0.0);
} else if (arguments.length === 1) {
if (typeof arguments[0] === "number") {
let x = arguments[0];
this.init(x);
} else if (arguments[0] instanceof DD) {
let dd = arguments[0];
this.init(dd);
} else if (typeof arguments[0] === "string") {
let str = arguments[0];
DD.call(this, DD.parse(str));
}
} else if (arguments.length === 2) {
let hi = arguments[0], lo = arguments[1];
this.init(hi, lo);
}
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(DD.prototype, {
le: function (y) {
return this._hi < y._hi || this._hi === y._hi && this._lo <= y._lo;
},
extractSignificantDigits: function (insertDecimalPoint, magnitude) {
var y = this.abs();
var mag = DD.magnitude(y._hi);
var scale = DD.TEN.pow(mag);
y = y.divide(scale);
if (y.gt(DD.TEN)) {
y = y.divide(DD.TEN);
mag += 1;
} else if (y.lt(DD.ONE)) {
y = y.multiply(DD.TEN);
mag -= 1;
}
var decimalPointPos = mag + 1;
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]();
var numDigits = DD.MAX_PRINT_DIGITS - 1;
for (var i = 0; i <= numDigits; i++) {
if (insertDecimalPoint && i === decimalPointPos) {
buf.append('.');
}
var digit = Math.trunc(y._hi);
if (digit < 0 || digit > 9) {}
if (digit < 0) {
break;
}
var rebiasBy10 = false;
var digitChar = 0;
if (digit > 9) {
rebiasBy10 = true;
digitChar = '9';
} else {
digitChar = '0' + digit;
}
buf.append(digitChar);
y = y.subtract(DD.valueOf(digit)).multiply(DD.TEN);
if (rebiasBy10) y.selfAdd(DD.TEN);
var continueExtractingDigits = true;
var remMag = DD.magnitude(y._hi);
if (remMag < 0 && Math.abs(remMag) >= numDigits - i) continueExtractingDigits = false;
if (!continueExtractingDigits) break;
}
magnitude[0] = mag;
return buf.toString();
},
sqr: function () {
return this.multiply(this);
},
doubleValue: function () {
return this._hi + this._lo;
},
subtract: function () {
if (arguments[0] instanceof DD) {
let y = arguments[0];
return this.add(y.negate());
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
return this.add(-y);
}
},
equals: function () {
if (arguments.length === 1) {
let y = arguments[0];
return this._hi === y._hi && this._lo === y._lo;
}
},
isZero: function () {
return this._hi === 0.0 && this._lo === 0.0;
},
selfSubtract: function () {
if (arguments[0] instanceof DD) {
let y = arguments[0];
if (this.isNaN()) return this;
return this.selfAdd(-y._hi, -y._lo);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
if (this.isNaN()) return this;
return this.selfAdd(-y, 0.0);
}
},
getSpecialNumberString: function () {
if (this.isZero()) return "0.0";
if (this.isNaN()) return "NaN ";
return null;
},
min: function (x) {
if (this.le(x)) {
return this;
} else {
return x;
}
},
selfDivide: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof DD) {
let y = arguments[0];
return this.selfDivide(y._hi, y._lo);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
return this.selfDivide(y, 0.0);
}
} else if (arguments.length === 2) {
let yhi = arguments[0], ylo = arguments[1];
var hc = null, tc = null, hy = null, ty = null, C = null, c = null, U = null, u = null;
C = this._hi / yhi;
c = DD.SPLIT * C;
hc = c - C;
u = DD.SPLIT * yhi;
hc = c - hc;
tc = C - hc;
hy = u - yhi;
U = C * yhi;
hy = u - hy;
ty = yhi - hy;
u = hc * hy - U + hc * ty + tc * hy + tc * ty;
c = (this._hi - U - u + this._lo - C * ylo) / yhi;
u = C + c;
this._hi = u;
this._lo = C - u + c;
return this;
}
},
dump: function () {
return "DD<" + this._hi + ", " + this._lo + ">";
},
divide: function () {
if (arguments[0] instanceof DD) {
let y = arguments[0];
var hc = null, tc = null, hy = null, ty = null, C = null, c = null, U = null, u = null;
C = this._hi / y._hi;
c = DD.SPLIT * C;
hc = c - C;
u = DD.SPLIT * y._hi;
hc = c - hc;
tc = C - hc;
hy = u - y._hi;
U = C * y._hi;
hy = u - hy;
ty = y._hi - hy;
u = hc * hy - U + hc * ty + tc * hy + tc * ty;
c = (this._hi - U - u + this._lo - C * y._lo) / y._hi;
u = C + c;
var zhi = u;
var zlo = C - u + c;
return new DD(zhi, zlo);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
if (__WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].isNaN(y)) return DD.createNaN();
return DD.copy(this).selfDivide(y, 0.0);
}
},
ge: function (y) {
return this._hi > y._hi || this._hi === y._hi && this._lo >= y._lo;
},
pow: function (exp) {
if (exp === 0.0) return DD.valueOf(1.0);
var r = new DD(this);
var s = DD.valueOf(1.0);
var n = Math.abs(exp);
if (n > 1) {
while (n > 0) {
if (n % 2 === 1) {
s.selfMultiply(r);
}
n /= 2;
if (n > 0) r = r.sqr();
}
} else {
s = r;
}
if (exp < 0) return s.reciprocal();
return s;
},
ceil: function () {
if (this.isNaN()) return DD.NaN;
var fhi = Math.ceil(this._hi);
var flo = 0.0;
if (fhi === this._hi) {
flo = Math.ceil(this._lo);
}
return new DD(fhi, flo);
},
compareTo: function (o) {
var other = o;
if (this._hi < other._hi) return -1;
if (this._hi > other._hi) return 1;
if (this._lo < other._lo) return -1;
if (this._lo > other._lo) return 1;
return 0;
},
rint: function () {
if (this.isNaN()) return this;
var plus5 = this.add(0.5);
return plus5.floor();
},
setValue: function () {
if (arguments[0] instanceof DD) {
let value = arguments[0];
this.init(value);
return this;
} else if (typeof arguments[0] === "number") {
let value = arguments[0];
this.init(value);
return this;
}
},
max: function (x) {
if (this.ge(x)) {
return this;
} else {
return x;
}
},
sqrt: function () {
if (this.isZero()) return DD.valueOf(0.0);
if (this.isNegative()) {
return DD.NaN;
}
var x = 1.0 / Math.sqrt(this._hi);
var ax = this._hi * x;
var axdd = DD.valueOf(ax);
var diffSq = this.subtract(axdd.sqr());
var d2 = diffSq._hi * (x * 0.5);
return axdd.add(d2);
},
selfAdd: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof DD) {
let y = arguments[0];
return this.selfAdd(y._hi, y._lo);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
var H = null, h = null, S = null, s = null, e = null, f = null;
S = this._hi + y;
e = S - this._hi;
s = S - e;
s = y - e + (this._hi - s);
f = s + this._lo;
H = S + f;
h = f + (S - H);
this._hi = H + h;
this._lo = h + (H - this._hi);
return this;
}
} else if (arguments.length === 2) {
let yhi = arguments[0], ylo = arguments[1];
var H = null, h = null, T = null, t = null, S = null, s = null, e = null, f = null;
S = this._hi + yhi;
T = this._lo + ylo;
e = S - this._hi;
f = T - this._lo;
s = S - e;
t = T - f;
s = yhi - e + (this._hi - s);
t = ylo - f + (this._lo - t);
e = s + T;
H = S + e;
h = e + (S - H);
e = t + h;
var zhi = H + e;
var zlo = e + (H - zhi);
this._hi = zhi;
this._lo = zlo;
return this;
}
},
selfMultiply: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof DD) {
let y = arguments[0];
return this.selfMultiply(y._hi, y._lo);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
return this.selfMultiply(y, 0.0);
}
} else if (arguments.length === 2) {
let yhi = arguments[0], ylo = arguments[1];
var hx = null, tx = null, hy = null, ty = null, C = null, c = null;
C = DD.SPLIT * this._hi;
hx = C - this._hi;
c = DD.SPLIT * yhi;
hx = C - hx;
tx = this._hi - hx;
hy = c - yhi;
C = this._hi * yhi;
hy = c - hy;
ty = yhi - hy;
c = hx * hy - C + hx * ty + tx * hy + tx * ty + (this._hi * ylo + this._lo * yhi);
var zhi = C + c;
hx = C - zhi;
var zlo = c + hx;
this._hi = zhi;
this._lo = zlo;
return this;
}
},
selfSqr: function () {
return this.selfMultiply(this);
},
floor: function () {
if (this.isNaN()) return DD.NaN;
var fhi = Math.floor(this._hi);
var flo = 0.0;
if (fhi === this._hi) {
flo = Math.floor(this._lo);
}
return new DD(fhi, flo);
},
negate: function () {
if (this.isNaN()) return this;
return new DD(-this._hi, -this._lo);
},
clone: function () {
try {
return null;
} catch (ex) {
if (ex instanceof CloneNotSupportedException) {
return null;
} else throw ex;
} finally {}
},
multiply: function () {
if (arguments[0] instanceof DD) {
let y = arguments[0];
if (y.isNaN()) return DD.createNaN();
return DD.copy(this).selfMultiply(y);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
if (__WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].isNaN(y)) return DD.createNaN();
return DD.copy(this).selfMultiply(y, 0.0);
}
},
isNaN: function () {
return __WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].isNaN(this._hi);
},
intValue: function () {
return Math.trunc(this._hi);
},
toString: function () {
var mag = DD.magnitude(this._hi);
if (mag >= -3 && mag <= 20) return this.toStandardNotation();
return this.toSciNotation();
},
toStandardNotation: function () {
var specialStr = this.getSpecialNumberString();
if (specialStr !== null) return specialStr;
var magnitude = new Array(1).fill(null);
var sigDigits = this.extractSignificantDigits(true, magnitude);
var decimalPointPos = magnitude[0] + 1;
var num = sigDigits;
if (sigDigits.charAt(0) === '.') {
num = "0" + sigDigits;
} else if (decimalPointPos < 0) {
num = "0." + DD.stringOfChar('0', -decimalPointPos) + sigDigits;
} else if (sigDigits.indexOf('.') === -1) {
var numZeroes = decimalPointPos - sigDigits.length;
var zeroes = DD.stringOfChar('0', numZeroes);
num = sigDigits + zeroes + ".0";
}
if (this.isNegative()) return "-" + num;
return num;
},
reciprocal: function () {
var hc = null, tc = null, hy = null, ty = null, C = null, c = null, U = null, u = null;
C = 1.0 / this._hi;
c = DD.SPLIT * C;
hc = c - C;
u = DD.SPLIT * this._hi;
hc = c - hc;
tc = C - hc;
hy = u - this._hi;
U = C * this._hi;
hy = u - hy;
ty = this._hi - hy;
u = hc * hy - U + hc * ty + tc * hy + tc * ty;
c = (1.0 - U - u - C * this._lo) / this._hi;
var zhi = C + c;
var zlo = C - zhi + c;
return new DD(zhi, zlo);
},
toSciNotation: function () {
if (this.isZero()) return DD.SCI_NOT_ZERO;
var specialStr = this.getSpecialNumberString();
if (specialStr !== null) return specialStr;
var magnitude = new Array(1).fill(null);
var digits = this.extractSignificantDigits(false, magnitude);
var expStr = DD.SCI_NOT_EXPONENT_CHAR + magnitude[0];
if (digits.charAt(0) === '0') {
throw new IllegalStateException("Found leading zero: " + digits);
}
var trailingDigits = "";
if (digits.length > 1) trailingDigits = digits.substring(1);
var digitsWithDecimal = digits.charAt(0) + "." + trailingDigits;
if (this.isNegative()) return "-" + digitsWithDecimal + expStr;
return digitsWithDecimal + expStr;
},
abs: function () {
if (this.isNaN()) return DD.NaN;
if (this.isNegative()) return this.negate();
return new DD(this);
},
isPositive: function () {
return this._hi > 0.0 || this._hi === 0.0 && this._lo > 0.0;
},
lt: function (y) {
return this._hi < y._hi || this._hi === y._hi && this._lo < y._lo;
},
add: function () {
if (arguments[0] instanceof DD) {
let y = arguments[0];
return DD.copy(this).selfAdd(y);
} else if (typeof arguments[0] === "number") {
let y = arguments[0];
return DD.copy(this).selfAdd(y);
}
},
init: function () {
if (arguments.length === 1) {
if (typeof arguments[0] === "number") {
let x = arguments[0];
this._hi = x;
this._lo = 0.0;
} else if (arguments[0] instanceof DD) {
let dd = arguments[0];
this._hi = dd._hi;
this._lo = dd._lo;
}
} else if (arguments.length === 2) {
let hi = arguments[0], lo = arguments[1];
this._hi = hi;
this._lo = lo;
}
},
gt: function (y) {
return this._hi > y._hi || this._hi === y._hi && this._lo > y._lo;
},
isNegative: function () {
return this._hi < 0.0 || this._hi === 0.0 && this._lo < 0.0;
},
trunc: function () {
if (this.isNaN()) return DD.NaN;
if (this.isPositive()) return this.floor(); else return this.ceil();
},
signum: function () {
if (this._hi > 0) return 1;
if (this._hi < 0) return -1;
if (this._lo > 0) return 1;
if (this._lo < 0) return -1;
return 0;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_7__java_io_Serializable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_5__java_lang_Comparable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_6__java_lang_Cloneable__["a" /* default */]];
},
getClass: function () {
return DD;
}
});
DD.sqr = function (x) {
return DD.valueOf(x).selfMultiply(x);
};
DD.valueOf = function () {
if (typeof arguments[0] === "string") {
let str = arguments[0];
return DD.parse(str);
} else if (typeof arguments[0] === "number") {
let x = arguments[0];
return new DD(x);
}
};
DD.sqrt = function (x) {
return DD.valueOf(x).sqrt();
};
DD.parse = function (str) {
var i = 0;
var strlen = str.length;
while (__WEBPACK_IMPORTED_MODULE_4__java_lang_Character__["a" /* default */].isWhitespace(str.charAt(i))) i++;
var isNegative = false;
if (i < strlen) {
var signCh = str.charAt(i);
if (signCh === '-' || signCh === '+') {
i++;
if (signCh === '-') isNegative = true;
}
}
var val = new DD();
var numDigits = 0;
var numBeforeDec = 0;
var exp = 0;
while (true) {
if (i >= strlen) break;
var ch = str.charAt(i);
i++;
if (__WEBPACK_IMPORTED_MODULE_4__java_lang_Character__["a" /* default */].isDigit(ch)) {
var d = ch - '0';
val.selfMultiply(DD.TEN);
val.selfAdd(d);
numDigits++;
continue;
}
if (ch === '.') {
numBeforeDec = numDigits;
continue;
}
if (ch === 'e' || ch === 'E') {
var expStr = str.substring(i);
try {
exp = __WEBPACK_IMPORTED_MODULE_3__java_lang_Integer__["a" /* default */].parseInt(expStr);
} catch (ex) {
if (ex instanceof NumberFormatException) {
throw new NumberFormatException("Invalid exponent " + expStr + " in string " + str);
} else throw ex;
} finally {}
break;
}
throw new NumberFormatException("Unexpected character '" + ch + "' at position " + i + " in string " + str);
}
var val2 = val;
var numDecPlaces = numDigits - numBeforeDec - exp;
if (numDecPlaces === 0) {
val2 = val;
} else if (numDecPlaces > 0) {
var scale = DD.TEN.pow(numDecPlaces);
val2 = val.divide(scale);
} else if (numDecPlaces < 0) {
var scale = DD.TEN.pow(-numDecPlaces);
val2 = val.multiply(scale);
}
if (isNegative) {
return val2.negate();
}
return val2;
};
DD.createNaN = function () {
return new DD(__WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].NaN, __WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].NaN);
};
DD.copy = function (dd) {
return new DD(dd);
};
DD.magnitude = function (x) {
var xAbs = Math.abs(x);
var xLog10 = Math.log(xAbs) / Math.log(10);
var xMag = Math.trunc(Math.floor(xLog10));
var xApprox = Math.pow(10, xMag);
if (xApprox * 10 <= xAbs) xMag += 1;
return xMag;
};
DD.stringOfChar = function (ch, len) {
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]();
for (var i = 0; i < len; i++) {
buf.append(ch);
}
return buf.toString();
};
DD.PI = new DD(3.141592653589793116e+00, 1.224646799147353207e-16);
DD.TWO_PI = new DD(6.283185307179586232e+00, 2.449293598294706414e-16);
DD.PI_2 = new DD(1.570796326794896558e+00, 6.123233995736766036e-17);
DD.E = new DD(2.718281828459045091e+00, 1.445646891729250158e-16);
DD.NaN = new DD(__WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].NaN, __WEBPACK_IMPORTED_MODULE_1__java_lang_Double__["a" /* default */].NaN);
DD.EPS = 1.23259516440783e-32;
DD.SPLIT = 134217729.0;
DD.MAX_PRINT_DIGITS = 32;
DD.TEN = DD.valueOf(10.0);
DD.ONE = DD.valueOf(1.0);
DD.SCI_NOT_EXPONENT_CHAR = "E";
DD.SCI_NOT_ZERO = "0.0E0";
/***/ }),
/* 117 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Character;
function Character () {}
Character.isWhitespace = c => ((c <= 32 && c >= 0) || c == 127)
Character.toUpperCase = c => c.toUpperCase()
/***/ }),
/* 118 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = WKTParser;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_GeometryFactory__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
const regExes = {
'typeStr': /^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,
'emptyTypeStr': /^\s*(\w+)\s*EMPTY\s*$/,
'spaces': /\s+/,
'parenComma': /\)\s*,\s*\(/,
'doubleParenComma': /\)\s*\)\s*,\s*\(\s*\(/, // can't use {2} here
'trimParens': /^\s*\(?(.*?)\)?\s*$/
}
/**
* Class for reading and writing Well-Known Text.
*
* NOTE: Adapted from OpenLayers 2.11 implementation.
*/
/** Create a new parser for WKT
*
* @param {GeometryFactory} geometryFactory
* @return An instance of WKTParser.
* @constructor
* @private
*/
function WKTParser (geometryFactory) {
this.geometryFactory = geometryFactory || new __WEBPACK_IMPORTED_MODULE_1__geom_GeometryFactory__["a" /* default */]()
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(WKTParser.prototype, {
/**
* Deserialize a WKT string and return a geometry. Supports WKT for POINT,
* MULTIPOINT, LINESTRING, LINEARRING, MULTILINESTRING, POLYGON, MULTIPOLYGON,
* and GEOMETRYCOLLECTION.
*
* @param {String} wkt A WKT string.
* @return {Geometry} A geometry instance.
* @private
*/
read (wkt) {
var geometry, type, str
wkt = wkt.replace(/[\n\r]/g, ' ')
var matches = regExes.typeStr.exec(wkt)
if (wkt.search('EMPTY') !== -1) {
matches = regExes.emptyTypeStr.exec(wkt)
matches[2] = undefined
}
if (matches) {
type = matches[1].toLowerCase()
str = matches[2]
if (parse[type]) {
geometry = parse[type].apply(this, [str])
}
}
if (geometry === undefined) throw new Error('Could not parse WKT ' + wkt)
return geometry
},
/**
* Serialize a geometry into a WKT string.
*
* @param {Geometry} geometry A feature or array of features.
* @return {String} The WKT string representation of the input geometries.
* @private
*/
write (geometry) {
return this.extractGeometry(geometry)
},
/**
* Entry point to construct the WKT for a single Geometry object.
*
* @param {Geometry} geometry
* @return {String} A WKT string of representing the geometry.
* @private
*/
extractGeometry (geometry) {
var type = geometry.getGeometryType().toLowerCase()
if (!extract[type]) {
return null
}
var wktType = type.toUpperCase()
var data
if (geometry.isEmpty()) {
data = wktType + ' EMPTY'
} else {
data = wktType + '(' + extract[type].apply(this, [geometry]) + ')'
}
return data
}
})
/**
* Object with properties corresponding to the geometry types. Property values
* are functions that do the actual data extraction.
* @private
*/
const extract = {
coordinate (coordinate) {
return coordinate.x + ' ' + coordinate.y
},
/**
* Return a space delimited string of point coordinates.
*
* @param {Point}
* point
* @return {String} A string of coordinates representing the point.
*/
point (point) {
return extract.coordinate.call(this, point._coordinates._coordinates[0])
},
/**
* Return a comma delimited string of point coordinates from a multipoint.
*
* @param {MultiPoint}
* multipoint
* @return {String} A string of point coordinate strings representing the
* multipoint.
*/
multipoint (multipoint) {
var array = []
for (let i = 0, len = multipoint._geometries.length; i < len; ++i) {
array.push('(' + extract.point.apply(this, [multipoint._geometries[i]]) + ')')
}
return array.join(',')
},
/**
* Return a comma delimited string of point coordinates from a line.
*
* @param {LineString} linestring
* @return {String} A string of point coordinate strings representing the linestring.
*/
linestring (linestring) {
var array = []
for (let i = 0, len = linestring._points._coordinates.length; i < len; ++i) {
array.push(extract.coordinate.apply(this, [linestring._points._coordinates[i]]))
}
return array.join(',')
},
linearring (linearring) {
var array = []
for (let i = 0, len = linearring._points._coordinates.length; i < len; ++i) {
array.push(extract.coordinate.apply(this, [linearring._points._coordinates[i]]))
}
return array.join(',')
},
/**
* Return a comma delimited string of linestring strings from a
* multilinestring.
*
* @param {MultiLineString} multilinestring
* @return {String} A string of of linestring strings representing the multilinestring.
*/
multilinestring (multilinestring) {
var array = []
for (let i = 0, len = multilinestring._geometries.length; i < len; ++i) {
array.push('(' +
extract.linestring.apply(this, [multilinestring._geometries[i]]) +
')')
}
return array.join(',')
},
/**
* Return a comma delimited string of linear ring arrays from a polygon.
*
* @param {Polygon} polygon
* @return {String} An array of linear ring arrays representing the polygon.
*/
polygon (polygon) {
var array = []
array.push('(' + extract.linestring.apply(this, [polygon._shell]) + ')')
for (let i = 0, len = polygon._holes.length; i < len; ++i) {
array.push('(' + extract.linestring.apply(this, [polygon._holes[i]]) + ')')
}
return array.join(',')
},
/**
* Return an array of polygon arrays from a multipolygon.
*
* @param {MultiPolygon} multipolygon
* @return {String} An array of polygon arrays representing the multipolygon.
*/
multipolygon (multipolygon) {
var array = []
for (let i = 0, len = multipolygon._geometries.length; i < len; ++i) {
array.push('(' + extract.polygon.apply(this, [multipolygon._geometries[i]]) + ')')
}
return array.join(',')
},
/**
* Return the WKT portion between 'GEOMETRYCOLLECTION(' and ')' for an
* geometrycollection.
*
* @param {GeometryCollection} collection
* @return {String} internal WKT representation of the collection.
*/
geometrycollection (collection) {
var array = []
for (let i = 0, len = collection._geometries.length; i < len; ++i) {
array.push(this.extractGeometry(collection._geometries[i]))
}
return array.join(',')
}
}
/**
* Object with properties corresponding to the geometry types. Property values
* are functions that do the actual parsing.
* @private
*/
const parse = {
/**
* Return point geometry given a point WKT fragment.
*
* @param {String} str A WKT fragment representing the point.
* @return {Point} A point geometry.
* @private
*/
point (str) {
if (str === undefined) {
return this.geometryFactory.createPoint()
}
var coords = str.trim().split(regExes.spaces)
return this.geometryFactory.createPoint(new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](Number.parseFloat(coords[0]),
Number.parseFloat(coords[1])))
},
/**
* Return a multipoint geometry given a multipoint WKT fragment.
*
* @param {String} str A WKT fragment representing the multipoint.
* @return {Point} A multipoint feature.
* @private
*/
multipoint (str) {
if (str === undefined) {
return this.geometryFactory.createMultiPoint()
}
var point
var points = str.trim().split(',')
var components = []
for (let i = 0, len = points.length; i < len; ++i) {
point = points[i].replace(regExes.trimParens, '$1')
components.push(parse.point.apply(this, [point]))
}
return this.geometryFactory.createMultiPoint(components)
},
/**
* Return a linestring geometry given a linestring WKT fragment.
*
* @param {String} str A WKT fragment representing the linestring.
* @return {LineString} A linestring geometry.
* @private
*/
linestring (str) {
if (str === undefined) {
return this.geometryFactory.createLineString()
}
var points = str.trim().split(',')
var components = []
var coords
for (let i = 0, len = points.length; i < len; ++i) {
coords = points[i].trim().split(regExes.spaces)
components.push(new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](Number.parseFloat(coords[0]), Number.parseFloat(coords[1])))
}
return this.geometryFactory.createLineString(components)
},
/**
* Return a linearring geometry given a linearring WKT fragment.
*
* @param {String} str A WKT fragment representing the linearring.
* @return {LinearRing} A linearring geometry.
* @private
*/
linearring (str) {
if (str === undefined) {
return this.geometryFactory.createLinearRing()
}
var points = str.trim().split(',')
var components = []
var coords
for (let i = 0, len = points.length; i < len; ++i) {
coords = points[i].trim().split(regExes.spaces)
components.push(new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](Number.parseFloat(coords[0]), Number.parseFloat(coords[1])))
}
return this.geometryFactory.createLinearRing(components)
},
/**
* Return a multilinestring geometry given a multilinestring WKT fragment.
*
* @param {String} str A WKT fragment representing the multilinestring.
* @return {MultiLineString} A multilinestring geometry.
* @private
*/
multilinestring (str) {
if (str === undefined) {
return this.geometryFactory.createMultiLineString()
}
var line
var lines = str.trim().split(regExes.parenComma)
var components = []
for (let i = 0, len = lines.length; i < len; ++i) {
line = lines[i].replace(regExes.trimParens, '$1')
components.push(parse.linestring.apply(this, [line]))
}
return this.geometryFactory.createMultiLineString(components)
},
/**
* Return a polygon geometry given a polygon WKT fragment.
*
* @param {String} str A WKT fragment representing the polygon.
* @return {Polygon} A polygon geometry.
* @private
*/
polygon (str) {
if (str === undefined) {
return this.geometryFactory.createPolygon()
}
var ring, linestring, linearring
var rings = str.trim().split(regExes.parenComma)
var shell
var holes = []
for (let i = 0, len = rings.length; i < len; ++i) {
ring = rings[i].replace(regExes.trimParens, '$1')
linestring = parse.linestring.apply(this, [ring])
linearring = this.geometryFactory.createLinearRing(linestring._points)
if (i === 0) {
shell = linearring
} else {
holes.push(linearring)
}
}
return this.geometryFactory.createPolygon(shell, holes)
},
/**
* Return a multipolygon geometry given a multipolygon WKT fragment.
*
* @param {String} str A WKT fragment representing the multipolygon.
* @return {MultiPolygon} A multipolygon geometry.
* @private
*/
multipolygon (str) {
if (str === undefined) {
return this.geometryFactory.createMultiPolygon()
}
var polygon
var polygons = str.trim().split(regExes.doubleParenComma)
var components = []
for (let i = 0, len = polygons.length; i < len; ++i) {
polygon = polygons[i].replace(regExes.trimParens, '$1')
components.push(parse.polygon.apply(this, [polygon]))
}
return this.geometryFactory.createMultiPolygon(components)
},
/**
* Return a geometrycollection given a geometrycollection WKT fragment.
*
* @param {String} str A WKT fragment representing the geometrycollection.
* @return {GeometryCollection}
* @private
*/
geometrycollection (str) {
if (str === undefined) {
return this.geometryFactory.createGeometryCollection()
}
// separate components of the collection with |
str = str.replace(/,\s*([A-Za-z])/g, '|$1')
var wktArray = str.trim().split('|')
var components = []
for (let i = 0, len = wktArray.length; i < len; ++i) {
components.push(this.read(wktArray[i]))
}
return this.geometryFactory.createGeometryCollection(components)
}
}
/***/ }),
/* 119 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CoordinateSequenceFactory;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CoordinateSequence__ = __webpack_require__(37);
function CoordinateSequenceFactory() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(CoordinateSequenceFactory.prototype, {
create: function () {
if (arguments.length === 1) {
if (arguments[0] instanceof Array) {
let coordinates = arguments[0];
} else if (Object(__WEBPACK_IMPORTED_MODULE_0__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_2__CoordinateSequence__["a" /* default */])) {
let coordSeq = arguments[0];
}
} else if (arguments.length === 2) {
let size = arguments[0], dimension = arguments[1];
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return CoordinateSequenceFactory;
}
});
/***/ }),
/* 120 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Map;
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/Map.html
*
* @constructor
* @private
*/
function Map() {};
/**
* Returns the value to which the specified key is mapped, or null if this map
* contains no mapping for the key.
* @param {Object} key
* @return {Object}
*/
Map.prototype.get = function() {};
/**
* Associates the specified value with the specified key in this map (optional
* operation).
* @param {Object} key
* @param {Object} value
* @return {Object}
*/
Map.prototype.put = function() {};
/**
* Returns the number of key-value mappings in this map.
* @return {number}
*/
Map.prototype.size = function() {};
/**
* Returns a Collection view of the values contained in this map.
* @return {javascript.util.Collection}
*/
Map.prototype.values = function() {};
/**
* Returns a {@link Set} view of the mappings contained in this map.
* The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through
* the iterator's own remove operation, or through the
* setValue operation on a map entry returned by the
* iterator) the results of the iteration are undefined. The set
* supports element removal, which removes the corresponding
* mapping from the map, via the Iterator.remove,
* Set.remove, removeAll, retainAll and
* clear operations. It does not support the
* add or addAll operations.
*
* @return {Set} a set view of the mappings contained in this map
*/
Map.prototype.entrySet = function() {};
/***/ }),
/* 121 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Set;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Collection__ = __webpack_require__(24);
/**
* @see http://download.oracle.com/javase/6/docs/api/java/util/Set.html
*
* @extends {Collection}
* @constructor
* @private
*/
function Set() {};
Set.prototype = new __WEBPACK_IMPORTED_MODULE_0__Collection__["a" /* default */]();
/**
* Returns true if this set contains the specified element. More formally,
* returns true if and only if this set contains an element e such that (o==null ?
* e==null : o.equals(e)).
* @param {Object} e
* @return {boolean}
*/
Set.prototype.contains = function() {};
/***/ }),
/* 122 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Puntal;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Puntal() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Puntal.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Puntal;
}
});
/***/ }),
/* 123 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = RayCrossingCounter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geom_CoordinateSequence__ = __webpack_require__(37);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__RobustDeterminant__ = __webpack_require__(124);
function RayCrossingCounter() {
this._p = null;
this._crossingCount = 0;
this._isPointOnSegment = false;
let p = arguments[0];
this._p = p;
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(RayCrossingCounter.prototype, {
countSegment: function (p1, p2) {
if (p1.x < this._p.x && p2.x < this._p.x) return null;
if (this._p.x === p2.x && this._p.y === p2.y) {
this._isPointOnSegment = true;
return null;
}
if (p1.y === this._p.y && p2.y === this._p.y) {
var minx = p1.x;
var maxx = p2.x;
if (minx > maxx) {
minx = p2.x;
maxx = p1.x;
}
if (this._p.x >= minx && this._p.x <= maxx) {
this._isPointOnSegment = true;
}
return null;
}
if (p1.y > this._p.y && p2.y <= this._p.y || p2.y > this._p.y && p1.y <= this._p.y) {
var x1 = p1.x - this._p.x;
var y1 = p1.y - this._p.y;
var x2 = p2.x - this._p.x;
var y2 = p2.y - this._p.y;
var xIntSign = __WEBPACK_IMPORTED_MODULE_5__RobustDeterminant__["a" /* default */].signOfDet2x2(x1, y1, x2, y2);
if (xIntSign === 0.0) {
this._isPointOnSegment = true;
return null;
}
if (y2 < y1) xIntSign = -xIntSign;
if (xIntSign > 0.0) {
this._crossingCount++;
}
}
},
isPointInPolygon: function () {
return this.getLocation() !== __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
},
getLocation: function () {
if (this._isPointOnSegment) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].BOUNDARY;
if (this._crossingCount % 2 === 1) {
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
}
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
},
isOnSegment: function () {
return this._isPointOnSegment;
},
interfaces_: function () {
return [];
},
getClass: function () {
return RayCrossingCounter;
}
});
RayCrossingCounter.locatePointInRing = function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */] && Object(__WEBPACK_IMPORTED_MODULE_1__hasInterface__["a" /* default */])(arguments[1], __WEBPACK_IMPORTED_MODULE_4__geom_CoordinateSequence__["a" /* default */])) {
let p = arguments[0], ring = arguments[1];
var counter = new RayCrossingCounter(p);
var p1 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
var p2 = new __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */]();
for (var i = 1; i < ring.size(); i++) {
ring.getCoordinate(i, p1);
ring.getCoordinate(i - 1, p2);
counter.countSegment(p1, p2);
if (counter.isOnSegment()) return counter.getLocation();
}
return counter.getLocation();
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_2__geom_Coordinate__["a" /* default */] && arguments[1] instanceof Array) {
let p = arguments[0], ring = arguments[1];
var counter = new RayCrossingCounter(p);
for (var i = 1; i < ring.length; i++) {
var p1 = ring[i];
var p2 = ring[i - 1];
counter.countSegment(p1, p2);
if (counter.isOnSegment()) return counter.getLocation();
}
return counter.getLocation();
}
};
/***/ }),
/* 124 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = RobustDeterminant;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function RobustDeterminant() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(RobustDeterminant.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return RobustDeterminant;
}
});
RobustDeterminant.orientationIndex = function (p1, p2, q) {
var dx1 = p2.x - p1.x;
var dy1 = p2.y - p1.y;
var dx2 = q.x - p2.x;
var dy2 = q.y - p2.y;
return RobustDeterminant.signOfDet2x2(dx1, dy1, dx2, dy2);
};
RobustDeterminant.signOfDet2x2 = function (x1, y1, x2, y2) {
var sign = null;
var swap = null;
var k = null;
var count = 0;
sign = 1;
if (x1 === 0.0 || y2 === 0.0) {
if (y1 === 0.0 || x2 === 0.0) {
return 0;
} else if (y1 > 0) {
if (x2 > 0) {
return -sign;
} else {
return sign;
}
} else {
if (x2 > 0) {
return sign;
} else {
return -sign;
}
}
}
if (y1 === 0.0 || x2 === 0.0) {
if (y2 > 0) {
if (x1 > 0) {
return sign;
} else {
return -sign;
}
} else {
if (x1 > 0) {
return -sign;
} else {
return sign;
}
}
}
if (0.0 < y1) {
if (0.0 < y2) {
if (y1 <= y2) {
;
} else {
sign = -sign;
swap = x1;
x1 = x2;
x2 = swap;
swap = y1;
y1 = y2;
y2 = swap;
}
} else {
if (y1 <= -y2) {
sign = -sign;
x2 = -x2;
y2 = -y2;
} else {
swap = x1;
x1 = -x2;
x2 = swap;
swap = y1;
y1 = -y2;
y2 = swap;
}
}
} else {
if (0.0 < y2) {
if (-y1 <= y2) {
sign = -sign;
x1 = -x1;
y1 = -y1;
} else {
swap = -x1;
x1 = x2;
x2 = swap;
swap = -y1;
y1 = y2;
y2 = swap;
}
} else {
if (y1 >= y2) {
x1 = -x1;
y1 = -y1;
x2 = -x2;
y2 = -y2;
;
} else {
sign = -sign;
swap = -x1;
x1 = -x2;
x2 = swap;
swap = -y1;
y1 = -y2;
y2 = swap;
}
}
}
if (0.0 < x1) {
if (0.0 < x2) {
if (x1 <= x2) {
;
} else {
return sign;
}
} else {
return sign;
}
} else {
if (0.0 < x2) {
return -sign;
} else {
if (x1 >= x2) {
sign = -sign;
x1 = -x1;
x2 = -x2;
;
} else {
return -sign;
}
}
}
while (true) {
count = count + 1;
k = Math.floor(x2 / x1);
x2 = x2 - k * x1;
y2 = y2 - k * y1;
if (y2 < 0.0) {
return -sign;
}
if (y2 > y1) {
return sign;
}
if (x1 > x2 + x2) {
if (y1 < y2 + y2) {
return sign;
}
} else {
if (y1 > y2 + y2) {
return -sign;
} else {
x2 = x1 - x2;
y2 = y1 - y2;
sign = -sign;
}
}
if (y2 === 0.0) {
if (x2 === 0.0) {
return 0;
} else {
return -sign;
}
}
if (x2 === 0.0) {
return sign;
}
k = Math.floor(x1 / x2);
x1 = x1 - k * x2;
y1 = y1 - k * y2;
if (y1 < 0.0) {
return sign;
}
if (y1 > y2) {
return -sign;
}
if (x2 > x1 + x1) {
if (y2 < y1 + y1) {
return -sign;
}
} else {
if (y2 > y1 + y1) {
return sign;
} else {
x1 = x2 - x1;
y1 = y2 - y1;
sign = -sign;
}
}
if (y1 === 0.0) {
if (x1 === 0.0) {
return 0;
} else {
return sign;
}
}
if (x1 === 0.0) {
return -sign;
}
}
};
/***/ }),
/* 125 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = IntersectionMatrix;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Dimension__ = __webpack_require__(38);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_Cloneable__ = __webpack_require__(53);
function IntersectionMatrix() {
this._matrix = null;
if (arguments.length === 0) {
this._matrix = Array(3).fill().map(() => Array(3));
this.setAll(__WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE);
} else if (arguments.length === 1) {
if (typeof arguments[0] === "string") {
let elements = arguments[0];
IntersectionMatrix.call(this);
this.set(elements);
} else if (arguments[0] instanceof IntersectionMatrix) {
let other = arguments[0];
IntersectionMatrix.call(this);
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY];
this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] = other._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR];
}
}
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(IntersectionMatrix.prototype, {
isIntersects: function () {
return !this.isDisjoint();
},
isCovers: function () {
var hasPointInCommon = IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY]);
return hasPointInCommon && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE;
},
isCoveredBy: function () {
var hasPointInCommon = IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY]);
return hasPointInCommon && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE;
},
set: function () {
if (arguments.length === 1) {
let dimensionSymbols = arguments[0];
for (var i = 0; i < dimensionSymbols.length; i++) {
var row = Math.trunc(i / 3);
var col = i % 3;
this._matrix[row][col] = __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].toDimensionValue(dimensionSymbols.charAt(i));
}
} else if (arguments.length === 3) {
let row = arguments[0], column = arguments[1], dimensionValue = arguments[2];
this._matrix[row][column] = dimensionValue;
}
},
isContains: function () {
return IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE;
},
setAtLeast: function () {
if (arguments.length === 1) {
let minimumDimensionSymbols = arguments[0];
for (var i = 0; i < minimumDimensionSymbols.length; i++) {
var row = Math.trunc(i / 3);
var col = i % 3;
this.setAtLeast(row, col, __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].toDimensionValue(minimumDimensionSymbols.charAt(i)));
}
} else if (arguments.length === 3) {
let row = arguments[0], column = arguments[1], minimumDimensionValue = arguments[2];
if (this._matrix[row][column] < minimumDimensionValue) {
this._matrix[row][column] = minimumDimensionValue;
}
}
},
setAtLeastIfValid: function (row, column, minimumDimensionValue) {
if (row >= 0 && column >= 0) {
this.setAtLeast(row, column, minimumDimensionValue);
}
},
isWithin: function () {
return IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE;
},
isTouches: function (dimensionOfGeometryA, dimensionOfGeometryB) {
if (dimensionOfGeometryA > dimensionOfGeometryB) {
return this.isTouches(dimensionOfGeometryB, dimensionOfGeometryA);
}
if (dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L) {
return this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && (IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) || IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY]));
}
return false;
},
isOverlaps: function (dimensionOfGeometryA, dimensionOfGeometryB) {
if (dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A) {
return IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) && IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR]) && IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]);
}
if (dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L) {
return this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === 1 && IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR]) && IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]);
}
return false;
},
isEquals: function (dimensionOfGeometryA, dimensionOfGeometryB) {
if (dimensionOfGeometryA !== dimensionOfGeometryB) {
return false;
}
return IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE;
},
toString: function () {
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]("123456789");
for (var ai = 0; ai < 3; ai++) {
for (var bi = 0; bi < 3; bi++) {
buf.setCharAt(3 * ai + bi, __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].toDimensionSymbol(this._matrix[ai][bi]));
}
}
return buf.toString();
},
setAll: function (dimensionValue) {
for (var ai = 0; ai < 3; ai++) {
for (var bi = 0; bi < 3; bi++) {
this._matrix[ai][bi] = dimensionValue;
}
}
},
get: function (row, column) {
return this._matrix[row][column];
},
transpose: function () {
var temp = this._matrix[1][0];
this._matrix[1][0] = this._matrix[0][1];
this._matrix[0][1] = temp;
temp = this._matrix[2][0];
this._matrix[2][0] = this._matrix[0][2];
this._matrix[0][2] = temp;
temp = this._matrix[2][1];
this._matrix[2][1] = this._matrix[1][2];
this._matrix[1][2] = temp;
return this;
},
matches: function (requiredDimensionSymbols) {
if (requiredDimensionSymbols.length !== 9) {
throw new __WEBPACK_IMPORTED_MODULE_2__java_lang_IllegalArgumentException__["a" /* default */]("Should be length 9: " + requiredDimensionSymbols);
}
for (var ai = 0; ai < 3; ai++) {
for (var bi = 0; bi < 3; bi++) {
if (!IntersectionMatrix.matches(this._matrix[ai][bi], requiredDimensionSymbols.charAt(3 * ai + bi))) {
return false;
}
}
}
return true;
},
add: function (im) {
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 3; j++) {
this.setAtLeast(i, j, im.get(i, j));
}
}
},
isDisjoint: function () {
return this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE && this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].BOUNDARY] === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE;
},
isCrosses: function (dimensionOfGeometryA, dimensionOfGeometryB) {
if (dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A) {
return IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) && IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR]);
}
if (dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P || dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L) {
return IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]) && IntersectionMatrix.isTrue(this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].EXTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR]);
}
if (dimensionOfGeometryA === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L && dimensionOfGeometryB === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L) {
return this._matrix[__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR][__WEBPACK_IMPORTED_MODULE_1__Location__["a" /* default */].INTERIOR] === 0;
}
return false;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_5__java_lang_Cloneable__["a" /* default */]];
},
getClass: function () {
return IntersectionMatrix;
}
});
IntersectionMatrix.matches = function () {
if (Number.isInteger(arguments[0]) && typeof arguments[1] === "string") {
let actualDimensionValue = arguments[0], requiredDimensionSymbol = arguments[1];
if (requiredDimensionSymbol === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].SYM_DONTCARE) {
return true;
}
if (requiredDimensionSymbol === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].SYM_TRUE && (actualDimensionValue >= 0 || actualDimensionValue === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].TRUE)) {
return true;
}
if (requiredDimensionSymbol === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].SYM_FALSE && actualDimensionValue === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].FALSE) {
return true;
}
if (requiredDimensionSymbol === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].SYM_P && actualDimensionValue === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].P) {
return true;
}
if (requiredDimensionSymbol === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].SYM_L && actualDimensionValue === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].L) {
return true;
}
if (requiredDimensionSymbol === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].SYM_A && actualDimensionValue === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].A) {
return true;
}
return false;
} else if (typeof arguments[0] === "string" && typeof arguments[1] === "string") {
let actualDimensionSymbols = arguments[0], requiredDimensionSymbols = arguments[1];
var m = new IntersectionMatrix(actualDimensionSymbols);
return m.matches(requiredDimensionSymbols);
}
};
IntersectionMatrix.isTrue = function (actualDimensionValue) {
if (actualDimensionValue >= 0 || actualDimensionValue === __WEBPACK_IMPORTED_MODULE_4__Dimension__["a" /* default */].TRUE) {
return true;
}
return false;
};
/***/ }),
/* 126 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryCollectionIterator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_util_Iterator__ = __webpack_require__(49);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_util_NoSuchElementException__ = __webpack_require__(71);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__GeometryCollection__ = __webpack_require__(13);
function GeometryCollectionIterator() {
this._parent = null;
this._atStart = null;
this._max = null;
this._index = null;
this._subcollectionIterator = null;
let parent = arguments[0];
this._parent = parent;
this._atStart = true;
this._index = 0;
this._max = parent.getNumGeometries();
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(GeometryCollectionIterator.prototype, {
next: function () {
if (this._atStart) {
this._atStart = false;
if (GeometryCollectionIterator.isAtomic(this._parent)) this._index++;
return this._parent;
}
if (this._subcollectionIterator !== null) {
if (this._subcollectionIterator.hasNext()) {
return this._subcollectionIterator.next();
} else {
this._subcollectionIterator = null;
}
}
if (this._index >= this._max) {
throw new __WEBPACK_IMPORTED_MODULE_1__java_util_NoSuchElementException__["a" /* default */]();
}
var obj = this._parent.getGeometryN(this._index++);
if (obj instanceof __WEBPACK_IMPORTED_MODULE_3__GeometryCollection__["a" /* default */]) {
this._subcollectionIterator = new GeometryCollectionIterator(obj);
return this._subcollectionIterator.next();
}
return obj;
},
remove: function () {
throw new UnsupportedOperationException(this.getClass().getName());
},
hasNext: function () {
if (this._atStart) {
return true;
}
if (this._subcollectionIterator !== null) {
if (this._subcollectionIterator.hasNext()) {
return true;
}
this._subcollectionIterator = null;
}
if (this._index >= this._max) {
return false;
}
return true;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_0__java_util_Iterator__["a" /* default */]];
},
getClass: function () {
return GeometryCollectionIterator;
}
});
GeometryCollectionIterator.isAtomic = function (geom) {
return !(geom instanceof __WEBPACK_IMPORTED_MODULE_3__GeometryCollection__["a" /* default */]);
};
/***/ }),
/* 127 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Octant;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
function Octant() {}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(Octant.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return Octant;
}
});
Octant.octant = function () {
if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
let dx = arguments[0], dy = arguments[1];
if (dx === 0.0 && dy === 0.0) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Cannot compute the octant for point ( " + dx + ", " + dy + " )");
var adx = Math.abs(dx);
var ady = Math.abs(dy);
if (dx >= 0) {
if (dy >= 0) {
if (adx >= ady) return 0; else return 1;
} else {
if (adx >= ady) return 7; else return 6;
}
} else {
if (dy >= 0) {
if (adx >= ady) return 3; else return 2;
} else {
if (adx >= ady) return 4; else return 5;
}
}
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */] && arguments[1] instanceof __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */]) {
let p0 = arguments[0], p1 = arguments[1];
var dx = p1.x - p0.x;
var dy = p1.y - p0.y;
if (dx === 0.0 && dy === 0.0) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Cannot compute the octant for two identical points " + p0);
return Octant.octant(dx, dy);
}
};
/***/ }),
/* 128 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ItemBoundable;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Boundable__ = __webpack_require__(129);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_io_Serializable__ = __webpack_require__(21);
function ItemBoundable() {
this._bounds = null;
this._item = null;
let bounds = arguments[0], item = arguments[1];
this._bounds = bounds;
this._item = item;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(ItemBoundable.prototype, {
getItem: function () {
return this._item;
},
getBounds: function () {
return this._bounds;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_0__Boundable__["a" /* default */], __WEBPACK_IMPORTED_MODULE_2__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return ItemBoundable;
}
});
/***/ }),
/* 129 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Boundable;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function Boundable() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(Boundable.prototype, {
getBounds: function () {},
interfaces_: function () {
return [];
},
getClass: function () {
return Boundable;
}
});
/***/ }),
/* 130 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = SpatialIndex;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function SpatialIndex() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(SpatialIndex.prototype, {
insert: function (itemEnv, item) {},
remove: function (itemEnv, item) {},
query: function () {
if (arguments.length === 1) {
let searchEnv = arguments[0];
} else if (arguments.length === 2) {
let searchEnv = arguments[0], visitor = arguments[1];
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return SpatialIndex;
}
});
/***/ }),
/* 131 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MonotoneChainBuilder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__MonotoneChain__ = __webpack_require__(243);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Integer__ = __webpack_require__(55);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geomgraph_Quadrant__ = __webpack_require__(47);
function MonotoneChainBuilder() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(MonotoneChainBuilder.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return MonotoneChainBuilder;
}
});
MonotoneChainBuilder.getChainStartIndices = function (pts) {
var start = 0;
var startIndexList = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
startIndexList.add(new __WEBPACK_IMPORTED_MODULE_2__java_lang_Integer__["a" /* default */](start));
do {
var last = MonotoneChainBuilder.findChainEnd(pts, start);
startIndexList.add(new __WEBPACK_IMPORTED_MODULE_2__java_lang_Integer__["a" /* default */](last));
start = last;
} while (start < pts.length - 1);
var startIndex = MonotoneChainBuilder.toIntArray(startIndexList);
return startIndex;
};
MonotoneChainBuilder.findChainEnd = function (pts, start) {
var safeStart = start;
while (safeStart < pts.length - 1 && pts[safeStart].equals2D(pts[safeStart + 1])) {
safeStart++;
}
if (safeStart >= pts.length - 1) {
return pts.length - 1;
}
var chainQuad = __WEBPACK_IMPORTED_MODULE_4__geomgraph_Quadrant__["a" /* default */].quadrant(pts[safeStart], pts[safeStart + 1]);
var last = start + 1;
while (last < pts.length) {
if (!pts[last - 1].equals2D(pts[last])) {
var quad = __WEBPACK_IMPORTED_MODULE_4__geomgraph_Quadrant__["a" /* default */].quadrant(pts[last - 1], pts[last]);
if (quad !== chainQuad) break;
}
last++;
}
return last - 1;
};
MonotoneChainBuilder.getChains = function () {
if (arguments.length === 1) {
let pts = arguments[0];
return MonotoneChainBuilder.getChains(pts, null);
} else if (arguments.length === 2) {
let pts = arguments[0], context = arguments[1];
var mcList = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
var startIndex = MonotoneChainBuilder.getChainStartIndices(pts);
for (var i = 0; i < startIndex.length - 1; i++) {
var mc = new __WEBPACK_IMPORTED_MODULE_0__MonotoneChain__["a" /* default */](pts, startIndex[i], startIndex[i + 1], context);
mcList.add(mc);
}
return mcList;
}
};
MonotoneChainBuilder.toIntArray = function (list) {
var array = new Array(list.size()).fill(null);
for (var i = 0; i < array.length; i++) {
array[i] = list.get(i).intValue();
}
return array;
};
/***/ }),
/* 132 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PolygonBuilder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_TopologyException__ = __webpack_require__(43);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__MaximalEdgeRing__ = __webpack_require__(133);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geomgraph_PlanarGraph__ = __webpack_require__(64);
function PolygonBuilder() {
this._geometryFactory = null;
this._shellList = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
let geometryFactory = arguments[0];
this._geometryFactory = geometryFactory;
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(PolygonBuilder.prototype, {
sortShellsAndHoles: function (edgeRings, shellList, freeHoleList) {
for (var it = edgeRings.iterator(); it.hasNext(); ) {
var er = it.next();
if (er.isHole()) {
freeHoleList.add(er);
} else {
shellList.add(er);
}
}
},
computePolygons: function (shellList) {
var resultPolyList = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
for (var it = shellList.iterator(); it.hasNext(); ) {
var er = it.next();
var poly = er.toPolygon(this._geometryFactory);
resultPolyList.add(poly);
}
return resultPolyList;
},
placeFreeHoles: function (shellList, freeHoleList) {
for (var it = freeHoleList.iterator(); it.hasNext(); ) {
var hole = it.next();
if (hole.getShell() === null) {
var shell = this.findEdgeRingContaining(hole, shellList);
if (shell === null) throw new __WEBPACK_IMPORTED_MODULE_1__geom_TopologyException__["a" /* default */]("unable to assign hole to a shell", hole.getCoordinate(0));
hole.setShell(shell);
}
}
},
buildMinimalEdgeRings: function (maxEdgeRings, shellList, freeHoleList) {
var edgeRings = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
for (var it = maxEdgeRings.iterator(); it.hasNext(); ) {
var er = it.next();
if (er.getMaxNodeDegree() > 2) {
er.linkDirectedEdgesForMinimalEdgeRings();
var minEdgeRings = er.buildMinimalRings();
var shell = this.findShell(minEdgeRings);
if (shell !== null) {
this.placePolygonHoles(shell, minEdgeRings);
shellList.add(shell);
} else {
freeHoleList.addAll(minEdgeRings);
}
} else {
edgeRings.add(er);
}
}
return edgeRings;
},
containsPoint: function (p) {
for (var it = this._shellList.iterator(); it.hasNext(); ) {
var er = it.next();
if (er.containsPoint(p)) return true;
}
return false;
},
buildMaximalEdgeRings: function (dirEdges) {
var maxEdgeRings = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
for (var it = dirEdges.iterator(); it.hasNext(); ) {
var de = it.next();
if (de.isInResult() && de.getLabel().isArea()) {
if (de.getEdgeRing() === null) {
var er = new __WEBPACK_IMPORTED_MODULE_3__MaximalEdgeRing__["a" /* default */](de, this._geometryFactory);
maxEdgeRings.add(er);
er.setInResult();
}
}
}
return maxEdgeRings;
},
placePolygonHoles: function (shell, minEdgeRings) {
for (var it = minEdgeRings.iterator(); it.hasNext(); ) {
var er = it.next();
if (er.isHole()) {
er.setShell(shell);
}
}
},
getPolygons: function () {
var resultPolyList = this.computePolygons(this._shellList);
return resultPolyList;
},
findEdgeRingContaining: function (testEr, shellList) {
var testRing = testEr.getLinearRing();
var testEnv = testRing.getEnvelopeInternal();
var testPt = testRing.getCoordinateN(0);
var minShell = null;
var minEnv = null;
for (var it = shellList.iterator(); it.hasNext(); ) {
var tryShell = it.next();
var tryRing = tryShell.getLinearRing();
var tryEnv = tryRing.getEnvelopeInternal();
if (minShell !== null) minEnv = minShell.getLinearRing().getEnvelopeInternal();
var isContained = false;
if (tryEnv.contains(testEnv) && __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].isPointInRing(testPt, tryRing.getCoordinates())) isContained = true;
if (isContained) {
if (minShell === null || minEnv.contains(tryEnv)) {
minShell = tryShell;
}
}
}
return minShell;
},
findShell: function (minEdgeRings) {
var shellCount = 0;
var shell = null;
for (var it = minEdgeRings.iterator(); it.hasNext(); ) {
var er = it.next();
if (!er.isHole()) {
shell = er;
shellCount++;
}
}
__WEBPACK_IMPORTED_MODULE_5__util_Assert__["a" /* default */].isTrue(shellCount <= 1, "found two shells in MinimalEdgeRing list");
return shell;
},
add: function () {
if (arguments.length === 1) {
let graph = arguments[0];
this.add(graph.getEdgeEnds(), graph.getNodes());
} else if (arguments.length === 2) {
let dirEdges = arguments[0], nodes = arguments[1];
__WEBPACK_IMPORTED_MODULE_6__geomgraph_PlanarGraph__["a" /* default */].linkResultDirectedEdges(nodes);
var maxEdgeRings = this.buildMaximalEdgeRings(dirEdges);
var freeHoleList = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
var edgeRings = this.buildMinimalEdgeRings(maxEdgeRings, this._shellList, freeHoleList);
this.sortShellsAndHoles(edgeRings, this._shellList, freeHoleList);
this.placeFreeHoles(this._shellList, freeHoleList);
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return PolygonBuilder;
}
});
/***/ }),
/* 133 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MaximalEdgeRing;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__MinimalEdgeRing__ = __webpack_require__(247);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geomgraph_EdgeRing__ = __webpack_require__(134);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__inherits__ = __webpack_require__(3);
function MaximalEdgeRing() {
let start = arguments[0], geometryFactory = arguments[1];
__WEBPACK_IMPORTED_MODULE_2__geomgraph_EdgeRing__["a" /* default */].call(this, start, geometryFactory);
}
Object(__WEBPACK_IMPORTED_MODULE_4__inherits__["a" /* default */])(MaximalEdgeRing, __WEBPACK_IMPORTED_MODULE_2__geomgraph_EdgeRing__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(MaximalEdgeRing.prototype, {
buildMinimalRings: function () {
var minEdgeRings = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
var de = this._startDe;
do {
if (de.getMinEdgeRing() === null) {
var minEr = new __WEBPACK_IMPORTED_MODULE_0__MinimalEdgeRing__["a" /* default */](de, this._geometryFactory);
minEdgeRings.add(minEr);
}
de = de.getNext();
} while (de !== this._startDe);
return minEdgeRings;
},
setEdgeRing: function (de, er) {
de.setEdgeRing(er);
},
linkDirectedEdgesForMinimalEdgeRings: function () {
var de = this._startDe;
do {
var node = de.getNode();
node.getEdges().linkMinimalDirectedEdges(this);
de = de.getNext();
} while (de !== this._startDe);
},
getNext: function (de) {
return de.getNext();
},
interfaces_: function () {
return [];
},
getClass: function () {
return MaximalEdgeRing;
}
});
/***/ }),
/* 134 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = EdgeRing;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__ = __webpack_require__(43);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_Assert__ = __webpack_require__(4);
function EdgeRing() {
this._startDe = null;
this._maxNodeDegree = -1;
this._edges = new __WEBPACK_IMPORTED_MODULE_6__java_util_ArrayList__["a" /* default */]();
this._pts = new __WEBPACK_IMPORTED_MODULE_6__java_util_ArrayList__["a" /* default */]();
this._label = new __WEBPACK_IMPORTED_MODULE_5__Label__["a" /* default */](__WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE);
this._ring = null;
this._isHole = null;
this._shell = null;
this._holes = new __WEBPACK_IMPORTED_MODULE_6__java_util_ArrayList__["a" /* default */]();
this._geometryFactory = null;
let start = arguments[0], geometryFactory = arguments[1];
this._geometryFactory = geometryFactory;
this.computePoints(start);
this.computeRing();
}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(EdgeRing.prototype, {
computeRing: function () {
if (this._ring !== null) return null;
var coord = new Array(this._pts.size()).fill(null);
for (var i = 0; i < this._pts.size(); i++) {
coord[i] = this._pts.get(i);
}
this._ring = this._geometryFactory.createLinearRing(coord);
this._isHole = __WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].isCCW(this._ring.getCoordinates());
},
isIsolated: function () {
return this._label.getGeometryCount() === 1;
},
computePoints: function (start) {
this._startDe = start;
var de = start;
var isFirstEdge = true;
do {
if (de === null) throw new __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__["a" /* default */]("Found null DirectedEdge");
if (de.getEdgeRing() === this) throw new __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__["a" /* default */]("Directed Edge visited twice during ring-building at " + de.getCoordinate());
this._edges.add(de);
var label = de.getLabel();
__WEBPACK_IMPORTED_MODULE_7__util_Assert__["a" /* default */].isTrue(label.isArea());
this.mergeLabel(label);
this.addPoints(de.getEdge(), de.isForward(), isFirstEdge);
isFirstEdge = false;
this.setEdgeRing(de, this);
de = this.getNext(de);
} while (de !== this._startDe);
},
getLinearRing: function () {
return this._ring;
},
getCoordinate: function (i) {
return this._pts.get(i);
},
computeMaxNodeDegree: function () {
this._maxNodeDegree = 0;
var de = this._startDe;
do {
var node = de.getNode();
var degree = node.getEdges().getOutgoingDegree(this);
if (degree > this._maxNodeDegree) this._maxNodeDegree = degree;
de = this.getNext(de);
} while (de !== this._startDe);
this._maxNodeDegree *= 2;
},
addPoints: function (edge, isForward, isFirstEdge) {
var edgePts = edge.getCoordinates();
if (isForward) {
var startIndex = 1;
if (isFirstEdge) startIndex = 0;
for (var i = startIndex; i < edgePts.length; i++) {
this._pts.add(edgePts[i]);
}
} else {
var startIndex = edgePts.length - 2;
if (isFirstEdge) startIndex = edgePts.length - 1;
for (var i = startIndex; i >= 0; i--) {
this._pts.add(edgePts[i]);
}
}
},
isHole: function () {
return this._isHole;
},
setInResult: function () {
var de = this._startDe;
do {
de.getEdge().setInResult(true);
de = de.getNext();
} while (de !== this._startDe);
},
containsPoint: function (p) {
var shell = this.getLinearRing();
var env = shell.getEnvelopeInternal();
if (!env.contains(p)) return false;
if (!__WEBPACK_IMPORTED_MODULE_1__algorithm_CGAlgorithms__["a" /* default */].isPointInRing(p, shell.getCoordinates())) return false;
for (var i = this._holes.iterator(); i.hasNext(); ) {
var hole = i.next();
if (hole.containsPoint(p)) return false;
}
return true;
},
addHole: function (ring) {
this._holes.add(ring);
},
isShell: function () {
return this._shell === null;
},
getLabel: function () {
return this._label;
},
getEdges: function () {
return this._edges;
},
getMaxNodeDegree: function () {
if (this._maxNodeDegree < 0) this.computeMaxNodeDegree();
return this._maxNodeDegree;
},
getShell: function () {
return this._shell;
},
mergeLabel: function () {
if (arguments.length === 1) {
let deLabel = arguments[0];
this.mergeLabel(deLabel, 0);
this.mergeLabel(deLabel, 1);
} else if (arguments.length === 2) {
let deLabel = arguments[0], geomIndex = arguments[1];
var loc = deLabel.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].RIGHT);
if (loc === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE) return null;
if (this._label.getLocation(geomIndex) === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].NONE) {
this._label.setLocation(geomIndex, loc);
return null;
}
}
},
setShell: function (shell) {
this._shell = shell;
if (shell !== null) shell.addHole(this);
},
toPolygon: function (geometryFactory) {
var holeLR = new Array(this._holes.size()).fill(null);
for (var i = 0; i < this._holes.size(); i++) {
holeLR[i] = this._holes.get(i).getLinearRing();
}
var poly = geometryFactory.createPolygon(this.getLinearRing(), holeLR);
return poly;
},
interfaces_: function () {
return [];
},
getClass: function () {
return EdgeRing;
}
});
/***/ }),
/* 135 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GraphComponent;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_Assert__ = __webpack_require__(4);
function GraphComponent() {
this._label = null;
this._isInResult = false;
this._isCovered = false;
this._isCoveredSet = false;
this._isVisited = false;
if (arguments.length === 0) {} else if (arguments.length === 1) {
let label = arguments[0];
this._label = label;
}
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(GraphComponent.prototype, {
setVisited: function (isVisited) {
this._isVisited = isVisited;
},
setInResult: function (isInResult) {
this._isInResult = isInResult;
},
isCovered: function () {
return this._isCovered;
},
isCoveredSet: function () {
return this._isCoveredSet;
},
setLabel: function (label) {
this._label = label;
},
getLabel: function () {
return this._label;
},
setCovered: function (isCovered) {
this._isCovered = isCovered;
this._isCoveredSet = true;
},
updateIM: function (im) {
__WEBPACK_IMPORTED_MODULE_1__util_Assert__["a" /* default */].isTrue(this._label.getGeometryCount() >= 2, "found partial label");
this.computeIM(im);
},
isInResult: function () {
return this._isInResult;
},
isVisited: function () {
return this._isVisited;
},
interfaces_: function () {
return [];
},
getClass: function () {
return GraphComponent;
}
});
/***/ }),
/* 136 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = DirectedEdge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__EdgeEnd__ = __webpack_require__(99);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__ = __webpack_require__(43);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__inherits__ = __webpack_require__(3);
function DirectedEdge() {
this._isForward = null;
this._isInResult = false;
this._isVisited = false;
this._sym = null;
this._next = null;
this._nextMin = null;
this._edgeRing = null;
this._minEdgeRing = null;
this._depth = [0, -999, -999];
let edge = arguments[0], isForward = arguments[1];
__WEBPACK_IMPORTED_MODULE_1__EdgeEnd__["a" /* default */].call(this, edge);
this._isForward = isForward;
if (isForward) {
this.init(edge.getCoordinate(0), edge.getCoordinate(1));
} else {
var n = edge.getNumPoints() - 1;
this.init(edge.getCoordinate(n), edge.getCoordinate(n - 1));
}
this.computeDirectedLabel();
}
Object(__WEBPACK_IMPORTED_MODULE_6__inherits__["a" /* default */])(DirectedEdge, __WEBPACK_IMPORTED_MODULE_1__EdgeEnd__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(DirectedEdge.prototype, {
getNextMin: function () {
return this._nextMin;
},
getDepth: function (position) {
return this._depth[position];
},
setVisited: function (isVisited) {
this._isVisited = isVisited;
},
computeDirectedLabel: function () {
this._label = new __WEBPACK_IMPORTED_MODULE_5__Label__["a" /* default */](this._edge.getLabel());
if (!this._isForward) this._label.flip();
},
getNext: function () {
return this._next;
},
setDepth: function (position, depthVal) {
if (this._depth[position] !== -999) {
if (this._depth[position] !== depthVal) throw new __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__["a" /* default */]("assigned depths do not match", this.getCoordinate());
}
this._depth[position] = depthVal;
},
isInteriorAreaEdge: function () {
var isInteriorAreaEdge = true;
for (var i = 0; i < 2; i++) {
if (!(this._label.isArea(i) && this._label.getLocation(i, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT) === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR && this._label.getLocation(i, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].RIGHT) === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR)) {
isInteriorAreaEdge = false;
}
}
return isInteriorAreaEdge;
},
setNextMin: function (nextMin) {
this._nextMin = nextMin;
},
print: function (out) {
__WEBPACK_IMPORTED_MODULE_1__EdgeEnd__["a" /* default */].prototype.print.call(this, out);
out.print(" " + this._depth[__WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT] + "/" + this._depth[__WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].RIGHT]);
out.print(" (" + this.getDepthDelta() + ")");
if (this._isInResult) out.print(" inResult");
},
setMinEdgeRing: function (minEdgeRing) {
this._minEdgeRing = minEdgeRing;
},
isLineEdge: function () {
var isLine = this._label.isLine(0) || this._label.isLine(1);
var isExteriorIfArea0 = !this._label.isArea(0) || this._label.allPositionsEqual(0, __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR);
var isExteriorIfArea1 = !this._label.isArea(1) || this._label.allPositionsEqual(1, __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR);
return isLine && isExteriorIfArea0 && isExteriorIfArea1;
},
setEdgeRing: function (edgeRing) {
this._edgeRing = edgeRing;
},
getMinEdgeRing: function () {
return this._minEdgeRing;
},
getDepthDelta: function () {
var depthDelta = this._edge.getDepthDelta();
if (!this._isForward) depthDelta = -depthDelta;
return depthDelta;
},
setInResult: function (isInResult) {
this._isInResult = isInResult;
},
getSym: function () {
return this._sym;
},
isForward: function () {
return this._isForward;
},
getEdge: function () {
return this._edge;
},
printEdge: function (out) {
this.print(out);
out.print(" ");
if (this._isForward) this._edge.print(out); else this._edge.printReverse(out);
},
setSym: function (de) {
this._sym = de;
},
setVisitedEdge: function (isVisited) {
this.setVisited(isVisited);
this._sym.setVisited(isVisited);
},
setEdgeDepths: function (position, depth) {
var depthDelta = this.getEdge().getDepthDelta();
if (!this._isForward) depthDelta = -depthDelta;
var directionFactor = 1;
if (position === __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT) directionFactor = -1;
var oppositePos = __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].opposite(position);
var delta = depthDelta * directionFactor;
var oppositeDepth = depth + delta;
this.setDepth(position, depth);
this.setDepth(oppositePos, oppositeDepth);
},
getEdgeRing: function () {
return this._edgeRing;
},
isInResult: function () {
return this._isInResult;
},
setNext: function (next) {
this._next = next;
},
isVisited: function () {
return this._isVisited;
},
interfaces_: function () {
return [];
},
getClass: function () {
return DirectedEdge;
}
});
DirectedEdge.depthFactor = function (currLocation, nextLocation) {
if (currLocation === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR && nextLocation === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR) return 1; else if (currLocation === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR && nextLocation === __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR) return -1;
return 0;
};
/***/ }),
/* 137 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = EdgeEndStar;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__ = __webpack_require__(34);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Position__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__ = __webpack_require__(43);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__algorithm_locate_SimplePointInAreaLocator__ = __webpack_require__(138);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__java_util_TreeMap__ = __webpack_require__(35);
function EdgeEndStar() {
this._edgeMap = new __WEBPACK_IMPORTED_MODULE_9__java_util_TreeMap__["a" /* default */]();
this._edgeList = null;
this._ptInAreaLocation = [__WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE];
}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(EdgeEndStar.prototype, {
getNextCW: function (ee) {
this.getEdges();
var i = this._edgeList.indexOf(ee);
var iNextCW = i - 1;
if (i === 0) iNextCW = this._edgeList.size() - 1;
return this._edgeList.get(iNextCW);
},
propagateSideLabels: function (geomIndex) {
var startLoc = __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE;
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
var label = e.getLabel();
if (label.isArea(geomIndex) && label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT) !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE) startLoc = label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT);
}
if (startLoc === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE) return null;
var currLoc = startLoc;
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
var label = e.getLabel();
if (label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].ON) === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE) label.setLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].ON, currLoc);
if (label.isArea(geomIndex)) {
var leftLoc = label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT);
var rightLoc = label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].RIGHT);
if (rightLoc !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE) {
if (rightLoc !== currLoc) throw new __WEBPACK_IMPORTED_MODULE_3__geom_TopologyException__["a" /* default */]("side location conflict", e.getCoordinate());
if (leftLoc === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE) {
__WEBPACK_IMPORTED_MODULE_8__util_Assert__["a" /* default */].shouldNeverReachHere("found single null side (at " + e.getCoordinate() + ")");
}
currLoc = leftLoc;
} else {
__WEBPACK_IMPORTED_MODULE_8__util_Assert__["a" /* default */].isTrue(label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT) === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, "found single null side");
label.setLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].RIGHT, currLoc);
label.setLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT, currLoc);
}
}
}
},
getCoordinate: function () {
var it = this.iterator();
if (!it.hasNext()) return null;
var e = it.next();
return e.getCoordinate();
},
print: function (out) {
__WEBPACK_IMPORTED_MODULE_5__java_lang_System__["a" /* default */].out.println("EdgeEndStar: " + this.getCoordinate());
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
e.print(out);
}
},
isAreaLabelsConsistent: function (geomGraph) {
this.computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
return this.checkAreaLabelsConsistent(0);
},
checkAreaLabelsConsistent: function (geomIndex) {
var edges = this.getEdges();
if (edges.size() <= 0) return true;
var lastEdgeIndex = edges.size() - 1;
var startLabel = edges.get(lastEdgeIndex).getLabel();
var startLoc = startLabel.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT);
__WEBPACK_IMPORTED_MODULE_8__util_Assert__["a" /* default */].isTrue(startLoc !== __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE, "Found unlabelled area edge");
var currLoc = startLoc;
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
var label = e.getLabel();
__WEBPACK_IMPORTED_MODULE_8__util_Assert__["a" /* default */].isTrue(label.isArea(geomIndex), "Found non-area edge");
var leftLoc = label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].LEFT);
var rightLoc = label.getLocation(geomIndex, __WEBPACK_IMPORTED_MODULE_2__Position__["a" /* default */].RIGHT);
if (leftLoc === rightLoc) {
return false;
}
if (rightLoc !== currLoc) {
return false;
}
currLoc = leftLoc;
}
return true;
},
findIndex: function (eSearch) {
this.iterator();
for (var i = 0; i < this._edgeList.size(); i++) {
var e = this._edgeList.get(i);
if (e === eSearch) return i;
}
return -1;
},
iterator: function () {
return this.getEdges().iterator();
},
getEdges: function () {
if (this._edgeList === null) {
this._edgeList = new __WEBPACK_IMPORTED_MODULE_7__java_util_ArrayList__["a" /* default */](this._edgeMap.values());
}
return this._edgeList;
},
getLocation: function (geomIndex, p, geom) {
if (this._ptInAreaLocation[geomIndex] === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE) {
this._ptInAreaLocation[geomIndex] = __WEBPACK_IMPORTED_MODULE_6__algorithm_locate_SimplePointInAreaLocator__["a" /* default */].locate(p, geom[geomIndex].getGeometry());
}
return this._ptInAreaLocation[geomIndex];
},
toString: function () {
var buf = new __WEBPACK_IMPORTED_MODULE_0__java_lang_StringBuffer__["a" /* default */]();
buf.append("EdgeEndStar: " + this.getCoordinate());
buf.append("\n");
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
buf.append(e);
buf.append("\n");
}
return buf.toString();
},
computeEdgeEndLabels: function (boundaryNodeRule) {
for (var it = this.iterator(); it.hasNext(); ) {
var ee = it.next();
ee.computeLabel(boundaryNodeRule);
}
},
computeLabelling: function (geomGraph) {
this.computeEdgeEndLabels(geomGraph[0].getBoundaryNodeRule());
this.propagateSideLabels(0);
this.propagateSideLabels(1);
var hasDimensionalCollapseEdge = [false, false];
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
var label = e.getLabel();
for (var geomi = 0; geomi < 2; geomi++) {
if (label.isLine(geomi) && label.getLocation(geomi) === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].BOUNDARY) hasDimensionalCollapseEdge[geomi] = true;
}
}
for (var it = this.iterator(); it.hasNext(); ) {
var e = it.next();
var label = e.getLabel();
for (var geomi = 0; geomi < 2; geomi++) {
if (label.isAnyNull(geomi)) {
var loc = __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].NONE;
if (hasDimensionalCollapseEdge[geomi]) {
loc = __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].EXTERIOR;
} else {
var p = e.getCoordinate();
loc = this.getLocation(geomi, p, geomGraph);
}
label.setAllLocationsIfNull(geomi, loc);
}
}
}
},
getDegree: function () {
return this._edgeMap.size();
},
insertEdgeEnd: function (e, obj) {
this._edgeMap.put(e, obj);
this._edgeList = null;
},
interfaces_: function () {
return [];
},
getClass: function () {
return EdgeEndStar;
}
});
/***/ }),
/* 138 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = SimplePointInAreaLocator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__PointOnGeometryLocator__ = __webpack_require__(139);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_GeometryCollectionIterator__ = __webpack_require__(126);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_GeometryCollection__ = __webpack_require__(13);
function SimplePointInAreaLocator() {
this._geom = null;
let geom = arguments[0];
this._geom = geom;
}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(SimplePointInAreaLocator.prototype, {
locate: function (p) {
return SimplePointInAreaLocator.locate(p, this._geom);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_3__PointOnGeometryLocator__["a" /* default */]];
},
getClass: function () {
return SimplePointInAreaLocator;
}
});
SimplePointInAreaLocator.isPointInRing = function (p, ring) {
if (!ring.getEnvelopeInternal().intersects(p)) return false;
return __WEBPACK_IMPORTED_MODULE_1__CGAlgorithms__["a" /* default */].isPointInRing(p, ring.getCoordinates());
};
SimplePointInAreaLocator.containsPointInPolygon = function (p, poly) {
if (poly.isEmpty()) return false;
var shell = poly.getExteriorRing();
if (!SimplePointInAreaLocator.isPointInRing(p, shell)) return false;
for (var i = 0; i < poly.getNumInteriorRing(); i++) {
var hole = poly.getInteriorRingN(i);
if (SimplePointInAreaLocator.isPointInRing(p, hole)) return false;
}
return true;
};
SimplePointInAreaLocator.containsPoint = function (p, geom) {
if (geom instanceof __WEBPACK_IMPORTED_MODULE_2__geom_Polygon__["a" /* default */]) {
return SimplePointInAreaLocator.containsPointInPolygon(p, geom);
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_6__geom_GeometryCollection__["a" /* default */]) {
var geomi = new __WEBPACK_IMPORTED_MODULE_5__geom_GeometryCollectionIterator__["a" /* default */](geom);
while (geomi.hasNext()) {
var g2 = geomi.next();
if (g2 !== geom) if (SimplePointInAreaLocator.containsPoint(p, g2)) return true;
}
}
return false;
};
SimplePointInAreaLocator.locate = function (p, geom) {
if (geom.isEmpty()) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
if (SimplePointInAreaLocator.containsPoint(p, geom)) return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].INTERIOR;
return __WEBPACK_IMPORTED_MODULE_0__geom_Location__["a" /* default */].EXTERIOR;
};
/***/ }),
/* 139 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PointOnGeometryLocator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function PointOnGeometryLocator() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(PointOnGeometryLocator.prototype, {
locate: function (p) {},
interfaces_: function () {
return [];
},
getClass: function () {
return PointOnGeometryLocator;
}
});
/***/ }),
/* 140 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = SegmentIntersector;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function SegmentIntersector() {
this._hasIntersection = false;
this._hasProper = false;
this._hasProperInterior = false;
this._properIntersectionPoint = null;
this._li = null;
this._includeProper = null;
this._recordIsolated = null;
this._isSelfIntersection = null;
this._numIntersections = 0;
this.numTests = 0;
this._bdyNodes = null;
this._isDone = false;
this._isDoneWhenProperInt = false;
let li = arguments[0], includeProper = arguments[1], recordIsolated = arguments[2];
this._li = li;
this._includeProper = includeProper;
this._recordIsolated = recordIsolated;
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(SegmentIntersector.prototype, {
isTrivialIntersection: function (e0, segIndex0, e1, segIndex1) {
if (e0 === e1) {
if (this._li.getIntersectionNum() === 1) {
if (SegmentIntersector.isAdjacentSegments(segIndex0, segIndex1)) return true;
if (e0.isClosed()) {
var maxSegIndex = e0.getNumPoints() - 1;
if (segIndex0 === 0 && segIndex1 === maxSegIndex || segIndex1 === 0 && segIndex0 === maxSegIndex) {
return true;
}
}
}
}
return false;
},
getProperIntersectionPoint: function () {
return this._properIntersectionPoint;
},
setIsDoneIfProperInt: function (isDoneWhenProperInt) {
this._isDoneWhenProperInt = isDoneWhenProperInt;
},
hasProperInteriorIntersection: function () {
return this._hasProperInterior;
},
isBoundaryPointInternal: function (li, bdyNodes) {
for (var i = bdyNodes.iterator(); i.hasNext(); ) {
var node = i.next();
var pt = node.getCoordinate();
if (li.isIntersection(pt)) return true;
}
return false;
},
hasProperIntersection: function () {
return this._hasProper;
},
hasIntersection: function () {
return this._hasIntersection;
},
isDone: function () {
return this._isDone;
},
isBoundaryPoint: function (li, bdyNodes) {
if (bdyNodes === null) return false;
if (this.isBoundaryPointInternal(li, bdyNodes[0])) return true;
if (this.isBoundaryPointInternal(li, bdyNodes[1])) return true;
return false;
},
setBoundaryNodes: function (bdyNodes0, bdyNodes1) {
this._bdyNodes = new Array(2).fill(null);
this._bdyNodes[0] = bdyNodes0;
this._bdyNodes[1] = bdyNodes1;
},
addIntersections: function (e0, segIndex0, e1, segIndex1) {
if (e0 === e1 && segIndex0 === segIndex1) return null;
this.numTests++;
var p00 = e0.getCoordinates()[segIndex0];
var p01 = e0.getCoordinates()[segIndex0 + 1];
var p10 = e1.getCoordinates()[segIndex1];
var p11 = e1.getCoordinates()[segIndex1 + 1];
this._li.computeIntersection(p00, p01, p10, p11);
if (this._li.hasIntersection()) {
if (this._recordIsolated) {
e0.setIsolated(false);
e1.setIsolated(false);
}
this._numIntersections++;
if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
this._hasIntersection = true;
if (this._includeProper || !this._li.isProper()) {
e0.addIntersections(this._li, segIndex0, 0);
e1.addIntersections(this._li, segIndex1, 1);
}
if (this._li.isProper()) {
this._properIntersectionPoint = this._li.getIntersection(0).copy();
this._hasProper = true;
if (this._isDoneWhenProperInt) {
this._isDone = true;
}
if (!this.isBoundaryPoint(this._li, this._bdyNodes)) this._hasProperInterior = true;
}
}
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return SegmentIntersector;
}
});
SegmentIntersector.isAdjacentSegments = function (i1, i2) {
return Math.abs(i1 - i2) === 1;
};
/***/ }),
/* 141 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = IntervalRTreeNode;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__io_WKTWriter__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_Comparator__ = __webpack_require__(48);
function IntervalRTreeNode() {
this._min = __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].POSITIVE_INFINITY;
this._max = __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].NEGATIVE_INFINITY;
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(IntervalRTreeNode.prototype, {
getMin: function () {
return this._min;
},
intersects: function (queryMin, queryMax) {
if (this._min > queryMax || this._max < queryMin) return false;
return true;
},
getMax: function () {
return this._max;
},
toString: function () {
return __WEBPACK_IMPORTED_MODULE_0__io_WKTWriter__["a" /* default */].toLineString(new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */](this._min, 0), new __WEBPACK_IMPORTED_MODULE_1__geom_Coordinate__["a" /* default */](this._max, 0));
},
interfaces_: function () {
return [];
},
getClass: function () {
return IntervalRTreeNode;
}
});
function NodeComparator() {}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(NodeComparator.prototype, {
compare: function (o1, o2) {
var n1 = o1;
var n2 = o2;
var mid1 = (n1._min + n1._max) / 2;
var mid2 = (n2._min + n2._max) / 2;
if (mid1 < mid2) return -1;
if (mid1 > mid2) return 1;
return 0;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_4__java_util_Comparator__["a" /* default */]];
},
getClass: function () {
return NodeComparator;
}
});
IntervalRTreeNode.NodeComparator = NodeComparator;
/***/ }),
/* 142 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ArrayListVisitor;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ItemVisitor__ = __webpack_require__(52);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__ = __webpack_require__(1);
function ArrayListVisitor() {
this._items = new __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(ArrayListVisitor.prototype, {
visitItem: function (item) {
this._items.add(item);
},
getItems: function () {
return this._items;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_0__ItemVisitor__["a" /* default */]];
},
getClass: function () {
return ArrayListVisitor;
}
});
/***/ }),
/* 143 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = EdgeList;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__noding_OrientedCoordinateArray__ = __webpack_require__(265);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_TreeMap__ = __webpack_require__(35);
function EdgeList() {
this._edges = new __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */]();
this._ocaMap = new __WEBPACK_IMPORTED_MODULE_3__java_util_TreeMap__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(EdgeList.prototype, {
print: function (out) {
out.print("MULTILINESTRING ( ");
for (var j = 0; j < this._edges.size(); j++) {
var e = this._edges.get(j);
if (j > 0) out.print(",");
out.print("(");
var pts = e.getCoordinates();
for (var i = 0; i < pts.length; i++) {
if (i > 0) out.print(",");
out.print(pts[i].x + " " + pts[i].y);
}
out.println(")");
}
out.print(") ");
},
addAll: function (edgeColl) {
for (var i = edgeColl.iterator(); i.hasNext(); ) {
this.add(i.next());
}
},
findEdgeIndex: function (e) {
for (var i = 0; i < this._edges.size(); i++) {
if (this._edges.get(i).equals(e)) return i;
}
return -1;
},
iterator: function () {
return this._edges.iterator();
},
getEdges: function () {
return this._edges;
},
get: function (i) {
return this._edges.get(i);
},
findEqualEdge: function (e) {
var oca = new __WEBPACK_IMPORTED_MODULE_0__noding_OrientedCoordinateArray__["a" /* default */](e.getCoordinates());
var matchEdge = this._ocaMap.get(oca);
return matchEdge;
},
add: function (e) {
this._edges.add(e);
var oca = new __WEBPACK_IMPORTED_MODULE_0__noding_OrientedCoordinateArray__["a" /* default */](e.getCoordinates());
this._ocaMap.put(oca, e);
},
interfaces_: function () {
return [];
},
getClass: function () {
return EdgeList;
}
});
/***/ }),
/* 144 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MCPointInRing;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_chain_MonotoneChainSelectAction__ = __webpack_require__(145);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index_bintree_Bintree__ = __webpack_require__(268);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__index_bintree_Interval__ = __webpack_require__(78);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__index_chain_MonotoneChainBuilder__ = __webpack_require__(131);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__RobustDeterminant__ = __webpack_require__(124);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__PointInRing__ = __webpack_require__(272);
function MCPointInRing() {
this._ring = null;
this._tree = null;
this._crossings = 0;
this._interval = new __WEBPACK_IMPORTED_MODULE_2__index_bintree_Interval__["a" /* default */]();
let ring = arguments[0];
this._ring = ring;
this.buildIndex();
}
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(MCPointInRing.prototype, {
testLineSegment: function (p, seg) {
var xInt = null;
var x1 = null;
var y1 = null;
var x2 = null;
var y2 = null;
var p1 = seg.p0;
var p2 = seg.p1;
x1 = p1.x - p.x;
y1 = p1.y - p.y;
x2 = p2.x - p.x;
y2 = p2.y - p.y;
if (y1 > 0 && y2 <= 0 || y2 > 0 && y1 <= 0) {
xInt = __WEBPACK_IMPORTED_MODULE_7__RobustDeterminant__["a" /* default */].signOfDet2x2(x1, y1, x2, y2) / (y2 - y1);
if (0.0 < xInt) {
this._crossings++;
}
}
},
buildIndex: function () {
this._tree = new __WEBPACK_IMPORTED_MODULE_1__index_bintree_Bintree__["a" /* default */]();
var pts = __WEBPACK_IMPORTED_MODULE_6__geom_CoordinateArrays__["a" /* default */].removeRepeatedPoints(this._ring.getCoordinates());
var mcList = __WEBPACK_IMPORTED_MODULE_5__index_chain_MonotoneChainBuilder__["a" /* default */].getChains(pts);
for (var i = 0; i < mcList.size(); i++) {
var mc = mcList.get(i);
var mcEnv = mc.getEnvelope();
this._interval.min = mcEnv.getMinY();
this._interval.max = mcEnv.getMaxY();
this._tree.insert(this._interval, mc);
}
},
testMonotoneChain: function (rayEnv, mcSelecter, mc) {
mc.select(rayEnv, mcSelecter);
},
isInside: function (pt) {
this._crossings = 0;
var rayEnv = new __WEBPACK_IMPORTED_MODULE_8__geom_Envelope__["a" /* default */](__WEBPACK_IMPORTED_MODULE_3__java_lang_Double__["a" /* default */].NEGATIVE_INFINITY, __WEBPACK_IMPORTED_MODULE_3__java_lang_Double__["a" /* default */].POSITIVE_INFINITY, pt.y, pt.y);
this._interval.min = pt.y;
this._interval.max = pt.y;
var segs = this._tree.query(this._interval);
var mcSelecter = new MCSelecter(this, pt);
for (var i = segs.iterator(); i.hasNext(); ) {
var mc = i.next();
this.testMonotoneChain(rayEnv, mcSelecter, mc);
}
if (this._crossings % 2 === 1) {
return true;
}
return false;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_10__PointInRing__["a" /* default */]];
},
getClass: function () {
return MCPointInRing;
}
});
function MCSelecter() {
__WEBPACK_IMPORTED_MODULE_0__index_chain_MonotoneChainSelectAction__["a" /* default */].apply(this);
this.mcp = null;
this.p = null;
let mcp = arguments[0], p = arguments[1];
this.mcp = mcp;
this.p = p;
}
Object(__WEBPACK_IMPORTED_MODULE_9__inherits__["a" /* default */])(MCSelecter, __WEBPACK_IMPORTED_MODULE_0__index_chain_MonotoneChainSelectAction__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_4__extend__["a" /* default */])(MCSelecter.prototype, {
select: function () {
if (arguments.length === 1) {
let ls = arguments[0];
this.mcp.testLineSegment(this.p, ls);
} else return __WEBPACK_IMPORTED_MODULE_0__index_chain_MonotoneChainSelectAction__["a" /* default */].prototype.select.apply(this, arguments);
},
interfaces_: function () {
return [];
},
getClass: function () {
return MCSelecter;
}
});
MCPointInRing.MCSelecter = MCSelecter;
/***/ }),
/* 145 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MonotoneChainSelectAction;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_LineSegment__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Envelope__ = __webpack_require__(7);
function MonotoneChainSelectAction() {
this.tempEnv1 = new __WEBPACK_IMPORTED_MODULE_2__geom_Envelope__["a" /* default */]();
this.selectedSegment = new __WEBPACK_IMPORTED_MODULE_1__geom_LineSegment__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(MonotoneChainSelectAction.prototype, {
select: function () {
if (arguments.length === 1) {
let seg = arguments[0];
} else if (arguments.length === 2) {
let mc = arguments[0], startIndex = arguments[1];
mc.getLineSegment(startIndex, this.selectedSegment);
this.select(this.selectedSegment);
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return MonotoneChainSelectAction;
}
});
/***/ }),
/* 146 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NodeBase;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__ = __webpack_require__(1);
function NodeBase() {
this._items = new __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__["a" /* default */]();
this._subnode = [null, null];
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(NodeBase.prototype, {
hasChildren: function () {
for (var i = 0; i < 2; i++) {
if (this._subnode[i] !== null) return true;
}
return false;
},
isPrunable: function () {
return !(this.hasChildren() || this.hasItems());
},
addAllItems: function (items) {
items.addAll(this._items);
for (var i = 0; i < 2; i++) {
if (this._subnode[i] !== null) {
this._subnode[i].addAllItems(items);
}
}
return items;
},
size: function () {
var subSize = 0;
for (var i = 0; i < 2; i++) {
if (this._subnode[i] !== null) {
subSize += this._subnode[i].size();
}
}
return subSize + this._items.size();
},
addAllItemsFromOverlapping: function (interval, resultItems) {
if (interval !== null && !this.isSearchMatch(interval)) return null;
resultItems.addAll(this._items);
if (this._subnode[0] !== null) this._subnode[0].addAllItemsFromOverlapping(interval, resultItems);
if (this._subnode[1] !== null) this._subnode[1].addAllItemsFromOverlapping(interval, resultItems);
},
hasItems: function () {
return !this._items.isEmpty();
},
remove: function (itemInterval, item) {
if (!this.isSearchMatch(itemInterval)) return false;
var found = false;
for (var i = 0; i < 2; i++) {
if (this._subnode[i] !== null) {
found = this._subnode[i].remove(itemInterval, item);
if (found) {
if (this._subnode[i].isPrunable()) this._subnode[i] = null;
break;
}
}
}
if (found) return found;
found = this._items.remove(item);
return found;
},
getItems: function () {
return this._items;
},
depth: function () {
var maxSubDepth = 0;
for (var i = 0; i < 2; i++) {
if (this._subnode[i] !== null) {
var sqd = this._subnode[i].depth();
if (sqd > maxSubDepth) maxSubDepth = sqd;
}
}
return maxSubDepth + 1;
},
nodeSize: function () {
var subSize = 0;
for (var i = 0; i < 2; i++) {
if (this._subnode[i] !== null) {
subSize += this._subnode[i].nodeSize();
}
}
return subSize + 1;
},
add: function (item) {
this._items.add(item);
},
interfaces_: function () {
return [];
},
getClass: function () {
return NodeBase;
}
});
NodeBase.getSubnodeIndex = function (interval, centre) {
var subnodeIndex = -1;
if (interval.min >= centre) subnodeIndex = 1;
if (interval.max <= centre) subnodeIndex = 0;
return subnodeIndex;
};
/***/ }),
/* 147 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = IntervalSize;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__DoubleBits__ = __webpack_require__(103);
function IntervalSize() {}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(IntervalSize.prototype, {
interfaces_: function () {
return [];
},
getClass: function () {
return IntervalSize;
}
});
IntervalSize.isZeroWidth = function (min, max) {
var width = max - min;
if (width === 0.0) return true;
var maxAbs = Math.max(Math.abs(min), Math.abs(max));
var scaledInterval = width / maxAbs;
var level = __WEBPACK_IMPORTED_MODULE_1__DoubleBits__["a" /* default */].exponent(scaledInterval);
return level <= IntervalSize.MIN_BINARY_EXPONENT;
};
IntervalSize.MIN_BINARY_EXPONENT = -50;
/***/ }),
/* 148 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = MarkHalfEdge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__HalfEdge__ = __webpack_require__(149);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__inherits__ = __webpack_require__(3);
function MarkHalfEdge() {
this._isMarked = false;
let orig = arguments[0];
__WEBPACK_IMPORTED_MODULE_1__HalfEdge__["a" /* default */].call(this, orig);
}
Object(__WEBPACK_IMPORTED_MODULE_2__inherits__["a" /* default */])(MarkHalfEdge, __WEBPACK_IMPORTED_MODULE_1__HalfEdge__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(MarkHalfEdge.prototype, {
mark: function () {
this._isMarked = true;
},
setMark: function (isMarked) {
this._isMarked = isMarked;
},
isMarked: function () {
return this._isMarked;
},
interfaces_: function () {
return [];
},
getClass: function () {
return MarkHalfEdge;
}
});
MarkHalfEdge.setMarkBoth = function (e, isMarked) {
e.setMark(isMarked);
e.sym().setMark(isMarked);
};
MarkHalfEdge.isMarked = function (e) {
return e.isMarked();
};
MarkHalfEdge.setMark = function (e, isMarked) {
e.setMark(isMarked);
};
MarkHalfEdge.markBoth = function (e) {
e.mark();
e.sym().mark();
};
MarkHalfEdge.mark = function (e) {
e.mark();
};
/***/ }),
/* 149 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = HalfEdge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geomgraph_Quadrant__ = __webpack_require__(47);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_Assert__ = __webpack_require__(4);
function HalfEdge() {
this._orig = null;
this._sym = null;
this._next = null;
let orig = arguments[0];
this._orig = orig;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(HalfEdge.prototype, {
find: function (dest) {
var oNext = this;
do {
if (oNext === null) return null;
if (oNext.dest().equals2D(dest)) return oNext;
oNext = oNext.oNext();
} while (oNext !== this);
return null;
},
dest: function () {
return this._sym._orig;
},
oNext: function () {
return this._sym._next;
},
insert: function (e) {
if (this.oNext() === this) {
this.insertAfter(e);
return null;
}
var ecmp = this.compareTo(e);
var ePrev = this;
do {
var oNext = ePrev.oNext();
var cmp = oNext.compareTo(e);
if (cmp !== ecmp || oNext === this) {
ePrev.insertAfter(e);
return null;
}
ePrev = oNext;
} while (ePrev !== this);
__WEBPACK_IMPORTED_MODULE_3__util_Assert__["a" /* default */].shouldNeverReachHere();
},
insertAfter: function (e) {
__WEBPACK_IMPORTED_MODULE_3__util_Assert__["a" /* default */].equals(this._orig, e.orig());
var save = this.oNext();
this._sym.setNext(e);
e.sym().setNext(save);
},
degree: function () {
var degree = 0;
var e = this;
do {
degree++;
e = e.oNext();
} while (e !== this);
return degree;
},
equals: function () {
if (arguments.length === 2) {
let p0 = arguments[0], p1 = arguments[1];
return this._orig.equals2D(p0) && this._sym._orig.equals(p1);
}
},
deltaY: function () {
return this._sym._orig.y - this._orig.y;
},
sym: function () {
return this._sym;
},
prev: function () {
return this._sym.next()._sym;
},
compareAngularDirection: function (e) {
var dx = this.deltaX();
var dy = this.deltaY();
var dx2 = e.deltaX();
var dy2 = e.deltaY();
if (dx === dx2 && dy === dy2) return 0;
var quadrant = __WEBPACK_IMPORTED_MODULE_2__geomgraph_Quadrant__["a" /* default */].quadrant(dx, dy);
var quadrant2 = __WEBPACK_IMPORTED_MODULE_2__geomgraph_Quadrant__["a" /* default */].quadrant(dx2, dy2);
if (quadrant > quadrant2) return 1;
if (quadrant < quadrant2) return -1;
return __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].computeOrientation(e._orig, e.dest(), this.dest());
},
prevNode: function () {
var e = this;
while (e.degree() === 2) {
e = e.prev();
if (e === this) return null;
}
return e;
},
compareTo: function (obj) {
var e = obj;
var comp = this.compareAngularDirection(e);
return comp;
},
next: function () {
return this._next;
},
setSym: function (e) {
this._sym = e;
},
orig: function () {
return this._orig;
},
toString: function () {
return "HE(" + this._orig.x + " " + this._orig.y + ", " + this._sym._orig.x + " " + this._sym._orig.y + ")";
},
setNext: function (e) {
this._next = e;
},
init: function (e) {
this.setSym(e);
e.setSym(this);
this.setNext(e);
e.setNext(this);
},
deltaX: function () {
return this._sym._orig.x - this._orig.x;
},
interfaces_: function () {
return [];
},
getClass: function () {
return HalfEdge;
}
});
HalfEdge.init = function (e0, e1) {
if (e0._sym !== null || e1._sym !== null || e0._next !== null || e1._next !== null) throw new IllegalStateException("Edges are already initialized");
e0.init(e1);
return e0;
};
HalfEdge.create = function (p0, p1) {
var e0 = new HalfEdge(p0);
var e1 = new HalfEdge(p1);
e0.init(e1);
return e0;
};
/***/ }),
/* 150 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Quadtree;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Root__ = __webpack_require__(285);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__SpatialIndex__ = __webpack_require__(130);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__ArrayListVisitor__ = __webpack_require__(142);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_io_Serializable__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_Envelope__ = __webpack_require__(7);
function Quadtree() {
this._root = null;
this._minExtent = 1.0;
this._root = new __WEBPACK_IMPORTED_MODULE_0__Root__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(Quadtree.prototype, {
size: function () {
if (this._root !== null) return this._root.size();
return 0;
},
insert: function (itemEnv, item) {
this.collectStats(itemEnv);
var insertEnv = Quadtree.ensureExtent(itemEnv, this._minExtent);
this._root.insert(insertEnv, item);
},
query: function () {
if (arguments.length === 1) {
let searchEnv = arguments[0];
var visitor = new __WEBPACK_IMPORTED_MODULE_4__ArrayListVisitor__["a" /* default */]();
this.query(searchEnv, visitor);
return visitor.getItems();
} else if (arguments.length === 2) {
let searchEnv = arguments[0], visitor = arguments[1];
this._root.visit(searchEnv, visitor);
}
},
queryAll: function () {
var foundItems = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
this._root.addAllItems(foundItems);
return foundItems;
},
remove: function (itemEnv, item) {
var posEnv = Quadtree.ensureExtent(itemEnv, this._minExtent);
return this._root.remove(posEnv, item);
},
collectStats: function (itemEnv) {
var delX = itemEnv.getWidth();
if (delX < this._minExtent && delX > 0.0) this._minExtent = delX;
var delY = itemEnv.getHeight();
if (delY < this._minExtent && delY > 0.0) this._minExtent = delY;
},
depth: function () {
if (this._root !== null) return this._root.depth();
return 0;
},
isEmpty: function () {
if (this._root === null) return true;
return false;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_1__SpatialIndex__["a" /* default */], __WEBPACK_IMPORTED_MODULE_5__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return Quadtree;
}
});
Quadtree.ensureExtent = function (itemEnv, minExtent) {
var minx = itemEnv.getMinX();
var maxx = itemEnv.getMaxX();
var miny = itemEnv.getMinY();
var maxy = itemEnv.getMaxY();
if (minx !== maxx && miny !== maxy) return itemEnv;
if (minx === maxx) {
minx = minx - minExtent / 2.0;
maxx = minx + minExtent / 2.0;
}
if (miny === maxy) {
miny = miny - minExtent / 2.0;
maxy = miny + minExtent / 2.0;
}
return new __WEBPACK_IMPORTED_MODULE_6__geom_Envelope__["a" /* default */](minx, maxx, miny, maxy);
};
Quadtree.serialVersionUID = -7461163625812743604;
/***/ }),
/* 151 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = NodeBase;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_io_Serializable__ = __webpack_require__(21);
function NodeBase() {
this._items = new __WEBPACK_IMPORTED_MODULE_1__java_util_ArrayList__["a" /* default */]();
this._subnode = new Array(4).fill(null);
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(NodeBase.prototype, {
hasChildren: function () {
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) return true;
}
return false;
},
isPrunable: function () {
return !(this.hasChildren() || this.hasItems());
},
addAllItems: function (resultItems) {
resultItems.addAll(this._items);
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
this._subnode[i].addAllItems(resultItems);
}
}
return resultItems;
},
getNodeCount: function () {
var subSize = 0;
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
subSize += this._subnode[i].size();
}
}
return subSize + 1;
},
size: function () {
var subSize = 0;
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
subSize += this._subnode[i].size();
}
}
return subSize + this._items.size();
},
addAllItemsFromOverlapping: function (searchEnv, resultItems) {
if (!this.isSearchMatch(searchEnv)) return null;
resultItems.addAll(this._items);
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
this._subnode[i].addAllItemsFromOverlapping(searchEnv, resultItems);
}
}
},
visitItems: function (searchEnv, visitor) {
for (var i = this._items.iterator(); i.hasNext(); ) {
visitor.visitItem(i.next());
}
},
hasItems: function () {
return !this._items.isEmpty();
},
remove: function (itemEnv, item) {
if (!this.isSearchMatch(itemEnv)) return false;
var found = false;
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
found = this._subnode[i].remove(itemEnv, item);
if (found) {
if (this._subnode[i].isPrunable()) this._subnode[i] = null;
break;
}
}
}
if (found) return found;
found = this._items.remove(item);
return found;
},
visit: function (searchEnv, visitor) {
if (!this.isSearchMatch(searchEnv)) return null;
this.visitItems(searchEnv, visitor);
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
this._subnode[i].visit(searchEnv, visitor);
}
}
},
getItems: function () {
return this._items;
},
depth: function () {
var maxSubDepth = 0;
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
var sqd = this._subnode[i].depth();
if (sqd > maxSubDepth) maxSubDepth = sqd;
}
}
return maxSubDepth + 1;
},
isEmpty: function () {
var isEmpty = true;
if (!this._items.isEmpty()) isEmpty = false;
for (var i = 0; i < 4; i++) {
if (this._subnode[i] !== null) {
if (!this._subnode[i].isEmpty()) isEmpty = false;
}
}
return isEmpty;
},
add: function (item) {
this._items.add(item);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_2__java_io_Serializable__["a" /* default */]];
},
getClass: function () {
return NodeBase;
}
});
NodeBase.getSubnodeIndex = function (env, centrex, centrey) {
var subnodeIndex = -1;
if (env.getMinX() >= centrex) {
if (env.getMinY() >= centrey) subnodeIndex = 3;
if (env.getMaxY() <= centrey) subnodeIndex = 1;
}
if (env.getMaxX() <= centrex) {
if (env.getMinY() >= centrey) subnodeIndex = 2;
if (env.getMaxY() <= centrey) subnodeIndex = 0;
}
return subnodeIndex;
};
/***/ }),
/* 152 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeoJSONParser;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_GeometryFactory__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
const geometryTypes = ['Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon']
/**
* Class for reading and writing Well-Known Text.Create a new parser for GeoJSON
* NOTE: Adapted from OpenLayers 2.11 implementation.
*/
/**
* Create a new parser for GeoJSON
*
* @param {GeometryFactory} geometryFactory
* @return An instance of GeoJsonParser.
* @constructor
* @private
*/
function GeoJSONParser (geometryFactory) {
this.geometryFactory = geometryFactory || new __WEBPACK_IMPORTED_MODULE_1__geom_GeometryFactory__["a" /* default */]()
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(GeoJSONParser.prototype, {
/**
* Deserialize a GeoJSON object and return the Geometry or Feature(Collection) with JSTS Geometries
*
* @param {}
* A GeoJSON object.
* @return {} A Geometry instance or object representing a Feature(Collection) with Geometry instances.
* @private
*/
read (json) {
let obj
if (typeof json === 'string') {
obj = JSON.parse(json)
} else {
obj = json
}
const type = obj.type
if (!parse[type]) {
throw new Error('Unknown GeoJSON type: ' + obj.type)
}
if (geometryTypes.indexOf(type) !== -1) {
return parse[type].apply(this, [obj.coordinates])
} else if (type === 'GeometryCollection') {
return parse[type].apply(this, [obj.geometries])
}
// feature or feature collection
return parse[type].apply(this, [obj])
},
/**
* Serialize a Geometry object into GeoJSON
*
* @param {Geometry}
* geometry A Geometry or array of Geometries.
* @return {Object} A GeoJSON object represting the input Geometry/Geometries.
* @private
*/
write (geometry) {
const type = geometry.getGeometryType()
if (!extract[type]) {
throw new Error('Geometry is not supported')
}
return extract[type].apply(this, [geometry])
}
})
const parse = {
/**
* Parse a GeoJSON Feature object
*
* @param {Object}
* obj Object to parse.
*
* @return {Object} Feature with geometry/bbox converted to JSTS Geometries.
*/
Feature: function (obj) {
const feature = {}
// copy features
for (let key in obj) {
feature[key] = obj[key]
}
// parse geometry
if (obj.geometry) {
const type = obj.geometry.type
if (!parse[type]) {
throw new Error('Unknown GeoJSON type: ' + obj.type)
}
feature.geometry = this.read(obj.geometry)
}
// bbox
if (obj.bbox) {
feature.bbox = parse.bbox.apply(this, [obj.bbox])
}
return feature
},
/**
* Parse a GeoJSON FeatureCollection object
*
* @param {Object}
* obj Object to parse.
*
* @return {Object} FeatureCollection with geometry/bbox converted to JSTS Geometries.
*/
FeatureCollection: function (obj) {
const featureCollection = {}
if (obj.features) {
featureCollection.features = []
for (let i = 0; i < obj.features.length; ++i) {
featureCollection.features.push(this.read(obj.features[i]))
}
}
if (obj.bbox) {
featureCollection.bbox = this.parse.bbox.apply(this, [obj.bbox])
}
return featureCollection
},
/**
* Convert the ordinates in an array to an array of Coordinates
*
* @param {Array}
* array Array with {Number}s.
*
* @return {Array} Array with Coordinates.
*/
coordinates: function (array) {
const coordinates = []
for (let i = 0; i < array.length; ++i) {
const sub = array[i]
coordinates.push(new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](sub[0], sub[1]))
}
return coordinates
},
/**
* Convert the bbox to a LinearRing
*
* @param {Array}
* array Array with [xMin, yMin, xMax, yMax].
*
* @return {Array} Array with Coordinates.
*/
bbox: function (array) {
return this.geometryFactory.createLinearRing([
new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](array[0], array[1]),
new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](array[2], array[1]),
new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](array[2], array[3]),
new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](array[0], array[3]),
new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](array[0], array[1])
])
},
/**
* Convert an Array with ordinates to a Point
*
* @param {Array}
* array Array with ordinates.
*
* @return {Point} Point.
*/
Point: function (array) {
const coordinate = new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](array[0], array[1])
return this.geometryFactory.createPoint(coordinate)
},
/**
* Convert an Array with coordinates to a MultiPoint
*
* @param {Array}
* array Array with coordinates.
*
* @return {MultiPoint} MultiPoint.
*/
MultiPoint: function (array) {
const points = []
for (let i = 0; i < array.length; ++i) {
points.push(parse.Point.apply(this, [array[i]]))
}
return this.geometryFactory.createMultiPoint(points)
},
/**
* Convert an Array with coordinates to a LineString
*
* @param {Array}
* array Array with coordinates.
*
* @return {LineString} LineString.
*/
LineString: function (array) {
const coordinates = parse.coordinates.apply(this, [array])
return this.geometryFactory.createLineString(coordinates)
},
/**
* Convert an Array with coordinates to a MultiLineString
*
* @param {Array}
* array Array with coordinates.
*
* @return {MultiLineString} MultiLineString.
*/
MultiLineString: function (array) {
const lineStrings = []
for (let i = 0; i < array.length; ++i) {
lineStrings.push(parse.LineString.apply(this, [array[i]]))
}
return this.geometryFactory.createMultiLineString(lineStrings)
},
/**
* Convert an Array to a Polygon
*
* @param {Array}
* array Array with shell and holes.
*
* @return {Polygon} Polygon.
*/
Polygon: function (array) {
const shellCoordinates = parse.coordinates.apply(this, [array[0]])
const shell = this.geometryFactory.createLinearRing(shellCoordinates)
const holes = []
for (let i = 1; i < array.length; ++i) {
var hole = array[i]
var coordinates = parse.coordinates.apply(this, [hole])
var linearRing = this.geometryFactory.createLinearRing(coordinates)
holes.push(linearRing)
}
return this.geometryFactory.createPolygon(shell, holes)
},
/**
* Convert an Array to a MultiPolygon
*
* @param {Array}
* array Array of arrays with shell and rings.
*
* @return {MultiPolygon} MultiPolygon.
*/
MultiPolygon: function (array) {
const polygons = []
for (let i = 0; i < array.length; ++i) {
const polygon = array[i]
polygons.push(parse.Polygon.apply(this, [polygon]))
}
return this.geometryFactory.createMultiPolygon(polygons)
},
/**
* Convert an Array to a GeometryCollection
*
* @param {Array}
* array Array of GeoJSON geometries.
*
* @return {GeometryCollection} GeometryCollection.
*/
GeometryCollection: function (array) {
const geometries = []
for (let i = 0; i < array.length; ++i) {
const geometry = array[i]
geometries.push(this.read(geometry))
}
return this.geometryFactory.createGeometryCollection(geometries)
}
}
const extract = {
/**
* Convert a Coordinate to an Array
*
* @param {Coordinate}
* coordinate Coordinate to convert.
*
* @return {Array} Array of ordinates.
*/
coordinate: function (coordinate) {
return [coordinate.x, coordinate.y]
},
/**
* Convert a Point to a GeoJSON object
*
* @param {Point}
* point Point to convert.
*
* @return {Array} Array of 2 ordinates (paired to a coordinate).
*/
Point: function (point) {
const array = extract.coordinate.apply(this, [point.getCoordinate()])
return {
type: 'Point',
coordinates: array
}
},
/**
* Convert a MultiPoint to a GeoJSON object
*
* @param {MultiPoint}
* multipoint MultiPoint to convert.
*
* @return {Array} Array of coordinates.
*/
MultiPoint: function (multipoint) {
const array = []
for (let i = 0; i < multipoint._geometries.length; ++i) {
const point = multipoint._geometries[i]
const geoJson = extract.Point.apply(this, [point])
array.push(geoJson.coordinates)
}
return {
type: 'MultiPoint',
coordinates: array
}
},
/**
* Convert a LineString to a GeoJSON object
*
* @param {LineString}
* linestring LineString to convert.
*
* @return {Array} Array of coordinates.
*/
LineString: function (linestring) {
const array = []
const coordinates = linestring.getCoordinates()
for (let i = 0; i < coordinates.length; ++i) {
const coordinate = coordinates[i]
array.push(extract.coordinate.apply(this, [coordinate]))
}
return {
type: 'LineString',
coordinates: array
}
},
/**
* Convert a MultiLineString to a GeoJSON object
*
* @param {MultiLineString}
* multilinestring MultiLineString to convert.
*
* @return {Array} Array of Array of coordinates.
*/
MultiLineString: function (multilinestring) {
const array = []
for (let i = 0; i < multilinestring._geometries.length; ++i) {
const linestring = multilinestring._geometries[i]
const geoJson = extract.LineString.apply(this, [linestring])
array.push(geoJson.coordinates)
}
return {
type: 'MultiLineString',
coordinates: array
}
},
/**
* Convert a Polygon to a GeoJSON object
*
* @param {Polygon}
* polygon Polygon to convert.
*
* @return {Array} Array with shell, holes.
*/
Polygon: function (polygon) {
const array = []
const shellGeoJson = extract.LineString.apply(this, [polygon._shell])
array.push(shellGeoJson.coordinates)
for (let i = 0; i < polygon._holes.length; ++i) {
const hole = polygon._holes[i]
const holeGeoJson = extract.LineString.apply(this, [hole])
array.push(holeGeoJson.coordinates)
}
return {
type: 'Polygon',
coordinates: array
}
},
/**
* Convert a MultiPolygon to a GeoJSON object
*
* @param {MultiPolygon}
* multipolygon MultiPolygon to convert.
*
* @return {Array} Array of polygons.
*/
MultiPolygon: function (multipolygon) {
const array = []
for (let i = 0; i < multipolygon._geometries.length; ++i) {
const polygon = multipolygon._geometries[i]
const geoJson = extract.Polygon.apply(this, [polygon])
array.push(geoJson.coordinates)
}
return {
type: 'MultiPolygon',
coordinates: array
}
},
/**
* Convert a GeometryCollection to a GeoJSON object
*
* @param {GeometryCollection}
* collection GeometryCollection to convert.
*
* @return {Array} Array of geometries.
*/
GeometryCollection: function (collection) {
const array = []
for (let i = 0; i < collection._geometries.length; ++i) {
const geometry = collection._geometries[i]
const type = geometry.getGeometryType()
array.push(extract[type].apply(this, [geometry]))
}
return {
type: 'GeometryCollection',
geometries: array
}
}
}
/***/ }),
/* 153 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ScaledNoder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_util_Collection__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Noder__ = __webpack_require__(96);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NodedSegmentString__ = __webpack_require__(63);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__ = __webpack_require__(1);
function ScaledNoder() {
this._noder = null;
this._scaleFactor = null;
this._offsetX = null;
this._offsetY = null;
this._isScaled = false;
if (arguments.length === 2) {
let noder = arguments[0], scaleFactor = arguments[1];
ScaledNoder.call(this, noder, scaleFactor, 0, 0);
} else if (arguments.length === 4) {
let noder = arguments[0], scaleFactor = arguments[1], offsetX = arguments[2], offsetY = arguments[3];
this._noder = noder;
this._scaleFactor = scaleFactor;
this._isScaled = !this.isIntegerPrecision();
}
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(ScaledNoder.prototype, {
rescale: function () {
if (Object(__WEBPACK_IMPORTED_MODULE_0__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_1__java_util_Collection__["a" /* default */])) {
let segStrings = arguments[0];
for (var i = segStrings.iterator(); i.hasNext(); ) {
var ss = i.next();
this.rescale(ss.getCoordinates());
}
} else if (arguments[0] instanceof Array) {
let pts = arguments[0];
var p0 = null;
var p1 = null;
if (pts.length === 2) {
p0 = new __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */](pts[0]);
p1 = new __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */](pts[1]);
}
for (var i = 0; i < pts.length; i++) {
pts[i].x = pts[i].x / this._scaleFactor + this._offsetX;
pts[i].y = pts[i].y / this._scaleFactor + this._offsetY;
}
if (pts.length === 2 && pts[0].equals2D(pts[1])) {
__WEBPACK_IMPORTED_MODULE_6__java_lang_System__["a" /* default */].out.println(pts);
}
}
},
scale: function () {
if (Object(__WEBPACK_IMPORTED_MODULE_0__hasInterface__["a" /* default */])(arguments[0], __WEBPACK_IMPORTED_MODULE_1__java_util_Collection__["a" /* default */])) {
let segStrings = arguments[0];
var nodedSegmentStrings = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
for (var i = segStrings.iterator(); i.hasNext(); ) {
var ss = i.next();
nodedSegmentStrings.add(new __WEBPACK_IMPORTED_MODULE_4__NodedSegmentString__["a" /* default */](this.scale(ss.getCoordinates()), ss.getData()));
}
return nodedSegmentStrings;
} else if (arguments[0] instanceof Array) {
let pts = arguments[0];
var roundPts = new Array(pts.length).fill(null);
for (var i = 0; i < pts.length; i++) {
roundPts[i] = new __WEBPACK_IMPORTED_MODULE_3__geom_Coordinate__["a" /* default */](Math.round((pts[i].x - this._offsetX) * this._scaleFactor), Math.round((pts[i].y - this._offsetY) * this._scaleFactor), pts[i].z);
}
var roundPtsNoDup = __WEBPACK_IMPORTED_MODULE_7__geom_CoordinateArrays__["a" /* default */].removeRepeatedPoints(roundPts);
return roundPtsNoDup;
}
},
isIntegerPrecision: function () {
return this._scaleFactor === 1.0;
},
getNodedSubstrings: function () {
var splitSS = this._noder.getNodedSubstrings();
if (this._isScaled) this.rescale(splitSS);
return splitSS;
},
computeNodes: function (inputSegStrings) {
var intSegStrings = inputSegStrings;
if (this._isScaled) intSegStrings = this.scale(inputSegStrings);
this._noder.computeNodes(intSegStrings);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_2__Noder__["a" /* default */]];
},
getClass: function () {
return ScaledNoder;
}
});
/***/ }),
/* 154 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PolygonExtracter;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Polygon__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__GeometryFilter__ = __webpack_require__(39);
function PolygonExtracter() {
this._comps = null;
let comps = arguments[0];
this._comps = comps;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(PolygonExtracter.prototype, {
filter: function (geom) {
if (geom instanceof __WEBPACK_IMPORTED_MODULE_0__Polygon__["a" /* default */]) this._comps.add(geom);
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_4__GeometryFilter__["a" /* default */]];
},
getClass: function () {
return PolygonExtracter;
}
});
PolygonExtracter.getPolygons = function () {
if (arguments.length === 1) {
let geom = arguments[0];
return PolygonExtracter.getPolygons(geom, new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]());
} else if (arguments.length === 2) {
let geom = arguments[0], list = arguments[1];
if (geom instanceof __WEBPACK_IMPORTED_MODULE_0__Polygon__["a" /* default */]) {
list.add(geom);
} else if (geom instanceof __WEBPACK_IMPORTED_MODULE_2__GeometryCollection__["a" /* default */]) {
geom.apply(new PolygonExtracter(list));
}
return list;
}
};
/***/ }),
/* 155 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = GeometryLocation;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
function GeometryLocation() {
this._component = null;
this._segIndex = null;
this._pt = null;
if (arguments.length === 2) {
let component = arguments[0], pt = arguments[1];
GeometryLocation.call(this, component, GeometryLocation.INSIDE_AREA, pt);
} else if (arguments.length === 3) {
let component = arguments[0], segIndex = arguments[1], pt = arguments[2];
this._component = component;
this._segIndex = segIndex;
this._pt = pt;
}
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(GeometryLocation.prototype, {
isInsideArea: function () {
return this._segIndex === GeometryLocation.INSIDE_AREA;
},
getCoordinate: function () {
return this._pt;
},
getGeometryComponent: function () {
return this._component;
},
getSegmentIndex: function () {
return this._segIndex;
},
interfaces_: function () {
return [];
},
getClass: function () {
return GeometryLocation;
}
});
GeometryLocation.INSIDE_AREA = -1;
/***/ }),
/* 156 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PlanarGraph;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__java_util_HashSet__ = __webpack_require__(45);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Node__ = __webpack_require__(82);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NodeMap__ = __webpack_require__(326);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__DirectedEdge__ = __webpack_require__(68);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Edge__ = __webpack_require__(83);
function PlanarGraph() {
this._edges = new __WEBPACK_IMPORTED_MODULE_0__java_util_HashSet__["a" /* default */]();
this._dirEdges = new __WEBPACK_IMPORTED_MODULE_0__java_util_HashSet__["a" /* default */]();
this._nodeMap = new __WEBPACK_IMPORTED_MODULE_3__NodeMap__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(PlanarGraph.prototype, {
findNodesOfDegree: function (degree) {
var nodesFound = new __WEBPACK_IMPORTED_MODULE_5__java_util_ArrayList__["a" /* default */]();
for (var i = this.nodeIterator(); i.hasNext(); ) {
var node = i.next();
if (node.getDegree() === degree) nodesFound.add(node);
}
return nodesFound;
},
dirEdgeIterator: function () {
return this._dirEdges.iterator();
},
edgeIterator: function () {
return this._edges.iterator();
},
remove: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_6__Edge__["a" /* default */]) {
let edge = arguments[0];
this.remove(edge.getDirEdge(0));
this.remove(edge.getDirEdge(1));
this._edges.remove(edge);
edge.remove();
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_4__DirectedEdge__["a" /* default */]) {
let de = arguments[0];
var sym = de.getSym();
if (sym !== null) sym.setSym(null);
de.getFromNode().remove(de);
de.remove();
this._dirEdges.remove(de);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__Node__["a" /* default */]) {
let node = arguments[0];
var outEdges = node.getOutEdges().getEdges();
for (var i = outEdges.iterator(); i.hasNext(); ) {
var de = i.next();
var sym = de.getSym();
if (sym !== null) this.remove(sym);
this._dirEdges.remove(de);
var edge = de.getEdge();
if (edge !== null) {
this._edges.remove(edge);
}
}
this._nodeMap.remove(node.getCoordinate());
node.remove();
}
},
findNode: function (pt) {
return this._nodeMap.find(pt);
},
getEdges: function () {
return this._edges;
},
nodeIterator: function () {
return this._nodeMap.iterator();
},
contains: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_6__Edge__["a" /* default */]) {
let e = arguments[0];
return this._edges.contains(e);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_4__DirectedEdge__["a" /* default */]) {
let de = arguments[0];
return this._dirEdges.contains(de);
}
},
add: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_1__Node__["a" /* default */]) {
let node = arguments[0];
this._nodeMap.add(node);
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_6__Edge__["a" /* default */]) {
let edge = arguments[0];
this._edges.add(edge);
this.add(edge.getDirEdge(0));
this.add(edge.getDirEdge(1));
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_4__DirectedEdge__["a" /* default */]) {
let dirEdge = arguments[0];
this._dirEdges.add(dirEdge);
}
},
getNodes: function () {
return this._nodeMap.values();
},
interfaces_: function () {
return [];
},
getClass: function () {
return PlanarGraph;
}
});
/***/ }),
/* 157 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = EdgeRing;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__io_WKTWriter__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_impl_CoordinateArraySequence__ = __webpack_require__(60);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__valid_IsValidOp__ = __webpack_require__(105);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_LinearRing__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__java_lang_Exception__ = __webpack_require__(87);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_lang_System__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__geom_CoordinateArrays__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__java_util_Comparator__ = __webpack_require__(48);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__util_Assert__ = __webpack_require__(4);
function EdgeRing() {
this._factory = null;
this._deList = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
this._lowestEdge = null;
this._ring = null;
this._ringPts = null;
this._holes = null;
this._shell = null;
this._isHole = null;
this._isProcessed = false;
this._isIncludedSet = false;
this._isIncluded = false;
let factory = arguments[0];
this._factory = factory;
}
Object(__WEBPACK_IMPORTED_MODULE_6__extend__["a" /* default */])(EdgeRing.prototype, {
isIncluded: function () {
return this._isIncluded;
},
getCoordinates: function () {
if (this._ringPts === null) {
var coordList = new __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__["a" /* default */]();
for (var i = this._deList.iterator(); i.hasNext(); ) {
var de = i.next();
var edge = de.getEdge();
EdgeRing.addEdge(edge.getLine().getCoordinates(), de.getEdgeDirection(), coordList);
}
this._ringPts = coordList.toCoordinateArray();
}
return this._ringPts;
},
isIncludedSet: function () {
return this._isIncludedSet;
},
isValid: function () {
this.getCoordinates();
if (this._ringPts.length <= 3) return false;
this.getRing();
return __WEBPACK_IMPORTED_MODULE_4__valid_IsValidOp__["a" /* default */].isValid(this._ring);
},
build: function (startDE) {
var de = startDE;
do {
this.add(de);
de.setRing(this);
de = de.getNext();
__WEBPACK_IMPORTED_MODULE_12__util_Assert__["a" /* default */].isTrue(de !== null, "found null DE in ring");
__WEBPACK_IMPORTED_MODULE_12__util_Assert__["a" /* default */].isTrue(de === startDE || !de.isInRing(), "found DE already in ring");
} while (de !== startDE);
},
isOuterHole: function () {
if (!this._isHole) return false;
return !this.hasShell();
},
getPolygon: function () {
var holeLR = null;
if (this._holes !== null) {
holeLR = new Array(this._holes.size()).fill(null);
for (var i = 0; i < this._holes.size(); i++) {
holeLR[i] = this._holes.get(i);
}
}
var poly = this._factory.createPolygon(this._ring, holeLR);
return poly;
},
isHole: function () {
return this._isHole;
},
isProcessed: function () {
return this._isProcessed;
},
addHole: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_5__geom_LinearRing__["a" /* default */]) {
let hole = arguments[0];
if (this._holes === null) this._holes = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
this._holes.add(hole);
} else if (arguments[0] instanceof EdgeRing) {
let holeER = arguments[0];
holeER.setShell(this);
var hole = holeER.getRing();
if (this._holes === null) this._holes = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
this._holes.add(hole);
}
},
setIncluded: function (isIncluded) {
this._isIncluded = isIncluded;
this._isIncludedSet = true;
},
getOuterHole: function () {
if (this.isHole()) return null;
for (var i = 0; i < this._deList.size(); i++) {
var de = this._deList.get(i);
var adjRing = de.getSym().getRing();
if (adjRing.isOuterHole()) return adjRing;
}
return null;
},
computeHole: function () {
var ring = this.getRing();
this._isHole = __WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].isCCW(ring.getCoordinates());
},
hasShell: function () {
return this._shell !== null;
},
isOuterShell: function () {
return this.getOuterHole() !== null;
},
getLineString: function () {
this.getCoordinates();
return this._factory.createLineString(this._ringPts);
},
toString: function () {
return __WEBPACK_IMPORTED_MODULE_2__io_WKTWriter__["a" /* default */].toLineString(new __WEBPACK_IMPORTED_MODULE_3__geom_impl_CoordinateArraySequence__["a" /* default */](this.getCoordinates()));
},
getShell: function () {
if (this.isHole()) return this._shell;
return this;
},
add: function (de) {
this._deList.add(de);
},
getRing: function () {
if (this._ring !== null) return this._ring;
this.getCoordinates();
if (this._ringPts.length < 3) __WEBPACK_IMPORTED_MODULE_8__java_lang_System__["a" /* default */].out.println(this._ringPts);
try {
this._ring = this._factory.createLinearRing(this._ringPts);
} catch (ex) {
if (ex instanceof __WEBPACK_IMPORTED_MODULE_7__java_lang_Exception__["a" /* default */]) {
__WEBPACK_IMPORTED_MODULE_8__java_lang_System__["a" /* default */].out.println(this._ringPts);
} else throw ex;
} finally {}
return this._ring;
},
updateIncluded: function () {
if (this.isHole()) return null;
for (var i = 0; i < this._deList.size(); i++) {
var de = this._deList.get(i);
var adjShell = de.getSym().getRing().getShell();
if (adjShell !== null && adjShell.isIncludedSet()) {
this.setIncluded(!adjShell.isIncluded());
return null;
}
}
},
setShell: function (shell) {
this._shell = shell;
},
setProcessed: function (isProcessed) {
this._isProcessed = isProcessed;
},
interfaces_: function () {
return [];
},
getClass: function () {
return EdgeRing;
}
});
EdgeRing.findDirEdgesInRing = function (startDE) {
var de = startDE;
var edges = new __WEBPACK_IMPORTED_MODULE_10__java_util_ArrayList__["a" /* default */]();
do {
edges.add(de);
de = de.getNext();
__WEBPACK_IMPORTED_MODULE_12__util_Assert__["a" /* default */].isTrue(de !== null, "found null DE in ring");
__WEBPACK_IMPORTED_MODULE_12__util_Assert__["a" /* default */].isTrue(de === startDE || !de.isInRing(), "found DE already in ring");
} while (de !== startDE);
return edges;
};
EdgeRing.addEdge = function (coords, isForward, coordList) {
if (isForward) {
for (var i = 0; i < coords.length; i++) {
coordList.add(coords[i], false);
}
} else {
for (var i = coords.length - 1; i >= 0; i--) {
coordList.add(coords[i], false);
}
}
};
EdgeRing.findEdgeRingContaining = function (testEr, shellList) {
var testRing = testEr.getRing();
var testEnv = testRing.getEnvelopeInternal();
var testPt = testRing.getCoordinateN(0);
var minShell = null;
var minShellEnv = null;
for (var it = shellList.iterator(); it.hasNext(); ) {
var tryShell = it.next();
var tryShellRing = tryShell.getRing();
var tryShellEnv = tryShellRing.getEnvelopeInternal();
if (tryShellEnv.equals(testEnv)) continue;
if (!tryShellEnv.contains(testEnv)) continue;
testPt = __WEBPACK_IMPORTED_MODULE_9__geom_CoordinateArrays__["a" /* default */].ptNotInList(testRing.getCoordinates(), tryShellRing.getCoordinates());
var isContained = false;
if (__WEBPACK_IMPORTED_MODULE_0__algorithm_CGAlgorithms__["a" /* default */].isPointInRing(testPt, tryShellRing.getCoordinates())) isContained = true;
if (isContained) {
if (minShell === null || minShellEnv.contains(tryShellEnv)) {
minShell = tryShell;
minShellEnv = minShell.getRing().getEnvelopeInternal();
}
}
}
return minShell;
};
function EnvelopeComparator() {}
Object(__WEBPACK_IMPORTED_MODULE_6__extend__["a" /* default */])(EnvelopeComparator.prototype, {
compare: function (obj0, obj1) {
var r0 = obj0;
var r1 = obj1;
return r0.getRing().getEnvelope().compareTo(r1.getRing().getEnvelope());
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_11__java_util_Comparator__["a" /* default */]];
},
getClass: function () {
return EnvelopeComparator;
}
});
EdgeRing.EnvelopeComparator = EnvelopeComparator;
/***/ }),
/* 158 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ConsistentAreaTester;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__relate_RelateNodeGraph__ = __webpack_require__(334);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__algorithm_RobustLineIntersector__ = __webpack_require__(22);
function ConsistentAreaTester() {
this._li = new __WEBPACK_IMPORTED_MODULE_2__algorithm_RobustLineIntersector__["a" /* default */]();
this._geomGraph = null;
this._nodeGraph = new __WEBPACK_IMPORTED_MODULE_0__relate_RelateNodeGraph__["a" /* default */]();
this._invalidPoint = null;
let geomGraph = arguments[0];
this._geomGraph = geomGraph;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(ConsistentAreaTester.prototype, {
isNodeEdgeAreaLabelsConsistent: function () {
for (var nodeIt = this._nodeGraph.getNodeIterator(); nodeIt.hasNext(); ) {
var node = nodeIt.next();
if (!node.getEdges().isAreaLabelsConsistent(this._geomGraph)) {
this._invalidPoint = node.getCoordinate().copy();
return false;
}
}
return true;
},
getInvalidPoint: function () {
return this._invalidPoint;
},
hasDuplicateRings: function () {
for (var nodeIt = this._nodeGraph.getNodeIterator(); nodeIt.hasNext(); ) {
var node = nodeIt.next();
for (var i = node.getEdges().iterator(); i.hasNext(); ) {
var eeb = i.next();
if (eeb.getEdgeEnds().size() > 1) {
this._invalidPoint = eeb.getEdge().getCoordinate(0);
return true;
}
}
}
return false;
},
isNodeConsistentArea: function () {
var intersector = this._geomGraph.computeSelfNodes(this._li, true, true);
if (intersector.hasProperIntersection()) {
this._invalidPoint = intersector.getProperIntersectionPoint();
return false;
}
this._nodeGraph.build(this._geomGraph);
return this.isNodeEdgeAreaLabelsConsistent();
},
interfaces_: function () {
return [];
},
getClass: function () {
return ConsistentAreaTester;
}
});
/***/ }),
/* 159 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = EdgeEndBuilder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geomgraph_EdgeEnd__ = __webpack_require__(99);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geomgraph_Label__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
function EdgeEndBuilder() {}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(EdgeEndBuilder.prototype, {
createEdgeEndForNext: function (edge, l, eiCurr, eiNext) {
var iNext = eiCurr.segmentIndex + 1;
if (iNext >= edge.getNumPoints() && eiNext === null) return null;
var pNext = edge.getCoordinate(iNext);
if (eiNext !== null && eiNext.segmentIndex === eiCurr.segmentIndex) pNext = eiNext.coord;
var e = new __WEBPACK_IMPORTED_MODULE_0__geomgraph_EdgeEnd__["a" /* default */](edge, eiCurr.coord, pNext, new __WEBPACK_IMPORTED_MODULE_2__geomgraph_Label__["a" /* default */](edge.getLabel()));
l.add(e);
},
createEdgeEndForPrev: function (edge, l, eiCurr, eiPrev) {
var iPrev = eiCurr.segmentIndex;
if (eiCurr.dist === 0.0) {
if (iPrev === 0) return null;
iPrev--;
}
var pPrev = edge.getCoordinate(iPrev);
if (eiPrev !== null && eiPrev.segmentIndex >= iPrev) pPrev = eiPrev.coord;
var label = new __WEBPACK_IMPORTED_MODULE_2__geomgraph_Label__["a" /* default */](edge.getLabel());
label.flip();
var e = new __WEBPACK_IMPORTED_MODULE_0__geomgraph_EdgeEnd__["a" /* default */](edge, eiCurr.coord, pPrev, label);
l.add(e);
},
computeEdgeEnds: function () {
if (arguments.length === 1) {
let edges = arguments[0];
var l = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
for (var i = edges; i.hasNext(); ) {
var e = i.next();
this.computeEdgeEnds(e, l);
}
return l;
} else if (arguments.length === 2) {
let edge = arguments[0], l = arguments[1];
var eiList = edge.getEdgeIntersectionList();
eiList.addEndpoints();
var it = eiList.iterator();
var eiPrev = null;
var eiCurr = null;
if (!it.hasNext()) return null;
var eiNext = it.next();
do {
eiPrev = eiCurr;
eiCurr = eiNext;
eiNext = null;
if (it.hasNext()) eiNext = it.next();
if (eiCurr !== null) {
this.createEdgeEndForPrev(edge, l, eiCurr, eiPrev);
this.createEdgeEndForNext(edge, l, eiCurr, eiNext);
}
} while (eiCurr !== null);
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return EdgeEndBuilder;
}
});
/***/ }),
/* 160 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = RelateNodeFactory;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__EdgeEndBundleStar__ = __webpack_require__(335);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__RelateNode__ = __webpack_require__(337);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__inherits__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geomgraph_NodeFactory__ = __webpack_require__(100);
function RelateNodeFactory() {
__WEBPACK_IMPORTED_MODULE_4__geomgraph_NodeFactory__["a" /* default */].apply(this);
}
Object(__WEBPACK_IMPORTED_MODULE_3__inherits__["a" /* default */])(RelateNodeFactory, __WEBPACK_IMPORTED_MODULE_4__geomgraph_NodeFactory__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(RelateNodeFactory.prototype, {
createNode: function (coord) {
return new __WEBPACK_IMPORTED_MODULE_2__RelateNode__["a" /* default */](coord, new __WEBPACK_IMPORTED_MODULE_0__EdgeEndBundleStar__["a" /* default */]());
},
interfaces_: function () {
return [];
},
getClass: function () {
return RelateNodeFactory;
}
});
/***/ }),
/* 161 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = CascadedPolygonUnion;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_util_PolygonExtracter__ = __webpack_require__(154);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index_strtree_STRtree__ = __webpack_require__(76);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_Geometry__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__hasInterface__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geom_GeometryFactory__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_util_GeometryCombiner__ = __webpack_require__(106);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_Polygonal__ = __webpack_require__(40);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__java_util_List__ = __webpack_require__(33);
function CascadedPolygonUnion() {
this._inputPolys = null;
this._geomFactory = null;
let polys = arguments[0];
this._inputPolys = polys;
if (this._inputPolys === null) this._inputPolys = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_5__extend__["a" /* default */])(CascadedPolygonUnion.prototype, {
reduceToGeometries: function (geomTree) {
var geoms = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
for (var i = geomTree.iterator(); i.hasNext(); ) {
var o = i.next();
var geom = null;
if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(o, __WEBPACK_IMPORTED_MODULE_9__java_util_List__["a" /* default */])) {
geom = this.unionTree(o);
} else if (o instanceof __WEBPACK_IMPORTED_MODULE_2__geom_Geometry__["a" /* default */]) {
geom = o;
}
geoms.add(geom);
}
return geoms;
},
extractByEnvelope: function (env, geom, disjointGeoms) {
var intersectingGeoms = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
for (var i = 0; i < geom.getNumGeometries(); i++) {
var elem = geom.getGeometryN(i);
if (elem.getEnvelopeInternal().intersects(env)) intersectingGeoms.add(elem); else disjointGeoms.add(elem);
}
return this._geomFactory.buildGeometry(intersectingGeoms);
},
unionOptimized: function (g0, g1) {
var g0Env = g0.getEnvelopeInternal();
var g1Env = g1.getEnvelopeInternal();
if (!g0Env.intersects(g1Env)) {
var combo = __WEBPACK_IMPORTED_MODULE_6__geom_util_GeometryCombiner__["a" /* default */].combine(g0, g1);
return combo;
}
if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) return this.unionActual(g0, g1);
var commonEnv = g0Env.intersection(g1Env);
return this.unionUsingEnvelopeIntersection(g0, g1, commonEnv);
},
union: function () {
if (this._inputPolys === null) throw new IllegalStateException("union() method cannot be called twice");
if (this._inputPolys.isEmpty()) return null;
this._geomFactory = this._inputPolys.iterator().next().getFactory();
var index = new __WEBPACK_IMPORTED_MODULE_1__index_strtree_STRtree__["a" /* default */](CascadedPolygonUnion.STRTREE_NODE_CAPACITY);
for (var i = this._inputPolys.iterator(); i.hasNext(); ) {
var item = i.next();
index.insert(item.getEnvelopeInternal(), item);
}
this._inputPolys = null;
var itemTree = index.itemsTree();
var unionAll = this.unionTree(itemTree);
return unionAll;
},
binaryUnion: function () {
if (arguments.length === 1) {
let geoms = arguments[0];
return this.binaryUnion(geoms, 0, geoms.size());
} else if (arguments.length === 3) {
let geoms = arguments[0], start = arguments[1], end = arguments[2];
if (end - start <= 1) {
var g0 = CascadedPolygonUnion.getGeometry(geoms, start);
return this.unionSafe(g0, null);
} else if (end - start === 2) {
return this.unionSafe(CascadedPolygonUnion.getGeometry(geoms, start), CascadedPolygonUnion.getGeometry(geoms, start + 1));
} else {
var mid = Math.trunc((end + start) / 2);
var g0 = this.binaryUnion(geoms, start, mid);
var g1 = this.binaryUnion(geoms, mid, end);
return this.unionSafe(g0, g1);
}
}
},
repeatedUnion: function (geoms) {
var union = null;
for (var i = geoms.iterator(); i.hasNext(); ) {
var g = i.next();
if (union === null) union = g.copy(); else union = union.union(g);
}
return union;
},
unionSafe: function (g0, g1) {
if (g0 === null && g1 === null) return null;
if (g0 === null) return g1.copy();
if (g1 === null) return g0.copy();
return this.unionOptimized(g0, g1);
},
unionActual: function (g0, g1) {
return CascadedPolygonUnion.restrictToPolygons(g0.union(g1));
},
unionTree: function (geomTree) {
var geoms = this.reduceToGeometries(geomTree);
var union = this.binaryUnion(geoms);
return union;
},
unionUsingEnvelopeIntersection: function (g0, g1, common) {
var disjointPolys = new __WEBPACK_IMPORTED_MODULE_8__java_util_ArrayList__["a" /* default */]();
var g0Int = this.extractByEnvelope(common, g0, disjointPolys);
var g1Int = this.extractByEnvelope(common, g1, disjointPolys);
var union = this.unionActual(g0Int, g1Int);
disjointPolys.add(union);
var overallUnion = __WEBPACK_IMPORTED_MODULE_6__geom_util_GeometryCombiner__["a" /* default */].combine(disjointPolys);
return overallUnion;
},
bufferUnion: function () {
if (arguments.length === 1) {
let geoms = arguments[0];
var factory = geoms.get(0).getFactory();
var gColl = factory.buildGeometry(geoms);
var unionAll = gColl.buffer(0.0);
return unionAll;
} else if (arguments.length === 2) {
let g0 = arguments[0], g1 = arguments[1];
var factory = g0.getFactory();
var gColl = factory.createGeometryCollection([g0, g1]);
var unionAll = gColl.buffer(0.0);
return unionAll;
}
},
interfaces_: function () {
return [];
},
getClass: function () {
return CascadedPolygonUnion;
}
});
CascadedPolygonUnion.restrictToPolygons = function (g) {
if (Object(__WEBPACK_IMPORTED_MODULE_3__hasInterface__["a" /* default */])(g, __WEBPACK_IMPORTED_MODULE_7__geom_Polygonal__["a" /* default */])) {
return g;
}
var polygons = __WEBPACK_IMPORTED_MODULE_0__geom_util_PolygonExtracter__["a" /* default */].getPolygons(g);
if (polygons.size() === 1) return polygons.get(0);
return g.getFactory().createMultiPolygon(__WEBPACK_IMPORTED_MODULE_4__geom_GeometryFactory__["a" /* default */].toPolygonArray(polygons));
};
CascadedPolygonUnion.getGeometry = function (list, index) {
if (index >= list.size()) return null;
return list.get(index);
};
CascadedPolygonUnion.union = function (polys) {
var op = new CascadedPolygonUnion(polys);
return op.union();
};
CascadedPolygonUnion.STRTREE_NODE_CAPACITY = 4;
/***/ }),
/* 162 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = PointGeometryUnion;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__algorithm_PointLocator__ = __webpack_require__(62);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_Location__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_TreeSet__ = __webpack_require__(46);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geom_util_GeometryCombiner__ = __webpack_require__(106);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_CoordinateArrays__ = __webpack_require__(19);
function PointGeometryUnion() {
this._pointGeom = null;
this._otherGeom = null;
this._geomFact = null;
let pointGeom = arguments[0], otherGeom = arguments[1];
this._pointGeom = pointGeom;
this._otherGeom = otherGeom;
this._geomFact = otherGeom.getFactory();
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(PointGeometryUnion.prototype, {
union: function () {
var locater = new __WEBPACK_IMPORTED_MODULE_0__algorithm_PointLocator__["a" /* default */]();
var exteriorCoords = new __WEBPACK_IMPORTED_MODULE_2__java_util_TreeSet__["a" /* default */]();
for (var i = 0; i < this._pointGeom.getNumGeometries(); i++) {
var point = this._pointGeom.getGeometryN(i);
var coord = point.getCoordinate();
var loc = locater.locate(coord, this._otherGeom);
if (loc === __WEBPACK_IMPORTED_MODULE_1__geom_Location__["a" /* default */].EXTERIOR) exteriorCoords.add(coord);
}
if (exteriorCoords.size() === 0) return this._otherGeom;
var ptComp = null;
var coords = __WEBPACK_IMPORTED_MODULE_5__geom_CoordinateArrays__["a" /* default */].toCoordinateArray(exteriorCoords);
if (coords.length === 1) {
ptComp = this._geomFact.createPoint(coords[0]);
} else {
ptComp = this._geomFact.createMultiPointFromCoords(coords);
}
return __WEBPACK_IMPORTED_MODULE_4__geom_util_GeometryCombiner__["a" /* default */].combine(ptComp, this._otherGeom);
},
interfaces_: function () {
return [];
},
getClass: function () {
return PointGeometryUnion;
}
});
PointGeometryUnion.union = function (pointGeom, otherGeom) {
var unioner = new PointGeometryUnion(pointGeom, otherGeom);
return unioner.union();
};
/***/ }),
/* 163 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LineSegmentIndex;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_quadtree_Quadtree__ = __webpack_require__(150);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index_ItemVisitor__ = __webpack_require__(52);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__geom_LineSegment__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__geom_Envelope__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__TaggedLineString__ = __webpack_require__(164);
function LineSegmentIndex() {
this._index = new __WEBPACK_IMPORTED_MODULE_0__index_quadtree_Quadtree__["a" /* default */]();
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(LineSegmentIndex.prototype, {
remove: function (seg) {
this._index.remove(new __WEBPACK_IMPORTED_MODULE_5__geom_Envelope__["a" /* default */](seg.p0, seg.p1), seg);
},
add: function () {
if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_6__TaggedLineString__["a" /* default */]) {
let line = arguments[0];
var segs = line.getSegments();
for (var i = 0; i < segs.length; i++) {
var seg = segs[i];
this.add(seg);
}
} else if (arguments[0] instanceof __WEBPACK_IMPORTED_MODULE_3__geom_LineSegment__["a" /* default */]) {
let seg = arguments[0];
this._index.insert(new __WEBPACK_IMPORTED_MODULE_5__geom_Envelope__["a" /* default */](seg.p0, seg.p1), seg);
}
},
query: function (querySeg) {
var env = new __WEBPACK_IMPORTED_MODULE_5__geom_Envelope__["a" /* default */](querySeg.p0, querySeg.p1);
var visitor = new LineSegmentVisitor(querySeg);
this._index.query(env, visitor);
var itemsFound = visitor.getItems();
return itemsFound;
},
interfaces_: function () {
return [];
},
getClass: function () {
return LineSegmentIndex;
}
});
function LineSegmentVisitor() {
this._querySeg = null;
this._items = new __WEBPACK_IMPORTED_MODULE_4__java_util_ArrayList__["a" /* default */]();
let querySeg = arguments[0];
this._querySeg = querySeg;
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(LineSegmentVisitor.prototype, {
visitItem: function (item) {
var seg = item;
if (__WEBPACK_IMPORTED_MODULE_5__geom_Envelope__["a" /* default */].intersects(seg.p0, seg.p1, this._querySeg.p0, this._querySeg.p1)) this._items.add(item);
},
getItems: function () {
return this._items;
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_1__index_ItemVisitor__["a" /* default */]];
},
getClass: function () {
return LineSegmentVisitor;
}
});
/***/ }),
/* 164 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = TaggedLineString;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TaggedLineSegment__ = __webpack_require__(362);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__ = __webpack_require__(1);
function TaggedLineString() {
this._parentLine = null;
this._segs = null;
this._resultSegs = new __WEBPACK_IMPORTED_MODULE_2__java_util_ArrayList__["a" /* default */]();
this._minimumSize = null;
if (arguments.length === 1) {
let parentLine = arguments[0];
TaggedLineString.call(this, parentLine, 2);
} else if (arguments.length === 2) {
let parentLine = arguments[0], minimumSize = arguments[1];
this._parentLine = parentLine;
this._minimumSize = minimumSize;
this.init();
}
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(TaggedLineString.prototype, {
addToResult: function (seg) {
this._resultSegs.add(seg);
},
asLineString: function () {
return this._parentLine.getFactory().createLineString(TaggedLineString.extractCoordinates(this._resultSegs));
},
getResultSize: function () {
var resultSegsSize = this._resultSegs.size();
return resultSegsSize === 0 ? 0 : resultSegsSize + 1;
},
getParent: function () {
return this._parentLine;
},
getSegment: function (i) {
return this._segs[i];
},
getParentCoordinates: function () {
return this._parentLine.getCoordinates();
},
getMinimumSize: function () {
return this._minimumSize;
},
asLinearRing: function () {
return this._parentLine.getFactory().createLinearRing(TaggedLineString.extractCoordinates(this._resultSegs));
},
getSegments: function () {
return this._segs;
},
init: function () {
var pts = this._parentLine.getCoordinates();
this._segs = new Array(pts.length - 1).fill(null);
for (var i = 0; i < pts.length - 1; i++) {
var seg = new __WEBPACK_IMPORTED_MODULE_1__TaggedLineSegment__["a" /* default */](pts[i], pts[i + 1], this._parentLine, i);
this._segs[i] = seg;
}
},
getResultCoordinates: function () {
return TaggedLineString.extractCoordinates(this._resultSegs);
},
interfaces_: function () {
return [];
},
getClass: function () {
return TaggedLineString;
}
});
TaggedLineString.extractCoordinates = function (segs) {
var pts = new Array(segs.size() + 1).fill(null);
var seg = null;
for (var i = 0; i < segs.size(); i++) {
seg = segs.get(i);
pts[i] = seg.p0;
}
pts[pts.length - 1] = seg.p1;
return pts;
};
/***/ }),
/* 165 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ConstraintVertex;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__quadedge_Vertex__ = __webpack_require__(84);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__inherits__ = __webpack_require__(3);
function ConstraintVertex() {
this._isOnConstraint = null;
this._constraint = null;
let p = arguments[0];
__WEBPACK_IMPORTED_MODULE_1__quadedge_Vertex__["a" /* default */].call(this, p);
}
Object(__WEBPACK_IMPORTED_MODULE_2__inherits__["a" /* default */])(ConstraintVertex, __WEBPACK_IMPORTED_MODULE_1__quadedge_Vertex__["a" /* default */]);
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(ConstraintVertex.prototype, {
getConstraint: function () {
return this._constraint;
},
setOnConstraint: function (isOnConstraint) {
this._isOnConstraint = isOnConstraint;
},
merge: function (other) {
if (other._isOnConstraint) {
this._isOnConstraint = true;
this._constraint = other._constraint;
}
},
isOnConstraint: function () {
return this._isOnConstraint;
},
setConstraint: function (constraint) {
this._isOnConstraint = true;
this._constraint = constraint;
},
interfaces_: function () {
return [];
},
getClass: function () {
return ConstraintVertex;
}
});
/***/ }),
/* 166 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = QuadEdge;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__io_WKTWriter__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__ = __webpack_require__(14);
function QuadEdge() {
this._rot = null;
this._vertex = null;
this._next = null;
this._data = null;
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(QuadEdge.prototype, {
equalsNonOriented: function (qe) {
if (this.equalsOriented(qe)) return true;
if (this.equalsOriented(qe.sym())) return true;
return false;
},
toLineSegment: function () {
return new __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__["a" /* default */](this._vertex.getCoordinate(), this.dest().getCoordinate());
},
dest: function () {
return this.sym().orig();
},
oNext: function () {
return this._next;
},
equalsOriented: function (qe) {
if (this.orig().getCoordinate().equals2D(qe.orig().getCoordinate()) && this.dest().getCoordinate().equals2D(qe.dest().getCoordinate())) return true;
return false;
},
dNext: function () {
return this.sym().oNext().sym();
},
lPrev: function () {
return this._next.sym();
},
rPrev: function () {
return this.sym().oNext();
},
rot: function () {
return this._rot;
},
oPrev: function () {
return this._rot._next._rot;
},
sym: function () {
return this._rot._rot;
},
setOrig: function (o) {
this._vertex = o;
},
lNext: function () {
return this.invRot().oNext().rot();
},
getLength: function () {
return this.orig().getCoordinate().distance(this.dest().getCoordinate());
},
invRot: function () {
return this._rot.sym();
},
setDest: function (d) {
this.sym().setOrig(d);
},
setData: function (data) {
this._data = data;
},
getData: function () {
return this._data;
},
delete: function () {
this._rot = null;
},
orig: function () {
return this._vertex;
},
rNext: function () {
return this._rot._next.invRot();
},
toString: function () {
var p0 = this._vertex.getCoordinate();
var p1 = this.dest().getCoordinate();
return __WEBPACK_IMPORTED_MODULE_0__io_WKTWriter__["a" /* default */].toLineString(p0, p1);
},
isLive: function () {
return this._rot !== null;
},
getPrimary: function () {
if (this.orig().getCoordinate().compareTo(this.dest().getCoordinate()) <= 0) return this; else return this.sym();
},
dPrev: function () {
return this.invRot().oNext().invRot();
},
setNext: function (next) {
this._next = next;
},
interfaces_: function () {
return [];
},
getClass: function () {
return QuadEdge;
}
});
QuadEdge.makeEdge = function (o, d) {
var q0 = new QuadEdge();
var q1 = new QuadEdge();
var q2 = new QuadEdge();
var q3 = new QuadEdge();
q0._rot = q1;
q1._rot = q2;
q2._rot = q3;
q3._rot = q0;
q0.setNext(q0);
q1.setNext(q3);
q2.setNext(q2);
q3.setNext(q1);
var base = q0;
base.setOrig(o);
base.setDest(d);
return base;
};
QuadEdge.swap = function (e) {
var a = e.oPrev();
var b = e.sym().oPrev();
QuadEdge.splice(e, a);
QuadEdge.splice(e.sym(), b);
QuadEdge.splice(e, a.lNext());
QuadEdge.splice(e.sym(), b.lNext());
e.setOrig(a.dest());
e.setDest(b.dest());
};
QuadEdge.splice = function (a, b) {
var alpha = a.oNext().rot();
var beta = b.oNext().rot();
var t1 = b.oNext();
var t2 = a.oNext();
var t3 = beta.oNext();
var t4 = alpha.oNext();
a.setNext(t1);
b.setNext(t2);
alpha.setNext(t3);
beta.setNext(t4);
};
QuadEdge.connect = function (a, b) {
var e = QuadEdge.makeEdge(a.dest(), b.orig());
QuadEdge.splice(e, a.lNext());
QuadEdge.splice(e.sym(), b);
return e;
};
/***/ }),
/* 167 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LastFoundQuadEdgeLocator;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__QuadEdgeLocator__ = __webpack_require__(370);
function LastFoundQuadEdgeLocator() {
this._subdiv = null;
this._lastEdge = null;
let subdiv = arguments[0];
this._subdiv = subdiv;
this.init();
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(LastFoundQuadEdgeLocator.prototype, {
init: function () {
this._lastEdge = this.findEdge();
},
locate: function (v) {
if (!this._lastEdge.isLive()) {
this.init();
}
var e = this._subdiv.locateFromEdge(v, this._lastEdge);
this._lastEdge = e;
return e;
},
findEdge: function () {
var edges = this._subdiv.getEdges();
return edges.iterator().next();
},
interfaces_: function () {
return [__WEBPACK_IMPORTED_MODULE_1__QuadEdgeLocator__["a" /* default */]];
},
getClass: function () {
return LastFoundQuadEdgeLocator;
}
});
/***/ }),
/* 168 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = Segment;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__ = __webpack_require__(14);
function Segment() {
this._ls = null;
this._data = null;
if (arguments.length === 2) {
let p0 = arguments[0], p1 = arguments[1];
this._ls = new __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__["a" /* default */](p0, p1);
} else if (arguments.length === 3) {
let p0 = arguments[0], p1 = arguments[1], data = arguments[2];
this._ls = new __WEBPACK_IMPORTED_MODULE_2__geom_LineSegment__["a" /* default */](p0, p1);
this._data = data;
} else if (arguments.length === 6) {
let x1 = arguments[0], y1 = arguments[1], z1 = arguments[2], x2 = arguments[3], y2 = arguments[4], z2 = arguments[5];
Segment.call(this, new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](x1, y1, z1), new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](x2, y2, z2));
} else if (arguments.length === 7) {
let x1 = arguments[0], y1 = arguments[1], z1 = arguments[2], x2 = arguments[3], y2 = arguments[4], z2 = arguments[5], data = arguments[6];
Segment.call(this, new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](x1, y1, z1), new __WEBPACK_IMPORTED_MODULE_0__geom_Coordinate__["a" /* default */](x2, y2, z2), data);
}
}
Object(__WEBPACK_IMPORTED_MODULE_1__extend__["a" /* default */])(Segment.prototype, {
getLineSegment: function () {
return this._ls;
},
getEndZ: function () {
var p = this._ls.getCoordinate(1);
return p.z;
},
getStartZ: function () {
var p = this._ls.getCoordinate(0);
return p.z;
},
intersection: function (s) {
return this._ls.intersection(s.getLineSegment());
},
getStart: function () {
return this._ls.getCoordinate(0);
},
getEnd: function () {
return this._ls.getCoordinate(1);
},
getEndY: function () {
var p = this._ls.getCoordinate(1);
return p.y;
},
getStartX: function () {
var p = this._ls.getCoordinate(0);
return p.x;
},
equalsTopo: function (s) {
return this._ls.equalsTopo(s.getLineSegment());
},
getStartY: function () {
var p = this._ls.getCoordinate(0);
return p.y;
},
setData: function (data) {
this._data = data;
},
getData: function () {
return this._data;
},
getEndX: function () {
var p = this._ls.getCoordinate(1);
return p.x;
},
toString: function () {
return this._ls.toString();
},
interfaces_: function () {
return [];
},
getClass: function () {
return Segment;
}
});
/***/ }),
/* 169 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LocationIndexedLine;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__LinearLocation__ = __webpack_require__(85);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__LocationIndexOfPoint__ = __webpack_require__(170);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__LocationIndexOfLine__ = __webpack_require__(171);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ExtractLineByLocation__ = __webpack_require__(172);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__geom_MultiLineString__ = __webpack_require__(28);
function LocationIndexedLine() {
this._linearGeom = null;
let linearGeom = arguments[0];
this._linearGeom = linearGeom;
this.checkGeometryType();
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(LocationIndexedLine.prototype, {
clampIndex: function (index) {
var loc = index.clone();
loc.clamp(this._linearGeom);
return loc;
},
project: function (pt) {
return __WEBPACK_IMPORTED_MODULE_4__LocationIndexOfPoint__["a" /* default */].indexOf(this._linearGeom, pt);
},
checkGeometryType: function () {
if (!(this._linearGeom instanceof __WEBPACK_IMPORTED_MODULE_0__geom_LineString__["a" /* default */] || this._linearGeom instanceof __WEBPACK_IMPORTED_MODULE_7__geom_MultiLineString__["a" /* default */])) throw new __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]("Input geometry must be linear");
},
extractPoint: function () {
if (arguments.length === 1) {
let index = arguments[0];
return index.getCoordinate(this._linearGeom);
} else if (arguments.length === 2) {
let index = arguments[0], offsetDistance = arguments[1];
var indexLow = index.toLowest(this._linearGeom);
return indexLow.getSegment(this._linearGeom).pointAlongOffset(indexLow.getSegmentFraction(), offsetDistance);
}
},
isValidIndex: function (index) {
return index.isValid(this._linearGeom);
},
getEndIndex: function () {
return __WEBPACK_IMPORTED_MODULE_2__LinearLocation__["a" /* default */].getEndLocation(this._linearGeom);
},
getStartIndex: function () {
return new __WEBPACK_IMPORTED_MODULE_2__LinearLocation__["a" /* default */]();
},
indexOfAfter: function (pt, minIndex) {
return __WEBPACK_IMPORTED_MODULE_4__LocationIndexOfPoint__["a" /* default */].indexOfAfter(this._linearGeom, pt, minIndex);
},
extractLine: function (startIndex, endIndex) {
return __WEBPACK_IMPORTED_MODULE_6__ExtractLineByLocation__["a" /* default */].extract(this._linearGeom, startIndex, endIndex);
},
indexOf: function (pt) {
return __WEBPACK_IMPORTED_MODULE_4__LocationIndexOfPoint__["a" /* default */].indexOf(this._linearGeom, pt);
},
indicesOf: function (subLine) {
return __WEBPACK_IMPORTED_MODULE_5__LocationIndexOfLine__["a" /* default */].indicesOf(this._linearGeom, subLine);
},
interfaces_: function () {
return [];
},
getClass: function () {
return LocationIndexedLine;
}
});
/***/ }),
/* 170 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LocationIndexOfPoint;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LinearIterator__ = __webpack_require__(69);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__LinearLocation__ = __webpack_require__(85);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__geom_LineSegment__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_Assert__ = __webpack_require__(4);
function LocationIndexOfPoint() {
this._linearGeom = null;
let linearGeom = arguments[0];
this._linearGeom = linearGeom;
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(LocationIndexOfPoint.prototype, {
indexOf: function (inputPt) {
return this.indexOfFromStart(inputPt, null);
},
indexOfFromStart: function (inputPt, minIndex) {
var minDistance = __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].MAX_VALUE;
var minComponentIndex = 0;
var minSegmentIndex = 0;
var minFrac = -1.0;
var seg = new __WEBPACK_IMPORTED_MODULE_4__geom_LineSegment__["a" /* default */]();
for (var it = new __WEBPACK_IMPORTED_MODULE_0__LinearIterator__["a" /* default */](this._linearGeom); it.hasNext(); it.next()) {
if (!it.isEndOfLine()) {
seg.p0 = it.getSegmentStart();
seg.p1 = it.getSegmentEnd();
var segDistance = seg.distance(inputPt);
var segFrac = seg.segmentFraction(inputPt);
var candidateComponentIndex = it.getComponentIndex();
var candidateSegmentIndex = it.getVertexIndex();
if (segDistance < minDistance) {
if (minIndex === null || minIndex.compareLocationValues(candidateComponentIndex, candidateSegmentIndex, segFrac) < 0) {
minComponentIndex = candidateComponentIndex;
minSegmentIndex = candidateSegmentIndex;
minFrac = segFrac;
minDistance = segDistance;
}
}
}
}
if (minDistance === __WEBPACK_IMPORTED_MODULE_2__java_lang_Double__["a" /* default */].MAX_VALUE) {
return new __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */](minIndex);
}
var loc = new __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */](minComponentIndex, minSegmentIndex, minFrac);
return loc;
},
indexOfAfter: function (inputPt, minIndex) {
if (minIndex === null) return this.indexOf(inputPt);
var endLoc = __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */].getEndLocation(this._linearGeom);
if (endLoc.compareTo(minIndex) <= 0) return endLoc;
var closestAfter = this.indexOfFromStart(inputPt, minIndex);
__WEBPACK_IMPORTED_MODULE_5__util_Assert__["a" /* default */].isTrue(closestAfter.compareTo(minIndex) >= 0, "computed location is before specified minimum location");
return closestAfter;
},
interfaces_: function () {
return [];
},
getClass: function () {
return LocationIndexOfPoint;
}
});
LocationIndexOfPoint.indexOf = function (linearGeom, inputPt) {
var locater = new LocationIndexOfPoint(linearGeom);
return locater.indexOf(inputPt);
};
LocationIndexOfPoint.indexOfAfter = function (linearGeom, inputPt, minIndex) {
var locater = new LocationIndexOfPoint(linearGeom);
return locater.indexOfAfter(inputPt, minIndex);
};
/***/ }),
/* 171 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LocationIndexOfLine;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__LocationIndexOfPoint__ = __webpack_require__(170);
function LocationIndexOfLine() {
this._linearGeom = null;
let linearGeom = arguments[0];
this._linearGeom = linearGeom;
}
Object(__WEBPACK_IMPORTED_MODULE_0__extend__["a" /* default */])(LocationIndexOfLine.prototype, {
indicesOf: function (subLine) {
var startPt = subLine.getGeometryN(0).getCoordinateN(0);
var lastLine = subLine.getGeometryN(subLine.getNumGeometries() - 1);
var endPt = lastLine.getCoordinateN(lastLine.getNumPoints() - 1);
var locPt = new __WEBPACK_IMPORTED_MODULE_1__LocationIndexOfPoint__["a" /* default */](this._linearGeom);
var subLineLoc = new Array(2).fill(null);
subLineLoc[0] = locPt.indexOf(startPt);
if (subLine.getLength() === 0.0) {
subLineLoc[1] = subLineLoc[0].clone();
} else {
subLineLoc[1] = locPt.indexOfAfter(endPt, subLineLoc[0]);
}
return subLineLoc;
},
interfaces_: function () {
return [];
},
getClass: function () {
return LocationIndexOfLine;
}
});
LocationIndexOfLine.indicesOf = function (linearGeom, subLine) {
var locater = new LocationIndexOfLine(linearGeom);
return locater.indicesOf(subLine);
};
/***/ }),
/* 172 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = ExtractLineByLocation;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_LineString__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__LinearIterator__ = __webpack_require__(69);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_Assert__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__LinearGeometryBuilder__ = __webpack_require__(173);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__geom_MultiLineString__ = __webpack_require__(28);
function ExtractLineByLocation() {
this._line = null;
let line = arguments[0];
this._line = line;
}
Object(__WEBPACK_IMPORTED_MODULE_3__extend__["a" /* default */])(ExtractLineByLocation.prototype, {
computeLinear: function (start, end) {
var builder = new __WEBPACK_IMPORTED_MODULE_5__LinearGeometryBuilder__["a" /* default */](this._line.getFactory());
builder.setFixInvalidLines(true);
if (!start.isVertex()) builder.add(start.getCoordinate(this._line));
for (var it = new __WEBPACK_IMPORTED_MODULE_2__LinearIterator__["a" /* default */](this._line, start); it.hasNext(); it.next()) {
if (end.compareLocationValues(it.getComponentIndex(), it.getVertexIndex(), 0.0) < 0) break;
var pt = it.getSegmentStart();
builder.add(pt);
if (it.isEndOfLine()) builder.endLine();
}
if (!end.isVertex()) builder.add(end.getCoordinate(this._line));
return builder.getGeometry();
},
computeLine: function (start, end) {
var coordinates = this._line.getCoordinates();
var newCoordinates = new __WEBPACK_IMPORTED_MODULE_1__geom_CoordinateList__["a" /* default */]();
var startSegmentIndex = start.getSegmentIndex();
if (start.getSegmentFraction() > 0.0) startSegmentIndex += 1;
var lastSegmentIndex = end.getSegmentIndex();
if (end.getSegmentFraction() === 1.0) lastSegmentIndex += 1;
if (lastSegmentIndex >= coordinates.length) lastSegmentIndex = coordinates.length - 1;
if (!start.isVertex()) newCoordinates.add(start.getCoordinate(this._line));
for (var i = startSegmentIndex; i <= lastSegmentIndex; i++) {
newCoordinates.add(coordinates[i]);
}
if (!end.isVertex()) newCoordinates.add(end.getCoordinate(this._line));
if (newCoordinates.size() <= 0) newCoordinates.add(start.getCoordinate(this._line));
var newCoordinateArray = newCoordinates.toCoordinateArray();
if (newCoordinateArray.length <= 1) {
newCoordinateArray = [newCoordinateArray[0], newCoordinateArray[0]];
}
return this._line.getFactory().createLineString(newCoordinateArray);
},
extract: function (start, end) {
if (end.compareTo(start) < 0) {
return this.reverse(this.computeLinear(end, start));
}
return this.computeLinear(start, end);
},
reverse: function (linear) {
if (linear instanceof __WEBPACK_IMPORTED_MODULE_0__geom_LineString__["a" /* default */]) return linear.reverse();
if (linear instanceof __WEBPACK_IMPORTED_MODULE_6__geom_MultiLineString__["a" /* default */]) return linear.reverse();
__WEBPACK_IMPORTED_MODULE_4__util_Assert__["a" /* default */].shouldNeverReachHere("non-linear geometry encountered");
return null;
},
interfaces_: function () {
return [];
},
getClass: function () {
return ExtractLineByLocation;
}
});
ExtractLineByLocation.extract = function (line, start, end) {
var ls = new ExtractLineByLocation(line);
return ls.extract(start, end);
};
/***/ }),
/* 173 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LinearGeometryBuilder;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geom_CoordinateList__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__ = __webpack_require__(1);
function LinearGeometryBuilder() {
this._geomFact = null;
this._lines = new __WEBPACK_IMPORTED_MODULE_3__java_util_ArrayList__["a" /* default */]();
this._coordList = null;
this._ignoreInvalidLines = false;
this._fixInvalidLines = false;
this._lastPt = null;
let geomFact = arguments[0];
this._geomFact = geomFact;
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(LinearGeometryBuilder.prototype, {
getGeometry: function () {
this.endLine();
return this._geomFact.buildGeometry(this._lines);
},
getLastCoordinate: function () {
return this._lastPt;
},
endLine: function () {
if (this._coordList === null) {
return null;
}
if (this._ignoreInvalidLines && this._coordList.size() < 2) {
this._coordList = null;
return null;
}
var rawPts = this._coordList.toCoordinateArray();
var pts = rawPts;
if (this._fixInvalidLines) pts = this.validCoordinateSequence(rawPts);
this._coordList = null;
var line = null;
try {
line = this._geomFact.createLineString(pts);
} catch (ex) {
if (ex instanceof __WEBPACK_IMPORTED_MODULE_1__java_lang_IllegalArgumentException__["a" /* default */]) {
if (!this._ignoreInvalidLines) throw ex;
} else throw ex;
} finally {}
if (line !== null) this._lines.add(line);
},
setFixInvalidLines: function (fixInvalidLines) {
this._fixInvalidLines = fixInvalidLines;
},
add: function () {
if (arguments.length === 1) {
let pt = arguments[0];
this.add(pt, true);
} else if (arguments.length === 2) {
let pt = arguments[0], allowRepeatedPoints = arguments[1];
if (this._coordList === null) this._coordList = new __WEBPACK_IMPORTED_MODULE_0__geom_CoordinateList__["a" /* default */]();
this._coordList.add(pt, allowRepeatedPoints);
this._lastPt = pt;
}
},
setIgnoreInvalidLines: function (ignoreInvalidLines) {
this._ignoreInvalidLines = ignoreInvalidLines;
},
validCoordinateSequence: function (pts) {
if (pts.length >= 2) return pts;
var validPts = [pts[0], pts[0]];
return validPts;
},
interfaces_: function () {
return [];
},
getClass: function () {
return LinearGeometryBuilder;
}
});
/***/ }),
/* 174 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = LengthLocationMap;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LinearIterator__ = __webpack_require__(69);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__LinearLocation__ = __webpack_require__(85);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__extend__ = __webpack_require__(0);
function LengthLocationMap() {
this._linearGeom = null;
let linearGeom = arguments[0];
this._linearGeom = linearGeom;
}
Object(__WEBPACK_IMPORTED_MODULE_2__extend__["a" /* default */])(LengthLocationMap.prototype, {
getLength: function (loc) {
var totalLength = 0.0;
var it = new __WEBPACK_IMPORTED_MODULE_0__LinearIterator__["a" /* default */](this._linearGeom);
while (it.hasNext()) {
if (!it.isEndOfLine()) {
var p0 = it.getSegmentStart();
var p1 = it.getSegmentEnd();
var segLen = p1.distance(p0);
if (loc.getComponentIndex() === it.getComponentIndex() && loc.getSegmentIndex() === it.getVertexIndex()) {
return totalLength + segLen * loc.getSegmentFraction();
}
totalLength += segLen;
}
it.next();
}
return totalLength;
},
resolveHigher: function (loc) {
if (!loc.isEndpoint(this._linearGeom)) return loc;
var compIndex = loc.getComponentIndex();
if (compIndex >= this._linearGeom.getNumGeometries() - 1) return loc;
do {
compIndex++;
} while (compIndex < this._linearGeom.getNumGeometries() - 1 && this._linearGeom.getGeometryN(compIndex).getLength() === 0);
return new __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */](compIndex, 0, 0.0);
},
getLocation: function () {
if (arguments.length === 1) {
let length = arguments[0];
return this.getLocation(length, true);
} else if (arguments.length === 2) {
let length = arguments[0], resolveLower = arguments[1];
var forwardLength = length;
if (length < 0.0) {
var lineLen = this._linearGeom.getLength();
forwardLength = lineLen + length;
}
var loc = this.getLocationForward(forwardLength);
if (resolveLower) {
return loc;
}
return this.resolveHigher(loc);
}
},
getLocationForward: function (length) {
if (length <= 0.0) return new __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */]();
var totalLength = 0.0;
var it = new __WEBPACK_IMPORTED_MODULE_0__LinearIterator__["a" /* default */](this._linearGeom);
while (it.hasNext()) {
if (it.isEndOfLine()) {
if (totalLength === length) {
var compIndex = it.getComponentIndex();
var segIndex = it.getVertexIndex();
return new __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */](compIndex, segIndex, 0.0);
}
} else {
var p0 = it.getSegmentStart();
var p1 = it.getSegmentEnd();
var segLen = p1.distance(p0);
if (totalLength + segLen > length) {
var frac = (length - totalLength) / segLen;
var compIndex = it.getComponentIndex();
var segIndex = it.getVertexIndex();
return new __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */](compIndex, segIndex, frac);
}
totalLength += segLen;
}
it.next();
}
return __WEBPACK_IMPORTED_MODULE_1__LinearLocation__["a" /* default */].getEndLocation(this._linearGeom);
},
interfaces_: function () {
return [];
},
getClass: function () {
return LengthLocationMap;
}
});
LengthLocationMap.getLength = function (linearGeom, loc) {
var locater = new LengthLocationMap(linearGeom);
return locater.getLength(loc);
};
LengthLocationMap.getLocation = function () {
if (arguments.length === 2) {
let linearGeom = arguments[0], length = arguments[1];
var locater = new LengthLocationMap(linearGeom);
return locater.getLocation(length);
} else if (arguments.length === 3) {
let linearGeom = arguments[0], length = arguments[1], resolveLower = arguments[2];
var locater = new LengthLocationMap(linearGeom);
return locater.getLocation(length, resolveLower);
}
};
/***/ }),
/* 175 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(176);
__webpack_require__(384);
module.exports = __webpack_require__(387);
/***/ }),
/* 176 */
/***/ (function(module, exports, __webpack_require__) {
var L, _, booleanPointOnLine, turf, turfBooleanOverlap, turfMeta, turfUnion,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
L = __webpack_require__(110);
_ = __webpack_require__(177);
turf = __webpack_require__(70);
turfMeta = __webpack_require__(178);
turfBooleanOverlap = __webpack_require__(179);
turfUnion = __webpack_require__(203);
booleanPointOnLine = __webpack_require__(381);
__webpack_require__(383);
L.Merging = {};
L.Merging = {};
L.Merging.Event = {};
L.Merging.Event.START = "merge:start";
L.Merging.Event.STOP = "merge:stop";
L.Merging.Event.SELECT = "merge:select";
L.Merging.Event.UNSELECT = "merge:unselect";
L.Merging.Event.MERGED = "merge:merged";
L.Merge = (function(superClass) {
extend(Merge, superClass);
Merge.TYPE = 'merge';
function Merge(map, options) {
this.type = this.constructor.TYPE;
this._map = map;
Merge.__super__.constructor.call(this, map);
this.options = _.merge(this.options, options);
this._featureGroup = options.featureGroup;
this._availableLayers = new L.FeatureGroup;
this._activeLayer = void 0;
this._uneditedLayerProps = [];
if (!(this._featureGroup instanceof L.FeatureGroup)) {
throw new Error('options.featureGroup must be a L.FeatureGroup');
}
}
Merge.prototype.enable = function() {
var poly, poly2;
if (this._enabled || !this._featureGroup.getLayers().length) {
return;
}
this.fire('enabled', {
handler: this.type
});
this._map.fire(L.Merging.Event.START, {
handler: this.type
});
Merge.__super__.enable.apply(this, arguments);
this._availableLayers.on('layeradd', this._enableLayer, this);
this._availableLayers.on('layerremove', this._disableLayer, this);
this._featureGroup.on('layeradd', this.refreshAvailableLayers, this);
this._featureGroup.on('layerremove', this.refreshAvailableLayers, this);
poly = new L.Polygon([[[45.824114, -0.796735], [45.824244, -0.796029], [45.824409, -0.795145], [45.824509, -0.794611], [45.824811, -0.795321], [45.824579, -0.79664], [45.824114, -0.796735]]]);
this._featureGroup.addData(poly.toGeoJSON());
poly2 = new L.Polygon([[[45.824483, -0.794565], [45.824308, -0.794476], [45.82399, -0.794315], [45.82394, -0.79429], [45.823719, -0.794154], [45.82434, -0.793379], [45.824728, -0.793706], [45.824483, -0.794565]]]);
this._featureGroup.addData(poly2.toGeoJSON());
this._map.on(L.Merging.Event.SELECT, this._mergeMode, this);
return this._map.on('zoomend moveend', (function(_this) {
return function() {
return _this.refreshAvailableLayers();
};
})(this));
};
Merge.prototype.disable = function() {
if (!this._enabled) {
return;
}
this._availableLayers.off('layeradd', this._enableLayer, this);
this._availableLayers.off('layerremove', this._disableLayer, this);
Merge.__super__.disable.apply(this, arguments);
this._map.fire(L.Merging.Event.STOP, {
handler: this.type
});
this._map.off(L.Merging.Event.SELECT, this._startCutDrawing, this);
this.fire('disabled', {
handler: this.type
});
};
Merge.prototype.addHooks = function() {
this.refreshAvailableLayers();
return this._availableLayers.eachLayer(this._enableLayer, this);
};
Merge.prototype.refreshAvailableLayers = function() {
var addList, l, len, len1, m, n, newLayers, removeList, results;
if (!this._featureGroup.getLayers().length) {
return;
}
if (typeof this._featureGroup.search === 'function') {
newLayers = new L.LayerGroup(this._featureGroup.search(this._map.getBounds()));
removeList = this._availableLayers.getLayers().filter(function(layer) {
return !newLayers.hasLayer(layer);
});
if (removeList.length) {
for (m = 0, len = removeList.length; m < len; m++) {
l = removeList[m];
this._availableLayers.removeLayer(l);
}
}
addList = newLayers.getLayers().filter((function(_this) {
return function(layer) {
return !_this._availableLayers.hasLayer(layer);
};
})(this));
if (addList.length) {
results = [];
for (n = 0, len1 = addList.length; n < len1; n++) {
l = addList[n];
results.push(this._availableLayers.addLayer(l));
}
return results;
}
} else {
return this._availableLayers = this._featureGroup;
}
};
Merge.prototype.removeHooks = function() {
return this._featureGroup.eachLayer(this._disableLayer, this);
};
Merge.prototype.save = function() {
this._featureGroup.eachLayer((function(_this) {
return function(l) {
return _this._map.removeLayer(l);
};
})(this));
this._featureGroup.addLayer(this._activeLayer._poly);
this._featureGroup.addTo(this._map);
delete this._activeLayer._poly;
delete this._activeLayer;
};
Merge.prototype._enableLayer = function(e) {
var layer, pathOptions;
layer = e.layer || e.target || e;
layer.options.original = L.extend({}, layer.options);
if (this.options.disabledPathOptions) {
pathOptions = L.Util.extend({}, this.options.disabledPathOptions);
if (pathOptions.maintainColor) {
pathOptions.color = layer.options.color;
pathOptions.fillColor = layer.options.fillColor;
}
layer.options.disabled = pathOptions;
}
if (this.options.selectedPathOptions) {
pathOptions = L.Util.extend({}, this.options.selectedPathOptions);
if (pathOptions.maintainColor) {
pathOptions.color = layer.options.color;
pathOptions.fillColor = layer.options.fillColor;
}
layer.options.selected = pathOptions;
}
layer.setStyle(layer.options.disabled);
layer.bindPopup("stamp" + L.stamp(layer));
return layer.on('click', this._activate, this);
};
Merge.prototype._unselectLayer = function(e) {
var layer;
layer = e.layer || e.target || e;
layer.selected = false;
if (this.options.selectedPathOptions) {
layer.setStyle(layer.options.disabled);
}
return this._activeLayer = null;
};
Merge.prototype._disableLayer = function(e) {
var layer;
layer = e.layer || e.target || e;
layer.selected = false;
if (this.options.selectedPathOptions) {
layer.setStyle(layer.options.original);
}
delete layer.options.disabled;
delete layer.options.selected;
return delete layer.options.original;
};
Merge.prototype._activate = function(e) {
var layer;
layer = e.target || e.layer || e;
if (!layer.selected) {
layer.selected = true;
layer.setStyle(layer.options.selected);
if (this._activeLayer) {
this._unselectLayer(this._activeLayer);
}
this._activeLayer = layer;
return this._map.fire(L.Merging.Event.SELECT, {
layer: this._activeLayer
});
} else {
layer.selected = false;
layer.setStyle(layer.options.disabled);
this._activeLayer = null;
return this._map.fire(L.Merging.Event.UNSELECT, {
layer: layer
});
}
};
Merge.prototype._mergeMode = function() {
var i, k;
i = 0;
k = 0;
return this._availableLayers.eachLayer((function(_this) {
return function(layer) {
var activePoly, closest, coord, coord2, j, len, m, outerRing, overlap, point, poly3, pt, ref, turfCoords, turfLayer, turfPoly, union;
if (L.stamp(layer) !== L.stamp(_this._activeLayer) && k === 0) {
console.error("try:", L.stamp(layer));
activePoly = _this._activeLayer.toTurfFeature();
turfLayer = layer.toTurfFeature();
console.error(activePoly, turfLayer);
overlap = turfBooleanOverlap(activePoly, turfLayer);
console.error(overlap);
if (overlap) {
console.error(turfLayer.geometry.coordinates);
outerRing = _this._activeLayer.outerRingAsTurfLineString();
j = 0;
turfCoords = [];
ref = turfLayer.geometry.coordinates[0];
for (m = 0, len = ref.length; m < len; m++) {
coord = ref[m];
closest = void 0;
coord2 = void 0;
if (j === 1 || j === 2) {
closest = L.GeometryUtil.closest(_this._map, _this._activeLayer, L.latLng(coord[1], coord[0]));
console.error("closest:", closest);
}
if (closest) {
coord2 = [closest.lng, closest.lat];
console.error('prev: ', coord, 'next:', coord2);
console.error('retest', L.GeometryUtil.closest(_this._map, _this._activeLayer, L.latLng(coord2[1], coord2[0])));
}
if (coord2) {
point = turf.point(coord2);
pt = L.latLng(coord2[1], coord2[0]);
turfCoords.push(coord2);
} else {
point = turf.point(coord);
pt = L.latLng(coord[1], coord[0]);
turfCoords.push(coord);
}
console.error(point);
L.marker(pt).addTo(_this._map);
console.error('on the line:', booleanPointOnLine["default"](point, outerRing));
j++;
}
turfPoly = turf.polygon([turfCoords]);
console.error(turfPoly);
union = turfUnion["default"](activePoly, turfPoly);
poly3 = new L.Polygon([], {
color: 'red'
});
console.error(union);
poly3.fromTurfFeature(union);
poly3.addTo(_this._map);
k = 1;
}
return i++;
}
};
})(this));
};
Merge.prototype._merge = (function() {});
Merge.prototype._hasAvailableLayers = function() {
return this._availableLayers.getLayers().length !== 0;
};
return Merge;
})(L.Handler);
L.Merge.include(L.Mixin.Events);
/***/ }),
/* 177 */
/***/ (function(module, exports) {
module.exports = _;
/***/ }),
/* 178 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["coordEach"] = coordEach;
/* harmony export (immutable) */ __webpack_exports__["coordReduce"] = coordReduce;
/* harmony export (immutable) */ __webpack_exports__["propEach"] = propEach;
/* harmony export (immutable) */ __webpack_exports__["propReduce"] = propReduce;
/* harmony export (immutable) */ __webpack_exports__["featureEach"] = featureEach;
/* harmony export (immutable) */ __webpack_exports__["featureReduce"] = featureReduce;
/* harmony export (immutable) */ __webpack_exports__["coordAll"] = coordAll;
/* harmony export (immutable) */ __webpack_exports__["geomEach"] = geomEach;
/* harmony export (immutable) */ __webpack_exports__["geomReduce"] = geomReduce;
/* harmony export (immutable) */ __webpack_exports__["flattenEach"] = flattenEach;
/* harmony export (immutable) */ __webpack_exports__["flattenReduce"] = flattenReduce;
/* harmony export (immutable) */ __webpack_exports__["segmentEach"] = segmentEach;
/* harmony export (immutable) */ __webpack_exports__["segmentReduce"] = segmentReduce;
/* harmony export (immutable) */ __webpack_exports__["lineEach"] = lineEach;
/* harmony export (immutable) */ __webpack_exports__["lineReduce"] = lineReduce;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__turf_helpers__ = __webpack_require__(70);
/**
* Callback for coordEach
*
* @callback coordEachCallback
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
*
* @name coordEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* });
*/
function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON
if (geojson === null) return;
var featureIndex, geometryIndex, j, k, l, geometry, stopG, coords,
geometryMaybeCollection,
wrapShrink = 0,
coordIndex = 0,
isGeometryCollection,
type = geojson.type,
isFeatureCollection = type === 'FeatureCollection',
isFeature = type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (featureIndex = 0; featureIndex < stop; featureIndex++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
(isFeature ? geojson.geometry : geojson));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;
// Handles null Geometry -- Skips this geometry
if (geometry === null) continue;
coords = geometry.coordinates;
var geomType = geometry.type;
wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;
switch (geomType) {
case null:
break;
case 'Point':
callback(coords, coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
break;
case 'LineString':
case 'MultiPoint':
for (j = 0; j < coords.length; j++) {
callback(coords[j], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
callback(coords[j][k][l], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
featureSubIndex++;
}
break;
case 'GeometryCollection':
for (j = 0; j < geometry.geometries.length; j++)
coordEach(geometry.geometries[j], callback, excludeWrapCoord);
break;
default:
throw new Error('Unknown Geometry Type');
}
}
}
}
/**
* Callback for coordReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback coordReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Reduce coordinates in any GeoJSON object, similar to Array.reduce()
*
* @name coordReduce
* @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* return currentCoord;
* });
*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;
coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex);
}, excludeWrapCoord);
return previousValue;
}
/**
* Callback for propEach
*
* @callback propEachCallback
* @param {Object} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over properties in any GeoJSON object, similar to Array.forEach()
*
* @name propEach
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentProperties, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propEach(features, function (currentProperties, featureIndex) {
* //=currentProperties
* //=featureIndex
* });
*/
function propEach(geojson, callback) {
var i;
switch (geojson.type) {
case 'FeatureCollection':
for (i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i].properties, i);
}
break;
case 'Feature':
callback(geojson.properties, 0);
break;
}
}
/**
* Callback for propReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback propReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {*} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce properties in any GeoJSON object into a single value,
* similar to how Array.reduce works. However, in this case we lazily run
* the reduction, so an array of all properties is unnecessary.
*
* @name propReduce
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
* //=previousValue
* //=currentProperties
* //=featureIndex
* return currentProperties
* });
*/
function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
propEach(geojson, function (currentProperties, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
else previousValue = callback(previousValue, currentProperties, featureIndex);
});
return previousValue;
}
/**
* Callback for featureEach
*
* @callback featureEachCallback
* @param {Feature} currentFeature The current feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over features in any GeoJSON object, similar to
* Array.forEach.
*
* @name featureEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.featureEach(features, function (currentFeature, featureIndex) {
* //=currentFeature
* //=featureIndex
* });
*/
function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {
callback(geojson, 0);
} else if (geojson.type === 'FeatureCollection') {
for (var i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i], i);
}
}
}
/**
* Callback for featureReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback featureReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name featureReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* return currentFeature
* });
*/
function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
featureEach(geojson, function (currentFeature, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex);
});
return previousValue;
}
/**
* Get all coordinates from any GeoJSON object.
*
* @name coordAll
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @returns {Array>} coordinate position array
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* var coords = turf.coordAll(features);
* //= [[26, 37], [36, 53]]
*/
function coordAll(geojson) {
var coords = [];
coordEach(geojson, function (coord) {
coords.push(coord);
});
return coords;
}
/**
* Callback for geomEach
*
* @callback geomEachCallback
* @param {Geometry} currentGeometry The current geometry being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} featureProperties The current feature properties being processed.
* @param {Array} featureBBox The current feature BBox being processed.
* @param {number|string} featureId The current feature Id being processed.
*/
/**
* Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
*
* @name geomEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentGeometry, featureIndex, currentProperties)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomEach(features, function (currentGeometry, featureIndex, currentProperties) {
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* });
*/
function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,
geometryMaybeCollection,
isGeometryCollection,
featureProperties,
featureBBox,
featureId,
featureIndex = 0,
isFeatureCollection = geojson.type === 'FeatureCollection',
isFeature = geojson.type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (i = 0; i < stop; i++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
(isFeature ? geojson.geometry : geojson));
featureProperties = (isFeatureCollection ? geojson.features[i].properties :
(isFeature ? geojson.properties : {}));
featureBBox = (isFeatureCollection ? geojson.features[i].bbox :
(isFeature ? geojson.bbox : undefined));
featureId = (isFeatureCollection ? geojson.features[i].id :
(isFeature ? geojson.id : undefined));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (g = 0; g < stopG; g++) {
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
// Handle null Geometry
if (geometry === null) {
callback(null, featureIndex, featureProperties, featureBBox, featureId);
continue;
}
switch (geometry.type) {
case 'Point':
case 'LineString':
case 'MultiPoint':
case 'Polygon':
case 'MultiLineString':
case 'MultiPolygon': {
callback(geometry, featureIndex, featureProperties, featureBBox, featureId);
break;
}
case 'GeometryCollection': {
for (j = 0; j < geometry.geometries.length; j++) {
callback(geometry.geometries[j], featureIndex, featureProperties, featureBBox, featureId);
}
break;
}
default:
throw new Error('Unknown Geometry Type');
}
}
// Only increase `featureIndex` per each feature
featureIndex++;
}
}
/**
* Callback for geomReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback geomReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Geometry} currentGeometry The current Feature being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} currentProperties The current feature properties being processed.
*/
/**
* Reduce geometry in any GeoJSON object, similar to Array.reduce().
*
* @name geomReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, currentProperties) {
* //=previousValue
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* return currentGeometry
* });
*/
function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
else previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties);
});
return previousValue;
}
/**
* Callback for flattenEach
*
* @callback flattenEachCallback
* @param {Feature} currentFeature The current flattened feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Iterate over flattened features in any GeoJSON object, similar to
* Array.forEach.
*
* @name flattenEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex, featureSubIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenEach(features, function (currentFeature, featureIndex, featureSubIndex) {
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* });
*/
function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties, bbox, id) {
// Callback for single geometry
var type = (geometry === null) ? null : geometry.type;
switch (type) {
case null:
case 'Point':
case 'LineString':
case 'Polygon':
callback(Object(__WEBPACK_IMPORTED_MODULE_0__turf_helpers__["feature"])(geometry, properties, bbox, id), featureIndex, 0);
return;
}
var geomType;
// Callback for multi-geometry
switch (type) {
case 'MultiPoint':
geomType = 'Point';
break;
case 'MultiLineString':
geomType = 'LineString';
break;
case 'MultiPolygon':
geomType = 'Polygon';
break;
}
geometry.coordinates.forEach(function (coordinate, featureSubIndex) {
var geom = {
type: geomType,
coordinates: coordinate
};
callback(Object(__WEBPACK_IMPORTED_MODULE_0__turf_helpers__["feature"])(geom, properties), featureIndex, featureSubIndex);
});
});
}
/**
* Callback for flattenReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback flattenReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Reduce flattened features in any GeoJSON object, similar to Array.reduce().
*
* @name flattenReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* return currentFeature
* });
*/
function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {
if (featureIndex === 0 && featureSubIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex, featureSubIndex);
});
return previousValue;
}
/**
* Callback for segmentEach
*
* @callback segmentEachCallback
* @param {Feature} currentSegment The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}
*/
/**
* Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (currentSegment, featureIndex, featureSubIndex)
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentIndex
* });
*
* // Calculate the total number of segments
* var total = 0;
* turf.segmentEach(polygon, function () {
* total++;
* });
*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;
// Generate 2-vertex line segments
coordReduce(feature, function (previousCoords, currentCoord) {
var currentSegment = Object(__WEBPACK_IMPORTED_MODULE_0__turf_helpers__["lineString"])([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;
});
});
}
/**
* Callback for segmentReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback segmentReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} [currentSegment] The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/
/**
* Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= previousSegment
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentInex
* return currentSegment
* });
*
* // Calculate the total number of segments
* var initialValue = 0
* var total = turf.segmentReduce(polygon, function (previousValue) {
* previousValue++;
* return previousValue;
* }, initialValue);
*/
function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});
return previousValue;
}
/**
* Callback for lineEach
*
* @callback lineEachCallback
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} featureIndex The feature index of the current element being processed in the array, starts at index 0.
* @param {number} featureSubIndex The feature sub-index of the current line being processed at index 0
* @param {number} lineIndex The current line being processed at index 0
*/
/**
* Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
* similar to Array.forEach.
*
* @name lineEach
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (currentLine, featureIndex, featureSubIndex, lineIndex)
* @example
* var multiLine = turf.multiLineString([
* [[26, 37], [35, 45]],
* [[36, 53], [38, 50], [41, 55]]
* ]);
*
* turf.lineEach(multiLine, function (currentLine, featureIndex, featureSubIndex, lineIndex) {
* //=currentLine
* //=featureIndex
* //=featureSubIndex
* //=lineIndex
* });
*/
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
if (feature.geometry === null) return;
var type = feature.geometry.type;
var coords = feature.geometry.coordinates;
switch (type) {
case 'LineString':
callback(feature, featureIndex, featureSubIndex, 0);
break;
case 'Polygon':
for (var lineIndex = 0; lineIndex < coords.length; lineIndex++) {
callback(Object(__WEBPACK_IMPORTED_MODULE_0__turf_helpers__["lineString"])(coords[lineIndex], feature.properties), featureIndex, featureSubIndex, lineIndex);
}
break;
}
});
}
/**
* Callback for lineReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback lineReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} featureIndex The feature index of the current element being processed in the array, starts at index 0.
* @param {number} featureSubIndex The feature sub-index of the current line being processed at index 0
* @param {number} lineIndex The current line being processed at index 0
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name lineReduce
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var mtp = turf.multiPolygon([
* turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
* turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
* ]);
*
* turf.lineReduce(mtp, function (previousValue, currentLine, featureIndex, featureSubIndex, lineIndex) {
* //=previousValue
* //=currentLine
* //=featureIndex
* //=featureSubIndex
* //=lineIndex
* return currentLine
* }, 2);
*/
function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
lineEach(geojson, function (currentLine, featureIndex, featureSubIndex, lineIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, featureIndex, featureSubIndex, lineIndex);
});
return previousValue;
}
/***/ }),
/* 179 */
/***/ (function(module, exports, __webpack_require__) {
var meta = __webpack_require__(180);
var invariant = __webpack_require__(32);
var lineOverlap = __webpack_require__(181);
var lineIntersect = __webpack_require__(114);
var GeojsonEquality = __webpack_require__(202);
var coordAll = meta.coordAll;
var segmentEach = meta.segmentEach;
var getGeomType = invariant.getGeomType;
/**
* Compares two geometries of the same dimension and returns true if their intersection set results in a geometry
* different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString,
* Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.
*
* @name booleanOverlap
* @param {Geometry|Feature} feature1 input
* @param {Geometry|Feature} feature2 input
* @returns {boolean} true/false
* @example
* var poly1 = turf.polygon([[[0,0],[0,5],[5,5],[5,0],[0,0]]]);
* var poly2 = turf.polygon([[[1,1],[1,6],[6,6],[6,1],[1,1]]]);
* var poly3 = turf.polygon([[[10,10],[10,15],[15,15],[15,10],[10,10]]]);
*
* turf.booleanOverlap(poly1, poly2)
* //=true
* turf.booleanOverlap(poly2, poly3)
* //=false
*/
module.exports = function (feature1, feature2) {
// validation
if (!feature1) throw new Error('feature1 is required');
if (!feature2) throw new Error('feature2 is required');
var type1 = getGeomType(feature1);
var type2 = getGeomType(feature2);
if (type1 !== type2) throw new Error('features must be of the same type');
if (type1 === 'Point') throw new Error('Point geometry not supported');
// features must be not equal
var equality = new GeojsonEquality({precision: 6});
if (equality.compare(feature1, feature2)) return false;
var overlap = 0;
switch (type1) {
case 'MultiPoint':
var coords1 = coordAll(feature1);
var coords2 = coordAll(feature2);
coords1.forEach(function (coord1) {
coords2.forEach(function (coord2) {
if (coord1[0] === coord2[0] && coord1[1] === coord2[1]) overlap++;
});
});
break;
case 'LineString':
case 'MultiLineString':
segmentEach(feature1, function (segment1) {
segmentEach(feature2, function (segment2) {
if (lineOverlap(segment1, segment2).features.length) overlap++;
});
});
break;
case 'Polygon':
case 'MultiPolygon':
segmentEach(feature1, function (segment1) {
segmentEach(feature2, function (segment2) {
if (lineIntersect(segment1, segment2).features.length) overlap++;
});
});
break;
}
return overlap > 0;
};
/***/ }),
/* 180 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["coordEach"] = coordEach;
/* harmony export (immutable) */ __webpack_exports__["coordReduce"] = coordReduce;
/* harmony export (immutable) */ __webpack_exports__["propEach"] = propEach;
/* harmony export (immutable) */ __webpack_exports__["propReduce"] = propReduce;
/* harmony export (immutable) */ __webpack_exports__["featureEach"] = featureEach;
/* harmony export (immutable) */ __webpack_exports__["featureReduce"] = featureReduce;
/* harmony export (immutable) */ __webpack_exports__["coordAll"] = coordAll;
/* harmony export (immutable) */ __webpack_exports__["geomEach"] = geomEach;
/* harmony export (immutable) */ __webpack_exports__["geomReduce"] = geomReduce;
/* harmony export (immutable) */ __webpack_exports__["flattenEach"] = flattenEach;
/* harmony export (immutable) */ __webpack_exports__["flattenReduce"] = flattenReduce;
/* harmony export (immutable) */ __webpack_exports__["segmentEach"] = segmentEach;
/* harmony export (immutable) */ __webpack_exports__["segmentReduce"] = segmentReduce;
/* harmony export (immutable) */ __webpack_exports__["feature"] = feature;
/* harmony export (immutable) */ __webpack_exports__["lineString"] = lineString;
/* harmony export (immutable) */ __webpack_exports__["lineEach"] = lineEach;
/* harmony export (immutable) */ __webpack_exports__["lineReduce"] = lineReduce;
/**
* GeoJSON BBox
*
* @private
* @typedef {[number, number, number, number]} BBox
*/
/**
* GeoJSON Id
*
* @private
* @typedef {(number|string)} Id
*/
/**
* GeoJSON FeatureCollection
*
* @private
* @typedef {Object} FeatureCollection
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {Feature[]} features
*/
/**
* GeoJSON Feature
*
* @private
* @typedef {Object} Feature
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {*} properties
* @property {Geometry} geometry
*/
/**
* GeoJSON Geometry
*
* @private
* @typedef {Object} Geometry
* @property {string} type
* @property {any[]} coordinates
*/
/**
* Callback for coordEach
*
* @callback coordEachCallback
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
*
* @name coordEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* });
*/
function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON
if (geojson === null) return;
var featureIndex, geometryIndex, j, k, l, geometry, stopG, coords,
geometryMaybeCollection,
wrapShrink = 0,
coordIndex = 0,
isGeometryCollection,
type = geojson.type,
isFeatureCollection = type === 'FeatureCollection',
isFeature = type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (featureIndex = 0; featureIndex < stop; featureIndex++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
(isFeature ? geojson.geometry : geojson));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;
// Handles null Geometry -- Skips this geometry
if (geometry === null) continue;
coords = geometry.coordinates;
var geomType = geometry.type;
wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;
switch (geomType) {
case null:
break;
case 'Point':
callback(coords, coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
break;
case 'LineString':
case 'MultiPoint':
for (j = 0; j < coords.length; j++) {
callback(coords[j], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
callback(coords[j][k][l], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
featureSubIndex++;
}
break;
case 'GeometryCollection':
for (j = 0; j < geometry.geometries.length; j++)
coordEach(geometry.geometries[j], callback, excludeWrapCoord);
break;
default:
throw new Error('Unknown Geometry Type');
}
}
}
}
/**
* Callback for coordReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback coordReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Reduce coordinates in any GeoJSON object, similar to Array.reduce()
*
* @name coordReduce
* @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* return currentCoord;
* });
*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;
coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex);
}, excludeWrapCoord);
return previousValue;
}
/**
* Callback for propEach
*
* @callback propEachCallback
* @param {Object} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over properties in any GeoJSON object, similar to Array.forEach()
*
* @name propEach
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentProperties, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propEach(features, function (currentProperties, featureIndex) {
* //=currentProperties
* //=featureIndex
* });
*/
function propEach(geojson, callback) {
var i;
switch (geojson.type) {
case 'FeatureCollection':
for (i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i].properties, i);
}
break;
case 'Feature':
callback(geojson.properties, 0);
break;
}
}
/**
* Callback for propReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback propReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {*} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce properties in any GeoJSON object into a single value,
* similar to how Array.reduce works. However, in this case we lazily run
* the reduction, so an array of all properties is unnecessary.
*
* @name propReduce
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
* //=previousValue
* //=currentProperties
* //=featureIndex
* return currentProperties
* });
*/
function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
propEach(geojson, function (currentProperties, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
else previousValue = callback(previousValue, currentProperties, featureIndex);
});
return previousValue;
}
/**
* Callback for featureEach
*
* @callback featureEachCallback
* @param {Feature} currentFeature The current feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over features in any GeoJSON object, similar to
* Array.forEach.
*
* @name featureEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.featureEach(features, function (currentFeature, featureIndex) {
* //=currentFeature
* //=featureIndex
* });
*/
function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {
callback(geojson, 0);
} else if (geojson.type === 'FeatureCollection') {
for (var i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i], i);
}
}
}
/**
* Callback for featureReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback featureReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name featureReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* return currentFeature
* });
*/
function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
featureEach(geojson, function (currentFeature, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex);
});
return previousValue;
}
/**
* Get all coordinates from any GeoJSON object.
*
* @name coordAll
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @returns {Array>} coordinate position array
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* var coords = turf.coordAll(features);
* //= [[26, 37], [36, 53]]
*/
function coordAll(geojson) {
var coords = [];
coordEach(geojson, function (coord) {
coords.push(coord);
});
return coords;
}
/**
* Callback for geomEach
*
* @callback geomEachCallback
* @param {Geometry} currentGeometry The current geometry being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} currentProperties The current feature properties being processed.
*/
/**
* Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
*
* @name geomEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentGeometry, featureIndex, currentProperties)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomEach(features, function (currentGeometry, featureIndex, currentProperties) {
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* });
*/
function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,
geometryMaybeCollection,
isGeometryCollection,
geometryProperties,
featureIndex = 0,
isFeatureCollection = geojson.type === 'FeatureCollection',
isFeature = geojson.type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (i = 0; i < stop; i++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
(isFeature ? geojson.geometry : geojson));
geometryProperties = (isFeatureCollection ? geojson.features[i].properties :
(isFeature ? geojson.properties : {}));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (g = 0; g < stopG; g++) {
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
// Handle null Geometry
if (geometry === null) {
callback(null, featureIndex, geometryProperties);
continue;
}
switch (geometry.type) {
case 'Point':
case 'LineString':
case 'MultiPoint':
case 'Polygon':
case 'MultiLineString':
case 'MultiPolygon': {
callback(geometry, featureIndex, geometryProperties);
break;
}
case 'GeometryCollection': {
for (j = 0; j < geometry.geometries.length; j++) {
callback(geometry.geometries[j], featureIndex, geometryProperties);
}
break;
}
default:
throw new Error('Unknown Geometry Type');
}
}
// Only increase `featureIndex` per each feature
featureIndex++;
}
}
/**
* Callback for geomReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback geomReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Geometry} currentGeometry The current Feature being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} currentProperties The current feature properties being processed.
*/
/**
* Reduce geometry in any GeoJSON object, similar to Array.reduce().
*
* @name geomReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, currentProperties) {
* //=previousValue
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* return currentGeometry
* });
*/
function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
else previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties);
});
return previousValue;
}
/**
* Callback for flattenEach
*
* @callback flattenEachCallback
* @param {Feature} currentFeature The current flattened feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Iterate over flattened features in any GeoJSON object, similar to
* Array.forEach.
*
* @name flattenEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex, featureSubIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenEach(features, function (currentFeature, featureIndex, featureSubIndex) {
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* });
*/
function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties) {
// Callback for single geometry
var type = (geometry === null) ? null : geometry.type;
switch (type) {
case null:
case 'Point':
case 'LineString':
case 'Polygon':
callback(feature(geometry, properties), featureIndex, 0);
return;
}
var geomType;
// Callback for multi-geometry
switch (type) {
case 'MultiPoint':
geomType = 'Point';
break;
case 'MultiLineString':
geomType = 'LineString';
break;
case 'MultiPolygon':
geomType = 'Polygon';
break;
}
geometry.coordinates.forEach(function (coordinate, featureSubIndex) {
var geom = {
type: geomType,
coordinates: coordinate
};
callback(feature(geom, properties), featureIndex, featureSubIndex);
});
});
}
/**
* Callback for flattenReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback flattenReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Reduce flattened features in any GeoJSON object, similar to Array.reduce().
*
* @name flattenReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* return currentFeature
* });
*/
function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {
if (featureIndex === 0 && featureSubIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex, featureSubIndex);
});
return previousValue;
}
/**
* Callback for segmentEach
*
* @callback segmentEachCallback
* @param {Feature} currentSegment The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}
*/
/**
* Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (currentSegment, featureIndex, featureSubIndex)
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentIndex
* });
*
* // Calculate the total number of segments
* var total = 0;
* turf.segmentEach(polygon, function () {
* total++;
* });
*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;
// Generate 2-vertex line segments
coordReduce(feature, function (previousCoords, currentCoord) {
var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;
});
});
}
/**
* Callback for segmentReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback segmentReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} [currentSegment] The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/
/**
* Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= previousSegment
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentInex
* return currentSegment
* });
*
* // Calculate the total number of segments
* var initialValue = 0
* var total = turf.segmentReduce(polygon, function (previousValue) {
* previousValue++;
* return previousValue;
* }, initialValue);
*/
function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});
return previousValue;
}
/**
* Create Feature
*
* @private
* @param {Geometry} geometry GeoJSON Geometry
* @param {Object} properties Properties
* @returns {Feature} GeoJSON Feature
*/
function feature(geometry, properties) {
if (geometry === undefined) throw new Error('No geometry passed');
return {
type: 'Feature',
properties: properties || {},
geometry: geometry
};
}
/**
* Create LineString
*
* @private
* @param {Array>} coordinates Line Coordinates
* @param {Object} properties Properties
* @returns {Feature} GeoJSON LineString Feature
*/
function lineString(coordinates, properties) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
return {
type: 'Feature',
properties: properties || {},
geometry: {
type: 'LineString',
coordinates: coordinates
}
};
}
/**
* Callback for lineEach
*
* @callback lineEachCallback
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the array, starts at index 0.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
* similar to Array.forEach.
*
* @name lineEach
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (currentLine, lineIndex, lineSubIndex)
* @example
* var mtLn = turf.multiLineString([
* turf.lineString([[26, 37], [35, 45]]),
* turf.lineString([[36, 53], [38, 50], [41, 55]])
* ]);
*
* turf.lineEach(mtLn, function (currentLine, lineIndex) {
* //=currentLine
* //=lineIndex
* });
*/
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
var type = geojson.geometry ? geojson.geometry.type : geojson.type;
if (!type) throw new Error('invalid geojson');
if (type === 'FeatureCollection') throw new Error('FeatureCollection is not supported');
if (type === 'GeometryCollection') throw new Error('GeometryCollection is not supported');
var coordinates = geojson.geometry ? geojson.geometry.coordinates : geojson.coordinates;
if (!coordinates) throw new Error('geojson must contain coordinates');
switch (type) {
case 'LineString':
callback(coordinates, 0, 0);
return;
case 'Polygon':
case 'MultiLineString':
var subIndex = 0;
for (var line = 0; line < coordinates.length; line++) {
if (type === 'MultiLineString') subIndex = line;
callback(coordinates[line], line, subIndex);
}
return;
case 'MultiPolygon':
for (var multi = 0; multi < coordinates.length; multi++) {
for (var ring = 0; ring < coordinates[multi].length; ring++) {
callback(coordinates[multi][ring], ring, multi);
}
}
return;
default:
throw new Error(type + ' geometry not supported');
}
}
/**
* Callback for lineReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback lineReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name lineReduce
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var mtp = turf.multiPolygon([
* turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
* turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
* ]);
*
* turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
* //=previousValue
* //=currentLine
* //=lineIndex
* //=lineSubIndex
* return currentLine
* }, 2);
*/
function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {
if (lineIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, lineIndex, lineSubIndex);
});
return previousValue;
}
/***/ }),
/* 181 */
/***/ (function(module, exports, __webpack_require__) {
var meta = __webpack_require__(182);
var equal = __webpack_require__(111);
var rbush = __webpack_require__(112);
var invariant = __webpack_require__(32);
var lineSegment = __webpack_require__(113);
var pointOnLine = __webpack_require__(190);
var booleanPointOnLine = __webpack_require__(200);
var featureCollection = __webpack_require__(201).featureCollection;
var getCoords = invariant.getCoords;
var featureEach = meta.featureEach;
var segmentEach = meta.segmentEach;
/**
* Takes any LineString or Polygon and returns the overlapping lines between both features.
*
* @name lineOverlap
* @param {Geometry|Feature} line1 any LineString or Polygon
* @param {Geometry|Feature} line2 any LineString or Polygon
* @param {number} [tolerance=0] Tolerance distance to match overlapping line segments (in kilometers)
* @returns {FeatureCollection} lines(s) that are overlapping between both features
* @example
* var line1 = turf.lineString([[115, -35], [125, -30], [135, -30], [145, -35]]);
* var line2 = turf.lineString([[115, -25], [125, -30], [135, -30], [145, -25]]);
*
* var overlapping = turf.lineOverlap(line1, line2);
*
* //addToMap
* var addToMap = [line1, line2, overlapping]
*/
module.exports = function (line1, line2, tolerance) {
var features = [];
tolerance = tolerance || 0;
// Create Spatial Index
var tree = rbush();
tree.load(lineSegment(line1));
var overlapSegment;
// Line Intersection
// Iterate over line segments
segmentEach(line2, function (segment) {
var doesOverlaps = false;
// Iterate over each segments which falls within the same bounds
featureEach(tree.search(segment), function (match) {
if (doesOverlaps === false) {
var coordsSegment = getCoords(segment).sort();
var coordsMatch = getCoords(match).sort();
// Segment overlaps feature
if (equal(coordsSegment, coordsMatch)) {
doesOverlaps = true;
// Overlaps already exists - only append last coordinate of segment
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
// Match segments which don't share nodes (Issue #901)
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
pointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
pointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
pointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
pointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
// Do not define (doesOverlap = true) since more matches can occur within the same segment
// doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
else overlapSegment = match;
}
}
});
// Segment doesn't overlap - add overlaps to results & reset
if (doesOverlaps === false && overlapSegment) {
features.push(overlapSegment);
overlapSegment = undefined;
}
});
// Add last segment if exists
if (overlapSegment) features.push(overlapSegment);
return featureCollection(features);
};
/**
* Concat Segment
*
* @private
* @param {Feature} line LineString
* @param {Feature} segment 2-vertex LineString
* @returns {Feature} concat linestring
*/
function concatSegment(line, segment) {
var coords = getCoords(segment);
var lineCoords = getCoords(line);
var start = lineCoords[0];
var end = lineCoords[lineCoords.length - 1];
var geom = line.geometry.coordinates;
if (equal(coords[0], start)) geom.unshift(coords[1]);
else if (equal(coords[0], end)) geom.push(coords[1]);
else if (equal(coords[1], start)) geom.unshift(coords[0]);
else if (equal(coords[1], end)) geom.push(coords[0]);
return line;
}
/***/ }),
/* 182 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["coordEach"] = coordEach;
/* harmony export (immutable) */ __webpack_exports__["coordReduce"] = coordReduce;
/* harmony export (immutable) */ __webpack_exports__["propEach"] = propEach;
/* harmony export (immutable) */ __webpack_exports__["propReduce"] = propReduce;
/* harmony export (immutable) */ __webpack_exports__["featureEach"] = featureEach;
/* harmony export (immutable) */ __webpack_exports__["featureReduce"] = featureReduce;
/* harmony export (immutable) */ __webpack_exports__["coordAll"] = coordAll;
/* harmony export (immutable) */ __webpack_exports__["geomEach"] = geomEach;
/* harmony export (immutable) */ __webpack_exports__["geomReduce"] = geomReduce;
/* harmony export (immutable) */ __webpack_exports__["flattenEach"] = flattenEach;
/* harmony export (immutable) */ __webpack_exports__["flattenReduce"] = flattenReduce;
/* harmony export (immutable) */ __webpack_exports__["segmentEach"] = segmentEach;
/* harmony export (immutable) */ __webpack_exports__["segmentReduce"] = segmentReduce;
/* harmony export (immutable) */ __webpack_exports__["feature"] = feature;
/* harmony export (immutable) */ __webpack_exports__["lineString"] = lineString;
/* harmony export (immutable) */ __webpack_exports__["lineEach"] = lineEach;
/* harmony export (immutable) */ __webpack_exports__["lineReduce"] = lineReduce;
/**
* GeoJSON BBox
*
* @private
* @typedef {[number, number, number, number]} BBox
*/
/**
* GeoJSON Id
*
* @private
* @typedef {(number|string)} Id
*/
/**
* GeoJSON FeatureCollection
*
* @private
* @typedef {Object} FeatureCollection
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {Feature[]} features
*/
/**
* GeoJSON Feature
*
* @private
* @typedef {Object} Feature
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {*} properties
* @property {Geometry} geometry
*/
/**
* GeoJSON Geometry
*
* @private
* @typedef {Object} Geometry
* @property {string} type
* @property {any[]} coordinates
*/
/**
* Callback for coordEach
*
* @callback coordEachCallback
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
*
* @name coordEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* });
*/
function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON
if (geojson === null) return;
var featureIndex, geometryIndex, j, k, l, geometry, stopG, coords,
geometryMaybeCollection,
wrapShrink = 0,
coordIndex = 0,
isGeometryCollection,
type = geojson.type,
isFeatureCollection = type === 'FeatureCollection',
isFeature = type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (featureIndex = 0; featureIndex < stop; featureIndex++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
(isFeature ? geojson.geometry : geojson));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;
// Handles null Geometry -- Skips this geometry
if (geometry === null) continue;
coords = geometry.coordinates;
var geomType = geometry.type;
wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;
switch (geomType) {
case null:
break;
case 'Point':
callback(coords, coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
break;
case 'LineString':
case 'MultiPoint':
for (j = 0; j < coords.length; j++) {
callback(coords[j], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
callback(coords[j][k][l], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
featureSubIndex++;
}
break;
case 'GeometryCollection':
for (j = 0; j < geometry.geometries.length; j++)
coordEach(geometry.geometries[j], callback, excludeWrapCoord);
break;
default:
throw new Error('Unknown Geometry Type');
}
}
}
}
/**
* Callback for coordReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback coordReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Reduce coordinates in any GeoJSON object, similar to Array.reduce()
*
* @name coordReduce
* @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* return currentCoord;
* });
*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;
coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex);
}, excludeWrapCoord);
return previousValue;
}
/**
* Callback for propEach
*
* @callback propEachCallback
* @param {Object} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over properties in any GeoJSON object, similar to Array.forEach()
*
* @name propEach
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentProperties, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propEach(features, function (currentProperties, featureIndex) {
* //=currentProperties
* //=featureIndex
* });
*/
function propEach(geojson, callback) {
var i;
switch (geojson.type) {
case 'FeatureCollection':
for (i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i].properties, i);
}
break;
case 'Feature':
callback(geojson.properties, 0);
break;
}
}
/**
* Callback for propReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback propReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {*} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce properties in any GeoJSON object into a single value,
* similar to how Array.reduce works. However, in this case we lazily run
* the reduction, so an array of all properties is unnecessary.
*
* @name propReduce
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
* //=previousValue
* //=currentProperties
* //=featureIndex
* return currentProperties
* });
*/
function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
propEach(geojson, function (currentProperties, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
else previousValue = callback(previousValue, currentProperties, featureIndex);
});
return previousValue;
}
/**
* Callback for featureEach
*
* @callback featureEachCallback
* @param {Feature} currentFeature The current feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over features in any GeoJSON object, similar to
* Array.forEach.
*
* @name featureEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.featureEach(features, function (currentFeature, featureIndex) {
* //=currentFeature
* //=featureIndex
* });
*/
function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {
callback(geojson, 0);
} else if (geojson.type === 'FeatureCollection') {
for (var i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i], i);
}
}
}
/**
* Callback for featureReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback featureReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name featureReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* return currentFeature
* });
*/
function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
featureEach(geojson, function (currentFeature, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex);
});
return previousValue;
}
/**
* Get all coordinates from any GeoJSON object.
*
* @name coordAll
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @returns {Array>} coordinate position array
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* var coords = turf.coordAll(features);
* //= [[26, 37], [36, 53]]
*/
function coordAll(geojson) {
var coords = [];
coordEach(geojson, function (coord) {
coords.push(coord);
});
return coords;
}
/**
* Callback for geomEach
*
* @callback geomEachCallback
* @param {Geometry} currentGeometry The current geometry being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} currentProperties The current feature properties being processed.
*/
/**
* Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
*
* @name geomEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentGeometry, featureIndex, currentProperties)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomEach(features, function (currentGeometry, featureIndex, currentProperties) {
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* });
*/
function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,
geometryMaybeCollection,
isGeometryCollection,
geometryProperties,
featureIndex = 0,
isFeatureCollection = geojson.type === 'FeatureCollection',
isFeature = geojson.type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (i = 0; i < stop; i++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
(isFeature ? geojson.geometry : geojson));
geometryProperties = (isFeatureCollection ? geojson.features[i].properties :
(isFeature ? geojson.properties : {}));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (g = 0; g < stopG; g++) {
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
// Handle null Geometry
if (geometry === null) {
callback(null, featureIndex, geometryProperties);
continue;
}
switch (geometry.type) {
case 'Point':
case 'LineString':
case 'MultiPoint':
case 'Polygon':
case 'MultiLineString':
case 'MultiPolygon': {
callback(geometry, featureIndex, geometryProperties);
break;
}
case 'GeometryCollection': {
for (j = 0; j < geometry.geometries.length; j++) {
callback(geometry.geometries[j], featureIndex, geometryProperties);
}
break;
}
default:
throw new Error('Unknown Geometry Type');
}
}
// Only increase `featureIndex` per each feature
featureIndex++;
}
}
/**
* Callback for geomReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback geomReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Geometry} currentGeometry The current Feature being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} currentProperties The current feature properties being processed.
*/
/**
* Reduce geometry in any GeoJSON object, similar to Array.reduce().
*
* @name geomReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, currentProperties) {
* //=previousValue
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* return currentGeometry
* });
*/
function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
else previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties);
});
return previousValue;
}
/**
* Callback for flattenEach
*
* @callback flattenEachCallback
* @param {Feature} currentFeature The current flattened feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Iterate over flattened features in any GeoJSON object, similar to
* Array.forEach.
*
* @name flattenEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex, featureSubIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenEach(features, function (currentFeature, featureIndex, featureSubIndex) {
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* });
*/
function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties) {
// Callback for single geometry
var type = (geometry === null) ? null : geometry.type;
switch (type) {
case null:
case 'Point':
case 'LineString':
case 'Polygon':
callback(feature(geometry, properties), featureIndex, 0);
return;
}
var geomType;
// Callback for multi-geometry
switch (type) {
case 'MultiPoint':
geomType = 'Point';
break;
case 'MultiLineString':
geomType = 'LineString';
break;
case 'MultiPolygon':
geomType = 'Polygon';
break;
}
geometry.coordinates.forEach(function (coordinate, featureSubIndex) {
var geom = {
type: geomType,
coordinates: coordinate
};
callback(feature(geom, properties), featureIndex, featureSubIndex);
});
});
}
/**
* Callback for flattenReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback flattenReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Reduce flattened features in any GeoJSON object, similar to Array.reduce().
*
* @name flattenReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* return currentFeature
* });
*/
function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {
if (featureIndex === 0 && featureSubIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex, featureSubIndex);
});
return previousValue;
}
/**
* Callback for segmentEach
*
* @callback segmentEachCallback
* @param {Feature} currentSegment The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}
*/
/**
* Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (currentSegment, featureIndex, featureSubIndex)
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentIndex
* });
*
* // Calculate the total number of segments
* var total = 0;
* turf.segmentEach(polygon, function () {
* total++;
* });
*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;
// Generate 2-vertex line segments
coordReduce(feature, function (previousCoords, currentCoord) {
var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;
});
});
}
/**
* Callback for segmentReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback segmentReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} [currentSegment] The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/
/**
* Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= previousSegment
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentInex
* return currentSegment
* });
*
* // Calculate the total number of segments
* var initialValue = 0
* var total = turf.segmentReduce(polygon, function (previousValue) {
* previousValue++;
* return previousValue;
* }, initialValue);
*/
function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});
return previousValue;
}
/**
* Create Feature
*
* @private
* @param {Geometry} geometry GeoJSON Geometry
* @param {Object} properties Properties
* @returns {Feature} GeoJSON Feature
*/
function feature(geometry, properties) {
if (geometry === undefined) throw new Error('No geometry passed');
return {
type: 'Feature',
properties: properties || {},
geometry: geometry
};
}
/**
* Create LineString
*
* @private
* @param {Array>} coordinates Line Coordinates
* @param {Object} properties Properties
* @returns {Feature} GeoJSON LineString Feature
*/
function lineString(coordinates, properties) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
return {
type: 'Feature',
properties: properties || {},
geometry: {
type: 'LineString',
coordinates: coordinates
}
};
}
/**
* Callback for lineEach
*
* @callback lineEachCallback
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the array, starts at index 0.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
* similar to Array.forEach.
*
* @name lineEach
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (currentLine, lineIndex, lineSubIndex)
* @example
* var mtLn = turf.multiLineString([
* turf.lineString([[26, 37], [35, 45]]),
* turf.lineString([[36, 53], [38, 50], [41, 55]])
* ]);
*
* turf.lineEach(mtLn, function (currentLine, lineIndex) {
* //=currentLine
* //=lineIndex
* });
*/
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
var type = geojson.geometry ? geojson.geometry.type : geojson.type;
if (!type) throw new Error('invalid geojson');
if (type === 'FeatureCollection') throw new Error('FeatureCollection is not supported');
if (type === 'GeometryCollection') throw new Error('GeometryCollection is not supported');
var coordinates = geojson.geometry ? geojson.geometry.coordinates : geojson.coordinates;
if (!coordinates) throw new Error('geojson must contain coordinates');
switch (type) {
case 'LineString':
callback(coordinates, 0, 0);
return;
case 'Polygon':
case 'MultiLineString':
var subIndex = 0;
for (var line = 0; line < coordinates.length; line++) {
if (type === 'MultiLineString') subIndex = line;
callback(coordinates[line], line, subIndex);
}
return;
case 'MultiPolygon':
for (var multi = 0; multi < coordinates.length; multi++) {
for (var ring = 0; ring < coordinates[multi].length; ring++) {
callback(coordinates[multi][ring], ring, multi);
}
}
return;
default:
throw new Error(type + ' geometry not supported');
}
}
/**
* Callback for lineReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback lineReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name lineReduce
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var mtp = turf.multiPolygon([
* turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
* turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
* ]);
*
* turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
* //=previousValue
* //=currentLine
* //=lineIndex
* //=lineSubIndex
* return currentLine
* }, 2);
*/
function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {
if (lineIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, lineIndex, lineSubIndex);
});
return previousValue;
}
/***/ }),
/* 183 */
/***/ (function(module, exports) {
exports = module.exports = typeof Object.keys === 'function'
? Object.keys : shim;
exports.shim = shim;
function shim (obj) {
var keys = [];
for (var key in obj) keys.push(key);
return keys;
}
/***/ }),
/* 184 */
/***/ (function(module, exports) {
var supportsArgumentsClass = (function(){
return Object.prototype.toString.call(arguments)
})() == '[object Arguments]';
exports = module.exports = supportsArgumentsClass ? supported : unsupported;
exports.supported = supported;
function supported(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
};
exports.unsupported = unsupported;
function unsupported(object){
return object &&
typeof object == 'object' &&
typeof object.length == 'number' &&
Object.prototype.hasOwnProperty.call(object, 'callee') &&
!Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
false;
};
/***/ }),
/* 185 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = rbush;
var quickselect = __webpack_require__(186);
function rbush(maxEntries, format) {
if (!(this instanceof rbush)) return new rbush(maxEntries, format);
// max entries in a node is 9 by default; min node fill is 40% for best performance
this._maxEntries = Math.max(4, maxEntries || 9);
this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
if (format) {
this._initFormat(format);
}
this.clear();
}
rbush.prototype = {
all: function () {
return this._all(this.data, []);
},
search: function (bbox) {
var node = this.data,
result = [],
toBBox = this.toBBox;
if (!intersects(bbox, node)) return result;
var nodesToSearch = [],
i, len, child, childBBox;
while (node) {
for (i = 0, len = node.children.length; i < len; i++) {
child = node.children[i];
childBBox = node.leaf ? toBBox(child) : child;
if (intersects(bbox, childBBox)) {
if (node.leaf) result.push(child);
else if (contains(bbox, childBBox)) this._all(child, result);
else nodesToSearch.push(child);
}
}
node = nodesToSearch.pop();
}
return result;
},
collides: function (bbox) {
var node = this.data,
toBBox = this.toBBox;
if (!intersects(bbox, node)) return false;
var nodesToSearch = [],
i, len, child, childBBox;
while (node) {
for (i = 0, len = node.children.length; i < len; i++) {
child = node.children[i];
childBBox = node.leaf ? toBBox(child) : child;
if (intersects(bbox, childBBox)) {
if (node.leaf || contains(bbox, childBBox)) return true;
nodesToSearch.push(child);
}
}
node = nodesToSearch.pop();
}
return false;
},
load: function (data) {
if (!(data && data.length)) return this;
if (data.length < this._minEntries) {
for (var i = 0, len = data.length; i < len; i++) {
this.insert(data[i]);
}
return this;
}
// recursively build the tree with the given data from stratch using OMT algorithm
var node = this._build(data.slice(), 0, data.length - 1, 0);
if (!this.data.children.length) {
// save as is if tree is empty
this.data = node;
} else if (this.data.height === node.height) {
// split root if trees have the same height
this._splitRoot(this.data, node);
} else {
if (this.data.height < node.height) {
// swap trees if inserted one is bigger
var tmpNode = this.data;
this.data = node;
node = tmpNode;
}
// insert the small tree into the large tree at appropriate level
this._insert(node, this.data.height - node.height - 1, true);
}
return this;
},
insert: function (item) {
if (item) this._insert(item, this.data.height - 1);
return this;
},
clear: function () {
this.data = createNode([]);
return this;
},
remove: function (item, equalsFn) {
if (!item) return this;
var node = this.data,
bbox = this.toBBox(item),
path = [],
indexes = [],
i, parent, index, goingUp;
// depth-first iterative tree traversal
while (node || path.length) {
if (!node) { // go up
node = path.pop();
parent = path[path.length - 1];
i = indexes.pop();
goingUp = true;
}
if (node.leaf) { // check current node
index = findItem(item, node.children, equalsFn);
if (index !== -1) {
// item found, remove the item and condense tree upwards
node.children.splice(index, 1);
path.push(node);
this._condense(path);
return this;
}
}
if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
path.push(node);
indexes.push(i);
i = 0;
parent = node;
node = node.children[0];
} else if (parent) { // go right
i++;
node = parent.children[i];
goingUp = false;
} else node = null; // nothing found
}
return this;
},
toBBox: function (item) { return item; },
compareMinX: compareNodeMinX,
compareMinY: compareNodeMinY,
toJSON: function () { return this.data; },
fromJSON: function (data) {
this.data = data;
return this;
},
_all: function (node, result) {
var nodesToSearch = [];
while (node) {
if (node.leaf) result.push.apply(result, node.children);
else nodesToSearch.push.apply(nodesToSearch, node.children);
node = nodesToSearch.pop();
}
return result;
},
_build: function (items, left, right, height) {
var N = right - left + 1,
M = this._maxEntries,
node;
if (N <= M) {
// reached leaf level; return leaf
node = createNode(items.slice(left, right + 1));
calcBBox(node, this.toBBox);
return node;
}
if (!height) {
// target height of the bulk-loaded tree
height = Math.ceil(Math.log(N) / Math.log(M));
// target number of root entries to maximize storage utilization
M = Math.ceil(N / Math.pow(M, height - 1));
}
node = createNode([]);
node.leaf = false;
node.height = height;
// split the items into M mostly square tiles
var N2 = Math.ceil(N / M),
N1 = N2 * Math.ceil(Math.sqrt(M)),
i, j, right2, right3;
multiSelect(items, left, right, N1, this.compareMinX);
for (i = left; i <= right; i += N1) {
right2 = Math.min(i + N1 - 1, right);
multiSelect(items, i, right2, N2, this.compareMinY);
for (j = i; j <= right2; j += N2) {
right3 = Math.min(j + N2 - 1, right2);
// pack each entry recursively
node.children.push(this._build(items, j, right3, height - 1));
}
}
calcBBox(node, this.toBBox);
return node;
},
_chooseSubtree: function (bbox, node, level, path) {
var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;
while (true) {
path.push(node);
if (node.leaf || path.length - 1 === level) break;
minArea = minEnlargement = Infinity;
for (i = 0, len = node.children.length; i < len; i++) {
child = node.children[i];
area = bboxArea(child);
enlargement = enlargedArea(bbox, child) - area;
// choose entry with the least area enlargement
if (enlargement < minEnlargement) {
minEnlargement = enlargement;
minArea = area < minArea ? area : minArea;
targetNode = child;
} else if (enlargement === minEnlargement) {
// otherwise choose one with the smallest area
if (area < minArea) {
minArea = area;
targetNode = child;
}
}
}
node = targetNode || node.children[0];
}
return node;
},
_insert: function (item, level, isNode) {
var toBBox = this.toBBox,
bbox = isNode ? item : toBBox(item),
insertPath = [];
// find the best node for accommodating the item, saving all nodes along the path too
var node = this._chooseSubtree(bbox, this.data, level, insertPath);
// put the item into the node
node.children.push(item);
extend(node, bbox);
// split on node overflow; propagate upwards if necessary
while (level >= 0) {
if (insertPath[level].children.length > this._maxEntries) {
this._split(insertPath, level);
level--;
} else break;
}
// adjust bboxes along the insertion path
this._adjustParentBBoxes(bbox, insertPath, level);
},
// split overflowed node into two
_split: function (insertPath, level) {
var node = insertPath[level],
M = node.children.length,
m = this._minEntries;
this._chooseSplitAxis(node, m, M);
var splitIndex = this._chooseSplitIndex(node, m, M);
var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
newNode.height = node.height;
newNode.leaf = node.leaf;
calcBBox(node, this.toBBox);
calcBBox(newNode, this.toBBox);
if (level) insertPath[level - 1].children.push(newNode);
else this._splitRoot(node, newNode);
},
_splitRoot: function (node, newNode) {
// split root node
this.data = createNode([node, newNode]);
this.data.height = node.height + 1;
this.data.leaf = false;
calcBBox(this.data, this.toBBox);
},
_chooseSplitIndex: function (node, m, M) {
var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
minOverlap = minArea = Infinity;
for (i = m; i <= M - m; i++) {
bbox1 = distBBox(node, 0, i, this.toBBox);
bbox2 = distBBox(node, i, M, this.toBBox);
overlap = intersectionArea(bbox1, bbox2);
area = bboxArea(bbox1) + bboxArea(bbox2);
// choose distribution with minimum overlap
if (overlap < minOverlap) {
minOverlap = overlap;
index = i;
minArea = area < minArea ? area : minArea;
} else if (overlap === minOverlap) {
// otherwise choose distribution with minimum area
if (area < minArea) {
minArea = area;
index = i;
}
}
}
return index;
},
// sorts node children by the best axis for split
_chooseSplitAxis: function (node, m, M) {
var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
xMargin = this._allDistMargin(node, m, M, compareMinX),
yMargin = this._allDistMargin(node, m, M, compareMinY);
// if total distributions margin value is minimal for x, sort by minX,
// otherwise it's already sorted by minY
if (xMargin < yMargin) node.children.sort(compareMinX);
},
// total margin of all possible split distributions where each node is at least m full
_allDistMargin: function (node, m, M, compare) {
node.children.sort(compare);
var toBBox = this.toBBox,
leftBBox = distBBox(node, 0, m, toBBox),
rightBBox = distBBox(node, M - m, M, toBBox),
margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
i, child;
for (i = m; i < M - m; i++) {
child = node.children[i];
extend(leftBBox, node.leaf ? toBBox(child) : child);
margin += bboxMargin(leftBBox);
}
for (i = M - m - 1; i >= m; i--) {
child = node.children[i];
extend(rightBBox, node.leaf ? toBBox(child) : child);
margin += bboxMargin(rightBBox);
}
return margin;
},
_adjustParentBBoxes: function (bbox, path, level) {
// adjust bboxes along the given tree path
for (var i = level; i >= 0; i--) {
extend(path[i], bbox);
}
},
_condense: function (path) {
// go through the path, removing empty nodes and updating bboxes
for (var i = path.length - 1, siblings; i >= 0; i--) {
if (path[i].children.length === 0) {
if (i > 0) {
siblings = path[i - 1].children;
siblings.splice(siblings.indexOf(path[i]), 1);
} else this.clear();
} else calcBBox(path[i], this.toBBox);
}
},
_initFormat: function (format) {
// data format (minX, minY, maxX, maxY accessors)
// uses eval-type function compilation instead of just accepting a toBBox function
// because the algorithms are very sensitive to sorting functions performance,
// so they should be dead simple and without inner calls
var compareArr = ['return a', ' - b', ';'];
this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
this.toBBox = new Function('a',
'return {minX: a' + format[0] +
', minY: a' + format[1] +
', maxX: a' + format[2] +
', maxY: a' + format[3] + '};');
}
};
function findItem(item, items, equalsFn) {
if (!equalsFn) return items.indexOf(item);
for (var i = 0; i < items.length; i++) {
if (equalsFn(item, items[i])) return i;
}
return -1;
}
// calculate node's bbox from bboxes of its children
function calcBBox(node, toBBox) {
distBBox(node, 0, node.children.length, toBBox, node);
}
// min bounding rectangle of node children from k to p-1
function distBBox(node, k, p, toBBox, destNode) {
if (!destNode) destNode = createNode(null);
destNode.minX = Infinity;
destNode.minY = Infinity;
destNode.maxX = -Infinity;
destNode.maxY = -Infinity;
for (var i = k, child; i < p; i++) {
child = node.children[i];
extend(destNode, node.leaf ? toBBox(child) : child);
}
return destNode;
}
function extend(a, b) {
a.minX = Math.min(a.minX, b.minX);
a.minY = Math.min(a.minY, b.minY);
a.maxX = Math.max(a.maxX, b.maxX);
a.maxY = Math.max(a.maxY, b.maxY);
return a;
}
function compareNodeMinX(a, b) { return a.minX - b.minX; }
function compareNodeMinY(a, b) { return a.minY - b.minY; }
function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
function enlargedArea(a, b) {
return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
(Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
}
function intersectionArea(a, b) {
var minX = Math.max(a.minX, b.minX),
minY = Math.max(a.minY, b.minY),
maxX = Math.min(a.maxX, b.maxX),
maxY = Math.min(a.maxY, b.maxY);
return Math.max(0, maxX - minX) *
Math.max(0, maxY - minY);
}
function contains(a, b) {
return a.minX <= b.minX &&
a.minY <= b.minY &&
b.maxX <= a.maxX &&
b.maxY <= a.maxY;
}
function intersects(a, b) {
return b.minX <= a.maxX &&
b.minY <= a.maxY &&
b.maxX >= a.minX &&
b.maxY >= a.minY;
}
function createNode(children) {
return {
children: children,
height: 1,
leaf: true,
minX: Infinity,
minY: Infinity,
maxX: -Infinity,
maxY: -Infinity
};
}
// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
// combines selection algorithm with binary divide & conquer approach
function multiSelect(arr, left, right, n, compare) {
var stack = [left, right],
mid;
while (stack.length) {
right = stack.pop();
left = stack.pop();
if (right - left <= n) continue;
mid = left + Math.ceil((right - left) / n / 2) * n;
quickselect(arr, mid, left, right, compare);
stack.push(left, mid, mid, right);
}
}
/***/ }),
/* 186 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = partialSort;
// Floyd-Rivest selection algorithm:
// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right];
// The k-th element will have the (k - left + 1)th smallest value in [left, right]
function partialSort(arr, k, left, right, compare) {
left = left || 0;
right = right || (arr.length - 1);
compare = compare || defaultCompare;
while (right > left) {
if (right - left > 600) {
var n = right - left + 1;
var m = k - left + 1;
var z = Math.log(n);
var s = 0.5 * Math.exp(2 * z / 3);
var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
partialSort(arr, k, newLeft, newRight, compare);
}
var t = arr[k];
var i = left;
var j = right;
swap(arr, left, k);
if (compare(arr[right], t) > 0) swap(arr, left, right);
while (i < j) {
swap(arr, i, j);
i++;
j--;
while (compare(arr[i], t) < 0) i++;
while (compare(arr[j], t) > 0) j--;
}
if (compare(arr[left], t) === 0) swap(arr, left, j);
else {
j++;
swap(arr, j, right);
}
if (j <= k) left = j + 1;
if (k <= j) right = j - 1;
}
}
function swap(arr, i, j) {
var tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
function defaultCompare(a, b) {
return a < b ? -1 : a > b ? 1 : 0;
}
/***/ }),
/* 187 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["coordEach"] = coordEach;
/* harmony export (immutable) */ __webpack_exports__["coordReduce"] = coordReduce;
/* harmony export (immutable) */ __webpack_exports__["propEach"] = propEach;
/* harmony export (immutable) */ __webpack_exports__["propReduce"] = propReduce;
/* harmony export (immutable) */ __webpack_exports__["featureEach"] = featureEach;
/* harmony export (immutable) */ __webpack_exports__["featureReduce"] = featureReduce;
/* harmony export (immutable) */ __webpack_exports__["coordAll"] = coordAll;
/* harmony export (immutable) */ __webpack_exports__["geomEach"] = geomEach;
/* harmony export (immutable) */ __webpack_exports__["geomReduce"] = geomReduce;
/* harmony export (immutable) */ __webpack_exports__["flattenEach"] = flattenEach;
/* harmony export (immutable) */ __webpack_exports__["flattenReduce"] = flattenReduce;
/* harmony export (immutable) */ __webpack_exports__["segmentEach"] = segmentEach;
/* harmony export (immutable) */ __webpack_exports__["segmentReduce"] = segmentReduce;
/* harmony export (immutable) */ __webpack_exports__["feature"] = feature;
/* harmony export (immutable) */ __webpack_exports__["lineString"] = lineString;
/* harmony export (immutable) */ __webpack_exports__["lineEach"] = lineEach;
/* harmony export (immutable) */ __webpack_exports__["lineReduce"] = lineReduce;
/**
* GeoJSON BBox
*
* @private
* @typedef {[number, number, number, number]} BBox
*/
/**
* GeoJSON Id
*
* @private
* @typedef {(number|string)} Id
*/
/**
* GeoJSON FeatureCollection
*
* @private
* @typedef {Object} FeatureCollection
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {Feature[]} features
*/
/**
* GeoJSON Feature
*
* @private
* @typedef {Object} Feature
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {*} properties
* @property {Geometry} geometry
*/
/**
* GeoJSON Geometry
*
* @private
* @typedef {Object} Geometry
* @property {string} type
* @property {any[]} coordinates
*/
/**
* Callback for coordEach
*
* @callback coordEachCallback
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
*
* @name coordEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* });
*/
function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON
if (geojson === null) return;
var featureIndex, geometryIndex, j, k, l, geometry, stopG, coords,
geometryMaybeCollection,
wrapShrink = 0,
coordIndex = 0,
isGeometryCollection,
type = geojson.type,
isFeatureCollection = type === 'FeatureCollection',
isFeature = type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (featureIndex = 0; featureIndex < stop; featureIndex++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
(isFeature ? geojson.geometry : geojson));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;
// Handles null Geometry -- Skips this geometry
if (geometry === null) continue;
coords = geometry.coordinates;
var geomType = geometry.type;
wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;
switch (geomType) {
case null:
break;
case 'Point':
callback(coords, coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
break;
case 'LineString':
case 'MultiPoint':
for (j = 0; j < coords.length; j++) {
callback(coords[j], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
callback(coords[j][k][l], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
featureSubIndex++;
}
break;
case 'GeometryCollection':
for (j = 0; j < geometry.geometries.length; j++)
coordEach(geometry.geometries[j], callback, excludeWrapCoord);
break;
default:
throw new Error('Unknown Geometry Type');
}
}
}
}
/**
* Callback for coordReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback coordReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Reduce coordinates in any GeoJSON object, similar to Array.reduce()
*
* @name coordReduce
* @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* return currentCoord;
* });
*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;
coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex);
}, excludeWrapCoord);
return previousValue;
}
/**
* Callback for propEach
*
* @callback propEachCallback
* @param {Object} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over properties in any GeoJSON object, similar to Array.forEach()
*
* @name propEach
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentProperties, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propEach(features, function (currentProperties, featureIndex) {
* //=currentProperties
* //=featureIndex
* });
*/
function propEach(geojson, callback) {
var i;
switch (geojson.type) {
case 'FeatureCollection':
for (i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i].properties, i);
}
break;
case 'Feature':
callback(geojson.properties, 0);
break;
}
}
/**
* Callback for propReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback propReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {*} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce properties in any GeoJSON object into a single value,
* similar to how Array.reduce works. However, in this case we lazily run
* the reduction, so an array of all properties is unnecessary.
*
* @name propReduce
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
* //=previousValue
* //=currentProperties
* //=featureIndex
* return currentProperties
* });
*/
function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
propEach(geojson, function (currentProperties, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
else previousValue = callback(previousValue, currentProperties, featureIndex);
});
return previousValue;
}
/**
* Callback for featureEach
*
* @callback featureEachCallback
* @param {Feature} currentFeature The current feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over features in any GeoJSON object, similar to
* Array.forEach.
*
* @name featureEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.featureEach(features, function (currentFeature, featureIndex) {
* //=currentFeature
* //=featureIndex
* });
*/
function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {
callback(geojson, 0);
} else if (geojson.type === 'FeatureCollection') {
for (var i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i], i);
}
}
}
/**
* Callback for featureReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback featureReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name featureReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* return currentFeature
* });
*/
function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
featureEach(geojson, function (currentFeature, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex);
});
return previousValue;
}
/**
* Get all coordinates from any GeoJSON object.
*
* @name coordAll
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @returns {Array>} coordinate position array
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* var coords = turf.coordAll(features);
* //= [[26, 37], [36, 53]]
*/
function coordAll(geojson) {
var coords = [];
coordEach(geojson, function (coord) {
coords.push(coord);
});
return coords;
}
/**
* Callback for geomEach
*
* @callback geomEachCallback
* @param {Geometry} currentGeometry The current geometry being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} currentProperties The current feature properties being processed.
*/
/**
* Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
*
* @name geomEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentGeometry, featureIndex, currentProperties)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomEach(features, function (currentGeometry, featureIndex, currentProperties) {
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* });
*/
function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,
geometryMaybeCollection,
isGeometryCollection,
geometryProperties,
featureIndex = 0,
isFeatureCollection = geojson.type === 'FeatureCollection',
isFeature = geojson.type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (i = 0; i < stop; i++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
(isFeature ? geojson.geometry : geojson));
geometryProperties = (isFeatureCollection ? geojson.features[i].properties :
(isFeature ? geojson.properties : {}));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (g = 0; g < stopG; g++) {
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
// Handle null Geometry
if (geometry === null) {
callback(null, featureIndex, geometryProperties);
continue;
}
switch (geometry.type) {
case 'Point':
case 'LineString':
case 'MultiPoint':
case 'Polygon':
case 'MultiLineString':
case 'MultiPolygon': {
callback(geometry, featureIndex, geometryProperties);
break;
}
case 'GeometryCollection': {
for (j = 0; j < geometry.geometries.length; j++) {
callback(geometry.geometries[j], featureIndex, geometryProperties);
}
break;
}
default:
throw new Error('Unknown Geometry Type');
}
}
// Only increase `featureIndex` per each feature
featureIndex++;
}
}
/**
* Callback for geomReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback geomReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Geometry} currentGeometry The current Feature being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} currentProperties The current feature properties being processed.
*/
/**
* Reduce geometry in any GeoJSON object, similar to Array.reduce().
*
* @name geomReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, currentProperties) {
* //=previousValue
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* return currentGeometry
* });
*/
function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
else previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties);
});
return previousValue;
}
/**
* Callback for flattenEach
*
* @callback flattenEachCallback
* @param {Feature} currentFeature The current flattened feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Iterate over flattened features in any GeoJSON object, similar to
* Array.forEach.
*
* @name flattenEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex, featureSubIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenEach(features, function (currentFeature, featureIndex, featureSubIndex) {
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* });
*/
function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties) {
// Callback for single geometry
var type = (geometry === null) ? null : geometry.type;
switch (type) {
case null:
case 'Point':
case 'LineString':
case 'Polygon':
callback(feature(geometry, properties), featureIndex, 0);
return;
}
var geomType;
// Callback for multi-geometry
switch (type) {
case 'MultiPoint':
geomType = 'Point';
break;
case 'MultiLineString':
geomType = 'LineString';
break;
case 'MultiPolygon':
geomType = 'Polygon';
break;
}
geometry.coordinates.forEach(function (coordinate, featureSubIndex) {
var geom = {
type: geomType,
coordinates: coordinate
};
callback(feature(geom, properties), featureIndex, featureSubIndex);
});
});
}
/**
* Callback for flattenReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback flattenReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Reduce flattened features in any GeoJSON object, similar to Array.reduce().
*
* @name flattenReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* return currentFeature
* });
*/
function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {
if (featureIndex === 0 && featureSubIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex, featureSubIndex);
});
return previousValue;
}
/**
* Callback for segmentEach
*
* @callback segmentEachCallback
* @param {Feature} currentSegment The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}
*/
/**
* Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (currentSegment, featureIndex, featureSubIndex)
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentIndex
* });
*
* // Calculate the total number of segments
* var total = 0;
* turf.segmentEach(polygon, function () {
* total++;
* });
*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;
// Generate 2-vertex line segments
coordReduce(feature, function (previousCoords, currentCoord) {
var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;
});
});
}
/**
* Callback for segmentReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback segmentReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} [currentSegment] The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/
/**
* Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= previousSegment
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentInex
* return currentSegment
* });
*
* // Calculate the total number of segments
* var initialValue = 0
* var total = turf.segmentReduce(polygon, function (previousValue) {
* previousValue++;
* return previousValue;
* }, initialValue);
*/
function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});
return previousValue;
}
/**
* Create Feature
*
* @private
* @param {Geometry} geometry GeoJSON Geometry
* @param {Object} properties Properties
* @returns {Feature} GeoJSON Feature
*/
function feature(geometry, properties) {
if (geometry === undefined) throw new Error('No geometry passed');
return {
type: 'Feature',
properties: properties || {},
geometry: geometry
};
}
/**
* Create LineString
*
* @private
* @param {Array>} coordinates Line Coordinates
* @param {Object} properties Properties
* @returns {Feature} GeoJSON LineString Feature
*/
function lineString(coordinates, properties) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
return {
type: 'Feature',
properties: properties || {},
geometry: {
type: 'LineString',
coordinates: coordinates
}
};
}
/**
* Callback for lineEach
*
* @callback lineEachCallback
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the array, starts at index 0.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
* similar to Array.forEach.
*
* @name lineEach
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (currentLine, lineIndex, lineSubIndex)
* @example
* var mtLn = turf.multiLineString([
* turf.lineString([[26, 37], [35, 45]]),
* turf.lineString([[36, 53], [38, 50], [41, 55]])
* ]);
*
* turf.lineEach(mtLn, function (currentLine, lineIndex) {
* //=currentLine
* //=lineIndex
* });
*/
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
var type = geojson.geometry ? geojson.geometry.type : geojson.type;
if (!type) throw new Error('invalid geojson');
if (type === 'FeatureCollection') throw new Error('FeatureCollection is not supported');
if (type === 'GeometryCollection') throw new Error('GeometryCollection is not supported');
var coordinates = geojson.geometry ? geojson.geometry.coordinates : geojson.coordinates;
if (!coordinates) throw new Error('geojson must contain coordinates');
switch (type) {
case 'LineString':
callback(coordinates, 0, 0);
return;
case 'Polygon':
case 'MultiLineString':
var subIndex = 0;
for (var line = 0; line < coordinates.length; line++) {
if (type === 'MultiLineString') subIndex = line;
callback(coordinates[line], line, subIndex);
}
return;
case 'MultiPolygon':
for (var multi = 0; multi < coordinates.length; multi++) {
for (var ring = 0; ring < coordinates[multi].length; ring++) {
callback(coordinates[multi][ring], ring, multi);
}
}
return;
default:
throw new Error(type + ' geometry not supported');
}
}
/**
* Callback for lineReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback lineReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name lineReduce
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var mtp = turf.multiPolygon([
* turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
* turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
* ]);
*
* turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
* //=previousValue
* //=currentLine
* //=lineIndex
* //=lineSubIndex
* return currentLine
* }, 2);
*/
function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {
if (lineIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, lineIndex, lineSubIndex);
});
return previousValue;
}
/***/ }),
/* 188 */
/***/ (function(module, exports) {
/**
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
*
* @name feature
* @param {Geometry} geometry input geometry
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON Feature
* @example
* var geometry = {
* "type": "Point",
* "coordinates": [110, 50]
* };
*
* var feature = turf.feature(geometry);
*
* //=feature
*/
function feature(geometry, properties, bbox, id) {
if (geometry === undefined) throw new Error('geometry is required');
if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var feat = {type: 'Feature'};
if (id) feat.id = id;
if (bbox) feat.bbox = bbox;
feat.properties = properties || {};
feat.geometry = geometry;
return feat;
}
/**
* Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
* For GeometryCollection type use `helpers.geometryCollection`
*
* @name geometry
* @param {string} type Geometry Type
* @param {Array} coordinates Coordinates
* @param {Array} [bbox] BBox [west, south, east, north]
* @returns {Geometry} a GeoJSON Geometry
* @example
* var type = 'Point';
* var coordinates = [110, 50];
*
* var geometry = turf.geometry(type, coordinates);
*
* //=geometry
*/
function geometry(type, coordinates, bbox) {
// Validation
if (!type) throw new Error('type is required');
if (!coordinates) throw new Error('coordinates is required');
if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
var geom;
switch (type) {
case 'Point': geom = point(coordinates).geometry; break;
case 'LineString': geom = lineString(coordinates).geometry; break;
case 'Polygon': geom = polygon(coordinates).geometry; break;
case 'MultiPoint': geom = multiPoint(coordinates).geometry; break;
case 'MultiLineString': geom = multiLineString(coordinates).geometry; break;
case 'MultiPolygon': geom = multiPolygon(coordinates).geometry; break;
default: throw new Error(type + ' is invalid');
}
if (bbox) geom.bbox = bbox;
return geom;
}
/**
* Takes coordinates and properties (optional) and returns a new {@link Point} feature.
*
* @name point
* @param {Array} coordinates longitude, latitude position (each in decimal degrees)
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Point feature
* @example
* var point = turf.point([-75.343, 39.984]);
*
* //=point
*/
function point(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'Point',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes an array of LinearRings and optionally an {@link Object} with properties and returns a {@link Polygon} feature.
*
* @name polygon
* @param {Array>>} coordinates an array of LinearRings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Polygon feature
* @throws {Error} throw an error if a LinearRing of the polygon has too few positions
* or if a LinearRing of the Polygon does not have matching Positions at the beginning & end.
* @example
* var polygon = turf.polygon([[
* [-2.275543, 53.464547],
* [-2.275543, 53.489271],
* [-2.215118, 53.489271],
* [-2.215118, 53.464547],
* [-2.275543, 53.464547]
* ]], { name: 'poly1', population: 400});
*
* //=polygon
*/
function polygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
for (var i = 0; i < coordinates.length; i++) {
var ring = coordinates[i];
if (ring.length < 4) {
throw new Error('Each LinearRing of a Polygon must have 4 or more Positions.');
}
for (var j = 0; j < ring[ring.length - 1].length; j++) {
// Check if first point of Polygon contains two numbers
if (i === 0 && j === 0 && !isNumber(ring[0][0]) || !isNumber(ring[0][1])) throw new Error('Coordinates must contain numbers');
if (ring[ring.length - 1][j] !== ring[0][j]) {
throw new Error('First and last Position are not equivalent.');
}
}
}
return feature({
type: 'Polygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link LineString} based on a
* coordinate array. Properties can be added optionally.
*
* @name lineString
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a LineString feature
* @throws {Error} if no coordinates are passed
* @example
* var linestring1 = turf.lineString([
* [-21.964416, 64.148203],
* [-21.956176, 64.141316],
* [-21.93901, 64.135924],
* [-21.927337, 64.136673]
* ]);
* var linestring2 = turf.lineString([
* [-21.929054, 64.127985],
* [-21.912918, 64.134726],
* [-21.916007, 64.141016],
* [-21.930084, 64.14446]
* ], {name: 'line 1', distance: 145});
*
* //=linestring1
*
* //=linestring2
*/
function lineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
// Check if first point of LineString contains two numbers
if (!isNumber(coordinates[0][1]) || !isNumber(coordinates[0][1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'LineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
*
* @name featureCollection
* @param {Feature[]} features input features
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {FeatureCollection} a FeatureCollection of input features
* @example
* var features = [
* turf.point([-75.343, 39.984], {name: 'Location A'}),
* turf.point([-75.833, 39.284], {name: 'Location B'}),
* turf.point([-75.534, 39.123], {name: 'Location C'})
* ];
*
* var collection = turf.featureCollection(features);
*
* //=collection
*/
function featureCollection(features, bbox, id) {
if (!features) throw new Error('No features passed');
if (!Array.isArray(features)) throw new Error('features must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var fc = {type: 'FeatureCollection'};
if (id) fc.id = id;
if (bbox) fc.bbox = bbox;
fc.features = features;
return fc;
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiLineString
* @param {Array>>} coordinates an array of LineStrings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiLineString feature
* @throws {Error} if no coordinates are passed
* @example
* var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
*
* //=multiLine
*/
function multiLineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiLineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPoint
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiPoint feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPt = turf.multiPoint([[0,0],[10,10]]);
*
* //=multiPt
*/
function multiPoint(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPoint',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPolygon
* @param {Array>>>} coordinates an array of Polygons
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a multipolygon feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
*
* //=multiPoly
*
*/
function multiPolygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPolygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name geometryCollection
* @param {Array} geometries an array of GeoJSON Geometries
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON GeometryCollection Feature
* @example
* var pt = {
* "type": "Point",
* "coordinates": [100, 0]
* };
* var line = {
* "type": "LineString",
* "coordinates": [ [101, 0], [102, 1] ]
* };
* var collection = turf.geometryCollection([pt, line]);
*
* //=collection
*/
function geometryCollection(geometries, properties, bbox, id) {
if (!geometries) throw new Error('geometries is required');
if (!Array.isArray(geometries)) throw new Error('geometries must be an Array');
return feature({
type: 'GeometryCollection',
geometries: geometries
}, properties, bbox, id);
}
// https://en.wikipedia.org/wiki/Great-circle_distance#Radius_for_spherical_Earth
var factors = {
miles: 3960,
nauticalmiles: 3441.145,
degrees: 57.2957795,
radians: 1,
inches: 250905600,
yards: 6969600,
meters: 6373000,
metres: 6373000,
centimeters: 6.373e+8,
centimetres: 6.373e+8,
kilometers: 6373,
kilometres: 6373,
feet: 20908792.65
};
var areaFactors = {
kilometers: 0.000001,
kilometres: 0.000001,
meters: 1,
metres: 1,
centimetres: 10000,
millimeter: 1000000,
acres: 0.000247105,
miles: 3.86e-7,
yards: 1.195990046,
feet: 10.763910417,
inches: 1550.003100006
};
/**
* Round number to precision
*
* @param {number} num Number
* @param {number} [precision=0] Precision
* @returns {number} rounded number
* @example
* turf.round(120.4321)
* //=120
*
* turf.round(120.4321, 2)
* //=120.43
*/
function round(num, precision) {
if (num === undefined || num === null || isNaN(num)) throw new Error('num is required');
if (precision && !(precision >= 0)) throw new Error('precision must be a positive number');
var multiplier = Math.pow(10, precision || 0);
return Math.round(num * multiplier) / multiplier;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name radiansToDistance
* @param {number} radians in radians across the sphere
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} distance
*/
function radiansToDistance(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error('units is invalid');
return radians * factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name distanceToRadians
* @param {number} distance in real units
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} radians
*/
function distanceToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error('units is invalid');
return distance / factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
*
* @name distanceToDegrees
* @param {number} distance in real units
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} degrees
*/
function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));
}
/**
* Converts any bearing angle from the north line direction (positive clockwise)
* and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
*
* @name bearingToAngle
* @param {number} bearing angle, between -180 and +180 degrees
* @returns {number} angle between 0 and 360 degrees
*/
function bearingToAngle(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');
var angle = bearing % 360;
if (angle < 0) angle += 360;
return angle;
}
/**
* Converts an angle in radians to degrees
*
* @name radians2degrees
* @param {number} radians angle in radians
* @returns {number} degrees between 0 and 360 degrees
*/
function radians2degrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');
var degrees = radians % (2 * Math.PI);
return degrees * 180 / Math.PI;
}
/**
* Converts an angle in degrees to radians
*
* @name degrees2radians
* @param {number} degrees angle between 0 and 360 degrees
* @returns {number} angle in radians
*/
function degrees2radians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');
var radians = degrees % 360;
return radians * Math.PI / 180;
}
/**
* Converts a distance to the requested unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @param {number} distance to be converted
* @param {string} originalUnit of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');
if (!(distance >= 0)) throw new Error('distance must be a positive number');
var convertedDistance = radiansToDistance(distanceToRadians(distance, originalUnit), finalUnit || 'kilometers');
return convertedDistance;
}
/**
* Converts a area to the requested unit.
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
* @param {number} area to be converted
* @param {string} [originalUnit=meters] of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertArea(area, originalUnit, finalUnit) {
if (area === null || area === undefined) throw new Error('area is required');
if (!(area >= 0)) throw new Error('area must be a positive number');
var startFactor = areaFactors[originalUnit || 'meters'];
if (!startFactor) throw new Error('invalid original units');
var finalFactor = areaFactors[finalUnit || 'kilometers'];
if (!finalFactor) throw new Error('invalid final units');
return (area / startFactor) * finalFactor;
}
/**
* isNumber
*
* @param {*} num Number to validate
* @returns {boolean} true/false
* @example
* turf.isNumber(123)
* //=true
* turf.isNumber('foo')
* //=false
*/
function isNumber(num) {
return !isNaN(num) && num !== null && !Array.isArray(num);
}
module.exports = {
feature: feature,
geometry: geometry,
featureCollection: featureCollection,
geometryCollection: geometryCollection,
point: point,
multiPoint: multiPoint,
lineString: lineString,
multiLineString: multiLineString,
polygon: polygon,
multiPolygon: multiPolygon,
radiansToDistance: radiansToDistance,
distanceToRadians: distanceToRadians,
distanceToDegrees: distanceToDegrees,
radians2degrees: radians2degrees,
degrees2radians: degrees2radians,
bearingToAngle: bearingToAngle,
convertDistance: convertDistance,
convertArea: convertArea,
round: round,
isNumber: isNumber
};
/***/ }),
/* 189 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["coordEach"] = coordEach;
/* harmony export (immutable) */ __webpack_exports__["coordReduce"] = coordReduce;
/* harmony export (immutable) */ __webpack_exports__["propEach"] = propEach;
/* harmony export (immutable) */ __webpack_exports__["propReduce"] = propReduce;
/* harmony export (immutable) */ __webpack_exports__["featureEach"] = featureEach;
/* harmony export (immutable) */ __webpack_exports__["featureReduce"] = featureReduce;
/* harmony export (immutable) */ __webpack_exports__["coordAll"] = coordAll;
/* harmony export (immutable) */ __webpack_exports__["geomEach"] = geomEach;
/* harmony export (immutable) */ __webpack_exports__["geomReduce"] = geomReduce;
/* harmony export (immutable) */ __webpack_exports__["flattenEach"] = flattenEach;
/* harmony export (immutable) */ __webpack_exports__["flattenReduce"] = flattenReduce;
/* harmony export (immutable) */ __webpack_exports__["segmentEach"] = segmentEach;
/* harmony export (immutable) */ __webpack_exports__["segmentReduce"] = segmentReduce;
/* harmony export (immutable) */ __webpack_exports__["feature"] = feature;
/* harmony export (immutable) */ __webpack_exports__["lineString"] = lineString;
/* harmony export (immutable) */ __webpack_exports__["lineEach"] = lineEach;
/* harmony export (immutable) */ __webpack_exports__["lineReduce"] = lineReduce;
/**
* GeoJSON BBox
*
* @private
* @typedef {[number, number, number, number]} BBox
*/
/**
* GeoJSON Id
*
* @private
* @typedef {(number|string)} Id
*/
/**
* GeoJSON FeatureCollection
*
* @private
* @typedef {Object} FeatureCollection
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {Feature[]} features
*/
/**
* GeoJSON Feature
*
* @private
* @typedef {Object} Feature
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {*} properties
* @property {Geometry} geometry
*/
/**
* GeoJSON Geometry
*
* @private
* @typedef {Object} Geometry
* @property {string} type
* @property {any[]} coordinates
*/
/**
* Callback for coordEach
*
* @callback coordEachCallback
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
*
* @name coordEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* });
*/
function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON
if (geojson === null) return;
var featureIndex, geometryIndex, j, k, l, geometry, stopG, coords,
geometryMaybeCollection,
wrapShrink = 0,
coordIndex = 0,
isGeometryCollection,
type = geojson.type,
isFeatureCollection = type === 'FeatureCollection',
isFeature = type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (featureIndex = 0; featureIndex < stop; featureIndex++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
(isFeature ? geojson.geometry : geojson));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;
// Handles null Geometry -- Skips this geometry
if (geometry === null) continue;
coords = geometry.coordinates;
var geomType = geometry.type;
wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;
switch (geomType) {
case null:
break;
case 'Point':
callback(coords, coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
break;
case 'LineString':
case 'MultiPoint':
for (j = 0; j < coords.length; j++) {
callback(coords[j], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
callback(coords[j][k][l], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
featureSubIndex++;
}
break;
case 'GeometryCollection':
for (j = 0; j < geometry.geometries.length; j++)
coordEach(geometry.geometries[j], callback, excludeWrapCoord);
break;
default:
throw new Error('Unknown Geometry Type');
}
}
}
}
/**
* Callback for coordReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback coordReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Reduce coordinates in any GeoJSON object, similar to Array.reduce()
*
* @name coordReduce
* @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* return currentCoord;
* });
*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;
coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex);
}, excludeWrapCoord);
return previousValue;
}
/**
* Callback for propEach
*
* @callback propEachCallback
* @param {Object} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over properties in any GeoJSON object, similar to Array.forEach()
*
* @name propEach
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentProperties, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propEach(features, function (currentProperties, featureIndex) {
* //=currentProperties
* //=featureIndex
* });
*/
function propEach(geojson, callback) {
var i;
switch (geojson.type) {
case 'FeatureCollection':
for (i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i].properties, i);
}
break;
case 'Feature':
callback(geojson.properties, 0);
break;
}
}
/**
* Callback for propReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback propReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {*} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce properties in any GeoJSON object into a single value,
* similar to how Array.reduce works. However, in this case we lazily run
* the reduction, so an array of all properties is unnecessary.
*
* @name propReduce
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
* //=previousValue
* //=currentProperties
* //=featureIndex
* return currentProperties
* });
*/
function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
propEach(geojson, function (currentProperties, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
else previousValue = callback(previousValue, currentProperties, featureIndex);
});
return previousValue;
}
/**
* Callback for featureEach
*
* @callback featureEachCallback
* @param {Feature} currentFeature The current feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over features in any GeoJSON object, similar to
* Array.forEach.
*
* @name featureEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.featureEach(features, function (currentFeature, featureIndex) {
* //=currentFeature
* //=featureIndex
* });
*/
function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {
callback(geojson, 0);
} else if (geojson.type === 'FeatureCollection') {
for (var i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i], i);
}
}
}
/**
* Callback for featureReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback featureReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name featureReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* return currentFeature
* });
*/
function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
featureEach(geojson, function (currentFeature, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex);
});
return previousValue;
}
/**
* Get all coordinates from any GeoJSON object.
*
* @name coordAll
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @returns {Array>} coordinate position array
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* var coords = turf.coordAll(features);
* //= [[26, 37], [36, 53]]
*/
function coordAll(geojson) {
var coords = [];
coordEach(geojson, function (coord) {
coords.push(coord);
});
return coords;
}
/**
* Callback for geomEach
*
* @callback geomEachCallback
* @param {Geometry} currentGeometry The current geometry being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} currentProperties The current feature properties being processed.
*/
/**
* Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
*
* @name geomEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentGeometry, featureIndex, currentProperties)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomEach(features, function (currentGeometry, featureIndex, currentProperties) {
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* });
*/
function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,
geometryMaybeCollection,
isGeometryCollection,
geometryProperties,
featureIndex = 0,
isFeatureCollection = geojson.type === 'FeatureCollection',
isFeature = geojson.type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (i = 0; i < stop; i++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
(isFeature ? geojson.geometry : geojson));
geometryProperties = (isFeatureCollection ? geojson.features[i].properties :
(isFeature ? geojson.properties : {}));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (g = 0; g < stopG; g++) {
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
// Handle null Geometry
if (geometry === null) {
callback(null, featureIndex, geometryProperties);
continue;
}
switch (geometry.type) {
case 'Point':
case 'LineString':
case 'MultiPoint':
case 'Polygon':
case 'MultiLineString':
case 'MultiPolygon': {
callback(geometry, featureIndex, geometryProperties);
break;
}
case 'GeometryCollection': {
for (j = 0; j < geometry.geometries.length; j++) {
callback(geometry.geometries[j], featureIndex, geometryProperties);
}
break;
}
default:
throw new Error('Unknown Geometry Type');
}
}
// Only increase `featureIndex` per each feature
featureIndex++;
}
}
/**
* Callback for geomReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback geomReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Geometry} currentGeometry The current Feature being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} currentProperties The current feature properties being processed.
*/
/**
* Reduce geometry in any GeoJSON object, similar to Array.reduce().
*
* @name geomReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, currentProperties) {
* //=previousValue
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* return currentGeometry
* });
*/
function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
else previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties);
});
return previousValue;
}
/**
* Callback for flattenEach
*
* @callback flattenEachCallback
* @param {Feature} currentFeature The current flattened feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Iterate over flattened features in any GeoJSON object, similar to
* Array.forEach.
*
* @name flattenEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex, featureSubIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenEach(features, function (currentFeature, featureIndex, featureSubIndex) {
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* });
*/
function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties) {
// Callback for single geometry
var type = (geometry === null) ? null : geometry.type;
switch (type) {
case null:
case 'Point':
case 'LineString':
case 'Polygon':
callback(feature(geometry, properties), featureIndex, 0);
return;
}
var geomType;
// Callback for multi-geometry
switch (type) {
case 'MultiPoint':
geomType = 'Point';
break;
case 'MultiLineString':
geomType = 'LineString';
break;
case 'MultiPolygon':
geomType = 'Polygon';
break;
}
geometry.coordinates.forEach(function (coordinate, featureSubIndex) {
var geom = {
type: geomType,
coordinates: coordinate
};
callback(feature(geom, properties), featureIndex, featureSubIndex);
});
});
}
/**
* Callback for flattenReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback flattenReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Reduce flattened features in any GeoJSON object, similar to Array.reduce().
*
* @name flattenReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* return currentFeature
* });
*/
function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {
if (featureIndex === 0 && featureSubIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex, featureSubIndex);
});
return previousValue;
}
/**
* Callback for segmentEach
*
* @callback segmentEachCallback
* @param {Feature} currentSegment The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}
*/
/**
* Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (currentSegment, featureIndex, featureSubIndex)
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentIndex
* });
*
* // Calculate the total number of segments
* var total = 0;
* turf.segmentEach(polygon, function () {
* total++;
* });
*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;
// Generate 2-vertex line segments
coordReduce(feature, function (previousCoords, currentCoord) {
var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;
});
});
}
/**
* Callback for segmentReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback segmentReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} [currentSegment] The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/
/**
* Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= previousSegment
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentInex
* return currentSegment
* });
*
* // Calculate the total number of segments
* var initialValue = 0
* var total = turf.segmentReduce(polygon, function (previousValue) {
* previousValue++;
* return previousValue;
* }, initialValue);
*/
function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});
return previousValue;
}
/**
* Create Feature
*
* @private
* @param {Geometry} geometry GeoJSON Geometry
* @param {Object} properties Properties
* @returns {Feature} GeoJSON Feature
*/
function feature(geometry, properties) {
if (geometry === undefined) throw new Error('No geometry passed');
return {
type: 'Feature',
properties: properties || {},
geometry: geometry
};
}
/**
* Create LineString
*
* @private
* @param {Array>} coordinates Line Coordinates
* @param {Object} properties Properties
* @returns {Feature} GeoJSON LineString Feature
*/
function lineString(coordinates, properties) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
return {
type: 'Feature',
properties: properties || {},
geometry: {
type: 'LineString',
coordinates: coordinates
}
};
}
/**
* Callback for lineEach
*
* @callback lineEachCallback
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the array, starts at index 0.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
* similar to Array.forEach.
*
* @name lineEach
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (currentLine, lineIndex, lineSubIndex)
* @example
* var mtLn = turf.multiLineString([
* turf.lineString([[26, 37], [35, 45]]),
* turf.lineString([[36, 53], [38, 50], [41, 55]])
* ]);
*
* turf.lineEach(mtLn, function (currentLine, lineIndex) {
* //=currentLine
* //=lineIndex
* });
*/
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
var type = geojson.geometry ? geojson.geometry.type : geojson.type;
if (!type) throw new Error('invalid geojson');
if (type === 'FeatureCollection') throw new Error('FeatureCollection is not supported');
if (type === 'GeometryCollection') throw new Error('GeometryCollection is not supported');
var coordinates = geojson.geometry ? geojson.geometry.coordinates : geojson.coordinates;
if (!coordinates) throw new Error('geojson must contain coordinates');
switch (type) {
case 'LineString':
callback(coordinates, 0, 0);
return;
case 'Polygon':
case 'MultiLineString':
var subIndex = 0;
for (var line = 0; line < coordinates.length; line++) {
if (type === 'MultiLineString') subIndex = line;
callback(coordinates[line], line, subIndex);
}
return;
case 'MultiPolygon':
for (var multi = 0; multi < coordinates.length; multi++) {
for (var ring = 0; ring < coordinates[multi].length; ring++) {
callback(coordinates[multi][ring], ring, multi);
}
}
return;
default:
throw new Error(type + ' geometry not supported');
}
}
/**
* Callback for lineReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback lineReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name lineReduce
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var mtp = turf.multiPolygon([
* turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
* turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
* ]);
*
* turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
* //=previousValue
* //=currentLine
* //=lineIndex
* //=lineSubIndex
* return currentLine
* }, 2);
*/
function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {
if (lineIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, lineIndex, lineSubIndex);
});
return previousValue;
}
/***/ }),
/* 190 */
/***/ (function(module, exports, __webpack_require__) {
var meta = __webpack_require__(191);
var helpers = __webpack_require__(192);
var bearing = __webpack_require__(193);
var distance = __webpack_require__(194);
var invariant = __webpack_require__(32);
var destination = __webpack_require__(196);
var lineIntersects = __webpack_require__(114);
var point = helpers.point;
var getCoords = invariant.getCoords;
var lineString = helpers.lineString;
var flattenEach = meta.flattenEach;
/**
* Takes a {@link Point} and a {@link LineString} and calculates the closest Point on the (Multi)LineString.
*
* @name pointOnLine
* @param {Geometry|Feature} lines lines to snap to
* @param {Geometry|Feature|number[]} pt point to snap from
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers
* @returns {Feature} closest point on the `line` to `point`. The properties object will contain three values: `index`: closest point was found on nth line part, `dist`: distance between pt and the closest point, `location`: distance along the line between start and the closest point.
* @example
* var line = turf.lineString([
* [-77.031669, 38.878605],
* [-77.029609, 38.881946],
* [-77.020339, 38.884084],
* [-77.025661, 38.885821],
* [-77.021884, 38.889563],
* [-77.019824, 38.892368]
* ]);
* var pt = turf.point([-77.037076, 38.884017]);
*
* var snapped = turf.pointOnLine(line, pt, 'miles');
*
* //addToMap
* var addToMap = [line, pt, snapped];
* snapped.properties['marker-color'] = '#00f';
*/
module.exports = function (lines, pt, units) {
// validation
var type = (lines.geometry) ? lines.geometry.type : lines.type;
if (type !== 'LineString' && type !== 'MultiLineString') {
throw new Error('lines must be LineString or MultiLineString');
}
var closestPt = point([Infinity, Infinity], {
dist: Infinity
});
var length = 0.0;
flattenEach(lines, function (line) {
var coords = getCoords(line);
for (var i = 0; i < coords.length - 1; i++) {
//start
var start = point(coords[i]);
start.properties.dist = distance(pt, start, units);
//stop
var stop = point(coords[i + 1]);
stop.properties.dist = distance(pt, stop, units);
// sectionLength
var sectionLength = distance(start, stop, units);
//perpendicular
var heightDistance = Math.max(start.properties.dist, stop.properties.dist);
var direction = bearing(start, stop);
var perpendicularPt1 = destination(pt, heightDistance, direction + 90, units);
var perpendicularPt2 = destination(pt, heightDistance, direction - 90, units);
var intersect = lineIntersects(lineString([perpendicularPt1.geometry.coordinates, perpendicularPt2.geometry.coordinates]), lineString([start.geometry.coordinates, stop.geometry.coordinates]));
var intersectPt = null;
if (intersect.features.length > 0) {
intersectPt = intersect.features[0];
intersectPt.properties.dist = distance(pt, intersectPt, units);
intersectPt.properties.location = length + distance(start, intersectPt, units);
}
if (start.properties.dist < closestPt.properties.dist) {
closestPt = start;
closestPt.properties.index = i;
closestPt.properties.location = length;
}
if (stop.properties.dist < closestPt.properties.dist) {
closestPt = stop;
closestPt.properties.index = i + 1;
closestPt.properties.location = length + sectionLength;
}
if (intersectPt && intersectPt.properties.dist < closestPt.properties.dist) {
closestPt = intersectPt;
closestPt.properties.index = i;
}
// update length
length += sectionLength;
}
});
return closestPt;
};
/***/ }),
/* 191 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["coordEach"] = coordEach;
/* harmony export (immutable) */ __webpack_exports__["coordReduce"] = coordReduce;
/* harmony export (immutable) */ __webpack_exports__["propEach"] = propEach;
/* harmony export (immutable) */ __webpack_exports__["propReduce"] = propReduce;
/* harmony export (immutable) */ __webpack_exports__["featureEach"] = featureEach;
/* harmony export (immutable) */ __webpack_exports__["featureReduce"] = featureReduce;
/* harmony export (immutable) */ __webpack_exports__["coordAll"] = coordAll;
/* harmony export (immutable) */ __webpack_exports__["geomEach"] = geomEach;
/* harmony export (immutable) */ __webpack_exports__["geomReduce"] = geomReduce;
/* harmony export (immutable) */ __webpack_exports__["flattenEach"] = flattenEach;
/* harmony export (immutable) */ __webpack_exports__["flattenReduce"] = flattenReduce;
/* harmony export (immutable) */ __webpack_exports__["segmentEach"] = segmentEach;
/* harmony export (immutable) */ __webpack_exports__["segmentReduce"] = segmentReduce;
/* harmony export (immutable) */ __webpack_exports__["feature"] = feature;
/* harmony export (immutable) */ __webpack_exports__["lineString"] = lineString;
/* harmony export (immutable) */ __webpack_exports__["lineEach"] = lineEach;
/* harmony export (immutable) */ __webpack_exports__["lineReduce"] = lineReduce;
/**
* GeoJSON BBox
*
* @private
* @typedef {[number, number, number, number]} BBox
*/
/**
* GeoJSON Id
*
* @private
* @typedef {(number|string)} Id
*/
/**
* GeoJSON FeatureCollection
*
* @private
* @typedef {Object} FeatureCollection
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {Feature[]} features
*/
/**
* GeoJSON Feature
*
* @private
* @typedef {Object} Feature
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {*} properties
* @property {Geometry} geometry
*/
/**
* GeoJSON Geometry
*
* @private
* @typedef {Object} Geometry
* @property {string} type
* @property {any[]} coordinates
*/
/**
* Callback for coordEach
*
* @callback coordEachCallback
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
*
* @name coordEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* });
*/
function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON
if (geojson === null) return;
var featureIndex, geometryIndex, j, k, l, geometry, stopG, coords,
geometryMaybeCollection,
wrapShrink = 0,
coordIndex = 0,
isGeometryCollection,
type = geojson.type,
isFeatureCollection = type === 'FeatureCollection',
isFeature = type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (featureIndex = 0; featureIndex < stop; featureIndex++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
(isFeature ? geojson.geometry : geojson));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;
// Handles null Geometry -- Skips this geometry
if (geometry === null) continue;
coords = geometry.coordinates;
var geomType = geometry.type;
wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;
switch (geomType) {
case null:
break;
case 'Point':
callback(coords, coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
break;
case 'LineString':
case 'MultiPoint':
for (j = 0; j < coords.length; j++) {
callback(coords[j], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
callback(coords[j][k][l], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
}
featureSubIndex++;
}
break;
case 'GeometryCollection':
for (j = 0; j < geometry.geometries.length; j++)
coordEach(geometry.geometries[j], callback, excludeWrapCoord);
break;
default:
throw new Error('Unknown Geometry Type');
}
}
}
}
/**
* Callback for coordReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback coordReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Array} currentCoord The current coordinate being processed.
* @param {number} coordIndex The current index of the coordinate being processed.
* Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureIndex The current index of the feature being processed.
* @param {number} featureSubIndex The current subIndex of the feature being processed.
*/
/**
* Reduce coordinates in any GeoJSON object, similar to Array.reduce()
*
* @name coordReduce
* @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentCoord
* //=coordIndex
* //=featureIndex
* //=featureSubIndex
* return currentCoord;
* });
*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;
coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {
if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, featureSubIndex);
}, excludeWrapCoord);
return previousValue;
}
/**
* Callback for propEach
*
* @callback propEachCallback
* @param {Object} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over properties in any GeoJSON object, similar to Array.forEach()
*
* @name propEach
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentProperties, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propEach(features, function (currentProperties, featureIndex) {
* //=currentProperties
* //=featureIndex
* });
*/
function propEach(geojson, callback) {
var i;
switch (geojson.type) {
case 'FeatureCollection':
for (i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i].properties, i);
}
break;
case 'Feature':
callback(geojson.properties, 0);
break;
}
}
/**
* Callback for propReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback propReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {*} currentProperties The current properties being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce properties in any GeoJSON object into a single value,
* similar to how Array.reduce works. However, in this case we lazily run
* the reduction, so an array of all properties is unnecessary.
*
* @name propReduce
* @param {(FeatureCollection|Feature)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
* //=previousValue
* //=currentProperties
* //=featureIndex
* return currentProperties
* });
*/
function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
propEach(geojson, function (currentProperties, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
else previousValue = callback(previousValue, currentProperties, featureIndex);
});
return previousValue;
}
/**
* Callback for featureEach
*
* @callback featureEachCallback
* @param {Feature} currentFeature The current feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Iterate over features in any GeoJSON object, similar to
* Array.forEach.
*
* @name featureEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.featureEach(features, function (currentFeature, featureIndex) {
* //=currentFeature
* //=featureIndex
* });
*/
function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {
callback(geojson, 0);
} else if (geojson.type === 'FeatureCollection') {
for (var i = 0; i < geojson.features.length; i++) {
callback(geojson.features[i], i);
}
}
}
/**
* Callback for featureReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback featureReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name featureReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {"foo": "bar"}),
* turf.point([36, 53], {"hello": "world"})
* ]);
*
* turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* return currentFeature
* });
*/
function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
featureEach(geojson, function (currentFeature, featureIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex);
});
return previousValue;
}
/**
* Get all coordinates from any GeoJSON object.
*
* @name coordAll
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @returns {Array>} coordinate position array
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* var coords = turf.coordAll(features);
* //= [[26, 37], [36, 53]]
*/
function coordAll(geojson) {
var coords = [];
coordEach(geojson, function (coord) {
coords.push(coord);
});
return coords;
}
/**
* Callback for geomEach
*
* @callback geomEachCallback
* @param {Geometry} currentGeometry The current geometry being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} currentProperties The current feature properties being processed.
*/
/**
* Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
*
* @name geomEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentGeometry, featureIndex, currentProperties)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomEach(features, function (currentGeometry, featureIndex, currentProperties) {
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* });
*/
function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,
geometryMaybeCollection,
isGeometryCollection,
geometryProperties,
featureIndex = 0,
isFeatureCollection = geojson.type === 'FeatureCollection',
isFeature = geojson.type === 'Feature',
stop = isFeatureCollection ? geojson.features.length : 1;
// This logic may look a little weird. The reason why it is that way
// is because it's trying to be fast. GeoJSON supports multiple kinds
// of objects at its root: FeatureCollection, Features, Geometries.
// This function has the responsibility of handling all of them, and that
// means that some of the `for` loops you see below actually just don't apply
// to certain inputs. For instance, if you give this just a
// Point geometry, then both loops are short-circuited and all we do
// is gradually rename the input until it's called 'geometry'.
//
// This also aims to allocate as few resources as possible: just a
// few numbers and booleans, rather than any temporary arrays as would
// be required with the normalization approach.
for (i = 0; i < stop; i++) {
geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
(isFeature ? geojson.geometry : geojson));
geometryProperties = (isFeatureCollection ? geojson.features[i].properties :
(isFeature ? geojson.properties : {}));
isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
for (g = 0; g < stopG; g++) {
geometry = isGeometryCollection ?
geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
// Handle null Geometry
if (geometry === null) {
callback(null, featureIndex, geometryProperties);
continue;
}
switch (geometry.type) {
case 'Point':
case 'LineString':
case 'MultiPoint':
case 'Polygon':
case 'MultiLineString':
case 'MultiPolygon': {
callback(geometry, featureIndex, geometryProperties);
break;
}
case 'GeometryCollection': {
for (j = 0; j < geometry.geometries.length; j++) {
callback(geometry.geometries[j], featureIndex, geometryProperties);
}
break;
}
default:
throw new Error('Unknown Geometry Type');
}
}
// Only increase `featureIndex` per each feature
featureIndex++;
}
}
/**
* Callback for geomReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback geomReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Geometry} currentGeometry The current Feature being processed.
* @param {number} currentIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {Object} currentProperties The current feature properties being processed.
*/
/**
* Reduce geometry in any GeoJSON object, similar to Array.reduce().
*
* @name geomReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.point([36, 53], {hello: 'world'})
* ]);
*
* turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, currentProperties) {
* //=previousValue
* //=currentGeometry
* //=featureIndex
* //=currentProperties
* return currentGeometry
* });
*/
function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
else previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties);
});
return previousValue;
}
/**
* Callback for flattenEach
*
* @callback flattenEachCallback
* @param {Feature} currentFeature The current flattened feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Iterate over flattened features in any GeoJSON object, similar to
* Array.forEach.
*
* @name flattenEach
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (currentFeature, featureIndex, featureSubIndex)
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenEach(features, function (currentFeature, featureIndex, featureSubIndex) {
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* });
*/
function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties) {
// Callback for single geometry
var type = (geometry === null) ? null : geometry.type;
switch (type) {
case null:
case 'Point':
case 'LineString':
case 'Polygon':
callback(feature(geometry, properties), featureIndex, 0);
return;
}
var geomType;
// Callback for multi-geometry
switch (type) {
case 'MultiPoint':
geomType = 'Point';
break;
case 'MultiLineString':
geomType = 'LineString';
break;
case 'MultiPolygon':
geomType = 'Polygon';
break;
}
geometry.coordinates.forEach(function (coordinate, featureSubIndex) {
var geom = {
type: geomType,
coordinates: coordinate
};
callback(feature(geom, properties), featureIndex, featureSubIndex);
});
});
}
/**
* Callback for flattenReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback flattenReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentFeature The current Feature being processed.
* @param {number} featureIndex The index of the current element being processed in the
* array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
*/
/**
* Reduce flattened features in any GeoJSON object, similar to Array.reduce().
*
* @name flattenReduce
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var features = turf.featureCollection([
* turf.point([26, 37], {foo: 'bar'}),
* turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
* ]);
*
* turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, featureSubIndex) {
* //=previousValue
* //=currentFeature
* //=featureIndex
* //=featureSubIndex
* return currentFeature
* });
*/
function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {
if (featureIndex === 0 && featureSubIndex === 0 && initialValue === undefined) previousValue = currentFeature;
else previousValue = callback(previousValue, currentFeature, featureIndex, featureSubIndex);
});
return previousValue;
}
/**
* Callback for segmentEach
*
* @callback segmentEachCallback
* @param {Feature} currentSegment The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}
*/
/**
* Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (currentSegment, featureIndex, featureSubIndex)
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentIndex
* });
*
* // Calculate the total number of segments
* var total = 0;
* turf.segmentEach(polygon, function () {
* total++;
* });
*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;
// Generate 2-vertex line segments
coordReduce(feature, function (previousCoords, currentCoord) {
var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;
});
});
}
/**
* Callback for segmentReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback segmentReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} [currentSegment] The current segment being processed.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/
/**
* Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
* (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
*
* @param {(FeatureCollection|Feature|Geometry)} geojson any GeoJSON
* @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {void}
* @example
* var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
*
* // Iterate over GeoJSON by 2-vertex segments
* turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
* //= previousSegment
* //= currentSegment
* //= featureIndex
* //= featureSubIndex
* //= segmentInex
* return currentSegment
* });
*
* // Calculate the total number of segments
* var initialValue = 0
* var total = turf.segmentReduce(polygon, function (previousValue) {
* previousValue++;
* return previousValue;
* }, initialValue);
*/
function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});
return previousValue;
}
/**
* Create Feature
*
* @private
* @param {Geometry} geometry GeoJSON Geometry
* @param {Object} properties Properties
* @returns {Feature} GeoJSON Feature
*/
function feature(geometry, properties) {
if (geometry === undefined) throw new Error('No geometry passed');
return {
type: 'Feature',
properties: properties || {},
geometry: geometry
};
}
/**
* Create LineString
*
* @private
* @param {Array>} coordinates Line Coordinates
* @param {Object} properties Properties
* @returns {Feature} GeoJSON LineString Feature
*/
function lineString(coordinates, properties) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
return {
type: 'Feature',
properties: properties || {},
geometry: {
type: 'LineString',
coordinates: coordinates
}
};
}
/**
* Callback for lineEach
*
* @callback lineEachCallback
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the array, starts at index 0.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
* similar to Array.forEach.
*
* @name lineEach
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (currentLine, lineIndex, lineSubIndex)
* @example
* var mtLn = turf.multiLineString([
* turf.lineString([[26, 37], [35, 45]]),
* turf.lineString([[36, 53], [38, 50], [41, 55]])
* ]);
*
* turf.lineEach(mtLn, function (currentLine, lineIndex) {
* //=currentLine
* //=lineIndex
* });
*/
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
var type = geojson.geometry ? geojson.geometry.type : geojson.type;
if (!type) throw new Error('invalid geojson');
if (type === 'FeatureCollection') throw new Error('FeatureCollection is not supported');
if (type === 'GeometryCollection') throw new Error('GeometryCollection is not supported');
var coordinates = geojson.geometry ? geojson.geometry.coordinates : geojson.coordinates;
if (!coordinates) throw new Error('geojson must contain coordinates');
switch (type) {
case 'LineString':
callback(coordinates, 0, 0);
return;
case 'Polygon':
case 'MultiLineString':
var subIndex = 0;
for (var line = 0; line < coordinates.length; line++) {
if (type === 'MultiLineString') subIndex = line;
callback(coordinates[line], line, subIndex);
}
return;
case 'MultiPolygon':
for (var multi = 0; multi < coordinates.length; multi++) {
for (var ring = 0; ring < coordinates[multi].length; ring++) {
callback(coordinates[multi][ring], ring, multi);
}
}
return;
default:
throw new Error(type + ' geometry not supported');
}
}
/**
* Callback for lineReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback lineReduceCallback
* @param {*} previousValue The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {Feature} currentLine The current LineString|LinearRing being processed.
* @param {number} lineIndex The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {number} lineSubIndex The sub-index of the current line being processed at index 0
*/
/**
* Reduce features in any GeoJSON object, similar to Array.reduce().
*
* @name lineReduce
* @param {Geometry|Feature} geojson object
* @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var mtp = turf.multiPolygon([
* turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
* turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
* ]);
*
* turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
* //=previousValue
* //=currentLine
* //=lineIndex
* //=lineSubIndex
* return currentLine
* }, 2);
*/
function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {
if (lineIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, lineIndex, lineSubIndex);
});
return previousValue;
}
/***/ }),
/* 192 */
/***/ (function(module, exports) {
/**
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
*
* @name feature
* @param {Geometry} geometry input geometry
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON Feature
* @example
* var geometry = {
* "type": "Point",
* "coordinates": [110, 50]
* };
*
* var feature = turf.feature(geometry);
*
* //=feature
*/
function feature(geometry, properties, bbox, id) {
if (geometry === undefined) throw new Error('geometry is required');
if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var feat = {type: 'Feature'};
if (id) feat.id = id;
if (bbox) feat.bbox = bbox;
feat.properties = properties || {};
feat.geometry = geometry;
return feat;
}
/**
* Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
* For GeometryCollection type use `helpers.geometryCollection`
*
* @name geometry
* @param {string} type Geometry Type
* @param {Array} coordinates Coordinates
* @param {Array} [bbox] BBox [west, south, east, north]
* @returns {Geometry} a GeoJSON Geometry
* @example
* var type = 'Point';
* var coordinates = [110, 50];
*
* var geometry = turf.geometry(type, coordinates);
*
* //=geometry
*/
function geometry(type, coordinates, bbox) {
// Validation
if (!type) throw new Error('type is required');
if (!coordinates) throw new Error('coordinates is required');
if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
var geom;
switch (type) {
case 'Point': geom = point(coordinates).geometry; break;
case 'LineString': geom = lineString(coordinates).geometry; break;
case 'Polygon': geom = polygon(coordinates).geometry; break;
case 'MultiPoint': geom = multiPoint(coordinates).geometry; break;
case 'MultiLineString': geom = multiLineString(coordinates).geometry; break;
case 'MultiPolygon': geom = multiPolygon(coordinates).geometry; break;
default: throw new Error(type + ' is invalid');
}
if (bbox) geom.bbox = bbox;
return geom;
}
/**
* Takes coordinates and properties (optional) and returns a new {@link Point} feature.
*
* @name point
* @param {Array} coordinates longitude, latitude position (each in decimal degrees)
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Point feature
* @example
* var point = turf.point([-75.343, 39.984]);
*
* //=point
*/
function point(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'Point',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes an array of LinearRings and optionally an {@link Object} with properties and returns a {@link Polygon} feature.
*
* @name polygon
* @param {Array>>} coordinates an array of LinearRings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Polygon feature
* @throws {Error} throw an error if a LinearRing of the polygon has too few positions
* or if a LinearRing of the Polygon does not have matching Positions at the beginning & end.
* @example
* var polygon = turf.polygon([[
* [-2.275543, 53.464547],
* [-2.275543, 53.489271],
* [-2.215118, 53.489271],
* [-2.215118, 53.464547],
* [-2.275543, 53.464547]
* ]], { name: 'poly1', population: 400});
*
* //=polygon
*/
function polygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
for (var i = 0; i < coordinates.length; i++) {
var ring = coordinates[i];
if (ring.length < 4) {
throw new Error('Each LinearRing of a Polygon must have 4 or more Positions.');
}
for (var j = 0; j < ring[ring.length - 1].length; j++) {
// Check if first point of Polygon contains two numbers
if (i === 0 && j === 0 && !isNumber(ring[0][0]) || !isNumber(ring[0][1])) throw new Error('Coordinates must contain numbers');
if (ring[ring.length - 1][j] !== ring[0][j]) {
throw new Error('First and last Position are not equivalent.');
}
}
}
return feature({
type: 'Polygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link LineString} based on a
* coordinate array. Properties can be added optionally.
*
* @name lineString
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a LineString feature
* @throws {Error} if no coordinates are passed
* @example
* var linestring1 = turf.lineString([
* [-21.964416, 64.148203],
* [-21.956176, 64.141316],
* [-21.93901, 64.135924],
* [-21.927337, 64.136673]
* ]);
* var linestring2 = turf.lineString([
* [-21.929054, 64.127985],
* [-21.912918, 64.134726],
* [-21.916007, 64.141016],
* [-21.930084, 64.14446]
* ], {name: 'line 1', distance: 145});
*
* //=linestring1
*
* //=linestring2
*/
function lineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
// Check if first point of LineString contains two numbers
if (!isNumber(coordinates[0][1]) || !isNumber(coordinates[0][1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'LineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
*
* @name featureCollection
* @param {Feature[]} features input features
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {FeatureCollection} a FeatureCollection of input features
* @example
* var features = [
* turf.point([-75.343, 39.984], {name: 'Location A'}),
* turf.point([-75.833, 39.284], {name: 'Location B'}),
* turf.point([-75.534, 39.123], {name: 'Location C'})
* ];
*
* var collection = turf.featureCollection(features);
*
* //=collection
*/
function featureCollection(features, bbox, id) {
if (!features) throw new Error('No features passed');
if (!Array.isArray(features)) throw new Error('features must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var fc = {type: 'FeatureCollection'};
if (id) fc.id = id;
if (bbox) fc.bbox = bbox;
fc.features = features;
return fc;
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiLineString
* @param {Array>>} coordinates an array of LineStrings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiLineString feature
* @throws {Error} if no coordinates are passed
* @example
* var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
*
* //=multiLine
*/
function multiLineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiLineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPoint
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiPoint feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPt = turf.multiPoint([[0,0],[10,10]]);
*
* //=multiPt
*/
function multiPoint(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPoint',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPolygon
* @param {Array>>>} coordinates an array of Polygons
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a multipolygon feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
*
* //=multiPoly
*
*/
function multiPolygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPolygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name geometryCollection
* @param {Array} geometries an array of GeoJSON Geometries
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON GeometryCollection Feature
* @example
* var pt = {
* "type": "Point",
* "coordinates": [100, 0]
* };
* var line = {
* "type": "LineString",
* "coordinates": [ [101, 0], [102, 1] ]
* };
* var collection = turf.geometryCollection([pt, line]);
*
* //=collection
*/
function geometryCollection(geometries, properties, bbox, id) {
if (!geometries) throw new Error('geometries is required');
if (!Array.isArray(geometries)) throw new Error('geometries must be an Array');
return feature({
type: 'GeometryCollection',
geometries: geometries
}, properties, bbox, id);
}
// https://en.wikipedia.org/wiki/Great-circle_distance#Radius_for_spherical_Earth
var factors = {
miles: 3960,
nauticalmiles: 3441.145,
degrees: 57.2957795,
radians: 1,
inches: 250905600,
yards: 6969600,
meters: 6373000,
metres: 6373000,
centimeters: 6.373e+8,
centimetres: 6.373e+8,
kilometers: 6373,
kilometres: 6373,
feet: 20908792.65
};
var areaFactors = {
kilometers: 0.000001,
kilometres: 0.000001,
meters: 1,
metres: 1,
centimetres: 10000,
millimeter: 1000000,
acres: 0.000247105,
miles: 3.86e-7,
yards: 1.195990046,
feet: 10.763910417,
inches: 1550.003100006
};
/**
* Round number to precision
*
* @param {number} num Number
* @param {number} [precision=0] Precision
* @returns {number} rounded number
* @example
* turf.round(120.4321)
* //=120
*
* turf.round(120.4321, 2)
* //=120.43
*/
function round(num, precision) {
if (num === undefined || num === null || isNaN(num)) throw new Error('num is required');
if (precision && !(precision >= 0)) throw new Error('precision must be a positive number');
var multiplier = Math.pow(10, precision || 0);
return Math.round(num * multiplier) / multiplier;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name radiansToDistance
* @param {number} radians in radians across the sphere
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} distance
*/
function radiansToDistance(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error('units is invalid');
return radians * factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name distanceToRadians
* @param {number} distance in real units
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} radians
*/
function distanceToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error('units is invalid');
return distance / factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
*
* @name distanceToDegrees
* @param {number} distance in real units
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} degrees
*/
function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));
}
/**
* Converts any bearing angle from the north line direction (positive clockwise)
* and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
*
* @name bearingToAngle
* @param {number} bearing angle, between -180 and +180 degrees
* @returns {number} angle between 0 and 360 degrees
*/
function bearingToAngle(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');
var angle = bearing % 360;
if (angle < 0) angle += 360;
return angle;
}
/**
* Converts an angle in radians to degrees
*
* @name radians2degrees
* @param {number} radians angle in radians
* @returns {number} degrees between 0 and 360 degrees
*/
function radians2degrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');
var degrees = radians % (2 * Math.PI);
return degrees * 180 / Math.PI;
}
/**
* Converts an angle in degrees to radians
*
* @name degrees2radians
* @param {number} degrees angle between 0 and 360 degrees
* @returns {number} angle in radians
*/
function degrees2radians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');
var radians = degrees % 360;
return radians * Math.PI / 180;
}
/**
* Converts a distance to the requested unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @param {number} distance to be converted
* @param {string} originalUnit of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');
if (!(distance >= 0)) throw new Error('distance must be a positive number');
var convertedDistance = radiansToDistance(distanceToRadians(distance, originalUnit), finalUnit || 'kilometers');
return convertedDistance;
}
/**
* Converts a area to the requested unit.
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
* @param {number} area to be converted
* @param {string} [originalUnit=meters] of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertArea(area, originalUnit, finalUnit) {
if (area === null || area === undefined) throw new Error('area is required');
if (!(area >= 0)) throw new Error('area must be a positive number');
var startFactor = areaFactors[originalUnit || 'meters'];
if (!startFactor) throw new Error('invalid original units');
var finalFactor = areaFactors[finalUnit || 'kilometers'];
if (!finalFactor) throw new Error('invalid final units');
return (area / startFactor) * finalFactor;
}
/**
* isNumber
*
* @param {*} num Number to validate
* @returns {boolean} true/false
* @example
* turf.isNumber(123)
* //=true
* turf.isNumber('foo')
* //=false
*/
function isNumber(num) {
return !isNaN(num) && num !== null && !Array.isArray(num);
}
module.exports = {
feature: feature,
geometry: geometry,
featureCollection: featureCollection,
geometryCollection: geometryCollection,
point: point,
multiPoint: multiPoint,
lineString: lineString,
multiLineString: multiLineString,
polygon: polygon,
multiPolygon: multiPolygon,
radiansToDistance: radiansToDistance,
distanceToRadians: distanceToRadians,
distanceToDegrees: distanceToDegrees,
radians2degrees: radians2degrees,
degrees2radians: degrees2radians,
bearingToAngle: bearingToAngle,
convertDistance: convertDistance,
convertArea: convertArea,
round: round,
isNumber: isNumber
};
/***/ }),
/* 193 */
/***/ (function(module, exports, __webpack_require__) {
var getCoord = __webpack_require__(32).getCoord;
//http://en.wikipedia.org/wiki/Haversine_formula
//http://www.movable-type.co.uk/scripts/latlong.html
/**
* Takes two {@link Point|points} and finds the geographic bearing between them,
* i.e. the angle measured in degrees from the north line (0 degrees)
*
* @name bearing
* @param {Geometry|Feature|Array} start starting Point
* @param {Geometry|Feature|Array} end ending Point
* @param {boolean} [final=false] calculates the final bearing if true
* @returns {number} bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
* @example
* var point1 = turf.point([-75.343, 39.984]);
* var point2 = turf.point([-75.534, 39.123]);
*
* var bearing = turf.bearing(point1, point2);
*
* //addToMap
* var addToMap = [point1, point2]
* point1.properties['marker-color'] = '#f00'
* point2.properties['marker-color'] = '#0f0'
* point1.properties.bearing = bearing
*/
function bearing(start, end, final) {
if (final === true) return calculateFinalBearing(start, end);
var degrees2radians = Math.PI / 180;
var radians2degrees = 180 / Math.PI;
var coordinates1 = getCoord(start);
var coordinates2 = getCoord(end);
var lon1 = degrees2radians * coordinates1[0];
var lon2 = degrees2radians * coordinates2[0];
var lat1 = degrees2radians * coordinates1[1];
var lat2 = degrees2radians * coordinates2[1];
var a = Math.sin(lon2 - lon1) * Math.cos(lat2);
var b = Math.cos(lat1) * Math.sin(lat2) -
Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
var bear = radians2degrees * Math.atan2(a, b);
return bear;
}
/**
* Calculates Final Bearing
* @private
* @param {Feature} start starting Point
* @param {Feature} end ending Point
* @returns {number} bearing
*/
function calculateFinalBearing(start, end) {
// Swap start & end
var bear = bearing(end, start);
bear = (bear + 180) % 360;
return bear;
}
module.exports = bearing;
/***/ }),
/* 194 */
/***/ (function(module, exports, __webpack_require__) {
var getCoord = __webpack_require__(32).getCoord;
var radiansToDistance = __webpack_require__(195).radiansToDistance;
//http://en.wikipedia.org/wiki/Haversine_formula
//http://www.movable-type.co.uk/scripts/latlong.html
/**
* Calculates the distance between two {@link Point|points} in degrees, radians,
* miles, or kilometers. This uses the
* [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula)
* to account for global curvature.
*
* @name distance
* @param {Geometry|Feature|Array} from origin point
* @param {Geometry|Feature|Array} to destination point
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers
* @returns {number} distance between the two points
* @example
* var from = turf.point([-75.343, 39.984]);
* var to = turf.point([-75.534, 39.123]);
*
* var distance = turf.distance(from, to, "miles");
*
* //addToMap
* var addToMap = [from, to];
* from.properties.distance = distance;
* to.properties.distance = distance;
*/
module.exports = function (from, to, units) {
var degrees2radians = Math.PI / 180;
var coordinates1 = getCoord(from);
var coordinates2 = getCoord(to);
var dLat = degrees2radians * (coordinates2[1] - coordinates1[1]);
var dLon = degrees2radians * (coordinates2[0] - coordinates1[0]);
var lat1 = degrees2radians * coordinates1[1];
var lat2 = degrees2radians * coordinates2[1];
var a = Math.pow(Math.sin(dLat / 2), 2) +
Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
return radiansToDistance(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units);
};
/***/ }),
/* 195 */
/***/ (function(module, exports) {
/**
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
*
* @name feature
* @param {Geometry} geometry input geometry
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON Feature
* @example
* var geometry = {
* "type": "Point",
* "coordinates": [110, 50]
* };
*
* var feature = turf.feature(geometry);
*
* //=feature
*/
function feature(geometry, properties, bbox, id) {
if (geometry === undefined) throw new Error('geometry is required');
if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var feat = {type: 'Feature'};
if (id) feat.id = id;
if (bbox) feat.bbox = bbox;
feat.properties = properties || {};
feat.geometry = geometry;
return feat;
}
/**
* Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
* For GeometryCollection type use `helpers.geometryCollection`
*
* @name geometry
* @param {string} type Geometry Type
* @param {Array} coordinates Coordinates
* @param {Array} [bbox] BBox [west, south, east, north]
* @returns {Geometry} a GeoJSON Geometry
* @example
* var type = 'Point';
* var coordinates = [110, 50];
*
* var geometry = turf.geometry(type, coordinates);
*
* //=geometry
*/
function geometry(type, coordinates, bbox) {
// Validation
if (!type) throw new Error('type is required');
if (!coordinates) throw new Error('coordinates is required');
if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
var geom;
switch (type) {
case 'Point': geom = point(coordinates).geometry; break;
case 'LineString': geom = lineString(coordinates).geometry; break;
case 'Polygon': geom = polygon(coordinates).geometry; break;
case 'MultiPoint': geom = multiPoint(coordinates).geometry; break;
case 'MultiLineString': geom = multiLineString(coordinates).geometry; break;
case 'MultiPolygon': geom = multiPolygon(coordinates).geometry; break;
default: throw new Error(type + ' is invalid');
}
if (bbox) geom.bbox = bbox;
return geom;
}
/**
* Takes coordinates and properties (optional) and returns a new {@link Point} feature.
*
* @name point
* @param {Array} coordinates longitude, latitude position (each in decimal degrees)
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Point feature
* @example
* var point = turf.point([-75.343, 39.984]);
*
* //=point
*/
function point(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'Point',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes an array of LinearRings and optionally an {@link Object} with properties and returns a {@link Polygon} feature.
*
* @name polygon
* @param {Array>>} coordinates an array of LinearRings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Polygon feature
* @throws {Error} throw an error if a LinearRing of the polygon has too few positions
* or if a LinearRing of the Polygon does not have matching Positions at the beginning & end.
* @example
* var polygon = turf.polygon([[
* [-2.275543, 53.464547],
* [-2.275543, 53.489271],
* [-2.215118, 53.489271],
* [-2.215118, 53.464547],
* [-2.275543, 53.464547]
* ]], { name: 'poly1', population: 400});
*
* //=polygon
*/
function polygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
for (var i = 0; i < coordinates.length; i++) {
var ring = coordinates[i];
if (ring.length < 4) {
throw new Error('Each LinearRing of a Polygon must have 4 or more Positions.');
}
for (var j = 0; j < ring[ring.length - 1].length; j++) {
// Check if first point of Polygon contains two numbers
if (i === 0 && j === 0 && !isNumber(ring[0][0]) || !isNumber(ring[0][1])) throw new Error('Coordinates must contain numbers');
if (ring[ring.length - 1][j] !== ring[0][j]) {
throw new Error('First and last Position are not equivalent.');
}
}
}
return feature({
type: 'Polygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link LineString} based on a
* coordinate array. Properties can be added optionally.
*
* @name lineString
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a LineString feature
* @throws {Error} if no coordinates are passed
* @example
* var linestring1 = turf.lineString([
* [-21.964416, 64.148203],
* [-21.956176, 64.141316],
* [-21.93901, 64.135924],
* [-21.927337, 64.136673]
* ]);
* var linestring2 = turf.lineString([
* [-21.929054, 64.127985],
* [-21.912918, 64.134726],
* [-21.916007, 64.141016],
* [-21.930084, 64.14446]
* ], {name: 'line 1', distance: 145});
*
* //=linestring1
*
* //=linestring2
*/
function lineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');
// Check if first point of LineString contains two numbers
if (!isNumber(coordinates[0][1]) || !isNumber(coordinates[0][1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'LineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
*
* @name featureCollection
* @param {Feature[]} features input features
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {FeatureCollection} a FeatureCollection of input features
* @example
* var features = [
* turf.point([-75.343, 39.984], {name: 'Location A'}),
* turf.point([-75.833, 39.284], {name: 'Location B'}),
* turf.point([-75.534, 39.123], {name: 'Location C'})
* ];
*
* var collection = turf.featureCollection(features);
*
* //=collection
*/
function featureCollection(features, bbox, id) {
if (!features) throw new Error('No features passed');
if (!Array.isArray(features)) throw new Error('features must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var fc = {type: 'FeatureCollection'};
if (id) fc.id = id;
if (bbox) fc.bbox = bbox;
fc.features = features;
return fc;
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiLineString
* @param {Array>>} coordinates an array of LineStrings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiLineString feature
* @throws {Error} if no coordinates are passed
* @example
* var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
*
* //=multiLine
*/
function multiLineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiLineString',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPoint
* @param {Array>} coordinates an array of Positions
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a MultiPoint feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPt = turf.multiPoint([[0,0],[10,10]]);
*
* //=multiPt
*/
function multiPoint(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPoint',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name multiPolygon
* @param {Array>>>} coordinates an array of Polygons
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a multipolygon feature
* @throws {Error} if no coordinates are passed
* @example
* var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
*
* //=multiPoly
*
*/
function multiPolygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
return feature({
type: 'MultiPolygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link Feature} based on a
* coordinate array. Properties can be added optionally.
*
* @name geometryCollection
* @param {Array} geometries an array of GeoJSON Geometries
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON GeometryCollection Feature
* @example
* var pt = {
* "type": "Point",
* "coordinates": [100, 0]
* };
* var line = {
* "type": "LineString",
* "coordinates": [ [101, 0], [102, 1] ]
* };
* var collection = turf.geometryCollection([pt, line]);
*
* //=collection
*/
function geometryCollection(geometries, properties, bbox, id) {
if (!geometries) throw new Error('geometries is required');
if (!Array.isArray(geometries)) throw new Error('geometries must be an Array');
return feature({
type: 'GeometryCollection',
geometries: geometries
}, properties, bbox, id);
}
// https://en.wikipedia.org/wiki/Great-circle_distance#Radius_for_spherical_Earth
var factors = {
miles: 3960,
nauticalmiles: 3441.145,
degrees: 57.2957795,
radians: 1,
inches: 250905600,
yards: 6969600,
meters: 6373000,
metres: 6373000,
centimeters: 6.373e+8,
centimetres: 6.373e+8,
kilometers: 6373,
kilometres: 6373,
feet: 20908792.65
};
var areaFactors = {
kilometers: 0.000001,
kilometres: 0.000001,
meters: 1,
metres: 1,
centimetres: 10000,
millimeter: 1000000,
acres: 0.000247105,
miles: 3.86e-7,
yards: 1.195990046,
feet: 10.763910417,
inches: 1550.003100006
};
/**
* Round number to precision
*
* @param {number} num Number
* @param {number} [precision=0] Precision
* @returns {number} rounded number
* @example
* turf.round(120.4321)
* //=120
*
* turf.round(120.4321, 2)
* //=120.43
*/
function round(num, precision) {
if (num === undefined || num === null || isNaN(num)) throw new Error('num is required');
if (precision && !(precision >= 0)) throw new Error('precision must be a positive number');
var multiplier = Math.pow(10, precision || 0);
return Math.round(num * multiplier) / multiplier;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name radiansToDistance
* @param {number} radians in radians across the sphere
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} distance
*/
function radiansToDistance(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error('units is invalid');
return radians * factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @name distanceToRadians
* @param {number} distance in real units
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} radians
*/
function distanceToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');
var factor = factors[units || 'kilometers'];
if (!factor) throw new Error('units is invalid');
return distance / factor;
}
/**
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
*
* @name distanceToDegrees
* @param {number} distance in real units
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
* @returns {number} degrees
*/
function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));
}
/**
* Converts any bearing angle from the north line direction (positive clockwise)
* and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
*
* @name bearingToAngle
* @param {number} bearing angle, between -180 and +180 degrees
* @returns {number} angle between 0 and 360 degrees
*/
function bearingToAngle(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');
var angle = bearing % 360;
if (angle < 0) angle += 360;
return angle;
}
/**
* Converts an angle in radians to degrees
*
* @name radians2degrees
* @param {number} radians angle in radians
* @returns {number} degrees between 0 and 360 degrees
*/
function radians2degrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');
var degrees = radians % (2 * Math.PI);
return degrees * 180 / Math.PI;
}
/**
* Converts an angle in degrees to radians
*
* @name degrees2radians
* @param {number} degrees angle between 0 and 360 degrees
* @returns {number} angle in radians
*/
function degrees2radians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');
var radians = degrees % 360;
return radians * Math.PI / 180;
}
/**
* Converts a distance to the requested unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @param {number} distance to be converted
* @param {string} originalUnit of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');
if (!(distance >= 0)) throw new Error('distance must be a positive number');
var convertedDistance = radiansToDistance(distanceToRadians(distance, originalUnit), finalUnit || 'kilometers');
return convertedDistance;
}
/**
* Converts a area to the requested unit.
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
* @param {number} area to be converted
* @param {string} [originalUnit=meters] of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertArea(area, originalUnit, finalUnit) {
if (area === null || area === undefined) throw new Error('area is required');
if (!(area >= 0)) throw new Error('area must be a positive number');
var startFactor = areaFactors[originalUnit || 'meters'];
if (!startFactor) throw new Error('invalid original units');
var finalFactor = areaFactors[finalUnit || 'kilometers'];
if (!finalFactor) throw new Error('invalid final units');
return (area / startFactor) * finalFactor;
}
/**
* isNumber
*
* @param {*} num Number to validate
* @returns {boolean} true/false
* @example
* turf.isNumber(123)
* //=true
* turf.isNumber('foo')
* //=false
*/
function isNumber(num) {
return !isNaN(num) && num !== null && !Array.isArray(num);
}
module.exports = {
feature: feature,
geometry: geometry,
featureCollection: featureCollection,
geometryCollection: geometryCollection,
point: point,
multiPoint: multiPoint,
lineString: lineString,
multiLineString: multiLineString,
polygon: polygon,
multiPolygon: multiPolygon,
radiansToDistance: radiansToDistance,
distanceToRadians: distanceToRadians,
distanceToDegrees: distanceToDegrees,
radians2degrees: radians2degrees,
degrees2radians: degrees2radians,
bearingToAngle: bearingToAngle,
convertDistance: convertDistance,
convertArea: convertArea,
round: round,
isNumber: isNumber
};
/***/ }),
/* 196 */
/***/ (function(module, exports, __webpack_require__) {
//http://en.wikipedia.org/wiki/Haversine_formula
//http://www.movable-type.co.uk/scripts/latlong.html
var getCoord = __webpack_require__(32).getCoord;
var helpers = __webpack_require__(197);
var point = helpers.point;
var distanceToRadians = helpers.distanceToRadians;
/**
* Takes a {@link Point} and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
*
* @name destination
* @param {Geometry|Feature|Array} origin starting point
* @param {number} distance distance from the origin point
* @param {number} bearing ranging from -180 to 180
* @param {string} [units=kilometers] miles, kilometers, degrees, or radians
* @returns {Feature} destination point
* @example
* var point = turf.point([-75.343, 39.984]);
* var distance = 50;
* var bearing = 90;
* var units = 'miles';
*
* var destination = turf.destination(point, distance, bearing, units);
*
* //addToMap
* var addToMap = [point, destination]
* destination.properties['marker-color'] = '#f00';
* point.properties['marker-color'] = '#0f0';
*/
module.exports = function (origin, distance, bearing, units) {
var degrees2radians = Math.PI / 180;
var radians2degrees = 180 / Math.PI;
var coordinates1 = getCoord(origin);
var longitude1 = degrees2radians * coordinates1[0];
var latitude1 = degrees2radians * coordinates1[1];
var bearing_rad = degrees2radians * bearing;
var radians = distanceToRadians(distance, units);
var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad));
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1),
Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
return point([radians2degrees * longitude2, radians2degrees * latitude2]);
};
/***/ }),
/* 197 */
/***/ (function(module, exports) {
/**
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
*
* @name feature
* @param {Geometry} geometry input geometry
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a GeoJSON Feature
* @example
* var geometry = {
* "type": "Point",
* "coordinates": [110, 50]
* };
*
* var feature = turf.feature(geometry);
*
* //=feature
*/
function feature(geometry, properties, bbox, id) {
if (geometry === undefined) throw new Error('geometry is required');
if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
var feat = {type: 'Feature'};
if (id) feat.id = id;
if (bbox) feat.bbox = bbox;
feat.properties = properties || {};
feat.geometry = geometry;
return feat;
}
/**
* Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
* For GeometryCollection type use `helpers.geometryCollection`
*
* @name geometry
* @param {string} type Geometry Type
* @param {Array} coordinates Coordinates
* @param {Array} [bbox] BBox [west, south, east, north]
* @returns {Geometry} a GeoJSON Geometry
* @example
* var type = 'Point';
* var coordinates = [110, 50];
*
* var geometry = turf.geometry(type, coordinates);
*
* //=geometry
*/
function geometry(type, coordinates, bbox) {
// Validation
if (!type) throw new Error('type is required');
if (!coordinates) throw new Error('coordinates is required');
if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
var geom;
switch (type) {
case 'Point': geom = point(coordinates).geometry; break;
case 'LineString': geom = lineString(coordinates).geometry; break;
case 'Polygon': geom = polygon(coordinates).geometry; break;
case 'MultiPoint': geom = multiPoint(coordinates).geometry; break;
case 'MultiLineString': geom = multiLineString(coordinates).geometry; break;
case 'MultiPolygon': geom = multiPolygon(coordinates).geometry; break;
default: throw new Error(type + ' is invalid');
}
if (bbox) geom.bbox = bbox;
return geom;
}
/**
* Takes coordinates and properties (optional) and returns a new {@link Point} feature.
*
* @name point
* @param {Array} coordinates longitude, latitude position (each in decimal degrees)
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Point feature
* @example
* var point = turf.point([-75.343, 39.984]);
*
* //=point
*/
function point(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');
return feature({
type: 'Point',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Takes an array of LinearRings and optionally an {@link Object} with properties and returns a {@link Polygon} feature.
*
* @name polygon
* @param {Array>>} coordinates an array of LinearRings
* @param {Object} [properties={}] an Object of key-value pairs to add as properties
* @param {Array} [bbox] BBox [west, south, east, north]
* @param {string|number} [id] Identifier
* @returns {Feature} a Polygon feature
* @throws {Error} throw an error if a LinearRing of the polygon has too few positions
* or if a LinearRing of the Polygon does not have matching Positions at the beginning & end.
* @example
* var polygon = turf.polygon([[
* [-2.275543, 53.464547],
* [-2.275543, 53.489271],
* [-2.215118, 53.489271],
* [-2.215118, 53.464547],
* [-2.275543, 53.464547]
* ]], { name: 'poly1', population: 400});
*
* //=polygon
*/
function polygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');
for (var i = 0; i < coordinates.length; i++) {
var ring = coordinates[i];
if (ring.length < 4) {
throw new Error('Each LinearRing of a Polygon must have 4 or more Positions.');
}
for (var j = 0; j < ring[ring.length - 1].length; j++) {
// Check if first point of Polygon contains two numbers
if (i === 0 && j === 0 && !isNumber(ring[0][0]) || !isNumber(ring[0][1])) throw new Error('Coordinates must contain numbers');
if (ring[ring.length - 1][j] !== ring[0][j]) {
throw new Error('First and last Position are not equivalent.');
}
}
}
return feature({
type: 'Polygon',
coordinates: coordinates
}, properties, bbox, id);
}
/**
* Creates a {@link LineString} based on a
* coordinate array. Properties can be added optionally.
*
* @name lineString
* @param {Array