@itwin/core-frontend
Version:
iTwin.js frontend components
58 lines • 2.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArcGisGeometryReaderJSON = void 0;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const internal_1 = require("../../../../tile/internal");
/** @internal */
class ArcGisGeometryReaderJSON {
_ringsOrPaths;
_points;
_fill;
_relativeCoords;
_renderer;
constructor(geometryType, renderer, relativeCoords = false) {
this._ringsOrPaths = geometryType === "esriGeometryPolyline" || geometryType === "esriGeometryPolygon";
this._points = geometryType === "esriGeometryPoint" || geometryType === "esriGeometryMultiPoint";
this._fill = geometryType === "esriGeometryPolygon";
this._renderer = renderer;
this._relativeCoords = relativeCoords;
}
async readGeometry(geometry) {
if (this._ringsOrPaths) {
await this.readRingsAndPaths(geometry, this._renderer, this._fill, this._relativeCoords);
}
else if (this._points) {
await this.readPoints(geometry, this._renderer, this._relativeCoords);
}
}
async readRingsAndPaths(geometry, renderer, fill, relativeCoords) {
let offset = 0;
const lengths = [];
const coords = [];
if (geometry?.rings) {
for (const ring of geometry?.rings) {
offset = (0, internal_1.deflateCoordinates)(ring, coords, 2, offset);
lengths.push(ring.length);
}
}
else if (geometry?.paths) {
for (const path of geometry?.paths) {
offset = (0, internal_1.deflateCoordinates)(path, coords, 2, offset);
lengths.push(path.length);
}
}
await renderer.renderPath(lengths, coords, fill, 2, relativeCoords);
}
async readPoints(geometry, renderer, relativeCoords) {
if (geometry) {
const lengths = [];
const coords = [geometry.x, geometry.y];
await renderer.renderPoint(lengths, coords, 2, relativeCoords);
}
}
}
exports.ArcGisGeometryReaderJSON = ArcGisGeometryReaderJSON;
//# sourceMappingURL=ArcGisGeometryReaderJSON.js.map