UNPKG

mapillary-js

Version:

A WebGL interactive street imagery library

1,942 lines (1,771 loc) 218 kB
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ /** * Convert coordinates from geodetic (WGS84) reference to local topocentric * (ENU) reference. * @param {number} lng Longitude in degrees. * @param {number} lat Latitude in degrees. * @param {number} alt Altitude in meters. * @param {number} refLng Reference longitude in degrees. * @param {number} refLat Reference latitude in degrees. * @param {number} refAlt Reference altitude in meters. * @returns {Array<number>} The x, y, z local topocentric ENU coordinates. */ declare function geodeticToEnu( lng: number, lat: number, alt: number, refLng: number, refLat: number, refAlt: number ): number[]; /** * Convert coordinates from local topocentric (ENU) reference to * geodetic (WGS84) reference. * @param {number} x Topocentric ENU coordinate in East direction. * @param {number} y Topocentric ENU coordinate in North direction. * @param {number} z Topocentric ENU coordinate in Up direction. * @param {number} refLng Reference longitude in degrees. * @param {number} refLat Reference latitude in degrees. * @param {number} refAlt Reference altitude in meters. * @returns {Array<number>} The longitude, latitude in degrees * and altitude in meters. */ declare function enuToGeodetic( x: number, y: number, z: number, refLng: number, refLat: number, refAlt: number ): number[]; /** * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference * to local topocentric (ENU) reference. * @param {number} X ECEF X-value. * @param {number} Y ECEF Y-value. * @param {number} Z ECEF Z-value. * @param {number} refLng Reference longitude in degrees. * @param {number} refLat Reference latitude in degrees. * @param {number} refAlt Reference altitude in meters. * @returns {Array<number>} The x, y, z topocentric ENU coordinates in East, North * and Up directions respectively. */ declare function ecefToEnu( X: number, Y: number, Z: number, refLng: number, refLat: number, refAlt: number ): number[]; /** * Convert coordinates from local topocentric (ENU) reference * to Earth-Centered, Earth-Fixed (ECEF) reference. * @param {number} x Topocentric ENU coordinate in East direction. * @param {number} y Topocentric ENU coordinate in North direction. * @param {number} z Topocentric ENU coordinate in Up direction. * @param {number} refLng Reference longitude in degrees. * @param {number} refLat Reference latitude in degrees. * @param {number} refAlt Reference altitude in meters. * @returns {Array<number>} The X, Y, Z ECEF coordinates. */ declare function enuToEcef( x: number, y: number, z: number, refLng: number, refLat: number, refAlt: number ): number[]; /** * Convert coordinates from geodetic reference (WGS84) to Earth-Centered, * Earth-Fixed (ECEF) reference. * @param {number} lng Longitude in degrees. * @param {number} lat Latitude in degrees. * @param {number} alt Altitude in meters. * @returns {Array<number>} The X, Y, Z ECEF coordinates. */ declare function geodeticToEcef( lng: number, lat: number, alt: number ): number[]; /** * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference * to geodetic reference (WGS84). * @param {number} X ECEF X-value. * @param {number} Y ECEF Y-value. * @param {number} Z ECEF Z-value. * @returns {Array<number>} The longitude, latitude in degrees * and altitude in meters. */ declare function ecefToGeodetic(X: number, Y: number, Z: number): number[]; /** * Contract describing triangulated meshes. */ export interface MeshContract { /** * Flattened array of faces for the mesh. Each face consist * three vertex indices. */ faces: number[]; /** * Flattened array of vertices for the mesh. Each vertex * consists of X, Y and Z coordinates in the camera * reference frame. */ vertices: number[]; } /** * Decompress and parse an array buffer containing zipped * json data and return as a json object. * @description Handles array buffers continaing zipped json * data. * @param {ArrayBuffer} buffer - Array buffer to decompress. * @returns {Object} Parsed object. */ declare function decompress<T>(buffer: ArrayBuffer): T; /** * Retrieves a resource as an array buffer and returns a promise * to the buffer. * @description Rejects the promise on request failure. * @param {string} url - URL for resource to retrieve. * @param {Promise} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<ArrayBuffer>} Promise to the array buffer * resource. */ declare function fetchArrayBuffer( url: string, abort?: Promise<void> ): Promise<ArrayBuffer>; /** * Read the fields of a protobuf array buffer into a mesh * object. * @param {ArrayBuffer} buffer - Protobuf array buffer * to read from. * @returns {MeshContract} Mesh object. */ declare function readMeshPbf(buffer: ArrayBuffer): MeshContract; /** * Interface describing event emitter members. * * This is a specification for implementers to model: it is * not an exported method or class. */ export interface IEventEmitter { fire<T>(type: string, event: T): void; off<T>(type: string, handler: (event: T) => void): void; on<T>(type: string, handler: (event: T) => void): void; } declare class EventEmitter implements IEventEmitter { constructor(): this; /** * Subscribe to an event by its name. * @param {string} type - The name of the event * to subscribe to. * @param {(event: T) => void} handler - The * handler called when the event occurs. */ on<T>(type: string, handler: (event: T) => void): void; /** * Unsubscribe from an event by its name. * @param {string} type - The name of the event * to unsubscribe from. * @param {(event: T) => void} handler - The * handler to remove. */ off<T>(type: string, handler: (event: T) => void): void; /** * @ignore */ fire<T>(type: string, event: T): void; } /** * Interface that represents a longitude, latitude coordinate, * measured in degrees. Coordinates are defined in the WGS84 datum. */ export interface LngLat { /** * Latitude, measured in degrees. */ lat: number; /** * Longitude, measured in degrees. */ lng: number; } /** * Interface that represents longitude-latitude-altitude * coordinates. Longitude and latitude are measured in degrees * and altitude in meters. Coordinates are defined in the WGS84 datum. * @interface */ export interface LngLatAlt extends LngLat { /** * Altitude, measured in meters. */ alt: number; } /** * Contract describing a reconstruction point. */ export interface PointContract { /** * RGB color vector of the point, normalized to floats * on the interval [0, 1]; */ color: number[]; /** * Coordinates in metric scale in topocentric ENU * reference frame with respect to a geo reference. */ coordinates: number[]; } /** * Contract describing cluster reconstruction data. */ export interface ClusterContract { /** * The unique id of the cluster. */ id: string; /** * The points of the reconstruction. */ points: { [pointId: string]: PointContract, ... }; /** * The reference longitude, latitude, altitude of * the reconstruction. Determines the * position of the reconstruction in world reference * frame. */ reference: LngLatAlt; } /** * Ent representing an entity with a unique ID. * @interface IDEnt */ export interface IDEnt { /** * Unique ID. */ id: string; } /** * Ent representing core image properties. */ export type CoreImageEnt = { /** * SfM computed longitude, latitude in WGS84 datum, measured in degrees. * @description Optional - no 3D interaction available * if unset. */ computed_geometry?: LngLat, /** * Original EXIF longitude, latitude in WGS84 datum, measured in degrees. */ geometry: LngLat, /** * Sequence that the image is part of. */ sequence: IDEnt, ... } & IDEnt; /** * Contract describing core image results. */ export interface CoreImagesContract { /** * Geometry cell ID. */ cell_id: string; /** * Array of core image ents. */ images: CoreImageEnt[]; } /** * Ent representing camera properties. */ export interface CameraEnt { /** * Camera type dependent camera parameters. * * For perspective and fisheye camera types, * the camera parameters array should be * constructed according to * * `[focal, k1, k2]` * * where focal is the camera focal length, * and k1, k2 are radial distortion parameters. * * For spherical camera type the camera * parameters should be an emtpy array. */ camera_parameters: number[]; /** * Projection type of the camera. * @description Supported camera types are: * * ```js * 'spherical' * 'fisheye' * 'perspective' * ``` * * Other camera types will be treated as * perspective images. */ camera_type: string; } /** * Ent representing URL properties. */ export type URLEnt = { /** * URL for fetching ent data. */ url: string, ... } & IDEnt; /** * Ent representing image creator properties. */ export type CreatorEnt = { /** * The username of the creator. */ username: string, ... } & IDEnt; /** * Ent representing spatial image properties. */ export type SpatialImageEnt = { /** * Original EXIF altitude above sea level, in meters. */ altitude: number, /** * Scale of atomic reconstruction. * @description Optional - no 3D interaction available * if unset. */ atomic_scale?: number, /** * Timestamp representing the capture date and time. * @description Unix epoch timestamp in milliseconds. */ captured_at: number, /** * Original EXIF compass angle, measured in degrees. */ compass_angle: number, /** * Computed altitude, in meters. * @description Optional - no 3D interaction available * if unset. */ computed_altitude?: number, /** * SfM computed compass angle, measured in degrees. * @description Optional - no 3D interaction available * if unset. */ computed_compass_angle?: number, /** * Rotation vector in angle axis representation. * @description Optional - no 3D interaction available * if unset. */ computed_rotation?: number[], /** * Cluster reconstruction to which the image belongs. */ cluster: URLEnt, /** * Image creator. */ creator: CreatorEnt, /** * EXIF orientation of original image. */ exif_orientation: number, /** * Height of original image, not adjusted for orientation. */ height: number, /** * SfM connected component id to which the image belongs. * @description Optional - no 3D interaction available * if unset. */ merge_id?: string, /** * 3D mesh resource. */ mesh: URLEnt, /** * Owner to which the image belongs. */ owner: IDEnt, /** * Value specifying if image is accessible to organization members only * or to everyone. */ private?: boolean, /** * Image quality score on the interval [0, 1]. */ quality_score?: number, /** * Image thumbnail resource. */ thumb: URLEnt, /** * Width of original image, not adjusted for orientation. */ width: number, ... } & CameraEnt & IDEnt; /** * Contract describing ent results. */ export interface EntContract<T> { /** * Ent node. */ node: T; /** * Ent node id. */ node_id: string; } /** * Contract describing spatial image results. */ export type SpatialImagesContract = EntContract<SpatialImageEnt>[]; /** * Ent representing image properties. */ export type ImageEnt = { ... } & CoreImageEnt & SpatialImageEnt; /** * Contract describing image results. */ export type ImagesContract = EntContract<ImageEnt>[]; /** * Ent representing sequence properties. * @interface SequenceEnt */ export type SequenceEnt = { /** * The image IDs of the sequence sorted in * acsending order based on capture time. */ image_ids: string[], ... } & IDEnt; /** * Contract describing sequence results. */ export type SequenceContract = SequenceEnt; /** * Ent representing image tile properties. */ export interface ImageTileEnt { /** * URL for fetching image tile pixel data. */ url: string; /** * X tile coordinate. */ x: number; /** * Y tile coordinate. */ y: number; /** * Tile level. */ z: number; } /** * Contract describing image tile results. */ export type ImageTilesContract = EntContract<ImageTileEnt[]>; /** * Contract describing image tile requests. */ export interface ImageTilesRequestContract { /** * ID of the tile's image. */ imageId: string; /** * Tile level. */ z: number; } /** * @event */ export type ProviderEventType = "datacreate"; /** * @interface IGeometryProvider * * Interface describing geometry provider members. * * This is a specification for implementers to model: it * is not an exported method or class. */ export interface IGeometryProvider { /** * Convert a geodetic bounding box to the the minimum set * of cell ids containing the bounding box. * @description The bounding box needs * to be sufficiently small to be contained in an area with the size * of maximally four tiles. Up to nine adjacent tiles may be returned. * @param {LngLat} sw - South west corner of bounding box. * @param {LngLat} ne - North east corner of bounding box. * @returns {Array<string>} Array of cell ids. */ bboxToCellIds(sw: LngLat, ne: LngLat): string[]; /** * Get the cell ids of all adjacent cells. * @description In the case of approximately rectangular cells * this is typically the eight orthogonally and diagonally adjacent * cells. * @param {string} cellId - Id of cell. * @returns {Array<string>} Array of cell ids. No specific * order is guaranteed. */ getAdjacent(cellId: string): string[]; /** * Get the vertices of a cell. * @description The vertices form an unclosed * clockwise polygon in the 2D longitude, latitude * space. No assumption on the position of the first * vertex relative to the others can be made. * @param {string} cellId - Id of cell. * @returns {Array<LngLat>} Unclosed clockwise polygon. */ getVertices(cellId: string): LngLat[]; /** * Convert geodetic coordinates to a cell id. * @param {LngLat} lngLat - Longitude, latitude to convert. * @returns {string} Cell id for the longitude, latitude. */ lngLatToCellId(lngLat: LngLat): string; } /** * Interface describing data provider members. * * This is a specification for implementers to model: it is * not an exported method or class. * @fires datacreate */ export interface IDataProvider extends IEventEmitter { /** * Get geometry property. * @returns {IGeometryProvider} Geometry provider instance. */ geometry: IGeometryProvider; /** * Get core images in a geometry cell. * @param {string} cellId - The id of the geometry cell. * @returns {Promise<CoreImagesContract>} Promise to * the core images of the requested geometry cell id. * @throws Rejects the promise on errors. */ getCoreImages(cellId: string): Promise<CoreImagesContract>; /** * Get a cluster reconstruction. * @param {string} url - URL for the cluster reconstruction * to retrieve. * @param {Promise} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<ClusterContract>} Promise to the * cluster reconstruction. * @throws Rejects the promise on errors. */ getCluster(url: string, abort?: Promise<void>): Promise<ClusterContract>; /** * Get spatial images. * @param {Array<string>} imageIds - The ids for the * images to retrieve. * @returns {Promise<SpatialImagesContract>} Promise to * the spatial images of the requested image ids. * @throws Rejects the promise on errors. */ getSpatialImages(imageIds: string[]): Promise<SpatialImagesContract>; /** * Get complete images. * @param {Array<string>} imageIds - The ids for the * images to retrieve. * @returns {Promise<ImagesContract>} Promise to the images of the * requested image ids. * @throws Rejects the promise on errors. */ getImages(imageIds: string[]): Promise<ImagesContract>; /** * Get an image as an array buffer. * @param {string} url - URL for image to retrieve. * @param {Promise<void>} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<ArrayBuffer>} Promise to the array * buffer containing the image. * @throws Rejects the promise on errors. */ getImageBuffer(url: string, abort?: Promise<void>): Promise<ArrayBuffer>; /** * Get image tiles urls for a tile level. * @param {ImageTilesRequestContract} tiles - Tiles to request * @returns {Promise<ImageTilesContract>} Promise to the * image tiles response contract * @throws Rejects the promise on errors. * @example ```js * var tileRequest = { imageId: 'image-id', z: 12 }; * provider.getImageTiles(tileRequest) * .then((response) => console.log(response)); * ``` */ getImageTiles(tiles: ImageTilesRequestContract): Promise<ImageTilesContract>; /** * Get a mesh. * @param {string} url - URL for mesh to retrieve. * @param {Promise<void>} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<MeshContract>} Promise to the mesh. * @throws Rejects the promise on errors. */ getMesh(url: string, abort?: Promise<void>): Promise<MeshContract>; /** * Get sequence. * @param {Array<string>} sequenceId - The id for the * sequence to retrieve. * @returns {Promise} Promise to the sequences of the * requested image ids. * @throws Rejects the promise on errors. */ getSequence(sequenceId: string): Promise<SequenceContract>; /** * Set an access token for authenticated API requests of * protected resources. * @param {string} [accessToken] accessToken - User access * token or client access token. */ setAccessToken(accessToken?: string): void; } /** * Interface for general provider events. */ export interface ProviderEvent { /** * Data provider target that emitted the event. */ target: IDataProvider; /** * Provider event type. */ type: ProviderEventType; } /** * * Interface for data provider cell events. */ export type ProviderCellEvent = { /** * Cell ids for cells where data have been created. */ cellIds: string[], /** * Provider event type. */ type: "datacreate", ... } & ProviderEvent; /** * @class DataProviderBase * @classdesc Base class to extend if implementing a data provider * class. * @fires datacreate * @example ```js * class MyDataProvider extends DataProviderBase { * constructor() { * super(new S2GeometryProvider()); * } * ... * } * ``` */ declare class DataProviderBase implements IDataProvider, IEventEmitter { _geometry: IGeometryProvider; /** * Create a new data provider base instance. * @param {IGeometryProvider} geometry - Geometry * provider instance. */ constructor(_geometry: IGeometryProvider): this; /** * Get geometry property. * @returns {IGeometryProvider} Geometry provider instance. */ geometry: IGeometryProvider; fire<T>(type: string, event: T): void; /** * Get core images in a geometry cell. * @param {string} cellId - The id of the geometry cell. * @returns {Promise<CoreImagesContract>} Promise to * the core images of the requested geometry cell id. * @throws Rejects the promise on errors. */ getCoreImages(cellId: string): Promise<CoreImagesContract>; /** * Get a cluster reconstruction. * @param {string} url - URL for the cluster reconstruction * to retrieve. * @param {Promise} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<ClusterContract>} Promise to the * cluster reconstruction. * @throws Rejects the promise on errors. */ getCluster(url: string, abort?: Promise<void>): Promise<ClusterContract>; /** * Get spatial images. * @param {Array<string>} imageIds - The ids for the * images to retrieve. * @returns {Promise<SpatialImagesContract>} Promise to * the spatial images of the requested image ids. * @throws Rejects the promise on errors. */ getSpatialImages(imageIds: string[]): Promise<SpatialImagesContract>; /** * Get complete images. * @param {Array<string>} imageIds - The ids for the * images to retrieve. * @returns {Promise<ImagesContract>} Promise to the images of the * requested image ids. * @throws Rejects the promise on errors. */ getImages(imageIds: string[]): Promise<ImagesContract>; /** * Get an image as an array buffer. * @param {string} url - URL for image to retrieve. * @param {Promise<void>} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<ArrayBuffer>} Promise to the array * buffer containing the image. * @throws Rejects the promise on errors. */ getImageBuffer(url: string, abort?: Promise<void>): Promise<ArrayBuffer>; /** * Get image tiles urls for a tile level. * @param {ImageTilesRequestContract} tiles - Tiles to request * @returns {Promise<ImageTilesContract>} Promise to the * image tiles response contract * @throws Rejects the promise on errors. * @example ```js * var tileRequest = { imageId: 'image-id', z: 12 }; * provider.getImageTiles(tileRequest) * .then((response) => console.log(response)); * ``` */ getImageTiles(tiles: ImageTilesRequestContract): Promise<ImageTilesContract>; /** * Get a mesh. * @param {string} url - URL for mesh to retrieve. * @param {Promise<void>} [abort] - Optional promise for aborting * the request through rejection. * @returns {Promise<MeshContract>} Promise to the mesh. * @throws Rejects the promise on errors. */ getMesh(url: string, abort?: Promise<void>): Promise<MeshContract>; /** * Get sequence. * @param {Array<string>} sequenceId - The id for the * sequence to retrieve. * @returns {Promise} Promise to the sequences of the * requested image ids. * @throws Rejects the promise on errors. */ getSequence(sequenceId: string): Promise<SequenceContract>; off<T>(type: string, handler: (event: T) => void): void; on<T>(type: string, handler: (event: T) => void): void; /** * Set an access token for authenticated API requests of * protected resources. * @param {string} [accessToken] accessToken - User access * token or client access token. */ setAccessToken(accessToken?: string): void; } /** * @class GeometryProviderBase * @classdesc Base class to extend if implementing a geometry * provider class. * @example ```js * class MyGeometryProvider extends GeometryProviderBase { * ... * } * ``` */ declare class GeometryProviderBase implements IGeometryProvider { /** * Create a new geometry provider base instance. */ constructor(): this; /** * Convert a geodetic bounding box to the the minimum set * of cell ids containing the bounding box. * @description The bounding box needs * to be sufficiently small to be contained in an area with the size * of maximally four tiles. Up to nine adjacent tiles may be returned. * @param {LngLat} sw - South west corner of bounding box. * @param {LngLat} ne - North east corner of bounding box. * @returns {Array<string>} Array of cell ids. */ bboxToCellIds(sw: LngLat, ne: LngLat): string[]; /** * Get the cell ids of all adjacent cells. * @description In the case of approximately rectangular cells * this is typically the eight orthogonally and diagonally adjacent * cells. * @param {string} cellId - Id of cell. * @returns {Array<string>} Array of cell ids. No specific * order is guaranteed. */ getAdjacent(cellId: string): string[]; /** * Get the vertices of a cell. * @description The vertices form an unclosed * clockwise polygon in the 2D longitude, latitude * space. No assumption on the position of the first * vertex relative to the others can be made. * @param {string} cellId - Id of cell. * @returns {Array<LngLat>} Unclosed clockwise polygon. */ getVertices(cellId: string): LngLat[]; /** * Convert geodetic coordinates to a cell id. * @param {LngLat} lngLat - Longitude, latitude to convert. * @returns {string} Cell id for the longitude, latitude. */ lngLatToCellId(lngLat: LngLat): string; /** * @ignore */ _approxBboxToCellIds(sw: LngLat, ne: LngLat): string[]; } declare interface GraphCameraContract { focal: number; k1: number; k2: number; projection_type: string; } declare interface GraphCameraShotContract { camera: string; rotation: number[]; translation: number[]; } declare interface GraphReferenceContract { altitude: number; latitude: number; longitude: number; } declare interface GraphPointContract { color: number[]; coordinates: number[]; } declare interface GraphClusterContract { cameras: { [cameraId: string]: GraphCameraContract, ... }; points: { [pointId: string]: GraphPointContract, ... }; reference_lla: GraphReferenceContract; shots: { [imageKey: string]: GraphCameraShotContract, ... }; } declare interface GraphGeometry { coordinates: [number, number]; } declare type GraphCoreImageEnt = { computed_geometry: GraphGeometry, geometry: GraphGeometry, sequence: string, ... } & IDEnt; declare type GraphSpatialImageEnt = { merge_cc: number, sfm_cluster: URLEnt, thumb_1024_url: string, thumb_2048_url: string, ... } & SpatialImageEnt; declare class GraphConverter { clusterReconstruction(source: GraphClusterContract): ClusterContract; coreImage(source: GraphCoreImageEnt): CoreImageEnt; spatialImage(source: GraphSpatialImageEnt): SpatialImageEnt; } declare interface GraphDataProviderOptions { endpoint?: string; accessToken?: string; } declare class GraphQueryCreator { +imagesPath: string; +sequencePath: string; +coreFields: string[]; +idFields: string[]; +spatialFields: string[]; +imageTileFields: string[]; constructor(): this; images(imageIds: string[], fields: string[]): string; imagesS2(cellId: string, fields: string[]): string; imageTiles(z: number, fields: string[]): string; imageTilesPath(imageId: string): string; sequence(sequenceId: string): string; } declare class GraphDataProvider extends DataProviderBase { constructor( options?: GraphDataProviderOptions, geometry?: IGeometryProvider, converter?: GraphConverter, queryCreator?: GraphQueryCreator ): this; getCluster(url: string, abort?: Promise<void>): Promise<ClusterContract>; getCoreImages(cellId: string): Promise<CoreImagesContract>; getImageBuffer(url: string, abort?: Promise<void>): Promise<ArrayBuffer>; getImages(imageIds: string[]): Promise<ImagesContract>; getImageTiles( request: ImageTilesRequestContract ): Promise<ImageTilesContract>; getMesh(url: string, abort?: Promise<void>): Promise<MeshContract>; getSequence(sequenceId: string): Promise<SequenceContract>; getSpatialImages(imageIds: string[]): Promise<SpatialImagesContract>; setAccessToken(accessToken?: string): void; } /** * @class S2GeometryProvider * @classdesc Geometry provider based on S2 cells. * @example ```js * class MyDataProvider extends DataProviderBase { * ... * } * * const geometryProvider = new S2GeometryProvider(); * const dataProvider = new MyDataProvider(geometryProvider); * ``` */ declare class S2GeometryProvider extends GeometryProviderBase { /** * Create a new S2 geometry provider instance. */ constructor(_level?: number): this; /** * @inheritdoc */ bboxToCellIds(sw: LngLat, ne: LngLat): string[]; /** * @inheritdoc */ getAdjacent(cellId: string): string[]; /** * @inheritdoc */ getVertices(cellId: string): LngLat[]; /** * @inheritdoc */ lngLatToCellId(lngLat: LngLat): string; } export interface ComponentConfiguration { [key: string]: mixed; } /** * Enumeration for render mode * @enum {number} * * @readonly * @description Modes for specifying how rendering is done * in the viewer. All modes preserves the original aspect * ratio of the images. */ declare var RenderMode: {| +Letterbox: 0, // 0 +Fill: 1, // 1 |}; declare interface ViewportSize { height: number; width: number; } declare type CameraType = "spherical" | "fisheye" | "perspective"; /** * @class Transform * @classdesc Class used for calculating coordinate transformations * and projections. */ declare class Transform { /** * Create a new transform instance. * @param {number} orientation - Image orientation. * @param {number} width - Image height. * @param {number} height - Image width. * @param {number} focal - Focal length. * @param {number} scale - Atomic scale. * @param {Array<number>} rotation - Rotation vector in three dimensions. * @param {Array<number>} translation - Translation vector in three dimensions. * @param {HTMLImageElement} image - Image for fallback size calculations. */ constructor( orientation: number, width: number, height: number, scale: number, rotation: number[], translation: number[], image: HTMLImageElement, textureScale?: number[], cameraParameters?: number[], cameraType?: CameraType ): this; ck1: number; ck2: number; cameraType: CameraType; /** * Get basic aspect. * @returns {number} The orientation adjusted aspect ratio. */ basicAspect: number; /** * Get basic height. * @description Does not fall back to image image height but * uses original value from API so can be faulty. * @returns {number} The height of the basic version image * (adjusted for orientation). */ basicHeight: number; /** * Get basic width. * @description Does not fall back to image image width but * uses original value from API so can be faulty. * @returns {number} The width of the basic version image * (adjusted for orientation). */ basicWidth: number; /** * Get focal. * @returns {number} The image focal length. */ focal: number; /** * Get height. * @description Falls back to the image image height if * the API data is faulty. * @returns {number} The orientation adjusted image height. */ height: number; /** * Get orientation. * @returns {number} The image orientation. */ orientation: number; /** * Get scale. * @returns {number} The image atomic reconstruction scale. */ scale: number; /** * Get has valid scale. * @returns {boolean} Value indicating if the scale of the transform is valid. */ hasValidScale: boolean; /** * Get radial peak. * @returns {number} Value indicating the radius where the radial * undistortion function peaks. */ radialPeak: number; /** * Get width. * @description Falls back to the image image width if * the API data is faulty. * @returns {number} The orientation adjusted image width. */ width: number; /** * Project 3D world coordinates to basic coordinates. * @param {Array<number>} point3d - 3D world coordinates. * @return {Array<number>} 2D basic coordinates. */ projectBasic(point3d: number[]): number[]; /** * Unproject basic coordinates to 3D world coordinates. * @param {Array<number>} basic - 2D basic coordinates. * @param {Array<number>} distance - Distance to unproject from camera center. * @param {boolean} [depth] - Treat the distance value as depth from camera center. * Only applicable for perspective images. Will be * ignored for spherical. * @returns {Array<number>} Unprojected 3D world coordinates. */ unprojectBasic(basic: number[], distance: number, depth?: boolean): number[]; /** * Project 3D world coordinates to SfM coordinates. * @param {Array<number>} point3d - 3D world coordinates. * @return {Array<number>} 2D SfM coordinates. */ projectSfM(point3d: number[]): number[]; /** * Unproject SfM coordinates to a 3D world coordinates. * @param {Array<number>} sfm - 2D SfM coordinates. * @param {Array<number>} distance - Distance to unproject * from camera center. * @param {boolean} [depth] - Treat the distance value as * depth from camera center. Only applicable for perspective * images. Will be ignored for spherical. * @returns {Array<number>} Unprojected 3D world coordinates. */ unprojectSfM(sfm: number[], distance: number, depth?: boolean): number[]; } /** * @class Camera * @classdesc Holds information about a camera. */ declare class Camera { /** * Create a new camera instance. * @param {Transform} [transform] - Optional transform instance. */ constructor(transform?: Transform): this; /** * Get focal. * @returns {number} The focal length. */ focal: number; /** * Set focal. */ -focal: number; /** * Update this camera to the linearly interpolated value of two other cameras. * @param {Camera} a - First camera. * @param {Camera} b - Second camera. * @param {number} alpha - Interpolation value on the interval [0, 1]. */ lerpCameras(a: Camera, b: Camera, alpha: number): void; /** * Copy the properties of another camera to this camera. * @param {Camera} other - Another camera. */ copy(other: Camera): void; /** * Clone this camera. * @returns {Camera} A camera with cloned properties equal to this camera. */ clone(): Camera; /** * Determine the distance between this camera and another camera. * @param {Camera} other - Another camera. * @returns {number} The distance between the cameras. */ diff(other: Camera): number; } declare var State: {| +Custom: 0, // 0 +Earth: 1, // 1 +Traversing: 2, // 2 +Waiting: 3, // 3 +WaitingInteractively: 4, // 4 |}; /** * Enumeration for edge directions * @enum {number} * * @readonly * @description Directions for edges in image graph describing * sequence, spatial and image type relations between nodes. */ declare var NavigationDirection: {| +Next: 0, // 0 +Prev: 1, // 1 +StepLeft: 2, // 2 +StepRight: 3, // 3 +StepForward: 4, // 4 +StepBackward: 5, // 5 +TurnLeft: 6, // 6 +TurnRight: 7, // 7 +TurnU: 8, // 8 +Spherical: 9, // 9 +Similar: 10, // 10 |}; /** * Interface that describes additional properties of an edge. * @interface NavigationEdgeData */ export interface NavigationEdgeData { /** * The edge direction. */ direction: $Values<typeof NavigationDirection>; /** * The counter clockwise horizontal rotation angle from * the X-axis in a spherical coordiante system of the * motion from the source image to the destination node. */ worldMotionAzimuth: number; } /** * Interface that describes the properties for a * navigation edge from a source image to a * target image. * @interface NavigationEdge */ export interface NavigationEdge { /** * The id of the source image. */ source: string; /** * The id of the target image. */ target: string; /** * Additional data describing properties of the edge. */ data: NavigationEdgeData; } /** * Interface that indicates edge status. * @interface NavigationEdgeStatus */ export interface NavigationEdgeStatus { /** * Value indicating whether the edges have been cached. */ cached: boolean; /** * The edges. * @description If the cached property is false the edges * property will always be an empty array. If the cached * property is true, there will exist edges in the the * array if the image has edges. */ edges: NavigationEdge[]; } /** * @class ImageCache * @classdesc Represents the cached properties of a image. */ declare class ImageCache { /** * Create a new image cache instance. */ constructor(provider: IDataProvider): this; /** * Get image. * @description Will not be set when assets have not been cached * or when the object has been disposed. * @returns {HTMLImageElement} Cached image element of the image. */ image: HTMLImageElement; /** * Get mesh. * @description Will not be set when assets have not been cached * or when the object has been disposed. * @returns {MeshContract} SfM triangulated mesh of reconstructed * atomic 3D points. */ mesh: MeshContract; /** * Get sequenceEdges. * @returns {NavigationEdgeStatus} Value describing the status of the * sequence edges. */ sequenceEdges: NavigationEdgeStatus; /** * Get spatialEdges. * @returns {NavigationEdgeStatus} Value describing the status of the * spatial edges. */ spatialEdges: NavigationEdgeStatus; /** * Cache the sequence edges. * @param {Array<NavigationEdge>} edges - Sequence edges to cache. */ cacheSequenceEdges(edges: NavigationEdge[]): void; /** * Cache the spatial edges. * @param {Array<NavigationEdge>} edges - Spatial edges to cache. */ cacheSpatialEdges(edges: NavigationEdge[]): void; /** * Dispose the image cache. * @description Disposes all cached assets and unsubscribes to * all streams. */ dispose(): void; /** * Reset the sequence edges. */ resetSequenceEdges(): void; /** * Reset the spatial edges. */ resetSpatialEdges(): void; } /** * @class Image * @classdesc [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] */ declare class Image { /** * Create a new image instance. * @description Images are always created internally by the library. * Images can not be added to the library through any API method. * @param {CoreImageEnt} core- Raw core image data. * @ignore */ constructor(core: CoreImageEnt): this; /** * Get assets cached. * @description The assets that need to be cached for this property * to report true are the following: fill properties, image and mesh. * The library ensures that the current image will always have the * assets cached. * @returns {boolean} Value indicating whether all assets have been * cached. * @ignore */ assetsCached: boolean; /** * Get cameraParameters. * @description Will be undefined if SfM has * not been run. * * Camera type dependent parameters. * * For perspective and fisheye camera types, * the camera parameters array should be * constructed according to * * `[focal, k1, k2]` * * where focal is the camera focal length, * and k1, k2 are radial distortion parameters. * * For spherical camera type the camera * parameters are unset or emtpy array. * @returns {Array<number>} The parameters * related to the camera type. */ cameraParameters: number[]; /** * Get cameraType. * @description Will be undefined if SfM has not been run. * @returns {string} The camera type that captured the image. */ cameraType: string; /** * Get capturedAt. * @description Timestamp of the image capture date * and time represented as a Unix epoch timestamp in milliseconds. * @returns {number} Timestamp when the image was captured. */ capturedAt: number; /** * Get clusterId. * @returns {string} Globally unique id of the SfM cluster to which * the image belongs. */ clusterId: string; /** * Get clusterUrl. * @returns {string} Url to the cluster reconstruction file. * @ignore */ clusterUrl: string; /** * Get compassAngle. * @description If the SfM computed compass angle exists it will * be returned, otherwise the original EXIF compass angle. * @returns {number} Compass angle, measured in degrees * clockwise with respect to north. */ compassAngle: number; /** * Get complete. * @description The library ensures that the current image will * always be full. * @returns {boolean} Value indicating whether the image has all * properties filled. * @ignore */ complete: boolean; /** * Get computedAltitude. * @description If SfM has not been run the computed altitude is * set to a default value of two meters. * @returns {number} Altitude, in meters. */ computedAltitude: number; /** * Get computedCompassAngle. * @description Will not be set if SfM has not been run. * @returns {number} SfM computed compass angle, measured * in degrees clockwise with respect to north. */ computedCompassAngle: number; /** * Get computedLngLat. * @description Will not be set if SfM has not been run. * @returns {LngLat} SfM computed longitude, latitude in WGS84 datum, * measured in degrees. */ computedLngLat: LngLat; /** * Get creatorId. * @description Note that the creator ID will not be set when using * the Mapillary API. * @returns {string} Globally unique id of the user who uploaded * the image. */ creatorId: string; /** * Get creatorUsername. * @description Note that the creator username will not be set when * using the Mapillary API. * @returns {string} Username of the creator who uploaded * the image. */ creatorUsername: string; /** * Get exifOrientation. * @returns {number} EXIF orientation of original image. */ exifOrientation: number; /** * Get height. * @returns {number} Height of original image, not adjusted * for orientation. */ height: number; /** * Get image. * @description The image will always be set on the current image. * @returns {HTMLImageElement} Cached image element of the image. */ image: HTMLImageElement; /** * Get id. * @returns {string} Globally unique id of the image. */ id: string; /** * Get lngLat. * @description If the SfM computed longitude, latitude exist * it will be returned, otherwise the original EXIF latitude * longitude. * @returns {LngLat} Longitude, latitude in WGS84 datum, * measured in degrees. */ lngLat: LngLat; /** * Get merged. * @returns {boolean} Value indicating whether SfM has been * run on the image and the image has been merged into a * connected component. */ merged: boolean; /** * Get mergeId. * @description Will not be set if SfM has not yet been run on * image. * @returns {stirng} Id of connected component to which image * belongs after the aligning merge. */ mergeId: string; /** * Get mesh. * @description The mesh will always be set on the current image. * @returns {MeshContract} SfM triangulated mesh of reconstructed * atomic 3D points. */ mesh: MeshContract; /** * Get originalAltitude. * @returns {number} EXIF altitude, in meters, if available. */ originalAltitude: number; /** * Get originalCompassAngle. * @returns {number} Original EXIF compass angle, measured in * degrees. */ originalCompassAngle: number; /** * Get originalLngLat. * @returns {LngLat} Original EXIF longitude, latitude in * WGS84 datum, measured in degrees. */ originalLngLat: LngLat; /** * Get ownerId. * @returns {string} Globally unique id of the owner to which * the image belongs. If the image does not belong to an * owner the owner id will be undefined. */ ownerId: string; /** * Get private. * @returns {boolean} Value specifying if image is accessible to * organization members only or to everyone. */ private: boolean; /** * Get qualityScore. * @returns {number} A number between zero and one * determining the quality of the image. Blurriness * (motion blur / out-of-focus), occlusion (camera * mount, ego vehicle, water-drops), windshield * reflections, bad illumination (exposure, glare), * and bad weather condition (fog, rain, snow) * affect the quality score. * @description Value should be on the interval [0, 1]. */ qualityScore: number; /** * Get rotation. * @description Will not be set if SfM has not been run. * @returns {Array<number>} Rotation vector in angle axis representation. */ rotation: number[]; /** * Get scale. * @description Will not be set if SfM has not been run. * @returns {number} Scale of reconstruction the image * belongs to. */ scale: number; /** * Get sequenceId. * @returns {string} Globally unique id of the sequence * to which the image belongs. */ sequenceId: string; /** * Get sequenceEdges. * @returns {NavigationEdgeStatus} Value describing the status of the * sequence edges. * @ignore */ sequenceEdges: NavigationEdgeStatus; /** * Get spatialEdges. * @returns {NavigationEdgeStatus} Value describing the status of the * spatial edges. * @ignore */ spatialEdges: NavigationEdgeStatus; /** * Get width. * @returns {number} Width of original image, not * adjusted for orientation. */ width: number; /** * Cache the sequence edges. * @description The sequence edges are cached asynchronously * internally by the library. * @param {Array<NavigationEdge>} edges - Sequence edges to cache. * @ignore */ cacheSequenceEdges(edges: NavigationEdge[]): void; /** * Cache the spatial edges. * @description The spatial edges are cached asynchronously * internally by the library. * @param {Array<NavigationEdge>} edges - Spatial edges to cache. * @ignore */ cacheSpatialEdges(edges: NavigationEdge[]): void; /** * Dispose the image. * @description Disposes all cached assets. * @ignore */ dispose(): void; /** * Initialize the image cache. * @description The image cache is initialized internally by * the library. * @param {ImageCache} cache - The image cache to set as cache. * @ignore */ initializeCache(cache: ImageCache): void; /** * Complete an image with spatial properties. * @description The image is completed internally by * the library. * @param {SpatialImageEnt} fill - The spatial image struct. * @ignore */ makeComplete(fill: SpatialImageEnt): void; /** * Reset the sequence edges. * @ignore */ resetSequenceEdges(): void; /** * Reset the spatial edges. * @ignore */ resetSpatialEdges(): void; /** * Clears the image and mesh assets, aborts * any outstanding requests and resets edges. * @ignore */ uncache(): void; } declare interface IAnimationState { reference: LngLatAlt; alpha: number; camera: Camera; zoom: number; currentImage: Image; currentCamera: Camera; previousImage: Image; trajectory: Image[]; currentIndex: number; lastImage: Image; imagesAhead: number; currentTransform: Transform; previousTransform: Transform; motionless: boolean; state: $Values<typeof State>; } declare interface AnimationFrame { id: number; fps: number; state: IAnimationState; } declare interface EulerRotation { phi: number; theta: number; } declare class RenderCamera { constructor( elementWidth: number, elementHeight: number, renderMode: $Values<typeof RenderMode> ): this; alpha: number; camera: Camera; changed: boolean; frameId: number; renderMode: $Values<typeof RenderMode>; rotation: EulerRotation; zoom: number; size: ViewportSize; getTilt(): number; fovToZoom(fov: number): number; setFrame(frame: AnimationFrame): void; setProjectionMatrix(matrix: number[]): void; setRenderMode(renderMode: $Values<typeof RenderMode>): void; setSize(size: ViewportSize): void; } declare class RenderService { constructor( element: HTMLElement, currentFrame$: mixed, renderMode: $Values<typeof RenderMode>, renderCamera?: RenderCamera ): this; element: HTMLElement; dispose(): void; } declare interface VirtualNodeHash { name: string; } declare class DOMRenderer { constructor(element: HTMLElement, renderService: RenderService): this; clear(name: string): void; remove(): void; } declare type GLRenderFunction = { (): void, }; declare var RenderPass$1: {| +Background: 0, // 0 +Opaque: 1, // 1 |}; declare interface GLFrameRenderer { frameId: number; needsRender: boolean; render: GLRenderFunction; pass: $Values<typeof RenderPass$1>; } declare interface GLRenderHash { name: string; renderer: GLFrameRenderer; } declare class GLRenderer { constructor( canvas: HTMLCanvasElement, canvasContainer: HTMLElement, renderService: RenderService ): this; clear(name: string): void; remove(): void; triggerRerender(): void; } /** * Enumeration for transition mode * @enum {number} * * @readonly * @description Modes for specifying how transitions * between images are performed. */ declare var TransitionMode: {| +Default: 0, // 0 +Instantaneous: 1, // 1 |}; declare class StateService { constructor( initialState: $Values<typeof State>, transitionMode?: $Values<typeof TransitionMode> ): this; dispose(): void; custom(): void; earth(): void; traverse(): void; wait(): void; waitInteractively(): void; appendImagess(images: Image[]): void; prependImages(images: Image[]): void; removeImages(n: number): void; clearImages(): void; clearPriorImages(): void; cutImages(): void; setImages(images: Image[]): void; setViewMatrix(matrix: number[]): void; rotate(delta: EulerRotation): void; rotateUnbounded(delta: EulerRotation): void; rotateWithoutInertia(delta: Eu