interface FrustumPlane { distance: number; normal: number[]; } interface FrustumPlanesInterface { left: FrustumPlane; right: FrustumPlane; bottom: FrustumPlane; top: FrustumPlane; near: FrustumPlane; far: FrustumPlane; } declare enum PROJECTION_MODE { WEB_MERCATOR = 1, GLOBE = 2, WEB_MERCATOR_AUTO_OFFSET = 4, IDENTITY = 0 } declare enum COORDINATE_SYSTEM { DEFAULT = -1, LNGLAT = 1, METER_OFFSETS = 2, LNGLAT_OFFSETS = 3, CARTESIAN = 0 } interface IDistanceScales { unitsPerMeter: number[]; metersPerUnit: number[]; unitsPerMeter2?: number[]; unitsPerDegree: number[]; degreesPerUnit: number[]; unitsPerDegree2?: number[]; } interface IViewportOpts { width: number; height: number; viewMatrix: number[]; longitude: number; latitude: number; zoom: number; distanceScales: IDistanceScales; orthographic: boolean; fovyRadians: number; aspect: number; focalDistance: number; near: number; far: number; fovy?: number; position?: number[]; projectionMatrix?: number[]; modelMatrix?: number[]; } interface IViewport extends IViewportOpts { id: string | number; x: number; y: number; pitch: number; bearing: number; nearZMultiplier: number; farZMultiplier: number; altitude: number; worldOffset: number; projectOffsetZoom: number; repeat: boolean; } declare class WebMercatorViewport { id: string | number; latitude: number; altitude: number; longitude: number; zoom: number; pitch: number; bearing: number; isGeospatial: boolean; scale: number; width: number; height: number; center: number[]; modelMatrix: number[]; viewMatrix: number[]; viewMatrixInverse: number[]; viewMatrixUncentered: number[]; projectionMatrix: number[] | Float32Array; pixelProjectionMatrix: number[]; pixelUnprojectionMatrix: number[]; viewportMatrix: number[]; viewProjectionMatrix: number[]; cameraPosition: number[]; focalDistance: number; distanceScales: IDistanceScales; position: number[]; projectOffsetZoom: number; private readonly _subViewports; private meterOffset; private x; private y; private _frustumPlanes; private orthographic; /** * Manages coordinate system transformations for deck.gl. * Note: The WebMercatorViewport is immutable in the sense that it only has accessors. * A new viewport instance should be created if any parameters have changed. */ constructor(opts: Partial); get metersPerPixel(): number; get projectionMode(): PROJECTION_MODE.WEB_MERCATOR | PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET | PROJECTION_MODE.IDENTITY; /** * Two viewports are equal if width and height are identical, and if their view and projection matrices are (approximately) equal. * @param viewport */ equals(viewport: any): boolean; /** * Projects xyz (possibly latitude and longitude) to pixel coordinates in window * using viewport projection parameters * - [longitude, latitude] to [x, y] * - [longitude, latitude, Z] => [x, y, z] * Note: By default, returns top-left coordinates for canvas/SVG type render * * @param {Array} lngLatZ - [lng, lat] or [lng, lat, Z] * @param {Object} opts.topLeft=true - Whether projected coords are top left * @return {Array} - [x, y] or [x, y, z] in top left coords * @param xyz */ project(xyz: number[], { topLeft, }?: { topLeft?: boolean; }): number[]; /** * Unproject pixel coordinates on screen onto world coordinates, * (possibly [lon, lat]) on map. * - [x, y] => [lng, lat] * - [x, y, z] => [lng, lat, Z] * @param {Array} xyz - * @param {Object} opts - options * @param {Object} opts.topLeft=true - Whether origin is top left * @return {Array|null} - [lng, lat, Z] or [X, Y, Z] */ unproject(xyz: number[], { topLeft, targetZ, }?: { topLeft?: boolean; targetZ?: number; }): (number | undefined)[]; projectPosition(xyz: number[]): number[]; unprojectPosition(xyz: number[]): number[]; /** * Project [lng,lat] on sphere onto [x,y] on 512*512 Mercator Zoom 0 tile. * Performs the nonlinear part of the web mercator projection. * Remaining projection is done with 4x4 matrices which also handles * perspective. * Specifies a point on the sphere to project onto the map. * @return {Array} [x,y] coordinates. * @param xyz */ projectFlat(xyz: number[]): number[]; /** * Unproject world point [x,y] on map onto {lat, lon} on sphere * representing point on projected map plane * @return {GeoCoordinates} - object with {lat,lon} of point on sphere. * Has toArray method if you need a GeoJSON Array. * Per cartographic tradition, lat and lon are specified as degrees. * @param xyz */ unprojectFlat(xyz: number[]): number[]; getDistanceScales(coordinateOrigin: null | number[]): IDistanceScales; /** * Judge whether the position is in the range * @param x * @param y * @param width * @param height */ containsPixel({ x, y, width, height }: { x: number; y: number; width?: number; height?: number; }): boolean; /** * Extract frustum planes in common space */ getFrustumPlanes(): FrustumPlanesInterface; getCameraPosition(): number[]; _createProjectionMatrix({ orthographic, fovyRadians, aspect, focalDistance, near, far, }: { fovyRadians: number; aspect: number; focalDistance: number; orthographic?: boolean; near?: number; far?: number; }): number[]; _initViewMatrix(opts: IViewportOpts): void; _initProjectionMatrix(opts: IViewportOpts): void; _initPixelMatrices(): void; _getCenterInWorld({ longitude, latitude }: { longitude: number; latitude: number; }): number[]; get subViewports(): WebMercatorViewport[] | undefined; /** * Add a meter delta to a base lnglat coordinate, returning a new lnglat array * * Note: Uses simple linear approximation around the viewport center * Error increases with size of offset (roughly 1% per 100km) * * @return {[Number,Number]|[Number,Number,Number]) array of [lng,lat,z] deltas * @param lngLatZ * @param xyz */ addMetersToLngLat(lngLatZ: number[], xyz: [number, number, number]): number[]; /** * Get the map center that place a given [lng, lat] coordinate at screen * point [x, y] * * @param {Array} lngLat - [lng,lat] coordinates * Specifies a point on the sphere. * @param {Array} pos - [x,y] coordinates * Specifies a point on the screen. * @return {Array} [lng,lat] new map center. */ getMapCenterByLngLatPosition({ lngLat, pos }: { lngLat: number[]; pos: number[]; }): number[]; getBounds(options?: {}): number[]; } type vec4 = [number, number, number, number] | Float32Array | number[]; type mat4 = number[] | [ number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number ] | Float32Array; interface IOptions { viewport: WebMercatorViewport; devicePixelRatio: number; modelMatrix: number[] | null; coordinateSystem: COORDINATE_SYSTEM; coordinateOrigin?: number[]; autoWrapLongitude?: boolean; } declare function isEqual(a: any, b: any): boolean; /** * Speed up consecutive function calls by caching the result of calls with identical input * https://en.wikipedia.org/wiki/Memoization * @param {function} compute - the function to be memoized */ declare function memoize(compute: (args: any) => any): (args: any) => { [key: string]: any; }; /** * Multiplies two mat4s * @param {mat4} out the receiving matrix * @param {ReadonlyMat4} a the first operand * @param {ReadonlyMat4} b the second operand * @returns {mat4} out */ declare function multiply(out: mat4, a: mat4 | number[], b: mat4 | number[]): mat4; /** * Transforms the vec4 with a mat4. * @param {vec4} out the receiving vector * @param {ReadonlyVec4} a the vector to transform * @param {ReadonlyMat4} m matrix to transform with * @returns {vec4} out */ declare function transformMat4(out: vec4, a: vec4, m: mat4 | number[]): vec4; /** * Inverts a mat4 * @param out * @param a */ declare function invert(out: vec4, a: vec4): Float32Array | number[] | null; declare function getOffsetOrigin(viewport: WebMercatorViewport, coordinateSystem: COORDINATE_SYSTEM, coordinateOrigin?: number[]): { geospatialOrigin: any; shaderCoordinateOrigin: number[]; offsetMode: boolean; }; /** * Returns uniforms for shaders based on current projection * includes: projection matrix suitable for shaders * @param viewport * @param devicePixelRatio * @param modelMatrix * @param coordinateSystem * @param coordinateOrigin * @param autoWrapLongitude * @return {Float32Array} - 4x4 projection matrix that can be used in shaders */ declare function getUniformsFromViewport({ viewport, devicePixelRatio, modelMatrix, coordinateSystem, coordinateOrigin, autoWrapLongitude, }: IOptions): { [key: string]: any; }; type MercatorUniformKeys = [ 'project_uCoordinateSystem', 'project_uProjectionMode', 'project_uCoordinateOrigin', 'project_uCenter', 'project_uAntimeridian', 'project_uViewportSize', 'project_uDevicePixelRatio', 'project_uFocalDistance', 'project_uCommonUnitsPerMeter', 'project_uCommonUnitsPerWorldUnit', 'project_uCommonUnitsPerWorldUnit2', 'project_uScale', 'project_uViewProjectionMatrix', 'project_metersPerPixel', 'project_uModelMatrix', 'project_uWrapLongitude', 'project_uCameraPosition', 'project_uCommonOrigin' ]; declare function getUniformKeys(): MercatorUniformKeys; declare function getUniforms(opts: IOptions): { [key: string]: any; }; declare function highPrecisionLngLat(lngLat: number[], offset?: number, stride?: number): Float32Array; declare function injectMercatorGLSL(gl: WebGLRenderingContext | WebGL2RenderingContext, source: string, defines?: { PROJECT_OFFSET_THRESHOLD: string; }): string; declare const fp32: { name: string; vs: string; fs: null; }; declare const project: { name: string; vs: string; fs: null; inject: {}; dependencies: { name: string; vs: string; fs: null; }[]; deprecations: never[]; getUniforms: typeof getUniforms; }; export { WebMercatorViewport, fp32, getOffsetOrigin, getUniformKeys, getUniforms, getUniformsFromViewport, highPrecisionLngLat, injectMercatorGLSL, invert, isEqual, memoize, multiply, project, transformMat4 }; export type { IOptions, MercatorUniformKeys, mat4, vec4 }; //# sourceMappingURL=index.d.ts.map