landxml 0.4.1 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # landxml
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fbd9682: Contour elevations from surface min/max elevations and increment are now calculated correctly (bugfix).
8
+
3
9
  ## 0.4.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -281,11 +281,14 @@ var linesToPolyLines = (lineSegments) => {
281
281
  return polylines;
282
282
  };
283
283
  var contourElevations = (minElevation, maxElevation, interval) => {
284
- if (maxElevation >= Infinity) {
284
+ if (!Number.isFinite(minElevation) || !Number.isFinite(maxElevation) || !Number.isFinite(interval)) {
285
285
  throw new Error("Contour elevations have to be finite numbers");
286
286
  }
287
+ if (minElevation + interval > maxElevation) {
288
+ throw new Error(`No contour lines at interval: ${interval} between elevation ${minElevation} and ${maxElevation}`);
289
+ }
287
290
  const elevations = [];
288
- let elevation = Math.ceil(minElevation * interval) / interval;
291
+ let elevation = Math.ceil(minElevation / interval) * interval;
289
292
  while (elevation < maxElevation) {
290
293
  elevations.push(elevation);
291
294
  elevation += interval;
package/dist/index.mjs CHANGED
@@ -246,11 +246,14 @@ var linesToPolyLines = (lineSegments) => {
246
246
  return polylines;
247
247
  };
248
248
  var contourElevations = (minElevation, maxElevation, interval) => {
249
- if (maxElevation >= Infinity) {
249
+ if (!Number.isFinite(minElevation) || !Number.isFinite(maxElevation) || !Number.isFinite(interval)) {
250
250
  throw new Error("Contour elevations have to be finite numbers");
251
251
  }
252
+ if (minElevation + interval > maxElevation) {
253
+ throw new Error(`No contour lines at interval: ${interval} between elevation ${minElevation} and ${maxElevation}`);
254
+ }
252
255
  const elevations = [];
253
- let elevation = Math.ceil(minElevation * interval) / interval;
256
+ let elevation = Math.ceil(minElevation / interval) * interval;
254
257
  while (elevation < maxElevation) {
255
258
  elevations.push(elevation);
256
259
  elevation += interval;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "landxml",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Parse LandXML surfaces on the modern web.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",