@dra2020/baseclient 1.0.49 → 1.0.50
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 +9 -8
- package/dist/baseclient.js.map +1 -1
- package/dist/poly/topo.d.ts +1 -0
- package/lib/poly/topo.ts +9 -8
- package/package.json +1 -1
package/dist/poly/topo.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare function topoToFeature(topo: Topo, geoid: string): any;
|
|
|
8
8
|
export declare function topoToCollection(topo: Topo): any;
|
|
9
9
|
export interface SimplifyOptions {
|
|
10
10
|
minArea?: number;
|
|
11
|
+
log?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare function topoSimplifyCollection(col: any, options?: SimplifyOptions): any;
|
|
13
14
|
export declare function topoMerge(topo: Topo, geoids: string[]): any;
|
package/lib/poly/topo.ts
CHANGED
|
@@ -215,13 +215,14 @@ function intpt(f: any): { x: number, y: number }
|
|
|
215
215
|
export interface SimplifyOptions
|
|
216
216
|
{
|
|
217
217
|
minArea?: number,
|
|
218
|
+
log?: boolean,
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
const DefaultSimplifyOptions: SimplifyOptions = { minArea: 500 };
|
|
221
222
|
|
|
222
|
-
function log(s: string): void
|
|
223
|
+
function log(emitlog: boolean, s: string): void
|
|
223
224
|
{
|
|
224
|
-
console.log(s);
|
|
225
|
+
if (emitlog) console.log(s);
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
//
|
|
@@ -248,10 +249,10 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
248
249
|
let elapsedTotal = new Util.Elapsed();
|
|
249
250
|
let elapsed = new Util.Elapsed();
|
|
250
251
|
let topo = topoFromCollection(col);
|
|
251
|
-
log(`topoSimplifyCollection: fromCollection: ${Math.round(elapsed.ms())}ms`);
|
|
252
|
+
log(options.log, `topoSimplifyCollection: fromCollection: ${Math.round(elapsed.ms())}ms`);
|
|
252
253
|
elapsed.start();
|
|
253
254
|
topo = TopoSimplify.presimplify(topo, TopoSimplify['sphericalTriangleArea']);
|
|
254
|
-
log(`topoSimplifyCollection: presimplify: ${Math.round(elapsed.ms())}ms`);
|
|
255
|
+
log(options.log, `topoSimplifyCollection: presimplify: ${Math.round(elapsed.ms())}ms`);
|
|
255
256
|
elapsed.start();
|
|
256
257
|
|
|
257
258
|
// Keep iterating on removing simplification from degenerate shapes
|
|
@@ -328,19 +329,19 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
328
329
|
keepTiny.set(f, f);
|
|
329
330
|
keepArcs(topo, oOld.arcs, 0); // keeps all points to avoid reprocessing these tiny shapes
|
|
330
331
|
nBad++, nTiny++;
|
|
331
|
-
log(`topoSimplifyCollection: ${f.properties.id}: increasing feature fidelity because intpt dist is ${d}`);
|
|
332
|
+
log(options.log, `topoSimplifyCollection: ${f.properties.id}: increasing feature fidelity because intpt dist is ${d}`);
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
336
|
}
|
|
336
337
|
});
|
|
337
|
-
log(`topoSimplifyCollection: pass ${nTries}: ${nBad} (${nTiny} tiny) of ${col.features.length} features are degenerate`);
|
|
338
|
+
log(options.log, `topoSimplifyCollection: pass ${nTries}: ${nBad} (${nTiny} tiny) of ${col.features.length} features are degenerate`);
|
|
338
339
|
|
|
339
340
|
// If not making progress, keep more points
|
|
340
341
|
if (nBad >= nBadLast)
|
|
341
342
|
{
|
|
342
343
|
keepweight /= 10;
|
|
343
|
-
log(`topoSimplifyCollection: pass ${nTries}: reducing weight limit to ${keepweight}`);
|
|
344
|
+
log(options.log, `topoSimplifyCollection: pass ${nTries}: reducing weight limit to ${keepweight}`);
|
|
344
345
|
}
|
|
345
346
|
nBadLast = nBad;
|
|
346
347
|
|
|
@@ -356,7 +357,7 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
356
357
|
nTries++;
|
|
357
358
|
}
|
|
358
359
|
|
|
359
|
-
log(`topoSimplifyCollection: total elapsed time: ${bigTimeString(elapsedTotal.ms())}`);
|
|
360
|
+
log(options.log, `topoSimplifyCollection: total elapsed time: ${bigTimeString(elapsedTotal.ms())}`);
|
|
360
361
|
|
|
361
362
|
return col;
|
|
362
363
|
}
|