@dra2020/baseclient 1.0.38 → 1.0.41
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 +42 -2
- package/dist/baseclient.js.map +1 -1
- package/dist/poly/poly.d.ts +1 -0
- package/dist/util/util.d.ts +2 -1
- package/lib/poly/poly.ts +25 -0
- package/lib/poly/topo.ts +21 -1
- package/lib/util/util.ts +3 -1
- package/package.json +1 -1
package/dist/poly/poly.d.ts
CHANGED
|
@@ -50,3 +50,4 @@ export declare function npoints(poly: any): number;
|
|
|
50
50
|
export declare function polyTransform(poly: any, transformFn: any): any;
|
|
51
51
|
export declare function featureRewind(poly: any): any;
|
|
52
52
|
export declare function polyRewindRings(pp: any, bLog?: boolean): any;
|
|
53
|
+
export declare function polyBadCoordinates(f: any): boolean;
|
package/dist/util/util.d.ts
CHANGED
|
@@ -41,7 +41,8 @@ export interface EqOptions {
|
|
|
41
41
|
[key: string]: boolean;
|
|
42
42
|
};
|
|
43
43
|
unorderedArrays?: boolean;
|
|
44
|
-
emptyStringIsNull
|
|
44
|
+
emptyStringIsNull?: boolean;
|
|
45
|
+
epsilon?: number;
|
|
45
46
|
}
|
|
46
47
|
export declare function deepEqual(o1: any, o2: any, options?: EqOptions): boolean;
|
|
47
48
|
export declare function prettyDate(d: Date): string;
|
package/lib/poly/poly.ts
CHANGED
|
@@ -766,3 +766,28 @@ function twoTimesArea(x2: number, x1: number, y2: number, y1: number): number
|
|
|
766
766
|
return (x2 - x1) * (y2 + y1);
|
|
767
767
|
}
|
|
768
768
|
|
|
769
|
+
function badCoord(c: number): boolean
|
|
770
|
+
{
|
|
771
|
+
return isNaN(c) || c > 360 || c < -360;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export function polyBadCoordinates(f: any): boolean
|
|
775
|
+
{
|
|
776
|
+
if (f.type === 'FeatureCollection' && f.features)
|
|
777
|
+
{
|
|
778
|
+
for (let i = 0; i < f.features.length; i++)
|
|
779
|
+
if (polyBadCoordinates(f.features[i])) return true;
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
let pp = polyNormalize(f);
|
|
784
|
+
let bad = false;
|
|
785
|
+
if (pp)
|
|
786
|
+
{
|
|
787
|
+
PP.polyPackEachPoint(pp, (b: Float64Array, iPoly: number, iRing: number, iOffset: number) => {
|
|
788
|
+
if (bad) return;
|
|
789
|
+
bad = badCoord(b[iOffset]) || badCoord(b[iOffset+1]);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
return bad;
|
|
793
|
+
}
|
package/lib/poly/topo.ts
CHANGED
|
@@ -14,6 +14,7 @@ import * as Q from './quad';
|
|
|
14
14
|
import * as PP from './polypack';
|
|
15
15
|
import * as PL from './polylabel';
|
|
16
16
|
import { selfIntersectFast } from './shamos';
|
|
17
|
+
import { polyContainsPoint } from './pointinpoly';
|
|
17
18
|
|
|
18
19
|
export type Topo = any;
|
|
19
20
|
|
|
@@ -193,6 +194,24 @@ function bigTimeString(ms: number): string
|
|
|
193
194
|
return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
194
195
|
}
|
|
195
196
|
|
|
197
|
+
function intpt(f: any): { x: number, y: number }
|
|
198
|
+
{
|
|
199
|
+
let x = 0, y = 0;
|
|
200
|
+
for (let p in ['INTPTLON20','INTPTLON10','INTPTLON','labelx'])
|
|
201
|
+
if (f.properties[p] && !isNaN(Number(f.properties[p])))
|
|
202
|
+
{
|
|
203
|
+
x = Number(f.properties[p]);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
for (let p in ['INTPTLAT20','INTPTLAT10','INTPTLAT','labely'])
|
|
207
|
+
if (f.properties[p] && !isNaN(Number(f.properties[p])))
|
|
208
|
+
{
|
|
209
|
+
y = Number(f.properties[p]);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
return {x: x, y: y};
|
|
213
|
+
}
|
|
214
|
+
|
|
196
215
|
export interface SimplifyOptions
|
|
197
216
|
{
|
|
198
217
|
minArea?: number,
|
|
@@ -294,7 +313,8 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
294
313
|
if (! bDecided)
|
|
295
314
|
{
|
|
296
315
|
let pp = PP.polyPackTopoArcs(testtopo, arcs);
|
|
297
|
-
|
|
316
|
+
let {x,y} = intpt(f);
|
|
317
|
+
if (selfIntersectFast(pp) || (x && y && !polyContainsPoint(pp, x, y)))
|
|
298
318
|
{
|
|
299
319
|
keepArcs(topo, oOld.arcs, keepweight);
|
|
300
320
|
nBad++;
|
package/lib/util/util.ts
CHANGED
|
@@ -264,12 +264,14 @@ export interface EqOptions
|
|
|
264
264
|
{
|
|
265
265
|
omitKey?: { [key: string]: boolean },
|
|
266
266
|
unorderedArrays?: boolean,
|
|
267
|
-
emptyStringIsNull
|
|
267
|
+
emptyStringIsNull?: boolean,
|
|
268
|
+
epsilon?: number,
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
function exactEqual(o1: any, o2: any, options?: EqOptions): boolean
|
|
271
272
|
{
|
|
272
273
|
if (o1 === o2) return true;
|
|
274
|
+
if (options && options.epsilon && typeof o1 === 'number' && typeof o2 === 'number' && Math.abs(o1-o2) < options.epsilon) return true;
|
|
273
275
|
if (options && options.emptyStringIsNull)
|
|
274
276
|
if ((o1 == null && o2 == '') || (o2 == null && o1 == ''))
|
|
275
277
|
return true;
|