@dra2020/baseclient 1.0.153 → 1.0.155

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/geo/all.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './geo';
2
2
  export * from './vfeature';
3
3
  export * from './flexname';
4
4
  export * from './multiblockmapping';
5
+ export * from './ensurecentroid';
@@ -0,0 +1,3 @@
1
+ import * as G from './geo';
2
+ export declare function ensureCentroidInFeature(f: G.GeoFeature): void;
3
+ export declare function ensureCentroidInCollection(col: G.GeoFeatureCollection): void;
package/lib/geo/all.ts CHANGED
@@ -2,3 +2,4 @@ export * from './geo';
2
2
  export * from './vfeature';
3
3
  export * from './flexname';
4
4
  export * from './multiblockmapping';
5
+ export * from './ensurecentroid';
@@ -0,0 +1,49 @@
1
+ import * as geojson from 'geojson';
2
+ import * as Util from '../util/all'
3
+ import * as Poly from '../poly/all'
4
+ import * as G from './geo'
5
+
6
+ function oneNumberOf(f: G.GeoFeature, props: string[]): number
7
+ {
8
+ for (let i = 0; i < props.length; i++)
9
+ if (f.properties[props[i]])
10
+ return Number(f.properties[props[i]]);
11
+ return 0;
12
+ }
13
+
14
+ export function ensureCentroidInFeature(f: G.GeoFeature): void
15
+ {
16
+ if (f.geometry && f.properties.labelx === undefined)
17
+ {
18
+ f.properties.labelx = oneNumberOf(f, ['INTPTLON30', 'INTPTLON20','INTPTLON10','INTPTLON']);
19
+ f.properties.labely = oneNumberOf(f, ['INTPTLAT30', 'INTPTLAT20','INTPTLAT10','INTPTLAT']);
20
+ if (f.properties.labelx && f.properties.labely)
21
+ if (! Poly.polyContainsPoint(f, f.properties.labelx, f.properties.labely))
22
+ {
23
+ delete f.properties.labelx;
24
+ delete f.properties.labely;
25
+ }
26
+
27
+ // If internal point not specified, compute it
28
+ if (!f.properties.labelx || !f.properties.labely)
29
+ {
30
+ let result = Poly.polyLabel(f);
31
+ f.properties.labelx = Util.precisionRound(result.x, 6);
32
+ f.properties.labely = Util.precisionRound(result.y, 6);
33
+ }
34
+
35
+ delete f.properties.INTPTLAT30;
36
+ delete f.properties.INTPTLON30;
37
+ delete f.properties.INTPTLAT20;
38
+ delete f.properties.INTPTLON20;
39
+ delete f.properties.INTPTLAT10;
40
+ delete f.properties.INTPTLON10;
41
+ delete f.properties.INTPTLAT;
42
+ delete f.properties.INTPTLON;
43
+ }
44
+ }
45
+
46
+ export function ensureCentroidInCollection(col: G.GeoFeatureCollection): void
47
+ {
48
+ col.features.forEach(ensureCentroidInFeature);
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.153",
3
+ "version": "1.0.155",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",
@@ -33,10 +33,12 @@
33
33
  "@types/node": "20.11.30",
34
34
  "@types/object-hash": "^3.0.6",
35
35
  "source-map-loader": "^5.0.0",
36
- "ts-loader": "^9.5.1",
36
+ "ts-loader": "^9.5.2",
37
37
  "tsify": "^5.0.4",
38
- "typescript": "^5.4.3",
39
- "webpack": "^5.91.0",
38
+ "pbkdf2":"^3.1.3",
39
+ "elliptic": "^6.6.1",
40
+ "typescript": "^5.8.3",
41
+ "webpack": "^5.99.5",
40
42
  "webpack-cli": "^5.1.4"
41
43
  },
42
44
  "dependencies": {