@dra2020/baseclient 1.0.9 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseclient.js +79 -10
- package/dist/baseclient.js.map +1 -1
- package/dist/filterexpr/filterexpr.d.ts +3 -0
- package/dist/ot-js/otsession.d.ts +1 -0
- package/lib/filterexpr/filterexpr.ts +79 -5
- package/lib/ot-js/otsession.ts +2 -1
- package/lib/poly/polypack.ts +12 -2
- package/package.json +1 -1
|
@@ -58,6 +58,9 @@ export declare class FilterExpr {
|
|
|
58
58
|
set(expr: string): void;
|
|
59
59
|
test(o: any, types?: any): boolean;
|
|
60
60
|
asString(): string;
|
|
61
|
+
containsClause(expr: string): boolean;
|
|
62
|
+
addClause(expr: string): void;
|
|
63
|
+
removeClause(expr: string): void;
|
|
61
64
|
asStringClause(clause: Clause): string;
|
|
62
65
|
testClause(o: any, types: any, clause: Clause, prop?: string, relation?: TokType): boolean;
|
|
63
66
|
}
|
|
@@ -20,6 +20,7 @@ export declare const FilterRecent: number;
|
|
|
20
20
|
export declare const FilterTrash: number;
|
|
21
21
|
export declare const FilterPublic: number;
|
|
22
22
|
export declare const FilterOfficial: number;
|
|
23
|
+
export declare const FilterCOI: number;
|
|
23
24
|
export declare const FilterCount: number;
|
|
24
25
|
export declare type Filter = number;
|
|
25
26
|
export declare const PermNone: number;
|
|
@@ -484,6 +484,45 @@ function wordyDate(s: string): string
|
|
|
484
484
|
return s;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
+
function clauseEqual(c1: Clause, c2: Clause): boolean
|
|
488
|
+
{
|
|
489
|
+
if (c1 == null && c2 == null) return true;
|
|
490
|
+
if (c1 == null || c2 == null) return false;
|
|
491
|
+
if (c1.op.tt === c2.op.tt)
|
|
492
|
+
{
|
|
493
|
+
if (c1.op.tt === TokType.Text)
|
|
494
|
+
return c1.op.text === c2.op.text;
|
|
495
|
+
else
|
|
496
|
+
return clauseEqual(c1.operand1, c2.operand1) && clauseEqual(c1.operand2, c2.operand2);
|
|
497
|
+
}
|
|
498
|
+
else
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function containsClause(c: Clause, s: Clause): boolean
|
|
503
|
+
{
|
|
504
|
+
if (clauseEqual(c, s))
|
|
505
|
+
return true;
|
|
506
|
+
if (c == null || s == null) return false;
|
|
507
|
+
return containsClause(c.operand1, s) || containsClause(c.operand2, s);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function removeClause(c: Clause, s: Clause): Clause
|
|
511
|
+
{
|
|
512
|
+
if (c == null || (c.op.tt === TokType.Text && c.op.tt !== s.op.tt))
|
|
513
|
+
return c;
|
|
514
|
+
else if (clauseEqual(c, s))
|
|
515
|
+
return null;
|
|
516
|
+
else
|
|
517
|
+
{
|
|
518
|
+
c.operand1 = removeClause(c.operand1, s);
|
|
519
|
+
c.operand2 = removeClause(c.operand2, s);
|
|
520
|
+
if ((c.op.tt === TokType.And || c.op.tt === TokType.Or) && (c.operand1 == null || c.operand2 == null))
|
|
521
|
+
return c.operand1 || c.operand2;
|
|
522
|
+
return c;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
487
526
|
export class FilterExpr
|
|
488
527
|
{
|
|
489
528
|
lexer: Lexer;
|
|
@@ -512,12 +551,47 @@ export class FilterExpr
|
|
|
512
551
|
return this.asStringClause(this.parser.clause);
|
|
513
552
|
}
|
|
514
553
|
|
|
554
|
+
containsClause(expr: string): boolean
|
|
555
|
+
{
|
|
556
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
557
|
+
return containsClause(this.parser.clause, sub.parser.clause);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
addClause(expr: string): void
|
|
561
|
+
{
|
|
562
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
563
|
+
if (! containsClause(this.parser.clause, sub.parser.clause))
|
|
564
|
+
{
|
|
565
|
+
if (this.parser.clause)
|
|
566
|
+
this.parser.clauses = [ { op: { tt: TokType.And }, operand1: this.parser.clause, operand2: sub.parser.clause } ];
|
|
567
|
+
else
|
|
568
|
+
this.parser.clauses = [ sub.parser.clause ];
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
removeClause(expr: string): void
|
|
573
|
+
{
|
|
574
|
+
if (this.containsClause(expr))
|
|
575
|
+
{
|
|
576
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
577
|
+
this.parser.clauses = [ removeClause(this.parser.clause, sub.parser.clause) ];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
515
581
|
asStringClause(clause: Clause): string
|
|
516
582
|
{
|
|
517
583
|
if (clause == null) return '';
|
|
518
|
-
if (clause.op.tt == TokType.Text)
|
|
584
|
+
if (clause.op.tt == TokType.Text)
|
|
585
|
+
{
|
|
586
|
+
this.lexer.set(clause.op.text);
|
|
587
|
+
if (this.lexer.tokens.length == 1 && this.lexer.tokens[0].tt === TokType.Text)
|
|
588
|
+
return clause.op.text;
|
|
589
|
+
else
|
|
590
|
+
return `'${clause.op.text}'`;
|
|
591
|
+
}
|
|
519
592
|
let a: string[] = [];
|
|
520
|
-
|
|
593
|
+
if (clause !== this.parser.clause)
|
|
594
|
+
a.push('(');
|
|
521
595
|
switch (clause.op.tt)
|
|
522
596
|
{
|
|
523
597
|
case TokType.And:
|
|
@@ -535,8 +609,7 @@ export class FilterExpr
|
|
|
535
609
|
a.push(this.asStringClause(clause.operand1));
|
|
536
610
|
break;
|
|
537
611
|
case TokType.Colon:
|
|
538
|
-
a.push(this.asStringClause(clause.operand1));
|
|
539
|
-
a.push(':');
|
|
612
|
+
a.push(`${this.asStringClause(clause.operand1)}:`);
|
|
540
613
|
a.push(this.asStringClause(clause.operand2));
|
|
541
614
|
break;
|
|
542
615
|
case TokType.Equal:
|
|
@@ -551,7 +624,8 @@ export class FilterExpr
|
|
|
551
624
|
default:
|
|
552
625
|
throw 'Unexpected token in asString';
|
|
553
626
|
}
|
|
554
|
-
|
|
627
|
+
if (clause !== this.parser.clause)
|
|
628
|
+
a.push(')');
|
|
555
629
|
return a.join(' ');
|
|
556
630
|
}
|
|
557
631
|
|
package/lib/ot-js/otsession.ts
CHANGED
|
@@ -23,7 +23,8 @@ export const FilterRecent: number = 3;
|
|
|
23
23
|
export const FilterTrash: number = 4;
|
|
24
24
|
export const FilterPublic: number = 5;
|
|
25
25
|
export const FilterOfficial: number = 6;
|
|
26
|
-
export const
|
|
26
|
+
export const FilterCOI: number = 7;
|
|
27
|
+
export const FilterCount: number = 8;
|
|
27
28
|
export type Filter = number;
|
|
28
29
|
|
|
29
30
|
// Permissions
|
package/lib/poly/polypack.ts
CHANGED
|
@@ -221,7 +221,8 @@ export function polyPack(coords: any, prepack?: PolyPack): PolyPack
|
|
|
221
221
|
|
|
222
222
|
// Transparently handle polygon or multi-polygon
|
|
223
223
|
let depth = Util.depthof(coords);
|
|
224
|
-
if (depth ==
|
|
224
|
+
if (depth == 2) coords = [ [ [ coords ] ] ];
|
|
225
|
+
else if (depth == 3) coords = [ [ coords ] ];
|
|
225
226
|
else if (depth == 4) coords = [ coords ];
|
|
226
227
|
|
|
227
228
|
let nFloats = polyPackSize(coords);
|
|
@@ -374,9 +375,18 @@ export function featureUnpack(f: any): any
|
|
|
374
375
|
if (f && f.geometry && f.geometry.packed !== undefined)
|
|
375
376
|
{
|
|
376
377
|
f.geometry.coordinates = polyUnpack(f.geometry.packed);
|
|
378
|
+
let depth = Util.depthof(f.geometry.coordinates);
|
|
377
379
|
// Check for oops, optimized away the multipolygon in polyUnpack
|
|
378
|
-
if (f.geometry.type === 'MultiPolygon' &&
|
|
380
|
+
if (f.geometry.type === 'MultiPolygon' && depth === 4)
|
|
379
381
|
f.geometry.coordinates = [ f.geometry.coordinates ];
|
|
382
|
+
else if (f.geometry.type === 'Point' && depth != 2)
|
|
383
|
+
{
|
|
384
|
+
while (depth > 2)
|
|
385
|
+
{
|
|
386
|
+
f.geometry.coordinates = f.geometry.coordinates[0];
|
|
387
|
+
depth = Util.depthof(f.geometry.coordinates);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
380
390
|
delete f.geometry.packed;
|
|
381
391
|
}
|
|
382
392
|
else if (f.type && f.type === 'FeatureCollection' && f.features)
|