@build-qube/takeoff-calculator 2.0.3 → 2.1.0

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.
Files changed (3) hide show
  1. package/index.d.ts +304 -171
  2. package/index.js +754 -749
  3. package/package.json +11 -31
package/index.d.ts CHANGED
@@ -1,215 +1,348 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ export declare class ContourWrapper {
4
+ constructor(contour: ContourInput);
5
+ /** Get the surface points for the contour. */
6
+ getSurfacePoints(): Array<Point3D> | null;
7
+ /**
8
+ * Compute cut/fill volume against a reference surface.
9
+ * Returns None if the surface mesh is not available (e.g. contour conversion failed).
10
+ */
11
+ volumeAgainst(
12
+ reference: ReferenceSurfaceInput,
13
+ cellSize?: number | undefined | null,
14
+ ): VolumetricResult | null;
15
+ /**
16
+ * Get the z value at a given x, y coordinate.
17
+ * Returns None if the surface mesh is not available (e.g. contour conversion failed).
18
+ */
19
+ getZAt(x: number, y: number): number | null;
20
+ /**
21
+ * Get scatter data for the contour.
22
+ * Returns None if the surface mesh is not available (e.g. contour conversion failed).
23
+ *
24
+ * # Arguments
25
+ *
26
+ * * `step` - The step size for the scatter data.
27
+ *
28
+ * # Returns
29
+ *
30
+ * * `Vec<Point3D>` - The scatter data.
31
+ * * `None` - If the surface mesh is not available (e.g. contour conversion failed).
32
+ */
33
+ getScatterData(step: number): Array<Point3D> | null;
34
+ }
35
+
3
36
  export declare class GroupWrapper {
4
- /** Get the id of the group. */
5
- get id(): string;
6
- get area(): UnitValue | null;
7
- get length(): UnitValue | null;
8
- get points(): number | null;
9
- get count(): number | null;
37
+ /** Get the id of the group. */
38
+ get id(): string;
39
+ get area(): UnitValue | null;
40
+ get length(): UnitValue | null;
41
+ get points(): number | null;
42
+ get count(): number | null;
43
+ get group(): Group;
10
44
  }
11
45
 
12
46
  export declare class MeasurementWrapper {
13
- get points(): number;
14
- get measurement(): Measurement;
15
- get area(): UnitValue | null;
16
- convertArea(unit: Unit): number | null;
17
- convertLength(unit: Unit): number | null;
18
- get length(): UnitValue | null;
19
- get scale(): Scale | null;
20
- get id(): string;
21
- get pageId(): string;
22
- get groupId(): string;
23
- get rawArea(): number;
24
- get rawPerimeter(): number;
47
+ get points(): number;
48
+ get measurement(): Measurement;
49
+ get area(): UnitValue | null;
50
+ convertArea(unit: Unit): number | null;
51
+ convertLength(unit: Unit): number | null;
52
+ get length(): UnitValue | null;
53
+ get scale(): Scale | null;
54
+ get id(): string;
55
+ get pageId(): string;
56
+ get groupId(): string;
57
+ get rawArea(): number;
58
+ get rawPerimeter(): number;
25
59
  }
26
60
 
