@itwin/geo-tools-react
Version:
React Geospatial Tools
39 lines • 1.68 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { Range3d } from "@itwin/core-geometry";
import { CartographicRange } from "@itwin/core-common";
import { IModelApp, ViewGlobeLocationTool } from "@itwin/core-frontend";
export class IModelGeoView {
static getFrustumLonLatBBox() {
var _a;
let result;
const vp = (_a = IModelApp.viewManager) === null || _a === void 0 ? void 0 : _a.selectedView;
if (vp === undefined) {
return result;
}
const view = vp.view;
const ecef = vp.iModel.ecefLocation;
if (!view.isSpatialView() || undefined === ecef) {
return result;
}
const frustum = view.calculateFrustum();
if (!frustum) {
return result;
}
const viewRange = Range3d.createArray(frustum.points);
const range = new CartographicRange(viewRange, ecef.getTransform());
return range.getLongitudeLatitudeBoundingBox();
}
static async locateAddress(address) {
var _a;
const vp = (_a = IModelApp.viewManager) === null || _a === void 0 ? void 0 : _a.selectedView;
if (vp === undefined) {
return Promise.resolve(false);
}
const locationTool = new ViewGlobeLocationTool(vp);
return locationTool.parseAndRun(address);
}
}
//# sourceMappingURL=IModelGeoView.js.map