s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
169 lines (168 loc) • 5.61 kB
TypeScript
import type Camera from '../index.js';
import type { MapOptions } from 'ui/s2mapUI.js';
import type { TileInView } from './getTiles/index.js';
import type { Point3D, VectorPoint } from 'gis-tools/index.js';
import type { Projection, StyleDefinition } from 'style/style.spec.js';
export * from './getTiles/index.js';
/**
* # View
*
* The view of the map
* Inputs are:
* - `lon`: the longitude of the map
* - `lat`: the latitude of the map
* - `zoom`: the zoom level of the map
* - `bearing`: the bearing/compass of the map camera
* - `pitch`: the pitch/vertical-angle of the map camera
*/
export interface View {
/** the longitude of the map */
lon?: number;
/** the latitude of the map */
lat?: number;
/** zoom level of the map */
zoom?: number;
/** bearing/compass of the map camera */
bearing?: number;
/** pitch/vertical-angle of the map camera */
pitch?: number;
}
/** The type of matrix. Either `m` (meters) or `km` (kilometers) */
export type MatrixType = 'm' | 'km';
/**
* # Projector
*
* Maintain state of the camera, view, zoom, and other parameters that control how we see the map.
* Also used as a tool to find the tiles that are currently visible.
* @see {@link Camera}
*/
export declare class Projector {
#private;
camera: Camera;
projection: Projection;
webworker: boolean;
noClamp: boolean;
radius: number;
radii: Point3D;
zTranslateStart: number;
zTranslateEnd: number;
zoomEnd: number;
positionalZoom: boolean;
view: Float32Array;
aspect: VectorPoint;
matrices: {
[key in MatrixType]?: Float32Array;
};
eye: VectorPoint;
constrainZoomToFill: boolean;
duplicateHorizontally: boolean;
minLatPosition: number;
maxLatPosition: number;
prevZoom: number;
zoom: number;
minzoom: number;
maxzoom: number;
zoomOffset: number;
lon: number;
lat: number;
bearing: number;
pitch: number;
zNear: number;
zFar: number;
tileSize: number;
multiplier: number;
dirty: boolean;
/**
* @param config - Map Options
* @param camera - Camera
*/
constructor(config: MapOptions, camera: Camera);
/** Reset the projector. This forces a re-calculation of it's internal data like matrices before rendering */
reset(): void;
/**
* Set the mouse position on the canvas for potential interactions
* Input is the pixel position (0->width, 0->height). Convert to -1->1 for the GPU
* @param x - x mouse position
* @param y - y mouse position
*/
setMousePosition(x: number, y: number): void;
/**
* Set the state of the current feature
* @param state - 0: none, 1: hover, 2: click
*/
setFeatureState(state: 0 | 1 | 2): void;
/**
* Set the current feature that's under the mouse
* @param id - the id of the feature
*/
setCurrentFeature(id: number): void;
/**
* Set the style parameters
* @param style - user defined style params
* @param ignorePosition - if set, do not update the view
*/
setStyleParameters(style: StyleDefinition, ignorePosition: boolean): void;
/**
* Update the view
* @param view - the new view
*/
setView(view: View): void;
/** @returns the amount the zoom has changed since the last update */
zoomChange(): number;
/**
* Get a zoom scale, if no zoom is provided, use the current zoom
* @param zoom - the zoom level
* @returns the zoom scale
*/
zoomScale(zoom?: number): number;
/**
* Resize the canvas. So we need to update our view's aspect
* @param width - new width
* @param height - new height
*/
resize(width: number, height: number): void;
/**
* The user has scrolled or two finger pinched
* @param zoomInput - the amount the user scrolled
* @param canvasX - the x position on the canvas
* @param canvasY - the y position on the canvas
*/
onZoom(zoomInput: number, canvasX: number, canvasY: number): void;
/**
* User mouse/touch input (or swipe animation)
* @param movementX - the change in x position
* @param movementY - the change in y position
* @param multiplierX - the multiplier for the x axis
* @param multiplierY - the multiplier for the y axis
*/
onMove(movementX?: number, movementY?: number, multiplierX?: number, multiplierY?: number): void;
/**
* Get the lon-lat based on the mouse position
* x and y are the distances from the center of the screen
* @param xOffset - x offset
* @param yOffset - y offset
* @returns longitude and latitude at the mouse position
*/
cursorToLonLat(xOffset: number, yOffset: number): undefined | VectorPoint;
/**
* Get the matrix for either a global state (S2) or a specific tile (WM)
* - S2 -> type of meters or kilometers
* - WM -> scale and offset
* @param typeOrScale - type or scale
* @param offset - offset in pixels
* @returns the matrix
*/
getMatrix(typeOrScale: number | MatrixType, offset?: VectorPoint): Float32Array;
/** @returns the tiles in this projector's current view */
getTilesInView(): TileInView[];
/**
* Get the tiles at a specific position
* @param lon - longitude
* @param lat - latitude
* @param zoom - zoom
* @param bearing - bearing
* @param pitch - pitch
* @returns the tiles in view
*/
getTilesAtPosition(lon: number, lat: number, zoom: number, bearing: number, pitch: number): TileInView[];
}