@itwin/core-common
Version:
iTwin.js components common to frontend and backend
374 lines • 20.1 kB
TypeScript
/** @packageDocumentation
* @module iModels
*/
import { BeEvent, GuidString, Id64String, OpenMode } from "@itwin/core-bentley";
import { Angle, Point3d, Range3dProps, Transform, TransformProps, Vector3d, XYAndZ, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
import { ChangesetIdWithIndex } from "./ChangesetProps";
import { Cartographic, CartographicProps } from "./geometry/Cartographic";
import { GeographicCRS, GeographicCRSProps } from "./geometry/CoordinateReferenceSystem";
import { AxisAlignedBox3d } from "./geometry/Placement";
import { ThumbnailProps } from "./Thumbnail";
/** The properties to open a connection to an iModel for RPC operations.
* @public
*/
export interface IModelRpcOpenProps {
/** The iTwin in which the iModel exists - must be defined for briefcases that are synchronized with iModelHub. */
readonly iTwinId?: GuidString;
/** Guid of the iModel. */
readonly iModelId?: GuidString;
/** Id of the last Changeset that was applied to the iModel - must be defined for briefcases that are synchronized with iModelHub.
* @note Changeset Ids are string hash values based on the content and parent.
*/
readonly changeset?: ChangesetIdWithIndex;
}
/** The properties that identify an opened iModel for RPC operations.
* @public
*/
export interface IModelRpcProps extends IModelRpcOpenProps {
/** Unique key used for identifying the iModel between the frontend and the backend */
readonly key: string;
}
/** Properties that position an iModel on the earth via [ECEF](https://en.wikipedia.org/wiki/ECEF) (Earth Centered Earth Fixed) coordinates
* The origin is specified as an ECEF coordinate. The cartographicOrigin property contains the latitude, longitude and elevation above the WGS84 ellipsoid
* of the origin property. This cartographicOrigin is offered as a convenient pre-calculated value representing the location of the ECEF origin.
* The 3D coordinate system this class represents is positioned at specified origin and the axis positioned according to
* the other properties.
* If transform property is defined then it will not be computed from other properties.
* If the xVector and yVector properties are defined (and transform is not defined) then they take precedence over the YawPitchRoll orientation property. The xVector and yVector
* represent the direction and scale of the X and Y axes. The Z axis is always perpendicular (according to the right hand rule) to these X-Y axes.
* The scaling in the Z direction is always unity. The scale of the X and Y axes is represented by the size of the vector length.
* If the xVector and yVector are not present then the YawPitchRoll properties indicates the angles for all tree axes. Scaling in that case
* is unity in all three directions.
* Note that the present class is intended to represent geolocated 3D coordinate systems that are normally tangent to the WGS84 ellipsoid
* possibly offset in altitude by the terrain elevation above the ellipsoid but other general 3D coordinate systems
* can be defined.
* @public
* @extensions
*/
export interface EcefLocationProps {
/** The Origin of an iModel on the earth in ECEF coordinates */
readonly origin: XYZProps;
/** The [orientation](https://en.wikipedia.org/wiki/Geographic_coordinate_conversion) of an iModel on the earth. */
readonly orientation: YawPitchRollProps;
/** Optional position on the earth used to establish the ECEF coordinates. */
readonly cartographicOrigin?: CartographicProps;
/** Optional X column vector used with [[yVector]] to calculate potentially non-rigid transform if a projection is present. */
readonly xVector?: XYZProps;
/** Optional Y column vector used with [[xVector]] to calculate potentially non-rigid transform if a projection is present. */
readonly yVector?: XYZProps;
/** Optional potentially non-rigid transform defining the ECEF location.
* @note If this property is supplied, the other properties are ignored.
*/
readonly transform?: TransformProps;
}
/** Properties of the [Root Subject]($docs/bis/guide/references/glossary#subject-root).
* @public
* @extensions
*/
export interface RootSubjectProps {
/** The name of the root subject. */
readonly name: string;
/** Description of the root subject (optional). */
readonly description?: string;
}
/** Properties of an iModel that are always held in memory whenever one is opened, both on the frontend and on the backend .
* @public
*/
export interface IModelProps {
/** The name and description of the root subject of this iModel */
readonly rootSubject: RootSubjectProps;
/** The volume of the entire project, in spatial coordinates */
readonly projectExtents?: Range3dProps;
/** An offset to be applied to all spatial coordinates. This is normally used to transform spatial coordinates into the Cartesian coordinate system of a Geographic Coordinate System. */
readonly globalOrigin?: XYZProps;
/** The location of the iModel in Earth Centered Earth Fixed coordinates. iModel units are always meters */
readonly ecefLocation?: EcefLocationProps;
/** The Geographic Coordinate Reference System indicating the projection and datum used. */
readonly geographicCoordinateSystem?: GeographicCRSProps;
/** The name of the iModel. */
readonly name?: string;
}
/** The properties returned by the backend when creating a new [[IModelConnection]] from the frontend, either with Rpc or with Ipc.
* These properties describe the iModel held on the backend for thew newly formed connection and are used to construct a new
* [[IModelConnection]] instance on the frontend to access it.
* @public
*/
export type IModelConnectionProps = IModelProps & IModelRpcProps;
/** The properties that can be supplied when creating a *new* iModel.
* @public
*/
export interface CreateIModelProps extends IModelProps {
/** The GUID of new iModel. If not present, a GUID will be generated. */
readonly guid?: GuidString;
/** Client name for new iModel */
readonly client?: string;
/** Thumbnail for new iModel
* @alpha
*/
readonly thumbnail?: ThumbnailProps;
}
/**
* Sqlite options.
* @public
*/
export interface OpenSqliteArgs {
/**
* Specify timeout after which SQLite stop retrying to acquire lock to database file and throw SQLITE_BUSY error.
* Timeout is specified in milliseconds.
* For more information https://www.sqlite.org/c3ref/busy_timeout.html.
* */
readonly busyTimeout?: number;
}
/**
* A key used to identify an opened [IModelDb]($backend) between the frontend and backend for Rpc and Ipc communications.
* Keys must be unique - that is there can never be two IModelDbs opened with the same key at any given time.
* If no key is supplied in a call to open an IModelDb, one is generated and returned.
* It is only necessary to supply a key if you have some reason to assign a specific value to identify an IModelDb.
* If you don't supply the key, you must use the returned value for Rpc and Ipc communications.
* @public
*/
export interface OpenDbKey {
readonly key?: string;
}
/** @beta TODO documentation */
export interface CloudContainerUri {
readonly uriParams: string;
}
/** Options to open a [SnapshotDb]($backend).
* @public
*/
export interface SnapshotOpenOptions extends OpenDbKey {
/**
* The "base" name that can be used for creating temporary files related to this Db.
* The string should be a name related to the current Db filename using some known pattern so that all files named "baseName*" can be deleted externally during cleanup.
* It must be the name of a file (that may or may not exist) in a writable directory.
* If not present, the baseName will default to the database's file name (including the path).
* @internal
*/
readonly tempFileBase?: string;
}
/** Options to open a [StandaloneDb]($backend) via [StandaloneDb.openFile]($backend) from the backend,
* or [BriefcaseConnection.openStandalone]($frontend) from the frontend.
* @public
*/
export type StandaloneOpenOptions = OpenDbKey;
/** Options that can be supplied when creating snapshot iModels.
* @public
*/
export interface CreateSnapshotIModelProps {
/** If true, then create SQLite views for Model, Element, ElementAspect, and Relationship classes.
* These database views can often be useful for interoperability workflows.
*/
readonly createClassViews?: boolean;
}
/** The options that can be specified when creating an *empty* snapshot iModel.
* @see [SnapshotDb.createEmpty]($backend)
* @public
*/
export type CreateEmptySnapshotIModelProps = CreateIModelProps & CreateSnapshotIModelProps;
/** Options that can be supplied when creating standalone iModels.
* @public
*/
export interface CreateStandaloneIModelProps {
/** If present, file will allow local editing, but cannot be used to create changesets */
readonly allowEdit?: string;
}
/** The options that can be specified when creating an *empty* standalone iModel.
* @see [StandaloneDb.createEmpty]($backend)
* @public
*/
export type CreateEmptyStandaloneIModelProps = CreateIModelProps & CreateStandaloneIModelProps;
/**
* @public
* @extensions
*/
export interface FilePropertyProps {
readonly namespace: string;
readonly name: string;
id?: number | string;
subId?: number | string;
}
/** The position and orientation of an iModel on the earth in [ECEF](https://en.wikipedia.org/wiki/ECEF) (Earth Centered Earth Fixed) coordinates
* @note This is an immutable type - all of its properties are frozen.
* @see [GeoLocation of iModels]($docs/learning/GeoLocation.md)
* @public
*/
export declare class EcefLocation implements EcefLocationProps {
/** The origin of the ECEF transform. */
readonly origin: Point3d;
/** The orientation of the ECEF transform */
readonly orientation: YawPitchRollAngles;
/** Optional position on the earth used to establish the ECEF origin and orientation. */
readonly cartographicOrigin?: Cartographic;
/** Optional X column vector used with [[yVector]] to calculate potentially non-rigid transform if a projection is present. */
readonly xVector?: Vector3d;
/** Optional Y column vector used with [[xVector]] to calculate potentially non-rigid transform if a projection is present. */
readonly yVector?: Vector3d;
/** The transform from iModel Spatial coordinates to ECEF from this EcefLocation */
private readonly _transform;
/** Get the transform from iModel Spatial coordinates to ECEF from this EcefLocation */
getTransform(): Transform;
/** Construct a new EcefLocation. Once constructed, it is frozen and cannot be modified. */
constructor(props: EcefLocationProps);
/** Returns true if this EcefLocation is not located at the center of the Earth.
* @alpha are locations very close to the center considered valid? What are the specific criteria?
*/
get isValid(): boolean;
/** Construct ECEF Location from cartographic origin with optional known point and angle. */
static createFromCartographicOrigin(origin: Cartographic, point?: Point3d, angle?: Angle): EcefLocation;
/** Construct ECEF Location from transform with optional position on the earth used to establish the ECEF origin and orientation. */
static createFromTransform(transform: Transform): EcefLocation;
/** Get the location center of the earth in the iModel coordinate system. */
get earthCenter(): Point3d;
/** Return true if this location is equivalent to another location within a small tolerance. */
isAlmostEqual(other: EcefLocation): boolean;
toJSON(): EcefLocationProps;
}
/** Represents an iModel in JavaScript.
* @see [GeoLocation of iModels]($docs/learning/GeoLocation.md)
* @public
*/
export declare abstract class IModel implements IModelProps {
private _projectExtents?;
private _name?;
private _rootSubject?;
private _globalOrigin?;
private _ecefLocation?;
private _geographicCoordinateSystem?;
private _iModelId?;
private _changeset;
/** The Id of the repository model. */
static readonly repositoryModelId: Id64String;
/** The Id of the root subject element. */
static readonly rootSubjectId: Id64String;
/** The Id of the dictionary model. */
static readonly dictionaryId: Id64String;
/** Event raised after [[name]] changes. */
readonly onNameChanged: BeEvent<(previousName: string) => void>;
/** Event raised after [[rootSubject]] changes. */
readonly onRootSubjectChanged: BeEvent<(previousSubject: RootSubjectProps) => void>;
/** Event raised after [[projectExtents]] changes. */
readonly onProjectExtentsChanged: BeEvent<(previousExtents: AxisAlignedBox3d) => void>;
/** Event raised after [[globalOrigin]] changes. */
readonly onGlobalOriginChanged: BeEvent<(previousOrigin: Point3d) => void>;
/** Event raised after [[ecefLocation]] changes. */
readonly onEcefLocationChanged: BeEvent<(previousLocation: EcefLocation | undefined) => void>;
/** Event raised after [[geographicCoordinateSystem]] changes. */
readonly onGeographicCoordinateSystemChanged: BeEvent<(previousGCS: GeographicCRS | undefined) => void>;
/** Event raised after [[changeset]] changes. */
readonly onChangesetChanged: BeEvent<(previousChangeset: ChangesetIdWithIndex) => void>;
/** Name of the iModel */
get name(): string;
set name(name: string);
/** The name and description of the root subject of this iModel */
get rootSubject(): RootSubjectProps;
set rootSubject(subject: RootSubjectProps);
/** Returns `true` if this is a snapshot iModel. */
abstract get isSnapshot(): boolean;
/** Returns `true` if this is a briefcase copy of an iModel that is synchronized with iModelHub. */
abstract get isBriefcase(): boolean;
abstract get isOpen(): boolean;
/**
* The volume, in spatial coordinates, inside which the entire project is contained.
* @note The object returned from this method is frozen. You *must* make a copy before you do anything that might attempt to modify it.
*/
get projectExtents(): AxisAlignedBox3d;
set projectExtents(extents: AxisAlignedBox3d);
/** An offset to be applied to all spatial coordinates. */
get globalOrigin(): Point3d;
set globalOrigin(org: Point3d);
/** The [EcefLocation]($docs/learning/glossary#ecefLocation) of the iModel in Earth Centered Earth Fixed coordinates.
* If the iModel property geographicCoordinateSystem is not defined then the ecefLocation provides a geolocation by defining a
* 3D coordinate system relative to the Earth model WGS84. Refer to additional documentation for details. If the geographicCoordinateSystem
* property is defined then the ecefLocation must be used with care. When the geographicCoordinateSystem is defined it indicates the
* iModel cartesian space is the result of a cartographic projection. This implies a flattening of the Earth surface process that
* results in scale, angular or area distortion. The ecefLocation is then an approximation calculated at the center of the project extent.
* If the project is more than 2 kilometer in size, the ecefLocation may represent a poor approximation of the effective
* cartographic projection used and a linear transformation should then be calculated at the exact origin of the data
* it must position.
* @see [GeoLocation of iModels]($docs/learning/GeoLocation.md)
*/
get ecefLocation(): EcefLocation | undefined;
set ecefLocation(ecefLocation: EcefLocation | undefined);
/** Set the [EcefLocation]($docs/learning/glossary#ecefLocation) for this iModel. */
setEcefLocation(ecef: EcefLocationProps): void;
/** The geographic coordinate reference system of the iModel. */
get geographicCoordinateSystem(): GeographicCRS | undefined;
set geographicCoordinateSystem(geoCRS: GeographicCRS | undefined);
/** Sets the geographic coordinate reference system from GeographicCRSProps. */
setGeographicCoordinateSystem(geoCRS: GeographicCRSProps): void;
/** @internal */
getConnectionProps(): IModelConnectionProps;
/** Convert this iModel to a JSON representation. */
toJSON(): IModelConnectionProps;
/** A key used to identify this iModel in RPC calls from frontend to backend.
* @internal
*/
protected _fileKey: string;
/** Get the key that was used to open this iModel. This is the value used for Rpc and Ipc communications. */
get key(): string;
/** @internal */
protected _iTwinId?: GuidString;
/** The Guid that identifies the iTwin that owns this iModel. */
get iTwinId(): GuidString | undefined;
/** The Guid that identifies this iModel. */
get iModelId(): GuidString | undefined;
/** @public */
get changeset(): ChangesetIdWithIndex;
set changeset(changeset: ChangesetIdWithIndex);
protected _openMode: OpenMode;
/** The [[OpenMode]] used for this IModel. */
get openMode(): OpenMode;
/** Return a token for RPC operations.
* @throws IModelError if the iModel is not open.
*/
getRpcProps(): IModelRpcProps;
/** Returns the iModel's RPC properties.
* @note It is an error to attempt to use these properties as a token for RPC operations if the iModel is not open.
* @internal
*/
protected _getRpcProps(): IModelRpcProps;
/** @internal */
protected constructor(tokenProps?: IModelRpcProps);
/** @internal */
protected initialize(name: string, props: IModelProps): void;
/** Get the default subCategoryId for the supplied categoryId */
static getDefaultSubCategoryId(categoryId: Id64String): Id64String;
/** True if this iModel has an [EcefLocation]($docs/learning/glossary#ecefLocation). */
get isGeoLocated(): boolean;
/** Get the Transform from this iModel's Spatial coordinates to ECEF coordinates using its [[IModel.ecefLocation]].
* @throws IModelError if [[isGeoLocated]] is false.
*/
getEcefTransform(): Transform;
/** Convert a point in this iModel's Spatial coordinates to an ECEF point using its [[IModel.ecefLocation]].
* @param spatial A point in the iModel's spatial coordinates
* @param result If defined, use this for output
* @returns A Point3d in ECEF coordinates
* @throws IModelError if [[isGeoLocated]] is false.
*/
spatialToEcef(spatial: XYAndZ, result?: Point3d): Point3d;
/** Convert a point in ECEF coordinates to a point in this iModel's Spatial coordinates using its [[ecefLocation]].
* @param ecef A point in ECEF coordinates
* @param result If defined, use this for output
* @returns A Point3d in this iModel's spatial coordinates
* @throws IModelError if [[isGeoLocated]] is false.
* @note The resultant point will only be meaningful if the ECEF coordinate is close on the earth to the iModel.
*/
ecefToSpatial(ecef: XYAndZ, result?: Point3d): Point3d;
/** Convert a point in this iModel's Spatial coordinates to a [[Cartographic]] using its [[IModel.ecefLocation]].
* @param spatial A point in the iModel's spatial coordinates
* @param result If defined, use this for output
* @returns A Cartographic location
* @throws IModelError if [[isGeoLocated]] is false.
*/
spatialToCartographicFromEcef(spatial: XYAndZ, result?: Cartographic): Cartographic;
/** Convert a [[Cartographic]] to a point in this iModel's Spatial coordinates using its [[IModel.ecefLocation]].
* @param cartographic A cartographic location
* @param result If defined, use this for output
* @returns A point in this iModel's spatial coordinates
* @throws IModelError if [[isGeoLocated]] is false.
* @note The resultant point will only be meaningful if the ECEF coordinate is close on the earth to the iModel.
*/
cartographicToSpatialFromEcef(cartographic: Cartographic, result?: Point3d): Point3d;
}
//# sourceMappingURL=IModel.d.ts.map