-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
functions.ts
812 lines (737 loc) · 17.2 KB
/
functions.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
/* eslint-disable @typescript-eslint/naming-convention */
import {
FunctionCall,
Expression,
PropertyType
} from './style';
export type GeoStylerFunction = GeoStylerNumberFunction |
GeoStylerStringFunction |
GeoStylerBooleanFunction |
GeoStylerUnknownFunction;
/**
* An expression of a function that returns a number.
*/
export type GeoStylerNumberFunction = GeoStylerUnknownFunction |
Fabs |
Facos |
Fadd |
Fasin |
Fatan |
Fatan2 |
Fceil |
Fcos |
Fdiv |
Fexp |
Ffloor |
Finterpolate |
Flog |
Fmax |
Fmin |
Fmodulo |
Fmul |
Fpi |
Fpow |
Frandom |
Frint |
Fround |
Fsin |
Fsqrt |
FstrIndexOf |
FstrLastIndexOf |
FstrLength |
Fsub |
Ftan |
FtoDegrees |
FtoNumber |
FtoRadians;
/**
* An expression of a function that returns a string.
*/
export type GeoStylerStringFunction = GeoStylerUnknownFunction |
FnumberFormat |
FstrAbbreviate |
FstrCapitalize |
FstrConcat |
FstrDefaultIfBlank |
FstrReplace |
FstrStripAccents |
FstrSubstring |
FstrSubstringStart |
FstrToLowerCase |
FstrToUpperCase |
FstrTrim |
FtoString;
/**
* An expression of a function that returns a boolean.
*/
export type GeoStylerBooleanFunction = GeoStylerUnknownFunction |
Fall |
Fany |
Fbetween |
Fdouble2bool |
FequalTo |
FgreaterThan |
FgreaterThanOrEqualTo |
Fin |
FlessThan |
FlessThanOrEqualTo |
Fnot |
FnotEqualTo |
FparseBoolean |
FstrEndsWith |
FstrEqualsIgnoreCase |
FstrMatches |
FstrStartsWith;
export type GeoStylerUnknownFunction = Fcase | Fstep | Fproperty;
/**
* The absolute value of the specified number value
*/
export interface Fabs extends FunctionCall<number> {
name: 'abs';
args: [
Expression<number>
];
};
/**
* Returns the arc cosine of an angle in radians, in the range of 0.0 through PI
*/
export interface Facos extends FunctionCall<number> {
name: 'acos';
args: [
Expression<number>
];
};
/**
* Returns the sum of the arguments
*/
export interface Fadd extends FunctionCall<number> {
name: 'add';
args: Expression<number>[];
};
/**
* Resolves to true if all passed arguments resolve to true
*/
export interface Fall extends FunctionCall<boolean> {
name: 'all';
args: Expression<boolean>[];
};
/**
* Resolves to true if any of the passed arguments resolves to true
*/
export interface Fany extends FunctionCall<boolean> {
name: 'any';
args: Expression<boolean>[];
};
/**
* Returns the arc sine of an angle in radians, in the range of -PI / 2 through PI / 2
*/
export interface Fasin extends FunctionCall<number> {
name: 'asin';
args: [
Expression<number>
];
};
/**
* Returns the arc tangent of an angle in radians, in the range of -PI/2 through PI/2
*/
export interface Fatan extends FunctionCall<number> {
name: 'atan';
args: [
Expression<number>
];
};
/**
* Converts a rectangular coordinate (x, y) to polar (r, theta) and returns theta.
*/
export interface Fatan2 extends FunctionCall<number> {
name: 'atan2';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Returns true if arg1 <= arg0 <= arg2
*/
export interface Fbetween extends FunctionCall<boolean> {
name: 'between';
args: [
Expression<number>,
Expression<number>,
Expression<number>
];
};
export type FCaseParameter = {
case: Expression<boolean>;
value: Expression<PropertyType>;
};
/**
* Textual representation of a switch-case function.
* argument[0] is the default value.
* argument[1] - argument[args.length] are objects with 'case' and 'value'.
*
* The value of the first object where its 'case' Expression resolves to true
* will be used.
* If no 'case' expression resolves to true the default value will be returned.
*/
export interface Fcase extends FunctionCall<PropertyType> {
name: 'case';
args: [
Expression<PropertyType>,
...FCaseParameter[]
];
};
/**
* Returns the smallest (closest to negative infinity) number value that is greater than or equal to
* x and is equal to a mathematical integer.
*/
export interface Fceil extends FunctionCall<number> {
name: 'ceil';
args: [
Expression<number>
];
};
/**
* Returns the cosine of an angle expressed in radians
*/
export interface Fcos extends FunctionCall<number> {
name: 'cos';
args: [
Expression<number>
];
};
/**
* Returns the division of argument[0] by argument[1]
*/
export interface Fdiv extends FunctionCall<number> {
name: 'div';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Returns true if x is zero, false otherwise
*/
export interface Fdouble2bool extends FunctionCall<boolean> {
name: 'double2bool';
args: [
Expression<number>
];
};
/**
* Resolves to true if both arguments are equal
*/
export interface FequalTo extends FunctionCall<boolean> {
name: 'equalTo';
args: [
Expression<PropertyType>,
Expression<PropertyType>
];
};
/**
* Returns Euler’s number e raised to the power of x
*/
export interface Fexp extends FunctionCall<number> {
name: 'exp';
args: [
Expression<number>
];
};
/**
* Returns the largest (closest to positive infinity) value that is less than or equal to x and is
* equal to a mathematical integer
*/
export interface Ffloor extends FunctionCall<number> {
name: 'floor';
args: [
Expression<number>
];
};
/**
* Resolves to true if argument[0] is greater than argument[1]
*/
export interface FgreaterThan extends FunctionCall<boolean> {
name: 'greaterThan';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Resolves to true if argument[0] is greater than or equal to argument[1]
*/
export interface FgreaterThanOrEqualTo extends FunctionCall<boolean> {
name: 'greaterThanOrEqualTo';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Returns true if arguments[0] is equal to one of the arguments[1], …, arguments[n] values. Use the
* function name matching the number of arguments specified.
*/
export interface Fin extends FunctionCall<boolean> {
name: 'in';
args: Expression<string | number>[];
};
/**
* Resolves to true if argument[0] is less than argument[1]
*/
export interface FlessThan extends FunctionCall<boolean> {
name: 'lessThan';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Resolves to true if argument[0] is less than or equal to argument[1]
*/
export interface FlessThanOrEqualTo extends FunctionCall<boolean> {
name: 'lessThanOrEqualTo';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Inverts the boolean value of argument[0]
*/
export interface Fnot extends FunctionCall<boolean> {
name: 'not';
args: [
Expression<boolean>
];
};
/**
* Resolves to false if both arguments are equal
*/
export interface FnotEqualTo extends FunctionCall<boolean> {
name: 'notEqualTo';
args: [
Expression<PropertyType>,
Expression<PropertyType>
];
};
/**
* Returns the natural logarithm (base e) of x
*/
export interface Flog extends FunctionCall<number> {
name: 'log';
args: [
Expression<number>
];
};
/**
* Returns the maximum between argument[0], …, argument[n]
*/
export interface Fmax extends FunctionCall<number> {
name: 'max';
args: Expression<number>[];
};
/**
* Returns the minimum between argument[0], …, argument[n]
*/
export interface Fmin extends FunctionCall<number> {
name: 'min';
args: Expression<number>[];
};
/**
* Returns the remainder after integer division of argument[0] by argument[1]
*/
export interface Fmodulo extends FunctionCall<number> {
name: 'modulo';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Returns the product of the arguments
*/
export interface Fmul extends FunctionCall<number> {
name: 'mul';
args: Expression<number>[];
};
/**
* Formats the number (argument[1]) according to the specified format (arguments[0]) using the default locale
* or the one provided (argument[2]) as an optional argument. The format syntax can be found
* in the Java DecimalFormat javadocs
*/
export interface FnumberFormat extends FunctionCall<string> {
name: 'numberFormat';
args: [
Expression<string>,
Expression<number>,
Expression<string>
];
};
/**
* Parses a string into a boolean. The empty string, f, 0.0 and 0 are considered false, everything
* else is considered true.
*/
export interface FparseBoolean extends FunctionCall<boolean> {
name: 'parseBoolean';
args: [
Expression<string>
];
};
/**
* Returns an approximation of pi, the ratio of the circumference of a circle to its diameter
*/
export interface Fpi extends Omit<FunctionCall<number>, 'args'> {
name: 'pi';
};
/**
* Returns the value of base (argument[0]) raised to the power of exponent (arguments[1])
*/
export interface Fpow extends FunctionCall<number> {
name: 'pow';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Returns the value of the property argument[0]. Allows property names to be compute
* or specified by Variable substitution in SLD.
*/
export interface Fproperty extends FunctionCall<unknown> {
name: 'property';
args: [
Expression<string>
];
};
/**
* Returns a Double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
*/
export interface Frandom extends Omit<FunctionCall<number>, 'args'> {
name: 'random';
};
/**
* Returns the Double value that is closest in value to the argument and is equal to a mathematical
* integer. If two double values that are mathematical integers are equally close, the result is the
* integer value that is even.
*/
export interface Frint extends FunctionCall<number> {
name: 'rint';
args: [
Expression<number>
];
};
/**
* Returns the closest number to argument[0].
*/
export interface Fround extends FunctionCall<number> {
name: 'round';
args: [
Expression<number>
];
};
/**
* Returns the sine of an angle expressed in radians
*/
export interface Fsin extends FunctionCall<number> {
name: 'sin';
args: [
Expression<number>
];
};
/**
* Returns the square root of argument[0]
*/
export interface Fsqrt extends FunctionCall<number> {
name: 'sqrt';
args: [
Expression<number>
];
};
export type FStepParameter = {
boundary: Expression<number>;
value: Expression<PropertyType>;
};
/**
* Returns an unknown value depending on the passed in value of argument[0]. In
* most cases this will be an {@link Fproperty}.
* The argument[1] is the initial value.
* All following arguments are an array of length 2 where the first element is
* a numeric value and the second element is the value to return if the value is
* larger than that boundry.
*/
export interface Fstep extends FunctionCall<unknown> {
name: 'step';
args: [
Expression<number>, Expression<PropertyType>,
...FStepParameter[]
];
};
/**
* Abbreviates the sentence (argument[0]) at first space beyond lower (argument[1])
* or at upper (argument[2]) if no space. Appends append (argument[3]) if string is abbreviated.
*/
export interface FstrAbbreviate extends FunctionCall<string> {
name: 'strAbbreviate';
args: [
Expression<string>,
Expression<number>,
Expression<number>,
Expression<string>
];
};
/**
* Fully capitalizes the sentence. For example, “HoW aRe YOU?” will be turned into “How Are You?”
*/
export interface FstrCapitalize extends FunctionCall<string> {
name: 'strCapitalize';
args: [
Expression<string>
];
};
/**
* Concatenates the two strings into one
*/
export interface FstrConcat extends FunctionCall<string> {
name: 'strConcat';
args: Expression<string>[];
};
/**
* Returns default (argument[1]) if str (argument[0]) is empty, blank or null
*/
export interface FstrDefaultIfBlank extends FunctionCall<string> {
name: 'strDefaultIfBlank';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Returns true if string (argument[0]) ends with suffix (argument[1])
*/
export interface FstrEndsWith extends FunctionCall<boolean> {
name: 'strEndsWith';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Returns true if the two strings are equal ignoring case considerations
*/
export interface FstrEqualsIgnoreCase extends FunctionCall<boolean> {
name: 'strEqualsIgnoreCase';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Returns the index within this string (argument[0]) of the first occurrence of the specified
* substring (argument[1]), or -1 if not found
*/
export interface FstrIndexOf extends FunctionCall<number> {
name: 'strIndexOf';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Returns the index within this string (arguments[0]) of the last occurrence of the specified
* substring (arguments[1]), or -1 if not found
*/
export interface FstrLastIndexOf extends FunctionCall<number> {
name: 'strLastIndexOf';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Returns the string length
*/
export interface FstrLength extends FunctionCall<number>{
name: 'strLength';
args: [
Expression<string>
];
};
/**
* Returns true if the string (arguments[0]) matches the specified regular expression (arguments[1]).
* For the full syntax of the pattern specification see the Java Pattern class javadocs
*/
export interface FstrMatches extends FunctionCall<boolean> {
name: 'strMatches';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Returns the string (argument[0]) with the pattern (argument[1]) replaced with the given
* replacement (argument[2]) text. If the global argument (argument[3]) is true then all occurrences of the pattern
* will be replaced, otherwise only the first. For the full syntax of the pattern specification see
* the Java Pattern class javadocs
*/
export interface FstrReplace extends FunctionCall<string> {
name: 'strReplace';
args: [
Expression<string>,
Expression<string>,
Expression<string>,
Expression<boolean>
];
};
/**
* Returns true if string (argument[0]) starts with prefix (argument[1]).
*/
export interface FstrStartsWith extends FunctionCall<boolean> {
name: 'strStartsWith';
args: [
Expression<string>,
Expression<string>
];
};
/**
* Removes diacritics (~= accents) from a string. The case will not be altered.
*/
export interface FstrStripAccents extends FunctionCall<string> {
name: 'strStripAccents';
args: [
Expression<string>
];
};
/**
* Returns a new string that is a substring of this string (argument[0]). The substring begins
* at the specified begin (argument[1]) and extends to the character at index endIndex (argument[2]) - 1
* (indexes are zero-based).
*/
export interface FstrSubstring extends FunctionCall<string> {
name: 'strSubstring';
args: [
Expression<string>,
Expression<number>,
Expression<number>
];
};
/**
* Returns a new string that is a substring of this string (argument[0]). The substring begins
* at the specified begin (arguments[1]) and extends to the last character of the string
*/
export interface FstrSubstringStart extends FunctionCall<string> {
name: 'strSubstringStart';
args: [
Expression<string>,
Expression<number>
];
};
/**
* Returns the lower case version of the string
*/
export interface FstrToLowerCase extends FunctionCall<string> {
name: 'strToLowerCase';
args: [
Expression<string>
];
};
/**
* Returns the upper case version of the string
*/
export interface FstrToUpperCase extends FunctionCall<string> {
name: 'strToUpperCase';
args: [
Expression<string>
];
};
/**
* Returns a copy of the string, with leading and trailing blank-space omitted
*/
export interface FstrTrim extends FunctionCall<string> {
name: 'strTrim';
args: [
Expression<string>
];
};
/**
* Returns the result of substracting argument[1] from argument[0]
*/
export interface Fsub extends FunctionCall<number> {
name: 'sub';
args: [
Expression<number>,
Expression<number>
];
};
/**
* Returns the trigonometric tangent of angle expressed in radians
*/
export interface Ftan extends FunctionCall<number> {
name: 'tan';
args: [
Expression<number>
];
};
/**
* Converts an angle expressed in radians into degrees
*/
export interface FtoDegrees extends FunctionCall<number> {
name: 'toDegrees';
args: [
Expression<number>
];
};
/**
* Converts an unknown value into a number
*/
export interface FtoNumber extends FunctionCall<number> {
name: 'toNumber';
args: [
Expression<unknown>
];
};
/**
* Converts an angle expressed in radians into degrees
*/
export interface FtoRadians extends FunctionCall<number> {
name: 'toRadians';
args: [
Expression<number>
];
};
/**
* Converts an unknown value into a string
*/
export interface FtoString extends FunctionCall<string> {
name: 'strToString';
args: [
Expression<unknown>
];
};
export type FInterpolateTypeLinear = {
name: 'linear';
};
export type FInterpolateType = FInterpolateTypeLinear;
export type FInterpolateParameter = {
stop: Expression<number>;
value: Expression<PropertyType>;
};
/**
* Textual representation of a interpolate function.
* argument[0] is the interpolation type.
* argument[1] is the input value.
* argument[2] - argument[args.length] are objects with 'stop' and 'value'.
*
* Will produce continuous results by interpolating between pairs
* of FInterpolateParamters.
*/
export interface Finterpolate extends FunctionCall<number> {
name: 'interpolate';
args: [
FInterpolateType,
Expression<number>,
FInterpolateParameter,
FInterpolateParameter,
...FInterpolateParameter[]
];
};