27
61
  export declare class TakeoffStateHandler {
28
- /**
29
- * Creates a new state.
30
- *
31
- * # Arguments
32
- *
33
- * * `options` - The options for the state.
34
- *
35
- * # Returns
36
- *
37
- * * `State` - The new state.
38
- */
39
- constructor(options?: StateOptions | undefined | null);
40
- getMeasurementsByGroupId(groupId: string): Array<MeasurementWrapper>;
41
- /**
42
- * Get the scale for a measurement.
43
- *
44
- * # Arguments
45
- *
46
- * * `measurement_id` - The id of the measurement.
47
- *
48
- * # Returns
49
- *
50
- * * `None` - If the measurement was not found.
51
- * * `Some(scale)` - If the scale was found.
52
- */
53
- getMeasurementScale(measurementId: string): Scale | null;
54
- /**
55
- * Inserts or updates a page in the state.
56
- *
57
- * # Arguments
58
- *
59
- * * `page` - The page to insert or update.
60
- *
61
- * # Returns
62
- *
63
- * * `None` - If the page was not found.
64
- * * `Some(page)` - If the page was found and updated.
65
- */
66
- upsertPage(page: Page): Page | null;
67
- getGroup(groupId: string): GroupWrapper | null;
68
- /**
69
- * Inserts or updates a group in the state.
70
- *
71
- * # Arguments
72
- *
73
- * * `group` - The group to insert or update.
74
- *
75
- * # Returns
76
- *
77
- * * `None` - If the group was not found.
78
- * * `Some(group)` - If the group was found and updated.
79
- */
80
- upsertGroup(group: Group): Group | null;
81
- /**
82
- * Inserts or updates a measurement in the state.
83
- *
84
- * # Arguments
85
- *
86
- * * `measurement` - The measurement to insert or update.
87
- *
88
- * # Returns
89
- *
90
- * * `None` - If the measurement was not found.
91
- * * `Some(measurement)` - If the measurement was found and updated.
92
- */
93
- upsertMeasurement(measurement: Measurement): Measurement | null;
94
- getMeasurement(measurementId: string): MeasurementWrapper | null;
95
- /**
96
- * Inserts or updates a scale in the state.
97
- *
98
- * # Arguments
99
- *
100
- * * `scale` - The scale to insert or update.
101
- *
102
- * # Returns
103
- *
104
- * * `None` - If the scale was not found.
105
- * * `Some(scale)` - If the scale was found and updated.
106
- */
107
- upsertScale(scale: Scale): Scale | null;
108
- /**
109
- * Get the measurements that are missing a scale.
110
- *
111
- * # Returns
112
- *
113
- * * `Vec<MeasurementWrapper>` - The measurements that are missing a scale.
114
- */
115
- getMeasurementsMissingScale(): Array<MeasurementWrapper>;
62
+ /**
63
+ * Creates a new state.
64
+ *
65
+ * # Arguments
66
+ *
67
+ * * `options` - The options for the state.
68
+ *
69
+ * # Returns
70
+ *
71
+ * * `State` - The new state.
72
+ */
73
+ constructor(options?: StateOptions | undefined | null);
74
+ getMeasurementsByGroupId(groupId: string): Array<MeasurementWrapper>;
75
+ /**
76
+ * Get the scale for a measurement.
77
+ *
78
+ * # Arguments
79
+ *
80
+ * * `measurement_id` - The id of the measurement.
81
+ *
82
+ * # Returns
83
+ *
84
+ * * `None` - If the measurement was not found.
85
+ * * `Some(scale)` - If the scale was found.
86
+ */
87
+ getMeasurementScale(measurementId: string): Scale | null;
88
+ /**
89
+ * Inserts or updates a page in the state.
90
+ *
91
+ * # Arguments
92
+ *
93
+ * * `page` - The page to insert or update.
94
+ *
95
+ * # Returns
96
+ *
97
+ * * `None` - If the page was not found.
98
+ * * `Some(page)` - If the page was found and updated.
99
+ */
100
+ upsertPage(page: Page): Page | null;
101
+ removePage(pageId: string): Page | null;
102
+ getGroup(groupId: string): GroupWrapper | null;
103
+ /**
104
+ * Inserts or updates a group in the state.
105
+ *
106
+ * # Arguments
107
+ *
108
+ * * `group` - The group to insert or update.
109
+ *
110
+ * # Returns
111
+ *
112
+ * * `None` - If the group was not found.
113
+ * * `Some(group)` - If the group was found and updated.
114
+ */
115
+ upsertGroup(group: Group): Group | null;
116
+ /**
117
+ * Removes a group from the state.
118
+ *
119
+ * # Arguments
120
+ *
121
+ * * `group_id` - The id of the group to remove.
122
+ *
123
+ * # Returns
124
+ * * `None` - If the group was not found.
125
+ * * `Some(group)` - If the group was found and removed.
126
+ */
127
+ removeGroup(groupId: string): Group | null;
128
+ /**
129
+ * Inserts or updates a measurement in the state.
130
+ *
131
+ * # Arguments
132
+ *
133
+ * * `measurement` - The measurement to insert or update.
134
+ *
135
+ * # Returns
136
+ *
137
+ * * `None` - If the measurement was not found.
138
+ * * `Some(measurement)` - If the measurement was found and updated.
139
+ */
140
+ upsertMeasurement(measurement: Measurement): Measurement | null;
141
+ /**
142
+ * Removes a measurement from the state.
143
+ *
144
+ * # Arguments
145
+ *
146
+ * * `measurement_id` - The id of the measurement to remove.
147
+ *
148
+ * # Returns
149
+ *
150
+ * * `None` - If the measurement was not found.
151
+ * * `Some(measurement)` - If the measurement was found and removed.
152
+ */
153
+ removeMeasurement(measurementId: string): Measurement | null;
154
+ getMeasurement(measurementId: string): MeasurementWrapper | null;
155
+ /**
156
+ * Inserts or updates a scale in the state.
157
+ *
158
+ * # Arguments
159
+ *
160
+ * * `scale` - The scale to insert or update.
161
+ *
162
+ * # Returns
163
+ *
164
+ * * `None` - If the scale was not found.
165
+ * * `Some(scale)` - If the scale was found and updated.
166
+ */
167
+ upsertScale(scale: Scale): Scale | null;
168
+ /**
169
+ * Removes a scale from the state.
170
+ *
171
+ * # Arguments
172
+ *
173
+ * * `scale_id` - The id of the scale to remove.
174
+ *
175
+ * # Returns
176
+ * * `None` - If the scale was not found.
177
+ * * `Some(scale)` - If the scale was found and removed.
178
+ */
179
+ removeScale(scaleId: string): Scale | null;
180
+ /**
181
+ * Get the measurements that are missing a scale.
182
+ *
183
+ * # Returns
184
+ *
185
+ * * `Vec<MeasurementWrapper>` - The measurements that are missing a scale.
186
+ */
187
+ getMeasurementsMissingScale(): Array<MeasurementWrapper>;
116
188
  }
