UNPKG

@itwin/geo-tools-react

Version:
52 lines 2.47 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.IModelGeoView = void 0; const core_common_1 = require("@itwin/core-common"); const core_frontend_1 = require("@itwin/core-frontend"); const core_geometry_1 = require("@itwin/core-geometry"); class IModelGeoView { static getFrustumLonLatBBox() { var _a; const vp = (_a = core_frontend_1.IModelApp.viewManager) === null || _a === void 0 ? void 0 : _a.selectedView; if (vp === undefined) { return undefined; } const view = vp.view; const ecef = vp.iModel.ecefLocation; if (!view.isSpatialView() || undefined === ecef) { return undefined; } const frustum = view.calculateFrustum(); if (!frustum) { return undefined; } const viewRange = core_geometry_1.Range3d.createArray(frustum.points); const range = new core_common_1.CartographicRange(viewRange, ecef.getTransform()); const latLongBBox = range.getLongitudeLatitudeBoundingBox(); return core_frontend_1.MapCartoRectangle.fromRadians(latLongBBox.low.x, latLongBBox.low.y, latLongBBox.high.x, latLongBBox.high.y); } static async locateAddress(address) { var _a; const vp = (_a = core_frontend_1.IModelApp.viewManager) === null || _a === void 0 ? void 0 : _a.selectedView; if (vp === undefined) { return Promise.resolve(false); } const locationTool = new core_frontend_1.ViewGlobeLocationTool(vp); return locationTool.parseAndRun(address); } static async locatePosition(carto) { var _a; const vp = (_a = core_frontend_1.IModelApp.viewManager) === null || _a === void 0 ? void 0 : _a.selectedView; if (vp === undefined) { return Promise.resolve(false); } const locationTool = new core_frontend_1.ViewGlobeLocationTool(vp); return locationTool.parseAndRun(`${carto.latitudeDegrees}`, `${carto.longitudeDegrees}`); } } exports.IModelGeoView = IModelGeoView; //# sourceMappingURL=IModelGeoView.js.map