@vaadin/bundles 23.1.0 → 23.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules_ol_ImageCanvas_js.js +121 -0
- package/node_modules_ol_ImageCanvas_js.js.map +1 -0
- package/node_modules_ol_ImageTile_js.js +177 -0
- package/node_modules_ol_ImageTile_js.js.map +1 -0
- package/node_modules_ol_TileRange_js.js +154 -0
- package/node_modules_ol_TileRange_js.js.map +1 -0
- package/node_modules_ol_VectorRenderTile_js.js +182 -0
- package/node_modules_ol_VectorRenderTile_js.js.map +1 -0
- package/node_modules_ol_VectorTile_js.js +158 -0
- package/node_modules_ol_VectorTile_js.js.map +1 -0
- package/node_modules_ol_geom_flat_geodesic_js.js +171 -0
- package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -0
- package/node_modules_ol_render_js.js +131 -0
- package/node_modules_ol_render_js.js.map +1 -0
- package/node_modules_ol_structs_LRUCache_js.js +275 -0
- package/node_modules_ol_structs_LRUCache_js.js.map +1 -0
- package/node_modules_ol_style_js.js +47 -0
- package/node_modules_ol_style_js.js.map +1 -0
- package/node_modules_ol_tilecoord_js.js +115 -0
- package/node_modules_ol_tilecoord_js.js.map +1 -0
- package/package.json +148 -120
- package/vaadin-bundle.json +2614 -996
- package/vaadin.js +83021 -36220
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_ol_Geolocation_js.js +379 -0
- package/vendors-node_modules_ol_Geolocation_js.js.map +1 -0
- package/vendors-node_modules_ol_TileCache_js.js +461 -0
- package/vendors-node_modules_ol_TileCache_js.js.map +1 -0
- package/vendors-node_modules_ol_Tile_js.js +330 -0
- package/vendors-node_modules_ol_Tile_js.js.map +1 -0
- package/vendors-node_modules_ol_index_js.js +874 -0
- package/vendors-node_modules_ol_index_js.js.map +1 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js +1359 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -0
- package/vendors-node_modules_ol_style_Text_js.js +509 -0
- package/vendors-node_modules_ol_style_Text_js.js.map +1 -0
- package/vendors-node_modules_rbush_index_js.js +531 -0
- package/vendors-node_modules_rbush_index_js.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendors-node_modules_ol_style_Text_js.js","mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AAC6B;AACkB;AACX;AACpC;AACA,0EAA0E;AAC1E;AACA;AACA,WAAW;AACX;AACA;AACA;AACA,aAAa,QAAQ;AACrB,cAAc,QAAQ;AACtB;AACA,cAAc,QAAQ;AACtB;AACA,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB;AACA,cAAc,6CAA6C;AAC3D,cAAc,kCAAkC;AAChD,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,sBAAsB;AACpC;AACA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA,cAAc,QAAQ;AACtB;AACA,cAAc,6BAA6B;AAC3C,cAAc,+BAA+B;AAC7C,cAAc,6BAA6B;AAC3C;AACA,cAAc,+BAA+B;AAC7C;AACA,cAAc,eAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,2BAA2B,gDAAM;AACjC;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,sBAAsB,gDAAI,GAAG,2BAA2B;AACxD;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA,kEAAkE,+DAAmB;AACrF;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA,gBAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,gBAAgB,SAAS;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,6CAA6C;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,6BAA6B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,4CAA4C;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,2BAA2B;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,+BAA+B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,gCAAgC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,6BAA6B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,+BAA+B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,6CAA6C;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,6BAA6B;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,4CAA4C;AAC3D;AACA;AACA;AACA;AACA,2BAA2B,gDAAM;AACjC;AACA;AACA;AACA;AACA,eAAe,+BAA+B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,6BAA6B;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,+BAA+B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,iEAAe,IAAI,EAAC;AACpB","sources":["webpack://@vaadin/bundles/./node_modules/ol/style/Text.js"],"sourcesContent":["/**\n * @module ol/style/Text\n */\nimport Fill from './Fill.js';\nimport TextPlacement from './TextPlacement.js';\nimport { toSize } from '../size.js';\n/**\n * The default fill color to use if no fill was set at construction time; a\n * blackish `#333`.\n *\n * @const {string}\n */\nvar DEFAULT_FILL_COLOR = '#333';\n/**\n * @typedef {Object} Options\n * @property {string} [font] Font style as CSS 'font' value, see:\n * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is '10px sans-serif'\n * @property {number} [maxAngle=Math.PI/4] When `placement` is set to `'line'`, allow a maximum angle between adjacent characters.\n * The expected value is in radians, and the default is 45° (`Math.PI / 4`).\n * @property {number} [offsetX=0] Horizontal text offset in pixels. A positive will shift the text right.\n * @property {number} [offsetY=0] Vertical text offset in pixels. A positive will shift the text down.\n * @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed\n * the width of the polygon at the label position or the length of the path that it follows.\n * @property {import(\"./TextPlacement.js\").default|string} [placement='point'] Text placement.\n * @property {number|import(\"../size.js\").Size} [scale] Scale.\n * @property {boolean} [rotateWithView=false] Whether to rotate the text with the view.\n * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).\n * @property {string|Array<string>} [text] Text content or rich text content. For plain text provide a string, which can\n * contain line breaks (`\\n`). For rich text provide an array of text/font tuples. A tuple consists of the text to\n * render and the font to use (or `''` to use the text style's font). A line break has to be a separate tuple (i.e. `'\\n', ''`).\n * **Example:** `['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']` will yield \"**foo** *bar* baz\".\n * **Note:** Rich text is not supported for the immediate rendering API.\n * @property {string} [textAlign] Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'.\n * Default is 'center' for `placement: 'point'`. For `placement: 'line'`, the default is to let the renderer choose a\n * placement where `maxAngle` is not exceeded.\n * @property {string} [textBaseline='middle'] Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic',\n * 'hanging', 'ideographic'.\n * @property {import(\"./Fill.js\").default} [fill] Fill style. If none is provided, we'll use a dark fill-style (#333).\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {import(\"./Fill.js\").default} [backgroundFill] Fill style for the text background when `placement` is\n * `'point'`. Default is no fill.\n * @property {import(\"./Stroke.js\").default} [backgroundStroke] Stroke style for the text background when `placement`\n * is `'point'`. Default is no stroke.\n * @property {Array<number>} [padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of\n * values in the array is `[top, right, bottom, left]`.\n */\n/**\n * @classdesc\n * Set text style for vector features.\n * @api\n */\nvar Text = /** @class */ (function () {\n /**\n * @param {Options} [opt_options] Options.\n */\n function Text(opt_options) {\n var options = opt_options || {};\n /**\n * @private\n * @type {string|undefined}\n */\n this.font_ = options.font;\n /**\n * @private\n * @type {number|undefined}\n */\n this.rotation_ = options.rotation;\n /**\n * @private\n * @type {boolean|undefined}\n */\n this.rotateWithView_ = options.rotateWithView;\n /**\n * @private\n * @type {number|import(\"../size.js\").Size|undefined}\n */\n this.scale_ = options.scale;\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.scaleArray_ = toSize(options.scale !== undefined ? options.scale : 1);\n /**\n * @private\n * @type {string|Array<string>|undefined}\n */\n this.text_ = options.text;\n /**\n * @private\n * @type {string|undefined}\n */\n this.textAlign_ = options.textAlign;\n /**\n * @private\n * @type {string|undefined}\n */\n this.textBaseline_ = options.textBaseline;\n /**\n * @private\n * @type {import(\"./Fill.js\").default}\n */\n this.fill_ =\n options.fill !== undefined\n ? options.fill\n : new Fill({ color: DEFAULT_FILL_COLOR });\n /**\n * @private\n * @type {number}\n */\n this.maxAngle_ =\n options.maxAngle !== undefined ? options.maxAngle : Math.PI / 4;\n /**\n * @private\n * @type {import(\"./TextPlacement.js\").default|string}\n */\n this.placement_ =\n options.placement !== undefined ? options.placement : TextPlacement.POINT;\n /**\n * @private\n * @type {boolean}\n */\n this.overflow_ = !!options.overflow;\n /**\n * @private\n * @type {import(\"./Stroke.js\").default}\n */\n this.stroke_ = options.stroke !== undefined ? options.stroke : null;\n /**\n * @private\n * @type {number}\n */\n this.offsetX_ = options.offsetX !== undefined ? options.offsetX : 0;\n /**\n * @private\n * @type {number}\n */\n this.offsetY_ = options.offsetY !== undefined ? options.offsetY : 0;\n /**\n * @private\n * @type {import(\"./Fill.js\").default}\n */\n this.backgroundFill_ = options.backgroundFill\n ? options.backgroundFill\n : null;\n /**\n * @private\n * @type {import(\"./Stroke.js\").default}\n */\n this.backgroundStroke_ = options.backgroundStroke\n ? options.backgroundStroke\n : null;\n /**\n * @private\n * @type {Array<number>|null}\n */\n this.padding_ = options.padding === undefined ? null : options.padding;\n }\n /**\n * Clones the style.\n * @return {Text} The cloned style.\n * @api\n */\n Text.prototype.clone = function () {\n var scale = this.getScale();\n return new Text({\n font: this.getFont(),\n placement: this.getPlacement(),\n maxAngle: this.getMaxAngle(),\n overflow: this.getOverflow(),\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n text: this.getText(),\n textAlign: this.getTextAlign(),\n textBaseline: this.getTextBaseline(),\n fill: this.getFill() ? this.getFill().clone() : undefined,\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n offsetX: this.getOffsetX(),\n offsetY: this.getOffsetY(),\n backgroundFill: this.getBackgroundFill()\n ? this.getBackgroundFill().clone()\n : undefined,\n backgroundStroke: this.getBackgroundStroke()\n ? this.getBackgroundStroke().clone()\n : undefined,\n padding: this.getPadding() || undefined,\n });\n };\n /**\n * Get the `overflow` configuration.\n * @return {boolean} Let text overflow the length of the path they follow.\n * @api\n */\n Text.prototype.getOverflow = function () {\n return this.overflow_;\n };\n /**\n * Get the font name.\n * @return {string|undefined} Font.\n * @api\n */\n Text.prototype.getFont = function () {\n return this.font_;\n };\n /**\n * Get the maximum angle between adjacent characters.\n * @return {number} Angle in radians.\n * @api\n */\n Text.prototype.getMaxAngle = function () {\n return this.maxAngle_;\n };\n /**\n * Get the label placement.\n * @return {import(\"./TextPlacement.js\").default|string} Text placement.\n * @api\n */\n Text.prototype.getPlacement = function () {\n return this.placement_;\n };\n /**\n * Get the x-offset for the text.\n * @return {number} Horizontal text offset.\n * @api\n */\n Text.prototype.getOffsetX = function () {\n return this.offsetX_;\n };\n /**\n * Get the y-offset for the text.\n * @return {number} Vertical text offset.\n * @api\n */\n Text.prototype.getOffsetY = function () {\n return this.offsetY_;\n };\n /**\n * Get the fill style for the text.\n * @return {import(\"./Fill.js\").default} Fill style.\n * @api\n */\n Text.prototype.getFill = function () {\n return this.fill_;\n };\n /**\n * Determine whether the text rotates with the map.\n * @return {boolean|undefined} Rotate with map.\n * @api\n */\n Text.prototype.getRotateWithView = function () {\n return this.rotateWithView_;\n };\n /**\n * Get the text rotation.\n * @return {number|undefined} Rotation.\n * @api\n */\n Text.prototype.getRotation = function () {\n return this.rotation_;\n };\n /**\n * Get the text scale.\n * @return {number|import(\"../size.js\").Size|undefined} Scale.\n * @api\n */\n Text.prototype.getScale = function () {\n return this.scale_;\n };\n /**\n * Get the symbolizer scale array.\n * @return {import(\"../size.js\").Size} Scale array.\n */\n Text.prototype.getScaleArray = function () {\n return this.scaleArray_;\n };\n /**\n * Get the stroke style for the text.\n * @return {import(\"./Stroke.js\").default} Stroke style.\n * @api\n */\n Text.prototype.getStroke = function () {\n return this.stroke_;\n };\n /**\n * Get the text to be rendered.\n * @return {string|Array<string>|undefined} Text.\n * @api\n */\n Text.prototype.getText = function () {\n return this.text_;\n };\n /**\n * Get the text alignment.\n * @return {string|undefined} Text align.\n * @api\n */\n Text.prototype.getTextAlign = function () {\n return this.textAlign_;\n };\n /**\n * Get the text baseline.\n * @return {string|undefined} Text baseline.\n * @api\n */\n Text.prototype.getTextBaseline = function () {\n return this.textBaseline_;\n };\n /**\n * Get the background fill style for the text.\n * @return {import(\"./Fill.js\").default} Fill style.\n * @api\n */\n Text.prototype.getBackgroundFill = function () {\n return this.backgroundFill_;\n };\n /**\n * Get the background stroke style for the text.\n * @return {import(\"./Stroke.js\").default} Stroke style.\n * @api\n */\n Text.prototype.getBackgroundStroke = function () {\n return this.backgroundStroke_;\n };\n /**\n * Get the padding for the text.\n * @return {Array<number>|null} Padding.\n * @api\n */\n Text.prototype.getPadding = function () {\n return this.padding_;\n };\n /**\n * Set the `overflow` property.\n *\n * @param {boolean} overflow Let text overflow the path that it follows.\n * @api\n */\n Text.prototype.setOverflow = function (overflow) {\n this.overflow_ = overflow;\n };\n /**\n * Set the font.\n *\n * @param {string|undefined} font Font.\n * @api\n */\n Text.prototype.setFont = function (font) {\n this.font_ = font;\n };\n /**\n * Set the maximum angle between adjacent characters.\n *\n * @param {number} maxAngle Angle in radians.\n * @api\n */\n Text.prototype.setMaxAngle = function (maxAngle) {\n this.maxAngle_ = maxAngle;\n };\n /**\n * Set the x offset.\n *\n * @param {number} offsetX Horizontal text offset.\n * @api\n */\n Text.prototype.setOffsetX = function (offsetX) {\n this.offsetX_ = offsetX;\n };\n /**\n * Set the y offset.\n *\n * @param {number} offsetY Vertical text offset.\n * @api\n */\n Text.prototype.setOffsetY = function (offsetY) {\n this.offsetY_ = offsetY;\n };\n /**\n * Set the text placement.\n *\n * @param {import(\"./TextPlacement.js\").default|string} placement Placement.\n * @api\n */\n Text.prototype.setPlacement = function (placement) {\n this.placement_ = placement;\n };\n /**\n * Set whether to rotate the text with the view.\n *\n * @param {boolean} rotateWithView Rotate with map.\n * @api\n */\n Text.prototype.setRotateWithView = function (rotateWithView) {\n this.rotateWithView_ = rotateWithView;\n };\n /**\n * Set the fill.\n *\n * @param {import(\"./Fill.js\").default} fill Fill style.\n * @api\n */\n Text.prototype.setFill = function (fill) {\n this.fill_ = fill;\n };\n /**\n * Set the rotation.\n *\n * @param {number|undefined} rotation Rotation.\n * @api\n */\n Text.prototype.setRotation = function (rotation) {\n this.rotation_ = rotation;\n };\n /**\n * Set the scale.\n *\n * @param {number|import(\"../size.js\").Size|undefined} scale Scale.\n * @api\n */\n Text.prototype.setScale = function (scale) {\n this.scale_ = scale;\n this.scaleArray_ = toSize(scale !== undefined ? scale : 1);\n };\n /**\n * Set the stroke.\n *\n * @param {import(\"./Stroke.js\").default} stroke Stroke style.\n * @api\n */\n Text.prototype.setStroke = function (stroke) {\n this.stroke_ = stroke;\n };\n /**\n * Set the text.\n *\n * @param {string|undefined} text Text.\n * @api\n */\n Text.prototype.setText = function (text) {\n this.text_ = text;\n };\n /**\n * Set the text alignment.\n *\n * @param {string|undefined} textAlign Text align.\n * @api\n */\n Text.prototype.setTextAlign = function (textAlign) {\n this.textAlign_ = textAlign;\n };\n /**\n * Set the text baseline.\n *\n * @param {string|undefined} textBaseline Text baseline.\n * @api\n */\n Text.prototype.setTextBaseline = function (textBaseline) {\n this.textBaseline_ = textBaseline;\n };\n /**\n * Set the background fill.\n *\n * @param {import(\"./Fill.js\").default} fill Fill style.\n * @api\n */\n Text.prototype.setBackgroundFill = function (fill) {\n this.backgroundFill_ = fill;\n };\n /**\n * Set the background stroke.\n *\n * @param {import(\"./Stroke.js\").default} stroke Stroke style.\n * @api\n */\n Text.prototype.setBackgroundStroke = function (stroke) {\n this.backgroundStroke_ = stroke;\n };\n /**\n * Set the padding (`[top, right, bottom, left]`).\n *\n * @param {Array<number>|null} padding Padding.\n * @api\n */\n Text.prototype.setPadding = function (padding) {\n this.padding_ = padding;\n };\n return Text;\n}());\nexport default Text;\n//# sourceMappingURL=Text.js.map"],"names":[],"sourceRoot":""}
|
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_rbush_index_js"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/rbush/index.js":
|
|
4
|
+
/*!*************************************!*\
|
|
5
|
+
!*** ./node_modules/rbush/index.js ***!
|
|
6
|
+
\*************************************/
|
|
7
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
8
|
+
|
|
9
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
/* harmony export */ "default": () => (/* binding */ RBush)
|
|
12
|
+
/* harmony export */ });
|
|
13
|
+
/* harmony import */ var quickselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! quickselect */ "./node_modules/quickselect/index.js");
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class RBush {
|
|
17
|
+
constructor(maxEntries = 9) {
|
|
18
|
+
// max entries in a node is 9 by default; min node fill is 40% for best performance
|
|
19
|
+
this._maxEntries = Math.max(4, maxEntries);
|
|
20
|
+
this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
|
|
21
|
+
this.clear();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
all() {
|
|
25
|
+
return this._all(this.data, []);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
search(bbox) {
|
|
29
|
+
let node = this.data;
|
|
30
|
+
const result = [];
|
|
31
|
+
|
|
32
|
+
if (!intersects(bbox, node)) return result;
|
|
33
|
+
|
|
34
|
+
const toBBox = this.toBBox;
|
|
35
|
+
const nodesToSearch = [];
|
|
36
|
+
|
|
37
|
+
while (node) {
|
|
38
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
39
|
+
const child = node.children[i];
|
|
40
|
+
const childBBox = node.leaf ? toBBox(child) : child;
|
|
41
|
+
|
|
42
|
+
if (intersects(bbox, childBBox)) {
|
|
43
|
+
if (node.leaf) result.push(child);
|
|
44
|
+
else if (contains(bbox, childBBox)) this._all(child, result);
|
|
45
|
+
else nodesToSearch.push(child);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
node = nodesToSearch.pop();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
collides(bbox) {
|
|
55
|
+
let node = this.data;
|
|
56
|
+
|
|
57
|
+
if (!intersects(bbox, node)) return false;
|
|
58
|
+
|
|
59
|
+
const nodesToSearch = [];
|
|
60
|
+
while (node) {
|
|
61
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
62
|
+
const child = node.children[i];
|
|
63
|
+
const childBBox = node.leaf ? this.toBBox(child) : child;
|
|
64
|
+
|
|
65
|
+
if (intersects(bbox, childBBox)) {
|
|
66
|
+
if (node.leaf || contains(bbox, childBBox)) return true;
|
|
67
|
+
nodesToSearch.push(child);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
node = nodesToSearch.pop();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
load(data) {
|
|
77
|
+
if (!(data && data.length)) return this;
|
|
78
|
+
|
|
79
|
+
if (data.length < this._minEntries) {
|
|
80
|
+
for (let i = 0; i < data.length; i++) {
|
|
81
|
+
this.insert(data[i]);
|
|
82
|
+
}
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// recursively build the tree with the given data from scratch using OMT algorithm
|
|
87
|
+
let node = this._build(data.slice(), 0, data.length - 1, 0);
|
|
88
|
+
|
|
89
|
+
if (!this.data.children.length) {
|
|
90
|
+
// save as is if tree is empty
|
|
91
|
+
this.data = node;
|
|
92
|
+
|
|
93
|
+
} else if (this.data.height === node.height) {
|
|
94
|
+
// split root if trees have the same height
|
|
95
|
+
this._splitRoot(this.data, node);
|
|
96
|
+
|
|
97
|
+
} else {
|
|
98
|
+
if (this.data.height < node.height) {
|
|
99
|
+
// swap trees if inserted one is bigger
|
|
100
|
+
const tmpNode = this.data;
|
|
101
|
+
this.data = node;
|
|
102
|
+
node = tmpNode;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// insert the small tree into the large tree at appropriate level
|
|
106
|
+
this._insert(node, this.data.height - node.height - 1, true);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
insert(item) {
|
|
113
|
+
if (item) this._insert(item, this.data.height - 1);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
clear() {
|
|
118
|
+
this.data = createNode([]);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
remove(item, equalsFn) {
|
|
123
|
+
if (!item) return this;
|
|
124
|
+
|
|
125
|
+
let node = this.data;
|
|
126
|
+
const bbox = this.toBBox(item);
|
|
127
|
+
const path = [];
|
|
128
|
+
const indexes = [];
|
|
129
|
+
let i, parent, goingUp;
|
|
130
|
+
|
|
131
|
+
// depth-first iterative tree traversal
|
|
132
|
+
while (node || path.length) {
|
|
133
|
+
|
|
134
|
+
if (!node) { // go up
|
|
135
|
+
node = path.pop();
|
|
136
|
+
parent = path[path.length - 1];
|
|
137
|
+
i = indexes.pop();
|
|
138
|
+
goingUp = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (node.leaf) { // check current node
|
|
142
|
+
const index = findItem(item, node.children, equalsFn);
|
|
143
|
+
|
|
144
|
+
if (index !== -1) {
|
|
145
|
+
// item found, remove the item and condense tree upwards
|
|
146
|
+
node.children.splice(index, 1);
|
|
147
|
+
path.push(node);
|
|
148
|
+
this._condense(path);
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
|
|
154
|
+
path.push(node);
|
|
155
|
+
indexes.push(i);
|
|
156
|
+
i = 0;
|
|
157
|
+
parent = node;
|
|
158
|
+
node = node.children[0];
|
|
159
|
+
|
|
160
|
+
} else if (parent) { // go right
|
|
161
|
+
i++;
|
|
162
|
+
node = parent.children[i];
|
|
163
|
+
goingUp = false;
|
|
164
|
+
|
|
165
|
+
} else node = null; // nothing found
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
toBBox(item) { return item; }
|
|
172
|
+
|
|
173
|
+
compareMinX(a, b) { return a.minX - b.minX; }
|
|
174
|
+
compareMinY(a, b) { return a.minY - b.minY; }
|
|
175
|
+
|
|
176
|
+
toJSON() { return this.data; }
|
|
177
|
+
|
|
178
|
+
fromJSON(data) {
|
|
179
|
+
this.data = data;
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
_all(node, result) {
|
|
184
|
+
const nodesToSearch = [];
|
|
185
|
+
while (node) {
|
|
186
|
+
if (node.leaf) result.push(...node.children);
|
|
187
|
+
else nodesToSearch.push(...node.children);
|
|
188
|
+
|
|
189
|
+
node = nodesToSearch.pop();
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
_build(items, left, right, height) {
|
|
195
|
+
|
|
196
|
+
const N = right - left + 1;
|
|
197
|
+
let M = this._maxEntries;
|
|
198
|
+
let node;
|
|
199
|
+
|
|
200
|
+
if (N <= M) {
|
|
201
|
+
// reached leaf level; return leaf
|
|
202
|
+
node = createNode(items.slice(left, right + 1));
|
|
203
|
+
calcBBox(node, this.toBBox);
|
|
204
|
+
return node;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!height) {
|
|
208
|
+
// target height of the bulk-loaded tree
|
|
209
|
+
height = Math.ceil(Math.log(N) / Math.log(M));
|
|
210
|
+
|
|
211
|
+
// target number of root entries to maximize storage utilization
|
|
212
|
+
M = Math.ceil(N / Math.pow(M, height - 1));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
node = createNode([]);
|
|
216
|
+
node.leaf = false;
|
|
217
|
+
node.height = height;
|
|
218
|
+
|
|
219
|
+
// split the items into M mostly square tiles
|
|
220
|
+
|
|
221
|
+
const N2 = Math.ceil(N / M);
|
|
222
|
+
const N1 = N2 * Math.ceil(Math.sqrt(M));
|
|
223
|
+
|
|
224
|
+
multiSelect(items, left, right, N1, this.compareMinX);
|
|
225
|
+
|
|
226
|
+
for (let i = left; i <= right; i += N1) {
|
|
227
|
+
|
|
228
|
+
const right2 = Math.min(i + N1 - 1, right);
|
|
229
|
+
|
|
230
|
+
multiSelect(items, i, right2, N2, this.compareMinY);
|
|
231
|
+
|
|
232
|
+
for (let j = i; j <= right2; j += N2) {
|
|
233
|
+
|
|
234
|
+
const right3 = Math.min(j + N2 - 1, right2);
|
|
235
|
+
|
|
236
|
+
// pack each entry recursively
|
|
237
|
+
node.children.push(this._build(items, j, right3, height - 1));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
calcBBox(node, this.toBBox);
|
|
242
|
+
|
|
243
|
+
return node;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
_chooseSubtree(bbox, node, level, path) {
|
|
247
|
+
while (true) {
|
|
248
|
+
path.push(node);
|
|
249
|
+
|
|
250
|
+
if (node.leaf || path.length - 1 === level) break;
|
|
251
|
+
|
|
252
|
+
let minArea = Infinity;
|
|
253
|
+
let minEnlargement = Infinity;
|
|
254
|
+
let targetNode;
|
|
255
|
+
|
|
256
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
257
|
+
const child = node.children[i];
|
|
258
|
+
const area = bboxArea(child);
|
|
259
|
+
const enlargement = enlargedArea(bbox, child) - area;
|
|
260
|
+
|
|
261
|
+
// choose entry with the least area enlargement
|
|
262
|
+
if (enlargement < minEnlargement) {
|
|
263
|
+
minEnlargement = enlargement;
|
|
264
|
+
minArea = area < minArea ? area : minArea;
|
|
265
|
+
targetNode = child;
|
|
266
|
+
|
|
267
|
+
} else if (enlargement === minEnlargement) {
|
|
268
|
+
// otherwise choose one with the smallest area
|
|
269
|
+
if (area < minArea) {
|
|
270
|
+
minArea = area;
|
|
271
|
+
targetNode = child;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
node = targetNode || node.children[0];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return node;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
_insert(item, level, isNode) {
|
|
283
|
+
const bbox = isNode ? item : this.toBBox(item);
|
|
284
|
+
const insertPath = [];
|
|
285
|
+
|
|
286
|
+
// find the best node for accommodating the item, saving all nodes along the path too
|
|
287
|
+
const node = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
288
|
+
|
|
289
|
+
// put the item into the node
|
|
290
|
+
node.children.push(item);
|
|
291
|
+
extend(node, bbox);
|
|
292
|
+
|
|
293
|
+
// split on node overflow; propagate upwards if necessary
|
|
294
|
+
while (level >= 0) {
|
|
295
|
+
if (insertPath[level].children.length > this._maxEntries) {
|
|
296
|
+
this._split(insertPath, level);
|
|
297
|
+
level--;
|
|
298
|
+
} else break;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// adjust bboxes along the insertion path
|
|
302
|
+
this._adjustParentBBoxes(bbox, insertPath, level);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// split overflowed node into two
|
|
306
|
+
_split(insertPath, level) {
|
|
307
|
+
const node = insertPath[level];
|
|
308
|
+
const M = node.children.length;
|
|
309
|
+
const m = this._minEntries;
|
|
310
|
+
|
|
311
|
+
this._chooseSplitAxis(node, m, M);
|
|
312
|
+
|
|
313
|
+
const splitIndex = this._chooseSplitIndex(node, m, M);
|
|
314
|
+
|
|
315
|
+
const newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
|
|
316
|
+
newNode.height = node.height;
|
|
317
|
+
newNode.leaf = node.leaf;
|
|
318
|
+
|
|
319
|
+
calcBBox(node, this.toBBox);
|
|
320
|
+
calcBBox(newNode, this.toBBox);
|
|
321
|
+
|
|
322
|
+
if (level) insertPath[level - 1].children.push(newNode);
|
|
323
|
+
else this._splitRoot(node, newNode);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
_splitRoot(node, newNode) {
|
|
327
|
+
// split root node
|
|
328
|
+
this.data = createNode([node, newNode]);
|
|
329
|
+
this.data.height = node.height + 1;
|
|
330
|
+
this.data.leaf = false;
|
|
331
|
+
calcBBox(this.data, this.toBBox);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
_chooseSplitIndex(node, m, M) {
|
|
335
|
+
let index;
|
|
336
|
+
let minOverlap = Infinity;
|
|
337
|
+
let minArea = Infinity;
|
|
338
|
+
|
|
339
|
+
for (let i = m; i <= M - m; i++) {
|
|
340
|
+
const bbox1 = distBBox(node, 0, i, this.toBBox);
|
|
341
|
+
const bbox2 = distBBox(node, i, M, this.toBBox);
|
|
342
|
+
|
|
343
|
+
const overlap = intersectionArea(bbox1, bbox2);
|
|
344
|
+
const area = bboxArea(bbox1) + bboxArea(bbox2);
|
|
345
|
+
|
|
346
|
+
// choose distribution with minimum overlap
|
|
347
|
+
if (overlap < minOverlap) {
|
|
348
|
+
minOverlap = overlap;
|
|
349
|
+
index = i;
|
|
350
|
+
|
|
351
|
+
minArea = area < minArea ? area : minArea;
|
|
352
|
+
|
|
353
|
+
} else if (overlap === minOverlap) {
|
|
354
|
+
// otherwise choose distribution with minimum area
|
|
355
|
+
if (area < minArea) {
|
|
356
|
+
minArea = area;
|
|
357
|
+
index = i;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return index || M - m;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// sorts node children by the best axis for split
|
|
366
|
+
_chooseSplitAxis(node, m, M) {
|
|
367
|
+
const compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
|
|
368
|
+
const compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
|
|
369
|
+
const xMargin = this._allDistMargin(node, m, M, compareMinX);
|
|
370
|
+
const yMargin = this._allDistMargin(node, m, M, compareMinY);
|
|
371
|
+
|
|
372
|
+
// if total distributions margin value is minimal for x, sort by minX,
|
|
373
|
+
// otherwise it's already sorted by minY
|
|
374
|
+
if (xMargin < yMargin) node.children.sort(compareMinX);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// total margin of all possible split distributions where each node is at least m full
|
|
378
|
+
_allDistMargin(node, m, M, compare) {
|
|
379
|
+
node.children.sort(compare);
|
|
380
|
+
|
|
381
|
+
const toBBox = this.toBBox;
|
|
382
|
+
const leftBBox = distBBox(node, 0, m, toBBox);
|
|
383
|
+
const rightBBox = distBBox(node, M - m, M, toBBox);
|
|
384
|
+
let margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
|
|
385
|
+
|
|
386
|
+
for (let i = m; i < M - m; i++) {
|
|
387
|
+
const child = node.children[i];
|
|
388
|
+
extend(leftBBox, node.leaf ? toBBox(child) : child);
|
|
389
|
+
margin += bboxMargin(leftBBox);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
for (let i = M - m - 1; i >= m; i--) {
|
|
393
|
+
const child = node.children[i];
|
|
394
|
+
extend(rightBBox, node.leaf ? toBBox(child) : child);
|
|
395
|
+
margin += bboxMargin(rightBBox);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return margin;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
_adjustParentBBoxes(bbox, path, level) {
|
|
402
|
+
// adjust bboxes along the given tree path
|
|
403
|
+
for (let i = level; i >= 0; i--) {
|
|
404
|
+
extend(path[i], bbox);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
_condense(path) {
|
|
409
|
+
// go through the path, removing empty nodes and updating bboxes
|
|
410
|
+
for (let i = path.length - 1, siblings; i >= 0; i--) {
|
|
411
|
+
if (path[i].children.length === 0) {
|
|
412
|
+
if (i > 0) {
|
|
413
|
+
siblings = path[i - 1].children;
|
|
414
|
+
siblings.splice(siblings.indexOf(path[i]), 1);
|
|
415
|
+
|
|
416
|
+
} else this.clear();
|
|
417
|
+
|
|
418
|
+
} else calcBBox(path[i], this.toBBox);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function findItem(item, items, equalsFn) {
|
|
424
|
+
if (!equalsFn) return items.indexOf(item);
|
|
425
|
+
|
|
426
|
+
for (let i = 0; i < items.length; i++) {
|
|
427
|
+
if (equalsFn(item, items[i])) return i;
|
|
428
|
+
}
|
|
429
|
+
return -1;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// calculate node's bbox from bboxes of its children
|
|
433
|
+
function calcBBox(node, toBBox) {
|
|
434
|
+
distBBox(node, 0, node.children.length, toBBox, node);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// min bounding rectangle of node children from k to p-1
|
|
438
|
+
function distBBox(node, k, p, toBBox, destNode) {
|
|
439
|
+
if (!destNode) destNode = createNode(null);
|
|
440
|
+
destNode.minX = Infinity;
|
|
441
|
+
destNode.minY = Infinity;
|
|
442
|
+
destNode.maxX = -Infinity;
|
|
443
|
+
destNode.maxY = -Infinity;
|
|
444
|
+
|
|
445
|
+
for (let i = k; i < p; i++) {
|
|
446
|
+
const child = node.children[i];
|
|
447
|
+
extend(destNode, node.leaf ? toBBox(child) : child);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return destNode;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function extend(a, b) {
|
|
454
|
+
a.minX = Math.min(a.minX, b.minX);
|
|
455
|
+
a.minY = Math.min(a.minY, b.minY);
|
|
456
|
+
a.maxX = Math.max(a.maxX, b.maxX);
|
|
457
|
+
a.maxY = Math.max(a.maxY, b.maxY);
|
|
458
|
+
return a;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function compareNodeMinX(a, b) { return a.minX - b.minX; }
|
|
462
|
+
function compareNodeMinY(a, b) { return a.minY - b.minY; }
|
|
463
|
+
|
|
464
|
+
function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
|
|
465
|
+
function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
|
|
466
|
+
|
|
467
|
+
function enlargedArea(a, b) {
|
|
468
|
+
return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
|
|
469
|
+
(Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function intersectionArea(a, b) {
|
|
473
|
+
const minX = Math.max(a.minX, b.minX);
|
|
474
|
+
const minY = Math.max(a.minY, b.minY);
|
|
475
|
+
const maxX = Math.min(a.maxX, b.maxX);
|
|
476
|
+
const maxY = Math.min(a.maxY, b.maxY);
|
|
477
|
+
|
|
478
|
+
return Math.max(0, maxX - minX) *
|
|
479
|
+
Math.max(0, maxY - minY);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function contains(a, b) {
|
|
483
|
+
return a.minX <= b.minX &&
|
|
484
|
+
a.minY <= b.minY &&
|
|
485
|
+
b.maxX <= a.maxX &&
|
|
486
|
+
b.maxY <= a.maxY;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function intersects(a, b) {
|
|
490
|
+
return b.minX <= a.maxX &&
|
|
491
|
+
b.minY <= a.maxY &&
|
|
492
|
+
b.maxX >= a.minX &&
|
|
493
|
+
b.maxY >= a.minY;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function createNode(children) {
|
|
497
|
+
return {
|
|
498
|
+
children,
|
|
499
|
+
height: 1,
|
|
500
|
+
leaf: true,
|
|
501
|
+
minX: Infinity,
|
|
502
|
+
minY: Infinity,
|
|
503
|
+
maxX: -Infinity,
|
|
504
|
+
maxY: -Infinity
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
|
|
509
|
+
// combines selection algorithm with binary divide & conquer approach
|
|
510
|
+
|
|
511
|
+
function multiSelect(arr, left, right, n, compare) {
|
|
512
|
+
const stack = [left, right];
|
|
513
|
+
|
|
514
|
+
while (stack.length) {
|
|
515
|
+
right = stack.pop();
|
|
516
|
+
left = stack.pop();
|
|
517
|
+
|
|
518
|
+
if (right - left <= n) continue;
|
|
519
|
+
|
|
520
|
+
const mid = left + Math.ceil((right - left) / n / 2) * n;
|
|
521
|
+
(0,quickselect__WEBPACK_IMPORTED_MODULE_0__["default"])(arr, mid, left, right, compare);
|
|
522
|
+
|
|
523
|
+
stack.push(left, mid, mid, right);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
/***/ })
|
|
529
|
+
|
|
530
|
+
}])
|
|
531
|
+
//# sourceMappingURL=vendors-node_modules_rbush_index_js.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendors-node_modules_rbush_index_js.js","mappings":";;;;;;;;;;;;;AAAsC;;AAEvB;AACf;AACA,kDAAkD;AAClD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,4BAA4B,0BAA0B;AACtD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,4BAA4B,0BAA0B;AACtD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,UAAU;AACV;AACA;;AAEA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;;AAEA,6BAA6B;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;;AAEA,cAAc,mBAAmB;AACjC;AACA;AACA;;AAEA,cAAc,kBAAkB;AAChC;;AAEA;AACA;;AAEA,mBAAmB;;AAEnB,wBAAwB;AACxB,wBAAwB;;AAExB,eAAe;;AAEf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA,2BAA2B,YAAY;;AAEvC;;AAEA;;AAEA,4BAA4B,aAAa;;AAEzC;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,4BAA4B,0BAA0B;AACtD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,mCAAmC;AACnC;AACA;AACA;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,wBAAwB,YAAY;AACpC;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,wBAAwB,WAAW;AACnC;AACA;AACA;AACA;;AAEA,gCAAgC,QAAQ;AACxC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,4BAA4B,QAAQ;AACpC;AACA;AACA;;AAEA;AACA;AACA,gDAAgD,QAAQ;AACxD;AACA;AACA;AACA;;AAEA,kBAAkB;;AAElB,cAAc;AACd;AACA;AACA;;AAEA;AACA;;AAEA,oBAAoB,kBAAkB;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB,OAAO;AAC3B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iCAAiC;AACjC,iCAAiC;;AAEjC,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,QAAQ,uDAAW;;AAEnB;AACA;AACA","sources":["webpack://@vaadin/bundles/./node_modules/rbush/index.js"],"sourcesContent":["import quickselect from 'quickselect';\n\nexport default class RBush {\n constructor(maxEntries = 9) {\n // max entries in a node is 9 by default; min node fill is 40% for best performance\n this._maxEntries = Math.max(4, maxEntries);\n this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));\n this.clear();\n }\n\n all() {\n return this._all(this.data, []);\n }\n\n search(bbox) {\n let node = this.data;\n const result = [];\n\n if (!intersects(bbox, node)) return result;\n\n const toBBox = this.toBBox;\n const nodesToSearch = [];\n\n while (node) {\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n const childBBox = node.leaf ? toBBox(child) : child;\n\n if (intersects(bbox, childBBox)) {\n if (node.leaf) result.push(child);\n else if (contains(bbox, childBBox)) this._all(child, result);\n else nodesToSearch.push(child);\n }\n }\n node = nodesToSearch.pop();\n }\n\n return result;\n }\n\n collides(bbox) {\n let node = this.data;\n\n if (!intersects(bbox, node)) return false;\n\n const nodesToSearch = [];\n while (node) {\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n const childBBox = node.leaf ? this.toBBox(child) : child;\n\n if (intersects(bbox, childBBox)) {\n if (node.leaf || contains(bbox, childBBox)) return true;\n nodesToSearch.push(child);\n }\n }\n node = nodesToSearch.pop();\n }\n\n return false;\n }\n\n load(data) {\n if (!(data && data.length)) return this;\n\n if (data.length < this._minEntries) {\n for (let i = 0; i < data.length; i++) {\n this.insert(data[i]);\n }\n return this;\n }\n\n // recursively build the tree with the given data from scratch using OMT algorithm\n let node = this._build(data.slice(), 0, data.length - 1, 0);\n\n if (!this.data.children.length) {\n // save as is if tree is empty\n this.data = node;\n\n } else if (this.data.height === node.height) {\n // split root if trees have the same height\n this._splitRoot(this.data, node);\n\n } else {\n if (this.data.height < node.height) {\n // swap trees if inserted one is bigger\n const tmpNode = this.data;\n this.data = node;\n node = tmpNode;\n }\n\n // insert the small tree into the large tree at appropriate level\n this._insert(node, this.data.height - node.height - 1, true);\n }\n\n return this;\n }\n\n insert(item) {\n if (item) this._insert(item, this.data.height - 1);\n return this;\n }\n\n clear() {\n this.data = createNode([]);\n return this;\n }\n\n remove(item, equalsFn) {\n if (!item) return this;\n\n let node = this.data;\n const bbox = this.toBBox(item);\n const path = [];\n const indexes = [];\n let i, parent, goingUp;\n\n // depth-first iterative tree traversal\n while (node || path.length) {\n\n if (!node) { // go up\n node = path.pop();\n parent = path[path.length - 1];\n i = indexes.pop();\n goingUp = true;\n }\n\n if (node.leaf) { // check current node\n const index = findItem(item, node.children, equalsFn);\n\n if (index !== -1) {\n // item found, remove the item and condense tree upwards\n node.children.splice(index, 1);\n path.push(node);\n this._condense(path);\n return this;\n }\n }\n\n if (!goingUp && !node.leaf && contains(node, bbox)) { // go down\n path.push(node);\n indexes.push(i);\n i = 0;\n parent = node;\n node = node.children[0];\n\n } else if (parent) { // go right\n i++;\n node = parent.children[i];\n goingUp = false;\n\n } else node = null; // nothing found\n }\n\n return this;\n }\n\n toBBox(item) { return item; }\n\n compareMinX(a, b) { return a.minX - b.minX; }\n compareMinY(a, b) { return a.minY - b.minY; }\n\n toJSON() { return this.data; }\n\n fromJSON(data) {\n this.data = data;\n return this;\n }\n\n _all(node, result) {\n const nodesToSearch = [];\n while (node) {\n if (node.leaf) result.push(...node.children);\n else nodesToSearch.push(...node.children);\n\n node = nodesToSearch.pop();\n }\n return result;\n }\n\n _build(items, left, right, height) {\n\n const N = right - left + 1;\n let M = this._maxEntries;\n let node;\n\n if (N <= M) {\n // reached leaf level; return leaf\n node = createNode(items.slice(left, right + 1));\n calcBBox(node, this.toBBox);\n return node;\n }\n\n if (!height) {\n // target height of the bulk-loaded tree\n height = Math.ceil(Math.log(N) / Math.log(M));\n\n // target number of root entries to maximize storage utilization\n M = Math.ceil(N / Math.pow(M, height - 1));\n }\n\n node = createNode([]);\n node.leaf = false;\n node.height = height;\n\n // split the items into M mostly square tiles\n\n const N2 = Math.ceil(N / M);\n const N1 = N2 * Math.ceil(Math.sqrt(M));\n\n multiSelect(items, left, right, N1, this.compareMinX);\n\n for (let i = left; i <= right; i += N1) {\n\n const right2 = Math.min(i + N1 - 1, right);\n\n multiSelect(items, i, right2, N2, this.compareMinY);\n\n for (let j = i; j <= right2; j += N2) {\n\n const right3 = Math.min(j + N2 - 1, right2);\n\n // pack each entry recursively\n node.children.push(this._build(items, j, right3, height - 1));\n }\n }\n\n calcBBox(node, this.toBBox);\n\n return node;\n }\n\n _chooseSubtree(bbox, node, level, path) {\n while (true) {\n path.push(node);\n\n if (node.leaf || path.length - 1 === level) break;\n\n let minArea = Infinity;\n let minEnlargement = Infinity;\n let targetNode;\n\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n const area = bboxArea(child);\n const enlargement = enlargedArea(bbox, child) - area;\n\n // choose entry with the least area enlargement\n if (enlargement < minEnlargement) {\n minEnlargement = enlargement;\n minArea = area < minArea ? area : minArea;\n targetNode = child;\n\n } else if (enlargement === minEnlargement) {\n // otherwise choose one with the smallest area\n if (area < minArea) {\n minArea = area;\n targetNode = child;\n }\n }\n }\n\n node = targetNode || node.children[0];\n }\n\n return node;\n }\n\n _insert(item, level, isNode) {\n const bbox = isNode ? item : this.toBBox(item);\n const insertPath = [];\n\n // find the best node for accommodating the item, saving all nodes along the path too\n const node = this._chooseSubtree(bbox, this.data, level, insertPath);\n\n // put the item into the node\n node.children.push(item);\n extend(node, bbox);\n\n // split on node overflow; propagate upwards if necessary\n while (level >= 0) {\n if (insertPath[level].children.length > this._maxEntries) {\n this._split(insertPath, level);\n level--;\n } else break;\n }\n\n // adjust bboxes along the insertion path\n this._adjustParentBBoxes(bbox, insertPath, level);\n }\n\n // split overflowed node into two\n _split(insertPath, level) {\n const node = insertPath[level];\n const M = node.children.length;\n const m = this._minEntries;\n\n this._chooseSplitAxis(node, m, M);\n\n const splitIndex = this._chooseSplitIndex(node, m, M);\n\n const newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));\n newNode.height = node.height;\n newNode.leaf = node.leaf;\n\n calcBBox(node, this.toBBox);\n calcBBox(newNode, this.toBBox);\n\n if (level) insertPath[level - 1].children.push(newNode);\n else this._splitRoot(node, newNode);\n }\n\n _splitRoot(node, newNode) {\n // split root node\n this.data = createNode([node, newNode]);\n this.data.height = node.height + 1;\n this.data.leaf = false;\n calcBBox(this.data, this.toBBox);\n }\n\n _chooseSplitIndex(node, m, M) {\n let index;\n let minOverlap = Infinity;\n let minArea = Infinity;\n\n for (let i = m; i <= M - m; i++) {\n const bbox1 = distBBox(node, 0, i, this.toBBox);\n const bbox2 = distBBox(node, i, M, this.toBBox);\n\n const overlap = intersectionArea(bbox1, bbox2);\n const area = bboxArea(bbox1) + bboxArea(bbox2);\n\n // choose distribution with minimum overlap\n if (overlap < minOverlap) {\n minOverlap = overlap;\n index = i;\n\n minArea = area < minArea ? area : minArea;\n\n } else if (overlap === minOverlap) {\n // otherwise choose distribution with minimum area\n if (area < minArea) {\n minArea = area;\n index = i;\n }\n }\n }\n\n return index || M - m;\n }\n\n // sorts node children by the best axis for split\n _chooseSplitAxis(node, m, M) {\n const compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;\n const compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;\n const xMargin = this._allDistMargin(node, m, M, compareMinX);\n const yMargin = this._allDistMargin(node, m, M, compareMinY);\n\n // if total distributions margin value is minimal for x, sort by minX,\n // otherwise it's already sorted by minY\n if (xMargin < yMargin) node.children.sort(compareMinX);\n }\n\n // total margin of all possible split distributions where each node is at least m full\n _allDistMargin(node, m, M, compare) {\n node.children.sort(compare);\n\n const toBBox = this.toBBox;\n const leftBBox = distBBox(node, 0, m, toBBox);\n const rightBBox = distBBox(node, M - m, M, toBBox);\n let margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);\n\n for (let i = m; i < M - m; i++) {\n const child = node.children[i];\n extend(leftBBox, node.leaf ? toBBox(child) : child);\n margin += bboxMargin(leftBBox);\n }\n\n for (let i = M - m - 1; i >= m; i--) {\n const child = node.children[i];\n extend(rightBBox, node.leaf ? toBBox(child) : child);\n margin += bboxMargin(rightBBox);\n }\n\n return margin;\n }\n\n _adjustParentBBoxes(bbox, path, level) {\n // adjust bboxes along the given tree path\n for (let i = level; i >= 0; i--) {\n extend(path[i], bbox);\n }\n }\n\n _condense(path) {\n // go through the path, removing empty nodes and updating bboxes\n for (let i = path.length - 1, siblings; i >= 0; i--) {\n if (path[i].children.length === 0) {\n if (i > 0) {\n siblings = path[i - 1].children;\n siblings.splice(siblings.indexOf(path[i]), 1);\n\n } else this.clear();\n\n } else calcBBox(path[i], this.toBBox);\n }\n }\n}\n\nfunction findItem(item, items, equalsFn) {\n if (!equalsFn) return items.indexOf(item);\n\n for (let i = 0; i < items.length; i++) {\n if (equalsFn(item, items[i])) return i;\n }\n return -1;\n}\n\n// calculate node's bbox from bboxes of its children\nfunction calcBBox(node, toBBox) {\n distBBox(node, 0, node.children.length, toBBox, node);\n}\n\n// min bounding rectangle of node children from k to p-1\nfunction distBBox(node, k, p, toBBox, destNode) {\n if (!destNode) destNode = createNode(null);\n destNode.minX = Infinity;\n destNode.minY = Infinity;\n destNode.maxX = -Infinity;\n destNode.maxY = -Infinity;\n\n for (let i = k; i < p; i++) {\n const child = node.children[i];\n extend(destNode, node.leaf ? toBBox(child) : child);\n }\n\n return destNode;\n}\n\nfunction extend(a, b) {\n a.minX = Math.min(a.minX, b.minX);\n a.minY = Math.min(a.minY, b.minY);\n a.maxX = Math.max(a.maxX, b.maxX);\n a.maxY = Math.max(a.maxY, b.maxY);\n return a;\n}\n\nfunction compareNodeMinX(a, b) { return a.minX - b.minX; }\nfunction compareNodeMinY(a, b) { return a.minY - b.minY; }\n\nfunction bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }\nfunction bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }\n\nfunction enlargedArea(a, b) {\n return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *\n (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));\n}\n\nfunction intersectionArea(a, b) {\n const minX = Math.max(a.minX, b.minX);\n const minY = Math.max(a.minY, b.minY);\n const maxX = Math.min(a.maxX, b.maxX);\n const maxY = Math.min(a.maxY, b.maxY);\n\n return Math.max(0, maxX - minX) *\n Math.max(0, maxY - minY);\n}\n\nfunction contains(a, b) {\n return a.minX <= b.minX &&\n a.minY <= b.minY &&\n b.maxX <= a.maxX &&\n b.maxY <= a.maxY;\n}\n\nfunction intersects(a, b) {\n return b.minX <= a.maxX &&\n b.minY <= a.maxY &&\n b.maxX >= a.minX &&\n b.maxY >= a.minY;\n}\n\nfunction createNode(children) {\n return {\n children,\n height: 1,\n leaf: true,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n}\n\n// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;\n// combines selection algorithm with binary divide & conquer approach\n\nfunction multiSelect(arr, left, right, n, compare) {\n const stack = [left, right];\n\n while (stack.length) {\n right = stack.pop();\n left = stack.pop();\n\n if (right - left <= n) continue;\n\n const mid = left + Math.ceil((right - left) / n / 2) * n;\n quickselect(arr, mid, left, right, compare);\n\n stack.push(left, mid, mid, right);\n }\n}\n"],"names":[],"sourceRoot":""}
|