117
189
 
190
+ /** Add 100 to the input */
118
191
  export declare function plus100(input: number): number;
192
+
193
+ /** Add 200 to the input */
194
+ export declare function plus200(input: number): number;
119
195
  export declare class UnitValue {
120
- constructor(value: number, unit: Unit, magnitude: UnitValueItemType);
121
- display(unit: Unit): string;
122
- getConvertedValue(to: Unit): number;
196
+ constructor(value: number, unit: Unit, magnitude: UnitValueItemType);
197
+ display(unit: Unit): string;
198
+ getConvertedValue(to: Unit): number;
199
+ }
200
+
201
+ export interface ContourInput {
202
+ id: string;
203
+ name?: string;
204
+ pageId: string;
205
+ /** The lines that make up the contour map */
206
+ lines: Array<ContourLineInput>;
207
+ /** The points of interest that are used to create the contour map */
208
+ pointsOfInterest: Array<ContourPointOfInterestInput>;
209
+ }
210
+
211
+ export interface ContourLineInput {
212
+ /** The elevation of the contour line (in pixels) */
213
+ elevation: number;
214
+ points: Array<Point>;
215
+ }
216
+
217
+ export interface ContourPointOfInterestInput {
218
+ /** The elevation of the point of interest (in pixels) */
219
+ elevation: number;
220
+ point: Point;
123
221
  }
124
222
 
223
+ /** Calculate distance between two points */
224
+ export declare function distance(
225
+ points: [Point, Point] | [Point3D, Point3D],
226
+ ): number;
227
+
228
+ /** Get the centroid of a measurement */
229
+ export declare function getCentroid(measurement: Measurement): Point | null;
230
+
125
231
  export interface Group {
126
- id: string;
127
- name?: string;
128
- measurementType: MeasurementType;
232
+ id: string;
233
+ name?: string;
234
+ measurementType: MeasurementType;
129
235
  }
130
236
 
131
237
  export type Measurement =
132
- | {
133
- type: "Count";
134
- id: string;
135
- pageId: string;
136
- groupId: string;
137
- points: [Point];
138
- }
139
- | {
140
- type: "Polygon";
141
- id: string;
142
- pageId: string;
143
- groupId: string;
144
- points: Array<Point>;
145
- }
146
- | {
147
- type: "Polyline";
148
- id: string;
149
- pageId: string;
150
- groupId: string;
151
- points: Array<Point>;
152
- }
153
- | {
154
- type: "Rectangle";
155
- id: string;
156
- pageId: string;
157
- groupId: string;
158
- points: [Point, Point];
159
- };
238
+ | {
239
+ type: "Count";
240
+ id: string;
241
+ pageId: string;
242
+ groupId: string;
243
+ points: [Point];
244
+ }
245
+ | {
246
+ type: "Polygon";
247
+ id: string;
248
+ pageId: string;
249
+ groupId: string;
250
+ points: Array<Point>;
251
+ }
252
+ | {
253
+ type: "Polyline";
254
+ id: string;
255
+ pageId: string;
256
+ groupId: string;
257
+ points: Array<Point>;
258
+ }
259
+ | {
260
+ type: "Rectangle";
261
+ id: string;
262
+ pageId: string;
263
+ groupId: string;
264
+ points: [Point, Point];
265
+ };
160
266
 
