UNPKG

@allmaps/render

Version:

Render functions for WebGL and image buffers

161 lines (159 loc) 7.9 kB
import { TileCache } from '../tilecache/TileCache.js'; import { WarpedMapList } from '../maps/WarpedMapList.js'; import { FetchableTile } from '../tilecache/FetchableTile.js'; import { Size, Tile } from '@allmaps/types'; import { Viewport } from '../viewport/Viewport.js'; import { WarpedMap } from '../maps/WarpedMap.js'; import { CacheableTileFactory, WarpedMapFactory, BaseRenderOptions, GetWarpedMapOptions, AnimationOptions, Sprite } from '../shared/types.js'; /** * Abstract base class for renderers */ export declare abstract class BaseRenderer<W extends WarpedMap, D> extends EventTarget { warpedMapList: WarpedMapList<W>; tileCache: TileCache<D>; spritesTileCache: TileCache<D>; mapsInPreviousViewport: Set<string>; mapsInViewport: Set<string>; mapsWithFetchableTilesForPreviousViewport: Set<string>; mapsWithFetchableTilesForViewport: Set<string>; mapsWithRequestedTilesForViewport: Set<string>; protected viewport: Viewport | undefined; options: Partial<BaseRenderOptions>; constructor(warpedMapFactory: WarpedMapFactory<W>, cacheableTileFactory: CacheableTileFactory<D>, options?: Partial<BaseRenderOptions>); /** * Parses an annotation and adds its georeferenced map to this renderer's warped map list * * @param annotation - Annotation * @param mapOptions - Map options */ addGeoreferenceAnnotation(annotation: unknown, mapOptions?: Partial<GetWarpedMapOptions<W>>): Promise<(string | Error)[]>; /** * Adds a georeferenced map to this renderer's warped map list * * @param georeferencedMap - Georeferenced Map * @param mapOptions - Map options */ addGeoreferencedMap(georeferencedMap: unknown, mapOptions?: Partial<GetWarpedMapOptions<W>>): Promise<string>; addSprites(sprites: Sprite[], imageUrl: string, imageSize: Size): Promise<unknown>; /** * Get the default options of the renderer and list */ getDefaultOptions(): BaseRenderOptions & GetWarpedMapOptions<W>; /** * Get the default options of a map * * These come from the default option settings for WebGL2WarpedMaps and the map's georeferenced map proporties * * @param mapId - Map ID for which the options apply */ getMapDefaultOptions(mapId: string): GetWarpedMapOptions<W> | undefined; /** * Get the render and list options */ getOptions(): Partial<BaseRenderOptions>; /** * Get the map-specific options of a map * * @param mapId - Map ID for which the options apply */ getMapMapOptions(mapId: string): Partial<GetWarpedMapOptions<W>> | undefined; /** * Get the options of a map * * These options are the result of merging the default, georeferenced map, * layer and map-specific options of that map. * * @param mapId - Map ID for which the options apply */ getMapOptions(mapId: string): GetWarpedMapOptions<W> | undefined; /** * Set the renderer and list options * * @param renderAndListOptions - Render and list Options to set * @param animationOptions - Animation options */ setOptions(renderAndListOptions?: Partial<BaseRenderOptions>, animationOptions?: Partial<AnimationOptions>): void; /** * Set the map-specific options of maps (and the renderer and list options) * * @param mapIds - Map IDs for which to set the options * @param mapOptions - Map-specific options to set * @param renderAndListOptions - Render and list options to set * @param animationOptions - Animation options */ setMapsOptions(mapIds: string[], mapOptions?: Partial<BaseRenderOptions>, renderAndListOptions?: Partial<BaseRenderOptions>, animationOptions?: Partial<AnimationOptions>): void; /** * Set the map-specific options of maps by map ID (and the render and list options) * * @param mapOptionsByMapId - Map-specific options to set by map ID * @param renderAndListOptions - Render and list options to set * @param animationOptions - Animation options */ setMapsOptionsByMapId(mapOptionsByMapId?: Map<string, Partial<BaseRenderOptions>>, renderAndListOptions?: Partial<BaseRenderOptions>, animationOptions?: Partial<AnimationOptions>): void; /** * Resets the list options * * An empty array resets all options, undefined resets no options. * Only resets the list options, not the render options * * @param listOptionKeys - Keys of the render and list options to reset * @param animationOptions - Animation options */ resetOptions(listOptionKeys?: string[], animationOptions?: Partial<AnimationOptions>): void; /** * Resets the map-specific options of maps (and the list options) * * An empty array resets all options, undefined resets no options. * Only resets the list options, not the render options * * @param mapIds - Map IDs for which to reset the options * @param mapOptionKeys - Keys of the map-specific options to reset * @param listOptionKeys - Keys of the render and list options to reset * @param animationOptions - Animation options */ resetMapsOptions(mapIds: string[], mapOptionKeys?: string[], listOptionKeys?: string[], animationOptions?: Partial<AnimationOptions>): void; /** * Resets the map-specific options of maps by map ID (and the list options) * * An empty array or map resets all options (for all maps), undefined resets no options. * Only resets the list options, not the render options * * @param mapOptionkeysByMapId - Keys of map-specific options to reset by map ID * @param listOptionKeys - Keys of the render and list options to reset * @param animationOptions - Animation options */ resetMapsOptionsByMapId(mapOptionkeysByMapId?: Map<string, string[]>, listOptionKeys?: string[], animationOptions?: Partial<AnimationOptions>): void; protected loadMissingImagesInViewport(): Promise<void>[]; protected someImagesInViewport(): boolean; protected shouldRequestFetchableTiles(): boolean; protected shouldAnticipateInteraction(): boolean; protected assureProjection(): void; protected requestFetchableTiles(): void; protected findMapsInViewport(viewportBufferRatio?: number): Set<string>; protected getMapFetchableTilesForViewport(mapId: string, mapsInViewportForRequest: Set<string>): FetchableTile[]; protected getMapOverviewFetchableTilesForViewport(mapId: string, totalFetchableTilesForViewportResolution: number, mapsInViewportForOverviewRequest: Set<string>, spriteFetchabelTiles: FetchableTile[]): FetchableTile[]; protected updateMapsForViewport(allFechableTilesForViewport: FetchableTile[]): { mapsWithFetchableTilesForViewportEntering: string[]; mapsWithFetchableTilesForViewportLeaving: string[]; mapsInViewportEntering: string[]; mapsInViewportLeaving: string[]; }; protected mapsInViewportsToEnteringAndLeaving(mapsForPreviousViewport: string[], mapsForViewport: string[]): { mapsForViewportEntering: string[]; mapsForViewportLeaving: string[]; }; protected pruneTileCache(mapsInViewportForOverviewPrune: Set<string>): void; protected filterOutTilesCloseToSpriteTiles(tiles: Tile[], warpedMap: WarpedMap): Tile[]; destroy(): void; protected clearMap(mapId: string): void; protected mapTileLoaded(event: Event): void; protected mapTileDeleted(event: Event): void; protected imageLoaded(event: Event): void; protected warpedMapAdded(event: Event): void; protected warpedMapRemoved(event: Event): void; protected prepareChange(event: Event): void; protected immediateChange(event: Event): void; protected animatedChange(event: Event): void; protected addEventListeners(): void; protected removeEventListeners(): void; }