@dra2020/baseclient 1.0.5 → 1.0.8
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 +26 -13
- package/dist/baseclient.js.map +1 -1
- package/dist/fsm/fsm.d.ts +1 -0
- package/lib/fsm/fsm.ts +12 -2
- package/lib/geo/geo.ts +7 -5
- package/lib/poly/topo.ts +10 -5
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -994,9 +994,17 @@ class FsmSleep extends Fsm {
|
|
|
994
994
|
this.delay = delay;
|
|
995
995
|
}
|
|
996
996
|
tick() {
|
|
997
|
-
|
|
997
|
+
// This allows canceling by simply setting state to done
|
|
998
|
+
if (this.done && this.timeoutHandle !== undefined) {
|
|
999
|
+
clearTimeout(this.timeoutHandle);
|
|
1000
|
+
delete this.timeoutHandle;
|
|
1001
|
+
}
|
|
1002
|
+
else if (this.ready && this.state === exports.FSM_STARTING) {
|
|
998
1003
|
this.setState(exports.FSM_PENDING);
|
|
999
|
-
setTimeout(() => {
|
|
1004
|
+
this.timeoutHandle = setTimeout(() => {
|
|
1005
|
+
delete this.timeoutHandle;
|
|
1006
|
+
this.setState(exports.FSM_DONE);
|
|
1007
|
+
}, this.delay);
|
|
1000
1008
|
}
|
|
1001
1009
|
}
|
|
1002
1010
|
}
|
|
@@ -1375,10 +1383,9 @@ class GeoMultiCollection {
|
|
|
1375
1383
|
let n = this.nEntries;
|
|
1376
1384
|
if (n == 1)
|
|
1377
1385
|
this.all.col = this._col(this.nthEntry(0));
|
|
1378
|
-
else
|
|
1379
|
-
|
|
1380
|
-
this.
|
|
1381
|
-
}
|
|
1386
|
+
else
|
|
1387
|
+
// Going from map to collection guarantees that any duplicates are removed
|
|
1388
|
+
this.all.col = geoMapToCollection(this.allMap());
|
|
1382
1389
|
}
|
|
1383
1390
|
return this.all.col;
|
|
1384
1391
|
}
|
|
@@ -1390,8 +1397,11 @@ class GeoMultiCollection {
|
|
|
1390
1397
|
let n = this.nEntries;
|
|
1391
1398
|
if (n == 1)
|
|
1392
1399
|
this.all.map = this._map(this.nthEntry(0));
|
|
1393
|
-
else
|
|
1394
|
-
|
|
1400
|
+
else {
|
|
1401
|
+
let map = {};
|
|
1402
|
+
this.all.map = map;
|
|
1403
|
+
this.forEach(f => { map[String(f.properties.id)] = f; });
|
|
1404
|
+
}
|
|
1395
1405
|
}
|
|
1396
1406
|
return this.all.map;
|
|
1397
1407
|
}
|
|
@@ -8050,6 +8060,9 @@ function bigTimeString(ms) {
|
|
|
8050
8060
|
return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
8051
8061
|
}
|
|
8052
8062
|
const DefaultSimplifyOptions = { minArea: 500 };
|
|
8063
|
+
function log(s) {
|
|
8064
|
+
//console.log(s);
|
|
8065
|
+
}
|
|
8053
8066
|
//
|
|
8054
8067
|
// topoSimplifyCollection:
|
|
8055
8068
|
// This implements our simplification strategy for block/precinct level shapes. The basic idea is to
|
|
@@ -8072,10 +8085,10 @@ function topoSimplifyCollection(col, options) {
|
|
|
8072
8085
|
let elapsedTotal = new Util.Elapsed();
|
|
8073
8086
|
let elapsed = new Util.Elapsed();
|
|
8074
8087
|
let topo = topoFromCollection(col);
|
|
8075
|
-
|
|
8088
|
+
log(`topoSimplifyCollection: fromCollection: ${Math.round(elapsed.ms())}ms`);
|
|
8076
8089
|
elapsed.start();
|
|
8077
8090
|
topo = TopoSimplify.presimplify(topo, TopoSimplify['sphericalTriangleArea']);
|
|
8078
|
-
|
|
8091
|
+
log(`topoSimplifyCollection: presimplify: ${Math.round(elapsed.ms())}ms`);
|
|
8079
8092
|
elapsed.start();
|
|
8080
8093
|
// Keep iterating on removing simplification from degenerate shapes
|
|
8081
8094
|
let nTries = 1;
|
|
@@ -8131,11 +8144,11 @@ function topoSimplifyCollection(col, options) {
|
|
|
8131
8144
|
}
|
|
8132
8145
|
}
|
|
8133
8146
|
});
|
|
8134
|
-
|
|
8147
|
+
log(`topoSimplifyCollection: pass ${nTries}: ${nBad} (${nTiny} tiny) of ${col.features.length} features are degenerate`);
|
|
8135
8148
|
// If not making progress, keep more points
|
|
8136
8149
|
if (nBad >= nBadLast) {
|
|
8137
8150
|
keepweight /= 10;
|
|
8138
|
-
|
|
8151
|
+
log(`topoSimplifyCollection: pass ${nTries}: reducing weight limit to ${keepweight}`);
|
|
8139
8152
|
}
|
|
8140
8153
|
nBadLast = nBad;
|
|
8141
8154
|
if (nBad && nTries > MAX_TRIES)
|
|
@@ -8147,7 +8160,7 @@ function topoSimplifyCollection(col, options) {
|
|
|
8147
8160
|
}
|
|
8148
8161
|
nTries++;
|
|
8149
8162
|
}
|
|
8150
|
-
|
|
8163
|
+
log(`topoSimplifyCollection: total elapsed time: ${bigTimeString(elapsedTotal.ms())}`);
|
|
8151
8164
|
return col;
|
|
8152
8165
|
}
|
|
8153
8166
|
exports.topoSimplifyCollection = topoSimplifyCollection;
|