@itwin/geo-tools-react
Version:
React Geospatial Tools
48 lines • 2.23 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 { CartographicRange } from "@itwin/core-common";
import { IModelApp, MapCartoRectangle, ViewGlobeLocationTool } from "@itwin/core-frontend";
import { Range3d } from "@itwin/core-geometry";
export class IModelGeoView {
static getFrustumLonLatBBox() {
var _a;
const vp = (_a = 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 = Range3d.createArray(frustum.points);
const range = new CartographicRange(viewRange, ecef.getTransform());
const latLongBBox = range.getLongitudeLatitudeBoundingBox();
return MapCartoRectangle.fromRadians(latLongBBox.low.x, latLongBBox.low.y, latLongBBox.high.x, latLongBBox.high.y);
}
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);
}
static async locatePosition(carto) {
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(`${carto.latitudeDegrees}`, `${carto.longitudeDegrees}`);
}
}
//# sourceMappingURL=IModelGeoView.js.map