import { MutableRefObject, ReactElement, ReactNode } from "react"; import { IFeatureSource } from "../sourceDefinition/LolOpenLayersSourceDef"; import { ILayerStatus } from "../model/layerstatus"; import Map from "ol/Map"; import { Geometry, LineString, Point } from "ol/geom"; import { Source } from "ol/source"; import { FeatureLike } from "ol/Feature"; import { MapSelectHandler } from "../events/LolOpenLayersMapSelectEvent"; import { Layer } from "ol/layer"; import { ClickedFeaturesByLayer, IMapImplement } from "../map/MapImplement"; import { AnchorPosition } from "../component/MapContextMenu"; import { Feature, Overlay } from "ol"; import { Pixel } from "ol/pixel"; import { PlacementParams } from "../map/placement/PlacementParams"; import GeoImage from "ol-ext/source/GeoImage"; /** A feature and its corresponding layer */ export interface ClickedFeature { layer: Layer; feature: FeatureLike; distance: number; } export declare enum ClickHandlerType { NONE = 0, PIXEL = 1, FEATURE = 2 } /** * Keep the state of event handlers implemented as custom hooks. * When the custom hook is used (currently this must be a singleton) the onXXX * field is set to the handler, which is marshalled through the hook. * Applications don't see this and will always use the hook interface. */ export type InternalContextRefType = { inContext: () => boolean; setMap: (map: Map) => void; setMapImplement: (v: IMapImplement) => void; setLoading: (isLoading: boolean) => void; setMapResolution: (res: number) => void; setOverlay: (overlay: Overlay) => void; setZoomed: () => void; zoomed: () => boolean; onMove?: (extent: number[][], size: number[]) => void; onClick?: (pixelCoordinate: number[], coordinateMetres: number[], mapImplement: IMapImplement) => void; clickHandlerType: ClickHandlerType; onSelect?: MapSelectHandler; onContextMenu?: (clickedFeatures: ClickedFeature[], coordinate: number[], anchorPoint: AnchorPosition) => void; onDrawStart?: () => void; onDrawEnd?: (drawFeatures: Feature) => void; onModifyStart?: (features: Feature[]) => void; onModifyEnd?: (features: Feature[]) => void; onRemoveInteraction?: () => void; onPlacement?: (placement: PlacementParams) => void; placementInProgress: () => boolean; setPlacementInProgress: (state: boolean) => void; enableAutoPlacement: () => boolean; setEnableAutoPlacement: (state: boolean) => void; showOnlyPlacedLabels: () => boolean; setShowOnlyPlacedLabels: (state: boolean) => void; autoLabelPlacementType: () => AutoLabelPlacementType | undefined; setAutoLabelPlacementType: (type: AutoLabelPlacementType | undefined) => void; ctrlKeyDown: () => boolean; setCtrlKeyDown(ctrlKeyState: boolean): void; enableClipFeatureLayers: () => Set; setEnableClipFeatureLayers: (layers: Set) => void; }; export declare enum AutoLabelPlacementType { ABSOLUTE = 0, OFFSET = 1 } export type InternalContextType = { ref: () => InternalContextRefType | undefined; }; export declare const InternalContext: import("react").Context; export type FeaturePlacements = Record; export type Placements = Record; export type StyleContext = { highlightIds?: number[]; missingLabelIds?: string[]; placements?: FeaturePlacements; }; export type LolOpenLayersMapContextType = { /** The status (visibility, etc) of each layer */ layerStatus: (layerName: string) => ILayerStatus; setLayerStatus: (layerName: string, layerStatus: ILayerStatus) => void; /** The features dispalyed on a vector layer */ featureData: (layerName: string) => IFeatureSource[] | string | GeoImage | undefined; setFeatureData: (layerName: string, features: IFeatureSource[] | string | GeoImage) => void; /** Features that are selected, can be changed using set or interactively in the map * We can specify either an array of features or of feature ids here **/ setFeatureSelect: (layerName: string, selectFeatures: (FeatureLike | number)[]) => void; featureSelect: (layerName: string) => (FeatureLike | number)[]; /** Zoom to fit features on identified layers (with `inInitialZoom` true) */ zoomToFit: () => void; /** Zoom by a delta amount */ zoomByDelta: (delta: number) => void; /** The resolution (e.g. scale) of the map */ readonly mapResolution: number; /** provide access to layers as a map */ layersStatusMap: () => Record; map: Map | undefined; readonly loading: boolean; readonly errorMessages: string[]; /** put context into here that gets passed into style functions */ getStyleContext: (layerName: string) => StyleContext | undefined; changeStyleContext: (layerNames: string | string[], f: (c: StyleContext) => StyleContext) => void; updateStyleContext: (layerNames: string, highlightIds?: number[], missingLabelIds?: string[], placements?: FeaturePlacements) => void; /** get features that are at the passed pixel click point and within `hitTolerance` pixels */ getFeaturesAtPixel?: (pixel: Pixel, hitTolerancePixels?: number) => ClickedFeature[]; /** * Gets a map of the closest feature (features if multiple equidistant features) to clicked pixel for each layer. * Result is in a map of layerName to featureIds. * * @param pixelCoordinates Pixel to search from. * @param hitTolerancePixels Maximum pixel radius to search. * @param includeLayerNames If present, only include listed layers * * @return Map of layerName to sorted featureIds. */ getFeaturesAtPixelOrderedByClosestToClick?: (pixelCoordinates: Pixel, hitTolerancePixels: number, includeLayerNames?: string[]) => ClickedFeaturesByLayer; /** * When the map has `withOverlay=true` this access a reference to the overlay */ getOverlayRef: () => MutableRefObject | undefined; /** * Set the automatic label placements * * @param placements Placement adjustments for labels */ setPlacements(placements: Placements): void; getPlacementParams: () => PlacementParams | undefined; }; export declare const LolOpenLayersMapContext: import("react").Context; interface ProviderProps { children: ReactNode; } export interface LayerState { layerHasChanged: boolean; featureSelect: (FeatureLike | number)[]; featuresChanged: boolean; features: IFeatureSource[] | string | GeoImage | undefined; status: ILayerStatus; } export interface MapState { layers: Record; } export declare const LolOpenLayersMapContextProvider: (props: ProviderProps) => ReactElement | null; export {};