@team-geospan/structuresio 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # GEOSPAN StructuresIO
2
2
 
3
- JavaScript utilities for working with the [StructuresJSON]() format.
3
+ JavaScript utilities for working with the [StructuresJSON](https://github.com/team-geospan/structures-json) format.
4
4
 
5
5
  ## Installation
6
6
 
package/lib/geojson.js CHANGED
@@ -94,10 +94,9 @@ const structureToPolygonFeature = ({ surfaces, points, edges }) => {
94
94
  */
95
95
  export const toPolygonGeoJSON = (collection) => {
96
96
  // handle either a collection or single structure
97
- const allFeatures =
98
- collection.kind === "StructureCollection"
99
- ? collection.structures.map(structureToPolygonFeature)
100
- : [structureToPolygonFeature(collection)];
97
+ const allFeatures = isCollection(collection)
98
+ ? collection.structures.map(structureToPolygonFeature)
99
+ : [structureToPolygonFeature(collection)];
101
100
 
102
101
  return {
103
102
  type: "FeatureCollection",
package/lib/summary.js CHANGED
@@ -49,3 +49,21 @@ export const summarizeSurfaceMaterials = (collection, flatten = false) => {
49
49
 
50
50
  return summary;
51
51
  };
52
+
53
+ export const summarizeEdges = (collection, flatten = false) => {
54
+ const summary = {};
55
+ collection.structures.forEach((structure) => {
56
+ Object.values(structure.edges).forEach((edge) => {
57
+ const kind = edge.kind || "";
58
+ summary[kind] =
59
+ (summary[kind] || 0) +
60
+ ((edge.properties && edge.properties.length) || 0);
61
+ });
62
+ });
63
+
64
+ if (flatten) {
65
+ return Object.keys(summary).map((key) => [key, summary[key]]);
66
+ }
67
+
68
+ return summary;
69
+ };
package/lib/units.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* v8 ignore start */
2
+
1
3
  /**
2
4
  * Copyright GEOSPAN Corp
3
5
  *
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@team-geospan/structuresio",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Collection of utilities for working with StructuresJSON",
5
5
  "type": "module",
6
+ "exports": {
7
+ "./*": "./lib/*"
8
+ },
6
9
  "files": [
7
10
  "./lib"
8
11
  ],
9
12
  "scripts": {
10
13
  "lint": "eslint --report-unused-disable-directives --max-warnings 0 ./tests ./lib --ext .js",
11
14
  "lint:fix": "npm run lint -- --fix",
12
- "test": "vitest ./tests"
15
+ "test": "vitest ./tests",
16
+ "coverage": "vitest ./tests --coverage"
13
17
  },
14
18
  "eslintConfig": {
15
19
  "env": {
@@ -29,6 +33,7 @@
29
33
  }
30
34
  },
31
35
  "devDependencies": {
36
+ "@vitest/coverage-v8": "^3.1.1",
32
37
  "eslint": "^8.57.0",
33
38
  "eslint-config-prettier": "^10.0.1",
34
39
  "eslint-plugin-prettier": "^5.2.3",