UNPKG

xtorcga

Version:

Xtor Compute Geometry Algorithm Libary 计算几何算法库

138 lines (137 loc) 5.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuadtreeTile = exports.QuadtreeTileLoadState = void 0; // * The state of a {@link QuadtreeTile} in the tile load pipeline. var QuadtreeTileLoadState; (function (QuadtreeTileLoadState) { /** * The tile is new and loading has not yet begun. */ QuadtreeTileLoadState[QuadtreeTileLoadState["START"] = 0] = "START"; /** * Loading is in progress. */ QuadtreeTileLoadState[QuadtreeTileLoadState["LOADING"] = 1] = "LOADING"; /** * Loading is complete. */ QuadtreeTileLoadState[QuadtreeTileLoadState["DONE"] = 2] = "DONE"; /** * The tile has failed to load. */ QuadtreeTileLoadState[QuadtreeTileLoadState["FAILED"] = 3] = "FAILED"; })(QuadtreeTileLoadState = exports.QuadtreeTileLoadState || (exports.QuadtreeTileLoadState = {})); ; var QuadtreeTile = /** @class */ (function () { function QuadtreeTile(options) { this.state = QuadtreeTileLoadState.START; this._tilingScheme = options.tilingScheme; this._x = options.x; this._y = options.y; this._level = options.level; this._parent = options.parent; this._rectangle = this._tilingScheme.tileXYToRectangle(this._x, this._y, this._level); this._southwestChild = undefined; this._southeastChild = undefined; this._northwestChild = undefined; this._northeastChild = undefined; // TileReplacementQueue gets/sets these private properties. this.replacementPrevious = undefined; this.replacementNext = undefined; } Object.defineProperty(QuadtreeTile.prototype, "northwestChild", { get: function () { if (!this._northwestChild) { this._northwestChild = new QuadtreeTile({ tilingScheme: this._tilingScheme, x: this._x * 2, y: this._y * 2, level: this._level + 1, parent: this, }); } return this._northwestChild; }, enumerable: false, configurable: true }); Object.defineProperty(QuadtreeTile.prototype, "southwestChild", { get: function () { if (!this._southwestChild) { this._southwestChild = new QuadtreeTile({ tilingScheme: this._tilingScheme, x: this._x * 2, y: this._y * 2 + 1, level: this._level + 1, parent: this, }); } return this._southwestChild; }, enumerable: false, configurable: true }); Object.defineProperty(QuadtreeTile.prototype, "southeastChild", { get: function () { if (!this._southeastChild) { this._southeastChild = new QuadtreeTile({ tilingScheme: this._tilingScheme, x: this._x * 2 + 1, y: this._y * 2 + 1, level: this._level + 1, parent: this, }); } return this._southeastChild; }, enumerable: false, configurable: true }); Object.defineProperty(QuadtreeTile.prototype, "northeastChild", { get: function () { if (!this._northeastChild) { this._northeastChild = new QuadtreeTile({ tilingScheme: this._tilingScheme, x: this._x * 2 + 1, y: this._y * 2, level: this._level + 1, parent: this, }); } return this._northeastChild; }, enumerable: false, configurable: true }); Object.defineProperty(QuadtreeTile.prototype, "children", { get: function () { return [ this.northwestChild, this.northeastChild, this.southwestChild, this.southeastChild, ]; }, enumerable: false, configurable: true }); QuadtreeTile.createLevelZeroTiles = function (tilingScheme) { var numberOfLevelZeroTilesX = tilingScheme.getNumberOfXTilesAtLevel(0); var numberOfLevelZeroTilesY = tilingScheme.getNumberOfYTilesAtLevel(0); var result = new Array(numberOfLevelZeroTilesX * numberOfLevelZeroTilesY); var i = 0; for (var x = 0; x < numberOfLevelZeroTilesX; x++) { for (var y = 0; y < numberOfLevelZeroTilesY; y++) { result[i++] = new QuadtreeTile({ tilingScheme: tilingScheme, x: x, y: y, level: 0, }); } } return result; }; return QuadtreeTile; }()); exports.QuadtreeTile = QuadtreeTile;