161
267
  export type MeasurementType = "Area" | "Linear" | "Count";
162
268
 
163
269
  export interface Page {
164
- id: string;
165
- name?: string;
166
- width?: number;
167
- height?: number;
168
- viewport?: PageViewport;
270
+ id: string;
271
+ name?: string;
272
+ width?: number;
273
+ height?: number;
274
+ viewport?: PageViewport;
169
275
  }
170
276
 
171
277
  export interface PageViewport {
172
- width: number;
173
- height: number;
278
+ width: number;
279
+ height: number;
174
280
  }
175
281
 
176
282
  /** Represents a 2D point with floating point coordinates */
177
283
  export interface Point {
178
- x: number;
179
- y: number;
284
+ x: number;
285
+ y: number;
286
+ }
287
+
288
+ export interface Point3D {
289
+ x: number;
290
+ y: number;
291
+ z: number;
180
292
  }
181
293
 
294
+ /** Input for creating a reference surface from JS/TS. */
295
+ export type ReferenceSurfaceInput =
296
+ | { type: "Polygon"; points: Array<Point>; elevation: number }
297
+ | { type: "Rectangle"; points: [Point, Point]; elevation: number };
298
+
182
299
  export type Scale =
183
- | {
184
- type: "Area";
185
- id: string;
186
- pageId: string;
187
- scale: ScaleDefinition;
188
- boundingBox: [Point, Point];
189
- }
190
- | { type: "Default"; id: string; pageId: string; scale: ScaleDefinition };
300
+ | {
301
+ type: "Area";
302
+ id: string;
303
+ pageId: string;
304
+ scale: ScaleDefinition;
305
+ boundingBox: [Point, Point];
306
+ }
307
+ | { type: "Default"; id: string; pageId: string; scale: ScaleDefinition };
191
308
 
192
309
  export interface ScaleDefinition {
193
- pixelDistance: number;
194
- realDistance: number;
195
- unit: Unit;
310
+ pixelDistance: number;
311
+ realDistance: number;
312
+ unit: Unit;
196
313
  }
197
314
 
315
+ /** Simplify a polyline using the Ramer-Douglas-Peucker algorithm */
316
+ export declare function simplifyPolyline(
317
+ points: Array<Point>,
318
+ tolerance: number,
319
+ ): Array<Point>;
320
+
198
321
  export interface StateOptions {
199
- pages: Array<Page>;
200
- groups: Array<Group>;
201
- measurements: Array<Measurement>;
202
- scales: Array<Scale>;
322
+ pages: Array<Page>;
323
+ groups: Array<Group>;
324
+ measurements: Array<Measurement>;
325
+ scales: Array<Scale>;
203
326
  }
204
327
 
205
328
  /** Measurement units supported by the system */
206
329
  export type Unit =
207
- /** Imperial units */
208
- | "Yards"
209
- | "Feet"
210
- | "Inches"
211
- /** Metric units */
212
- | "Meters"
213
- | "Centimeters";
330
+ /** Imperial units */
331
+ | "Yards"
332
+ | "Feet"
333
+ | "Inches"
334
+ /** Metric units */
335
+ | "Meters"
336
+ | "Centimeters";
214
337
 
215
338
  export type UnitValueItemType = "Area" | "Length";
339
+
340
+ /** Result of a volumetric cut/fill calculation. */
341
+ export interface VolumetricResult {
342
+ /** Volume to remove (terrain above reference). */
343
+ cut: number;
344
+ /** Volume to add (terrain below reference). */
345
+ fill: number;
346
+ /** Area where terrain data was unavailable (z_at returned None). */
347
+ uncoveredArea: number;
348
+ }