import { PointSymbolizer, Rule, Style, StyleParser, Symbolizer, FillSymbolizer, LineSymbolizer, IconSymbolizer, TextSymbolizer, Filter, SymbolizerKind, MarkSymbolizer, ScaleDenominator, UnsupportedProperties, ReadStyleResult, GeoStylerBooleanFunction, GeoStylerStringFunction, WriteStyleResult, Sprite } from 'geostyler-style'; import { AnyLayer, AnyLayout, AnyPaint, CircleLayout, CirclePaint, CustomLayerInterface, FillLayer, FillLayout, FillPaint, LineLayer, LineLayout, LinePaint, SymbolLayout, SymbolPaint, Style as MapboxStyle, Sources, Expression } from 'mapbox-gl'; /** * The style representation of mapbox-gl but with optional sources, as these are * not required for reading the style and get stripped when writing. */ export type MbStyle = MapboxStyle; type NoneCustomLayer = Exclude; /** * Generated ids contain information about the position of a layer inside the * geostyler-style: * r* -> rule index * sy* -> symbolizer index * st* -> mapboxlayer index */ type LayerId = AnyLayer['id']; export type GeoStylerRef = { rules: { name?: string; symbolizers?: LayerId[][]; }[]; }; export type MapboxRef = { splitSymbolizers?: { rule: number; symbolizers: number[]; }[]; sources: Sources; sourceMapping?: { [source: keyof Sources]: number[]; }; sourceLayerMapping?: { [key: string]: number[]; }; sprite?: { [key: string]: { 'icon-size'?: number; position: [number, number]; size: [number, number]; }; }; }; type MapboxSpriteInfo = { x: number; y: number; width: number; height: number; }; type SymbolType = { textSymbolizer?: TextSymbolizer; iconSymbolizer?: IconSymbolizer; }; type OptionsType = { ignoreConversionErrors?: boolean; /** Replace repeated shapes (such as dotted areas and lines) with a transparent color. * This is a fallback since Mapbox doesn't allow repeated shapes unless they're * in the spritesheet. */ replaceGraphicFillWithColor?: boolean; pretty?: boolean; }; export declare class MapboxStyleParser implements StyleParser> { static title: string; private static readonly fillSymbolizerStrokeProperties; title: string; /** * Object of unsupported properties. */ unsupportedProperties: { Symbolizer: { FillSymbolizer: { fillOpacity: { support: "none"; info: string; }; outlineWidthUnit: "none"; graphicFill: { support: "partial"; info: string; }; }; LineSymbolizer: { dashOffset: "none"; graphicStroke: "none"; gapWidthUnit: "none"; spacing: "none"; spacingUnit: "none"; widthUnit: "none"; graphicFill: { support: "partial"; info: string; }; }; MarkSymbolizer: { support: "partial"; wellKnownName: { support: "partial"; info: string; }; opacity: { support: "none"; info: string; }; }; IconSymbolizer: { haloOpacity: "none"; haloWidthUnit: "none"; sizeUnit: "none"; image: { support: "partial"; info: string; }; }; RasterSymbolizer: "none"; TextSymbolizer: { fontStyle: "none"; fontWeight: "none"; haloOpacity: "none"; haloWidthUnit: "none"; letterSpacingUnit: "none"; lineHeightUnit: "none"; }; }; Function: { numberFormat: "none"; strAbbreviate: "none"; strCapitalize: "none"; strDefaultIfBlank: "none"; strEndsWith: "none"; strEqualsIgnoreCase: "none"; strIndexOf: "none"; strLastIndexOf: "none"; strMatches: "none"; strReplace: "none"; strStartsWith: "none"; strStripAccents: "none"; strSubstringStart: "none"; strSubstring: { support: "partial"; info: string; }; strTrim: "none"; exp: { support: "partial"; info: string; }; atan2: "none"; random: "none"; rint: "none"; toDegrees: "none"; toRadians: "none"; double2bool: "none"; }; }; ignoreConversionErrors: boolean; replaceGraphicFillWithColor: boolean; pretty: boolean; private mbMetadata; private gsMetadata; private spriteBaseUrl; private spriteCache; constructor(options?: OptionsType); isSymbolType(s: Symbolizer | SymbolType): s is SymbolType; /** * Parses the GeoStylerStyle-SymbolizerKind from a Mapbox Style Layer * * @param type A Mapbox Style Layer * @return A GeoStylerStyle SymbolizerKind 'Symbol' or 'Circle' */ getSymbolizerKindFromMapboxLayerType(type: AnyLayer['type']): SymbolizerKind | 'Symbol' | 'Circle'; /** * Creates a GeoStylerStyle-TextSymbolizer label from a Mapbox Layer Paint Symbol text-field * * @param label A Mapbox Layer Paint Symbol text-field * @return A GeoStylerStyle-TextSymbolizer label */ getLabelFromTextField(label: string | Expression): (string | GeoStylerStringFunction | undefined); getSpriteData(spriteName: string): Promise; /** * Transforms the mapbox sprite into a GeoStyler sprite * * @param spriteName Name of the sprite * @return the url that returns the single image */ getIconImage(spriteName: string): Promise; /** * Creates a GeoStylerStyle-MarkSymbolizer with wellKnownName 'circle' * from a Mapbox Style Layer. This one will be handled explicitly * because mapbox has a dedicated layer type for circles. Other shapes are covered * in layer type 'symbol' using fonts. * * @param paint A Mapbox paint * @param layout A Mapbox layout * @return A GeoStylerStyle-MarkSymbolizer */ getMarkSymbolizerFromMapboxCircleLayer(paint: CirclePaint, layout: CircleLayout): MarkSymbolizer | undefined; /** * Creates a GeoStylerStyle-IconSymbolizer from a Mapbox Style Layer * * @param paint A Mapbox paint * @param layout A Mapbox layout * @return A GeoStylerStyle-IconSymbolizer */ getIconSymbolizerFromMapboxSymbolLayer(paint: SymbolPaint, layout: SymbolLayout): Promise; /** * Creates a GeoStylerStyle-TextSymbolizer from a Mapbox Style Layer * * @param paint A Mapbox paint * @param layout A Mapbox layout * @return A GeoStylerStyle-TextSymbolizer */ getTextSymbolizerFromMapboxLayer(paint: SymbolPaint, layout: SymbolLayout): TextSymbolizer | undefined; /** * Creates a GeoStylerStyle-FillSymbolizer from a Mapbox Style Layer. * * @param paint A Mapbox paint * @param layout A Mapbox layout * @return A GeoStylerStyle-FillSymbolizer */ getFillSymbolizerFromMapboxFillLayer(paint: FillPaint, layout: FillLayout): Promise; getPatternOrGradientFromMapboxLayer(icon: any): Promise; /** * Creates a GeoStylerStyle-LineSymbolizer from a Mapbox Style Layer * * @param paint A Mapbox paint * @param layout A Mapbox layout * @return A GeoStylerStyle-LineSymbolizer */ getLineSymbolizerFromMapboxLineLayer(paint: LinePaint, layout: LineLayout): Promise; /** * Creates GeoStyler-Style TextSymbolizer and IconSymbolizer from a mapbox layer paint object. * * @param paint A Mapbox paint * @param layout A Mapbox layout */ getIconTextSymbolizersFromMapboxSymbolLayer(paint: SymbolPaint, layout: SymbolLayout): Promise; /** * Creates a GeoStylerStyle-Symbolizer from a Mapbox Style Layer * * @param paint A Mapbox paint * @param layout A Mapbox layout * @param type A Mapbox LayerType * @return A GeoStylerStyle-Symbolizer */ getSymbolizersFromMapboxLayer({ paint, layout, type }: { paint?: AnyPaint; layout?: AnyLayout; type: AnyLayer['type']; }): Promise; /** * Creates a GeoStylerStyle-Filter from a Mapbox Style Layer Filter * * @param filter A Mapbox Style Layer Filter * @return A GeoStylerStyle-Filter */ getFilterFromMapboxFilter(filter?: any[]): Filter | undefined; /** * Creates a GeoStylerStyle-ScaleDenominator from a Mapvox Style Layer Min/Max Zoom * * @param minZoom A Mapbox Style Layer minZoom property * @param maxZoom A Mapbox Style Layer maxZoom property * @return A GeoStylerStyle-ScaleDenominator */ getScaleDenominatorFromMapboxZoom(minZoom?: number, maxZoom?: number): ScaleDenominator | undefined; /** * This merges all the passed symbolizers into one if possbile. * * @param symbolizers The array of geostyler-style Symbolizers * @returns */ mergeSymbolizers(symbolizers: Symbolizer[]): Symbolizer; /** * Creates a GeoStyler-Style Rule from a mapbox layer. * * @param layer The mapbox Layer * @param mbRef The mapbox ref object * @return A GeoStyler-Style Rule Array and the updated mapboxRef */ mapboxLayersToGeoStylerRules(layers: NoneCustomLayer[]): Promise<{ rules: Rule[]; }>; /** * Creates a GeoStylerStyle-Style from a Mapbox Style * * @param mapboxStyle The Mapbox Style object * @return A GeoStylerStyle-Style */ mapboxStyleToGeoStylerStyle(mapboxStyle: MbStyle): Promise