forked from geostyler/geostyler-style
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.ts
982 lines (921 loc) · 27 KB
/
style.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
import {
GeoStylerBooleanFunction,
GeoStylerFunction,
GeoStylerNumberFunction,
GeoStylerStringFunction
} from './functions';
/**
* The special character to use to indicate a line break.
*/
export type newlineToken = '/n';
/**
* The ScaleDenominator defines a range of scales.
*/
export interface ScaleDenominator {
/**
* Minimum value of the ScaleDenominator. The value is inclusive.
*
*/
min?: Expression<number>;
/**
* Maximum value of the ScaleDenominator. The value is exclusive.
*/
max?: Expression<number>;
}
/**
* Expression that evaluates to the result of a function
* call on a list of argument expressions.
*/
export interface FunctionCall<T> {
name: T extends string ? GeoStylerStringFunction['name'] :
T extends number ? GeoStylerNumberFunction['name'] :
GeoStylerBooleanFunction['name'];
args: Expression<PropertyType>[];
};
/**
* Expressions can be a literal value, a property name or a function call.
*/
export type Expression<T extends PropertyType> =
T extends string ? GeoStylerStringFunction | T :
T extends number ? GeoStylerNumberFunction | T :
T extends boolean ? GeoStylerBooleanFunction | T :
T;
/**
* The type of the Style.
*/
export type StyleType = 'Point' | 'Fill' | 'Line' | 'Raster';
/**
* A datatype of a property of the data.
*/
export type PropertyType = string | number | boolean | unknown;
/**
* The possible Operators used for comparison Filters.
*/
export type ComparisonOperator = '==' | '*=' | '!=' | '<' | '<=' | '>' | '>=' | '<=x<=';
/**
* The possible Operators used for combination Filters.
*/
export type CombinationOperator = '&&' | '||';
/**
* The Operator used for negation Filters.
*/
export type NegationOperator = '!';
/**
* All operators.
*/
export type Operator = ComparisonOperator | CombinationOperator | NegationOperator;
/**
* A Filter that checks if a property is in a range of two values (inclusive).
*/
export type RangeFilter = [
'<=x<=',
Expression<string>,
Expression<number>,
Expression<number>
];
/**
* A ComparisonFilter compares two values.
* If the first argument is a GeoStylerFunction it will be evaluated it.
* If it is a string it will be treated as key of an object.
*/
export type ComparisonFilter = [
ComparisonOperator,
Expression<string | number | boolean | null>,
Expression<string | number | boolean | null>
] | RangeFilter;
/**
* A CombinationFilter combines N Filters with a logical OR / AND operator.
*/
export type CombinationFilter = [
CombinationOperator,
...Filter[]
];
/**
* A NegationFilter negates a given Filter.
*/
export type NegationFilter = [
NegationOperator,
Filter
];
export type Filter = ComparisonFilter | NegationFilter | CombinationFilter | Expression<boolean>;
/**
* The kind of the Symbolizer
*/
export type SymbolizerKind = 'Fill' | 'Icon' | 'Line' | 'Text' | 'Mark' | 'Raster';
/**
* A Symbolizer describes the style representation of geographical data.
*/
export interface BaseSymbolizer {
/**
* Describes the type of the kind of the Symbolizer.
*/
kind: SymbolizerKind;
/**
* A color defined as a hex-color string.
*/
color?: Expression<string>;
/**
* Determines the total opacity for the Symbolizer.
* A value between 0 and 1. 0 is none opaque and 1 is full opaque.
*/
opacity?: Expression<number>;
/**
* Defines whether the Symbolizer should be visibile or not.
*/
visibility?: Expression<boolean>;
}
/**
* A PointSymbolizer describes the style representation of POINT data.
*/
export interface BasePointSymbolizer extends BaseSymbolizer {
/**
* This is a property relevant if using tiled datasets.
* If true, the symbols will not cross tile edges to avoid mutual collisions.
*/
avoidEdges?: Expression<boolean>;
/**
* The offset of the Symbolizer as [x, y] coordinates. Positive values indicate
* right and down, while negative values indicate left and up.
*/
offset?: [Expression<number>, Expression<number>];
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-symbol-icon-translate-anchor
*/
offsetAnchor?: Expression<'map' | 'viewport'>;
}
/**
* Template literal to be more precise on what a font specification of a wellknownname can look like.
* font-based symbols following Geotools/Geoserver syntax: ttf://<font name>#<hex code>
*/
export type FontSpec = `ttf://${string}#0x${string}`;
/**
* Supported WellKnownNames
* Note that due to TypeScript limitations any string will be valid for this type; this will not change
* until regexp or equivalent is supported, see:
* https://github.com/microsoft/TypeScript/issues/6579
*
*/
export type WellKnownName = 'circle' | 'square' | 'triangle' | 'star' | 'cross' | 'x'
| 'shape://vertline' | 'shape://horline' | 'shape://slash'
| 'shape://backslash' | 'shape://dot' | 'shape://plus'
| 'shape://times' | 'shape://oarrow' | 'shape://carrow'
| FontSpec;
/**
* Unit that defines how to handle the corresponding symbolizer property.
* Default should be pixel in your parser.
* 'px' => pixel
* 'm' => meter
*/
export type DistanceUnit = 'px' | 'm';
/**
* MarkSymbolizer describes the style representation of POINT data, if styled as
* with a regular geometry.
*/
export interface MarkSymbolizer extends BasePointSymbolizer {
kind: 'Mark';
/**
* The WellKnownName of the MarkSymbolizer.
*/
wellKnownName: WellKnownName;
/**
* The radius of the Symbolizer. Values describing the full size of the Symbolizer
* have to be divided by two (pixels if radiusUnit is not defined).
*/
radius?: Expression<number>;
/**
* Unit to use for the radius.
*/
radiusUnit?: DistanceUnit;
/**
* The rotation of the Symbolizer in degrees. Value should be between 0 and 360.
*/
rotate?: Expression<number>;
/**
* The opacity of the fill. A value between 0 and 1.
* 0 is none opaque and 1 is full opaque.
*/
fillOpacity?: Expression<number>;
/**
* The color of the stroke represented as a hex-color string.
*/
strokeColor?: Expression<string>;
/**
* The opacity of the stroke. A value between 0 and 1.
* 0 is none opaque and 1 is full opaque.
*/
strokeOpacity?: Expression<number>;
/**
* The width of the stroke (pixels if strokeWidthUnit is not defined).
*/
strokeWidth?: Expression<number>;
/**
* Unit to use for the strokeWidth.
*/
strokeWidthUnit?: DistanceUnit;
/**
* Amount to blur the Symbolizer. 1 blurs the Symbolizer such that only the
* centerpoint has full opacity. Mostly relevant for circles.
*/
blur?: Expression<number>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-circle-circle-pitch-alignment
*/
pitchAlignment?: Expression<'map' | 'viewport'>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-circle-circle-pitch-scale
*/
pitchScale?: Expression<'map' | 'viewport'>;
}
/**
* The TextSymbolizer describes the style representation of point data, if styled
* with a text.
*/
export interface TextSymbolizer extends BasePointSymbolizer {
kind: 'Text';
/**
* If true, the text will be visible even if it collides with other previously
* drawn symbols.
*/
allowOverlap?: Expression<boolean>;
/**
* The anchor position of the label referred to the center of the geometry.
*/
anchor?: Expression<
'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
>;
/**
* Template string where {{PROPERTYNAME}} can be used to be replaced by values
* from the dataset.
* e.g.: "Name {{country_name}}"
*/
label?: Expression<string>;
/**
* An Array of fonts. Comparable to https://www.w3schools.com/cssref/pr_font_font-family.asp
*/
font?: Expression<string>[];
/**
* The halo's fadeout distance towards the outside.
*/
haloBlur?: Expression<number>;
/**
* The color of the text's halo, which helps it stand out from backgrounds
* represented as a hex-color string.
*/
haloColor?: Expression<string>;
/**
* Distance of halo to the font outline (pixels if haloWidthUnit is not defined).
*/
haloWidth?: Expression<number>;
/**
* Unit to use for the haloWidth.
*/
haloWidthUnit?: DistanceUnit;
/**
* The opacity of the halo. A value between 0 and 1.
* 0 means no opacity (i.e. transparent) and 1 is fully opaque.
*/
haloOpacity?: Expression<number>;
/**
* Text justification option to align the text.
*/
justify?: Expression<'left' | 'center' | 'right'>;
/**
* If true, the text will be kept upright.
*/
keepUpright?: Expression<boolean>;
/**
* Sets the spacing between text characters (pixels if letterSpacingUnit is not defined).
*/
letterSpacing?: Expression<number>;
/**
* Unit to use for the letterSpacing.
*/
letterSpacingUnit?: DistanceUnit | 'em';
/**
* Sets the line height (pixels if lineHeightUnit is not defined).
* 'em' -> fontsize
*/
lineHeight?: Expression<number>;
/**
* Unit to use for the lineHeight.
* 'em' -> fontsize
*/
lineHeightUnit?: DistanceUnit | 'em';
/**
* Maximum angle change between adjacent characters in degrees.
*/
maxAngle?: Expression<number>;
/**
* The maximum line width for text wrapping.
*/
maxWidth?: Expression<number>;
/**
* Property relevant for mapbox-styles.
* If true, icons will display without their corresponding text when the text
* collides with other symbols and the icon does not.
*/
optional?: Expression<boolean>;
/**
* Size of the additional area around the text bounding box used for detecting
* symbol collisions.
*/
padding?: Expression<number>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-text-pitch-alignment
*/
pitchAlignment?: Expression<'map' | 'viewport' | 'auto'>;
/**
* The rotation of the Symbolizer in degrees. Value should be between 0 and 360.
*/
rotate?: Expression<number>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-text-rotation-alignment
*/
rotationAlignment?: Expression<'map' | 'viewport' | 'auto'>;
/**
* The fontsize in pixels.
*/
size?: Expression<number>;
/**
* Specifies how to capitalize text, similar to the CSS text-transform property.
*/
transform?: Expression<'none' | 'uppercase' | 'lowercase'>;
/**
* Specifies whether a font should be styled with a normal, italic, or oblique
* face from its font-family.
*/
fontStyle?: Expression<'normal' | 'italic' | 'oblique'>;
/**
* Specifies the weight (or boldness) of the font. The weights available depend
* on the font-family you are using.
*/
fontWeight?: Expression<'normal' | 'bold'>;
/**
* Specifies label placement relative to its geometry.
*/
placement?: Expression<'point' | 'line' | 'line-center'>;
}
/**
* Configuration for a sprite image.
*/
export type Sprite = {
/**
* A path/URL to the sprite image file.
*/
source: Expression<string>;
/**
* The starting position of the sprite to cut out. Origing [0, 0] is top left in pixels.
*/
position: [Expression<number>, Expression<number>];
/**
* The size of the sprite [width, height] in pixels.
*/
size: [Expression<number>, Expression<number>];
};
/**
* An IconSymbolizer describes the style representation of POINT data if styled
* with a specific icon.
*/
export interface IconSymbolizer extends BasePointSymbolizer {
kind: 'Icon';
/**
* If true, the icon will be visible even if it collides with other previously
* drawn symbols.
*/
allowOverlap?: Expression<boolean>;
/**
* Part of the icon placed closest to the anchor. This may conflict with a set
* offset.
*/
anchor?: Expression<
'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
>;
/**
* The halo's fadeout distance towards the outside.
*/
haloBlur?: Expression<number>;
/**
* The color of the icons halo, which helps it stand out from backgrounds represented
* as a hex-color string.
*/
haloColor?: Expression<string>;
/**
* Distance of halo to the icons outline (pixels if haloWidthUnit is not defined).
*/
haloWidth?: Expression<number>;
/**
* Unit to use for the haloWidth.
*/
haloWidthUnit?: DistanceUnit;
/**
* The opacity of the halo. A value between 0 and 1.
* 0 means no opacity (i.e. transparent) and 1 is fully opaque.
*/
haloOpacity?: Expression<number>;
/**
* A path/URL to the icon image file or a {@link Sprite} configuration.
*/
image?: Expression<string> | Sprite;
/**
* An optional configuration for the image format as MIME type.
* This might be needed if the image(path) has no filending specified. e.g. http://myserver/getImage
*/
format?: Expression<`image/${'png' | 'jpg' | 'jpeg' | 'gif' | 'svg+xml'}`>;
/**
* If true, the icon will be kept upright.
*/
keepUpright?: Expression<boolean>;
/**
* Property relevant for mapbox-styles.
* If true, text will display without their corresponding icons when the icon
* collides with other symbols and the text does not.
*/
optional?: Expression<boolean>;
/**
* Size of the additional area around the icon used for detecting symbol collisions.
*/
padding?: Expression<number>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-pitch-alignment
*/
pitchAlignment?: Expression<'map' | 'viewport' | 'auto'>;
/**
* The rotation of the Symbolizer in degrees. Value should be between 0 and 360.
*/
rotate?: Expression<number>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-rotation-alignment
*/
rotationAlignment?: Expression<'map' | 'viewport' | 'auto'>;
/**
* The Symbolizer size (pixels if sizeUnit is not defined).
*/
size?: Expression<number>;
/**
* Unit to use for the size.
*/
sizeUnit?: DistanceUnit;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-text-fit
*/
textFit?: Expression<'none' | 'width' | 'height' | 'both'>;
/**
* Property relevant for mapbox-styles.
* Compare https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-text-fit-padding
*/
textFitPadding?: [Expression<number>, Expression<number>, Expression<number>, Expression<number>];
}
/**
* A FillSymbolizer describes the style representation of POLYGON data.
*/
export interface FillSymbolizer extends BaseSymbolizer {
kind: 'Fill';
/**
* Whether the fill should be antialiased or not .
*/
antialias?: Expression<boolean>;
/**
* The opacity of the fill. A value between 0 and 1.
* 0 is none opaque and 1 is full opaque.
*/
fillOpacity?: Expression<number>;
/**
* The outline color as a hex-color string. Matches the value of fill-color if
* unspecified.
*/
outlineColor?: Expression<string>;
/**
* The opacity of the outline. A value between 0 and 1.
* 0 is none opaque and 1 is full opaque.
*/
outlineOpacity?: Expression<number>;
/**
* The outline width (pixels if outlineWidthUnit is not defined).
*/
outlineWidth?: Expression<number>;
/**
* The Captype for the outLine.
*/
outlineCap?: Expression<CapType>;
/**
* The JoinType for the outLine.
*/
outlineJoin?: Expression<JoinType>;
/**
* Unit to use for the outlineWidth.
*/
outlineWidthUnit?: DistanceUnit;
/**
* Encodes a dash pattern as an array of numbers. Odd-indexed numbers (first,
* third, etc) determine the length in pixels to draw the line, and even-indexed
* numbers (second, fourth, etc) determine the length in pixels to blank out
* the line. Default is an unbroken line.
*/
outlineDasharray?: Expression<number>[];
/**
* Renders the fill of the polygon with a repeated pattern of PointSymbolizer.
*/
graphicFill?: PointSymbolizer;
/**
* Size of the additional area around the repeated graphic fill symbolizer.
*/
graphicFillPadding?: [Expression<number>, Expression<number>, Expression<number>, Expression<number>];
}
/**
* The Types that are allowed in a graphic
*/
export type GraphicType = 'Mark' | 'Icon';
/**
* Determines how lines are rendered at their ends.
* Possible values are butt (sharp square edge), round (rounded edge),
* and square (slightly elongated square edge).
*/
export type CapType = 'butt' | 'round' | 'square';
/**
* Determines how lines are rendered at intersections of line segments.
* Possible values are mitre (sharp corner), round (rounded corner), and bevel
* diagonal corner).
*/
export type JoinType = 'bevel' | 'round' | 'miter';
/**
* A LineSymbolizer describes the style representation of LINESTRING data.
*/
export interface LineSymbolizer extends BaseSymbolizer {
kind: 'Line';
blur?: Expression<number>;
/**
* The Captype for the LineSymbolizer.
*/
cap?: Expression<CapType>;
/**
* Encodes a dash pattern as an array of numbers. Odd-indexed numbers (first,
* third, etc) determine the length in pixels to draw the line, and even-indexed
* numbers (second, fourth, etc) determine the length in pixels to blank out
* the line. Default is an unbroken line.
*/
dasharray?: Expression<number>[];
/**
* Number of pixels into the dasharray to offset the drawing of the dash,
* used to shift the location of the lines and gaps in a dash.
*/
dashOffset?: Expression<number>;
/**
* Draws a line casing outside of a line's actual path. Value indicates the
* width of the inner gap (pixels if gapWidthUnit is not defined).
*/
gapWidth?: Expression<number>;
/**
* Unit to use for the gapWidth.
*/
gapWidthUnit?: DistanceUnit;
/**
* Defines a gradient with which to color a line feature.
*/
gradient?: any[];
/**
* Renders the line with a repeated linear PointSymbolizer.
*/
graphicStroke?: PointSymbolizer;
/**
* Renders the pixels of the line with a repeated pattern.
*/
graphicFill?: PointSymbolizer;
/**
* Size of the additional area around the repeated graphic fill symbolizer.
*/
graphicFillPadding?: [Expression<number>, Expression<number>];
/**
* The JoinType for the LineSymbolizer.
*/
join?: Expression<JoinType>;
/**
* Used to automatically convert miter joins to bevel joins for sharp angles.
*/
miterLimit?: Expression<number>;
/**
* If present, it makes the renderer draw a line parallel to the original one,
* at the given distance. When applied on lines, positive values generate a
* parallel line on the left hand side, negative values on the right hand side.
*/
perpendicularOffset?: Expression<number>;
/**
* Used to automatically convert round joins to miter joins for shallow angles.
*/
roundLimit?: Expression<number>;
/**
* Distance between two symbol anchors (pixels if spacingUnit is not defined).
*/
spacing?: Expression<number>;
/**
* Unit to use for the spacing.
* 'em' -> fontsize
*/
spacingUnit?: DistanceUnit | 'em';
/**
* The width of the Line (pixels if widthUnit is not defined).
*/
width?: Expression<number>;
/**
* Unit to use for the width.
*/
widthUnit?: DistanceUnit;
}
/**
* Operators used for Point symbolization.
*/
export type PointSymbolizer = IconSymbolizer | MarkSymbolizer | TextSymbolizer;
/**
* A single entry for the ColorMap.
*/
export interface ColorMapEntry {
color: Expression<string>;
quantity?: Expression<number>;
label?: Expression<string>;
opacity?: Expression<number>;
}
/**
* The Types that are allowed in a ColorMap.
*/
export type ColorMapType = 'ramp' | 'intervals' | 'values';
/**
* A ColorMap defines the color values for the pixels of a raster image.
*/
export interface ColorMap {
type: Expression<ColorMapType>;
colorMapEntries?: ColorMapEntry[];
extended?: Expression<boolean>;
}
/**
* A ContrastEnhancement defines how the contrast of image data should be enhanced.
*/
export interface ContrastEnhancement {
enhancementType?: Expression<'normalize' | 'histogram'>;
gammaValue?: Expression<number>;
}
/**
* A Channel defines the properties for a color channel.
*/
export interface Channel {
sourceChannelName?: Expression<string>;
contrastEnhancement?: ContrastEnhancement;
}
/**
* A RGBChannel defines how dataset bands are mapped to image color channels.
*/
export interface RGBChannel {
redChannel: Channel;
blueChannel: Channel;
greenChannel: Channel;
}
/**
* A GrayChannel defines how a single dataset band is mapped to a grayscale channel.
*/
export interface GrayChannel {
grayChannel: Channel;
}
export type ChannelSelection = RGBChannel | GrayChannel;
/**
* A RasterSymbolizer defines the style representation of RASTER data.
*/
export interface RasterSymbolizer {
kind: 'Raster';
/**
* Defines whether the Symbolizer should be visible or not.
*/
visibility?: Expression<boolean>;
/**
* Determines the total opacity for the Symbolizer.
* A value between 0 and 1. 0 is none opaque and 1 is fully opaque.
*/
opacity?: Expression<number>;
/**
* Defines the color values for the pixels of a raster image,
* as either color gradients, or a mapping of specific values to fixed colors.
*/
colorMap?: ColorMap;
/**
* Specifies how dataset bands are mapped to image color channels.
*/
channelSelection?: ChannelSelection;
/**
* Can be used to adjust the relative brightness of the image data.
*/
contrastEnhancement?: ContrastEnhancement;
hueRotate?: Expression<number>;
brightnessMin?: Expression<number>;
brightnessMax?: Expression<number>;
saturation?: Expression<number>;
contrast?: Expression<number>;
resampling?: Expression<'linear' | 'nearest'>;
fadeDuration?: Expression<number>;
}
/**
* All operators.
*/
export type Symbolizer = PointSymbolizer | LineSymbolizer | FillSymbolizer | RasterSymbolizer | TextSymbolizer;
/**
* A Rule combines a specific amount of data (defined by a Filter and a
* ScaleDenominator) and an associated Symbolizer.
*/
export interface Rule {
name: string;
filter?: Filter;
scaleDenominator?: ScaleDenominator;
symbolizers: Symbolizer[];
}
/**
* The Style is the main interface and the root for all other interfaces.
*/
export interface Style {
name: string;
rules: Rule[];
metadata?: {
[key: string]: any;
};
}
/**
* Interface for defining unsupported properties in the parsers.
*/
export interface UnsupportedProperties {
ScaleDenominator?: SupportDef;
Filter?: SupportDef | {
'&&'?: SupportDef;
'!'?: SupportDef;
'||'?: SupportDef;
'>'?: SupportDef;
'>='?: SupportDef;
'=='?: SupportDef;
'<'?: SupportDef;
'<='?: SupportDef;
'!='?: SupportDef;
'*='?: SupportDef;
};
Symbolizer?: SupportDef | {
LineSymbolizer?: SupportDef | {
[key in keyof Required<LineSymbolizer>]?: SupportDef
};
FillSymbolizer?: SupportDef | {
[key in keyof Required<FillSymbolizer>]?: SupportDef
};
MarkSymbolizer?: SupportDef | {
[key in keyof Required<MarkSymbolizer>]?: SupportDef
};
IconSymbolizer?: SupportDef | {
[key in keyof Required<IconSymbolizer>]?: SupportDef
};
TextSymbolizer?: SupportDef | {
[key in keyof Required<TextSymbolizer>]?: SupportDef
};
RasterSymbolizer?: SupportDef | {
[key in keyof Required<RasterSymbolizer>]?: SupportDef
};
};
Function?: SupportDef | {
[key in GeoStylerFunction['name']]?: SupportDef;
};
}
/**
* Level of support for a functionality.
*/
export type SupportLevel = 'partial' | 'none';
/**
* Detailed information about the support of a functionality.
* Can contain an info text.
*/
export type SupportInfo = {
support: SupportLevel;
info?: string;
};
/**
* Defines in which way a functionality is supported.
*/
export type SupportDef = SupportInfo | SupportLevel;
/**
* The Result of the readStyle function of a StyleParser.
*/
export type ReadStyleResult = {
/**
* A list of warnings occured while reading the stlye.
*/
warnings?: string[];
/**
* A list of unsupportedProperties used while reading the style.
*/
unsupportedProperties?: UnsupportedProperties;
/**
* The geostyler-style as read by the parser.
*/
output?: Style;
/**
* A list of errors occured while reading the style.
*/
errors?: Error[];
};
/**
* The Result of the writeStyle function of a StyleParser.
*/
export type WriteStyleResult<T = any> = {
/**
* A list of warnings occured while writing the style.
*/
warnings?: string[];
/**
* A list of unsupportedProperties used while writing the style.
*/
unsupportedProperties?: UnsupportedProperties;
/**
* The target-style as written by the parser.
*/
output?: T;
/**
* A list of errors occured while writing the style.
*/
errors?: Error[];
};
/**
* Interface, which has to be implemented by all GeoStyler style parser classes.
*/
export interface StyleParser<T = any> {
/**
* The name of the Parser
*/
title: string;
/**
* Object specifying which properties are not or just partially supported.
*/
unsupportedProperties?: UnsupportedProperties;
/**
* Parses the inputStyle and transforms it to the GeoStyler Style
*
* @param inputStyle
*/
readStyle(inputStyle: T): Promise<ReadStyleResult>;
/**
* Reads the GeoStyler Style and transforms it to the target Style
* representation.
*
* @param geoStylerStyle Style
*/
writeStyle(geoStylerStyle: Style): Promise<WriteStyleResult<T>>;
/**
* Parses an input Rule and transforms it to a GeoStyler Rule
*
* @param inputRule
*/
readRule?(inputRule: any): Promise<Rule>;
/**
* Reads a GeoStyler Rule and transforms it to a target Rule
* representation.
*
* @param geoStylerRule Rule
*/
writeRule?(geoStylerRule: Rule): Promise<any>;
/**
* Parses an input Filter and transforms it to a GeoStyler Filter
*
* @param inputFilter
*/
readFilter?(inputFilter: any): Promise<Filter>;
/**
* Reads a GeoStyler Filter and transforms it to a target Filter
* representation.
*
* @param geoStylerFilter Filter
*/
writeFilter?(geoStylerFilter: Filter): Promise<any>;
/**
* Parses an input ScaleDenominator and transforms it to a GeoStyler
* ScaleDenominator
*
* @param inputScaleDenominator
*/
readScaleDenominator?(inputScaleDenominator: any): Promise<ScaleDenominator>;
/**
* Reads a GeoStyler ScaleDenominator and transforms it to a target
* ScaleDenominator representation
*
* @param geoStylerScaleDenominator ScaleDenominator
*/
writeScaleDenominator?(geoStylerScaleDenominator: ScaleDenominator): Promise<any>;
/**
* Parses an input Symbolizer and transforms it to a GeoStyler Symbolizer
*
* @param inputSymbolizer
*/
readSymbolizer?(inputSymbolizer: any): Promise<Symbolizer>;
/**
* Reads a GeoStyler Symbolizer and transforms it to a target Symbolizer
* representation
*
* @param geoStylerSymbolizer Symbolizer
*/
writeSymbolizer?(geoStylerSymbolizer: Symbolizer): Promise<any>;
}