import { LayerType, LolOpenLayersLayerDef, } from "../../layerDefinition/LolOpenLayersLayerDef"; import { IFeatureSource, SourceType, } from "../../sourceDefinition/LolOpenLayersSourceDef"; import { LolOpenLayersXYZSourceDef } from "../../sourceDefinition/LolOpenLayersXYZSourceDef"; import { FeatureLike } from "ol/Feature"; import { Fill, Style } from "ol/style"; import CircleStyle from "ol/style/Circle"; import Stroke from "ol/style/Stroke"; import Text from "ol/style/Text"; import { LolOpenLayersMVTSourceDef } from "../../sourceDefinition/LolOpenLayersMVTSourceDef"; import { LolOpenLayersVectorTileLayerDef } from "../../layerDefinition/LolOpenLayersVectorTileLayerDef"; import { ReactNode } from "react"; import { LolOpenLayersMap } from "../../map/LolOpenLayersMap"; import { LolOpenLayersTileLayerDef } from "../../layerDefinition/LolOpenLayersTileLayerDef"; import { LolOpenLayersMapLibreSourceDef } from "../../sourceDefinition/LolOpenLayersMapLibreSourceDef"; import { LolOpenLayersWMTSSourceDef } from "../../sourceDefinition/LolOpenLayersWMTSSourceDef"; import { Feature } from "ol"; import { Geometry } from "ol/geom"; import { LolOpenLayersFeatureSourceDef } from "../../sourceDefinition/LolOpenLayersFeatureSourceDef"; import { LolOpenLayersVectorLayerDef } from "../../layerDefinition/LolOpenLayersVectorLayerDef"; import log from "../../utils/Log"; import { QueryKey } from "@tanstack/react-query"; export const UNDERLYING_PARCELS_LAYER = "viw_parcel_all"; export const UNDERLYING_MARKS_LAYER = "underlying_marks"; export const UNDERLYING_PARCELS_SOURCE_URL = "/geotiles/viw_parcel_all/{z}/{x}/{-y}.pbf"; export const UNDERLYING_MARKS_SOURCE_URL = "/geotiles/underlying_marks/{z}/{x}/{-y}.pbf"; export const IMAGE_LAYER = "test_image"; export const IMAGE_LAYER_2 = "test_image_2"; export const basinReserveView = { projection: "EPSG:3857", center: [19457143.791, -5057154.019], zoom: 18, maxZoom: 21, }; // NOTE: mock (downloaded) tiles at `src/stories/assets/geotiles` are // centred in Oamaru, not Wellington export const oamaruView = { projection: "EPSG:3857", center: [19034650.0, -5632180.0], minZoom: 18, zoom: 20, maxZoom: 21, }; export const basemap = () => ({ type: LayerType.TILE, name: "basemap", visible: true, source: { type: SourceType.XYZ, url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}", maxZoom: 19, attributions: "Tiles: Esri; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, LINZ, StatsNZ and the GIS User Community", projection: "EPSG:3857", } as LolOpenLayersXYZSourceDef, }); export const tunnelLineFeature = { id: 1, shape: { geometry: { type: "LineString", coordinates: [ [14.786663981000004, -41.3024962918], [14.781817665999995, -41.3006873858], ], }, }, }; // Uses conventional NZGD2000 export const tunnelLineFeatureEpsg4326 = { id: 1, shape: { geometry: { type: "LineString", coordinates: [ [174.786663981000004, -41.3024962918], [174.781817665999995, -41.3006873858], ], }, }, }; export const fourLineFeatures = [ { id: 1, label: "Line 1", shape: { geometry: { type: "LineString", coordinates: [ [14.786663981000004, -41.3024962918], [14.781817665999995, -41.3006873858], ], }, }, }, { id: 2, label: "Line 2", shape: { geometry: { type: "LineString", coordinates: [ [14.781817665999995, -41.3006873858], [14.781, -41.303], ], }, }, }, { id: 3, label: "Line 3", shape: { geometry: { type: "LineString", coordinates: [ [14.781, -41.303], [14.786, -41.304], ], }, }, }, { id: 4, label: "Line 4", shape: { geometry: { type: "LineString", coordinates: [ [14.786, -41.304], [14.786663981000004, -41.3024962918], ], }, }, }, ]; export const fourLineFeaturesEPSG4326 = [ { id: 1, label: "Line 1", shape: { geometry: { type: "LineString", coordinates: [ [174.786663981000004, -41.3024962918], [174.781817665999995, -41.3006873858], ], }, }, }, { id: 2, label: "Line 2", shape: { geometry: { type: "LineString", coordinates: [ [174.781817665999995, -41.3006873858], [174.781, -41.303], ], }, }, }, { id: 3, label: "Line 3", shape: { geometry: { type: "LineString", coordinates: [ [174.781, -41.303], [174.786, -41.304], ], }, }, }, { id: 4, label: "Line 4", shape: { geometry: { type: "LineString", coordinates: [ [174.786, -41.304], [174.786663981000004, -41.3024962918], ], }, }, }, ]; export const labelledMarksLayer = { type: LayerType.VECTOR_TILE, name: "underlying_marks", minZoom: 18, maxZoom: 21, zIndex: 500, declutter: true, declutterLabels: true, style: (feature: FeatureLike) => { const textName = feature.get("name"); return new Style({ image: new CircleStyle({ radius: 2, fill: new Fill({ color: "#ff0000" }), stroke: new Stroke({ color: "#ff0000", width: 2, }), }), text: new Text({ text: textName, }), }); }, source: { type: SourceType.MVT, url: UNDERLYING_MARKS_SOURCE_URL, } as LolOpenLayersMVTSourceDef, visible: true, } as LolOpenLayersVectorTileLayerDef; export const vectorFeatureSource = [ tunnelLineFeature, { id: 2, shape: { geometry: { type: "LineString", coordinates: [ [14.781817665999995, -41.3006873858], [14.786664, -41.301], ], }, }, }, { id: 3, shape: { geometry: { type: "LineString", coordinates: [ [14.786664, -41.302395], [14.786663981000004, -41.301], ], }, }, }, ]; export const vectorHighlightStyleTestLine = { type: LayerType.VECTOR, name: "test_line", minResolution: 0, maxResolution: 10, zIndex: 500, togglable: true, selectableLabel: true, // we can click on labels to select style: (f: Feature) => { log.debug(`style ${JSON.stringify(f)}`); return new Style({ stroke: new Stroke({ color: "#11FF44", width: 2, }), }); }, labelStyle: (f: Feature) => new Style({ text: new Text({ text: `Label${f.get("id")}`, font: 'bold 14px "Open Sans"', stroke: new Stroke({ color: "#1122AA" }), }), }), highlightStyle: ( style: Style, _feature: Feature, _resolution: number ) => { const hStyle = style; // style(feature, resolution) as Style; hStyle.getStroke().setColor("#114411"); return hStyle; }, source: { type: SourceType.FEATURES, data: vectorFeatureSource, maxZoom: 28, } as LolOpenLayersFeatureSourceDef, visible: true, } as LolOpenLayersVectorLayerDef; /** For draw interaction layer **/ export const drawInteractionTestLayer = { type: LayerType.VECTOR, name: "draw_test", minResolution: 0, maxResolution: 10, zIndex: 500, togglable: true, style: (f: Feature) => { log.debug(`style ${JSON.stringify(f)}`); return new Style({ stroke: new Stroke({ color: "rgba(252,18,248,0.76)", width: 2, }), }); }, highlightStyle: ( style: Style, _feature: Feature, _resolution: number ) => { const hStyle = style; // style(feature, resolution) as Style; hStyle.getStroke().setColor("#114411"); return hStyle; }, source: { type: SourceType.FEATURES, data: [], maxZoom: 28, } as LolOpenLayersFeatureSourceDef, visible: true, } as LolOpenLayersVectorLayerDef; // NOTE: this is a public repo so we'd rather not put a valid key in here interface KeyEntryProps { apiKey: string | null; setApiKey: (key: string) => void; } export const ApiKeyEntry = (props: KeyEntryProps) => { return (
Paste API key (from{" "} https://basemaps.linz.govt.nz/ ) { props.setApiKey(event.target.value); }} />
); }; export interface MapWithLinzProps { apiKey: string; layers?: LolOpenLayersLayerDef[]; children?: ReactNode; excludeLayers?: string[]; } export const MapWithLinzBasemapLayer = (props: MapWithLinzProps) => ( {props.children} ); export const underlyingParcelsLayer = { type: LayerType.VECTOR_TILE, name: UNDERLYING_PARCELS_LAYER, style: new Style({ fill: new Fill({ color: "rgba(0,0,0,0)", }), stroke: new Stroke({ color: "#AA5555", width: 1, }), }), minZoom: 18, maxZoom: 21, source: { type: SourceType.MVT, url: UNDERLYING_PARCELS_SOURCE_URL, minZoom: 18, maxZoom: 21, } as LolOpenLayersMVTSourceDef, visible: true, } as LolOpenLayersVectorTileLayerDef; export const MapWithLinzAerialLayer = (props: MapWithLinzProps) => { return ( {props.children} ); }; export const testLineVectorQueryLayer = { type: LayerType.VECTOR, name: "test_line", minResolution: 0, maxResolution: 10, zIndex: 500, style: (_f: Feature) => { return new Style({ stroke: new Stroke({ color: "#CC4444", width: 2, }), }); }, source: { type: SourceType.FEATURES, queryFun: async (): Promise => { await new Promise((r) => setTimeout(r, 10000)); return [tunnelLineFeature] as IFeatureSource[]; }, queryKey: ["feature_line"] as QueryKey, maxZoom: 28, } as LolOpenLayersFeatureSourceDef, visible: true, inInitialZoom: true, } as LolOpenLayersVectorLayerDef; export const epsg4326PointData = [ { id: 1, label: "Mark1", shape: { geometry: { type: "Point", coordinates: [170.99, -45.0], }, }, }, { id: 2, label: "Mark2", shape: { geometry: { type: "Point", coordinates: [170.991, -45.1], }, }, }, ];