landxml 0.8.0 → 0.9.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.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/dist/index.js +13 -3
- package/dist/index.mjs +13 -3
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# landxml
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 604418b: Replaced proj4 dependency with mproj, which has more accurate transformation results.
|
|
8
|
+
|
|
9
|
+
## 0.8.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- e886c37: Return empty geojson and console.warn rather than throwing error when generating contours.
|
|
14
|
+
|
|
3
15
|
## 0.8.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Easily transform LandXML surfaces into GeoJSON contours or GLB 3D models for use
|
|
|
9
9
|
- **`toGlbAndContours`** — Generate both a GLB model and GeoJSON contours in a single pass (fastest when you need both outputs).
|
|
10
10
|
- **`toGlb`** — Generate a GLB 3D model from LandXML surfaces.
|
|
11
11
|
- **`toGeojsonContours`** — Convert LandXML surfaces into contour line GeoJSON.
|
|
12
|
-
- **`reprojectGeoJson`** — Reproject GeoJSON coordinates to any projection using `
|
|
12
|
+
- **`reprojectGeoJson`** — Reproject GeoJSON coordinates to any projection using `mproj`.
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -117,7 +117,7 @@ const byIndex = await toGeojsonContours(landXmlString, 2, true, 1);
|
|
|
117
117
|
|
|
118
118
|
### Reproject GeoJSON
|
|
119
119
|
|
|
120
|
-
`reprojectGeoJson` wraps `
|
|
120
|
+
`reprojectGeoJson` wraps `mproj` and works with both WKT strings (exported by Civil 3D when a drawing is geo-referenced) and standard proj4 definition strings.
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
import { reprojectGeoJson } from "landxml";
|
package/dist/index.js
CHANGED
|
@@ -448,7 +448,8 @@ var contourElevations = (minElevation, maxElevation, interval) => {
|
|
|
448
448
|
throw new Error("Contour elevations have to be finite numbers");
|
|
449
449
|
}
|
|
450
450
|
if (minElevation + interval > maxElevation) {
|
|
451
|
-
|
|
451
|
+
console.warn(`No contour lines at interval: ${interval} between elevation ${minElevation} and ${maxElevation}`);
|
|
452
|
+
return [];
|
|
452
453
|
}
|
|
453
454
|
const elevations = [];
|
|
454
455
|
const firstStep = Math.ceil(minElevation / interval);
|
|
@@ -501,6 +502,7 @@ var bucketTrianglesByElevation = (triangles, elevations, interval) => {
|
|
|
501
502
|
var getContours = (data, interval = 2, precomputed) => __async(null, null, function* () {
|
|
502
503
|
const { triangles, minElevation, maxElevation } = precomputed != null ? precomputed : precomputeSurfaceData(data);
|
|
503
504
|
const elevations = contourElevations(minElevation, maxElevation, interval);
|
|
505
|
+
if (elevations.length === 0) return constructGeojson([]);
|
|
504
506
|
const trianglesByElevation = bucketTrianglesByElevation(triangles, elevations, interval);
|
|
505
507
|
const elevationPolylines = yield Promise.all(
|
|
506
508
|
elevations.map(
|
|
@@ -563,15 +565,23 @@ var toGeojsonContours = (landXmlString, contourInterval = 2, generateOutline = t
|
|
|
563
565
|
var to_geojson_contours_default = toGeojsonContours;
|
|
564
566
|
|
|
565
567
|
// src/public/reproject-geojson.ts
|
|
566
|
-
var
|
|
568
|
+
var import_mproj = __toESM(require("mproj"));
|
|
569
|
+
var NAMED_PROJECTIONS = {
|
|
570
|
+
WGS84: "+proj=longlat +datum=WGS84 +no_defs"
|
|
571
|
+
};
|
|
567
572
|
var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
|
|
568
573
|
const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
|
|
574
|
+
var _a, _b;
|
|
569
575
|
if (Array.isArray(coordinates[0])) {
|
|
570
576
|
coordinates = coordinates.map(
|
|
571
577
|
(subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
|
|
572
578
|
);
|
|
573
579
|
} else {
|
|
574
|
-
coordinates = (0,
|
|
580
|
+
coordinates = (0, import_mproj.default)(
|
|
581
|
+
(_a = NAMED_PROJECTIONS[sourceProjection2]) != null ? _a : sourceProjection2,
|
|
582
|
+
(_b = NAMED_PROJECTIONS[targetProjection2]) != null ? _b : targetProjection2,
|
|
583
|
+
coordinates
|
|
584
|
+
);
|
|
575
585
|
}
|
|
576
586
|
return coordinates;
|
|
577
587
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -411,7 +411,8 @@ var contourElevations = (minElevation, maxElevation, interval) => {
|
|
|
411
411
|
throw new Error("Contour elevations have to be finite numbers");
|
|
412
412
|
}
|
|
413
413
|
if (minElevation + interval > maxElevation) {
|
|
414
|
-
|
|
414
|
+
console.warn(`No contour lines at interval: ${interval} between elevation ${minElevation} and ${maxElevation}`);
|
|
415
|
+
return [];
|
|
415
416
|
}
|
|
416
417
|
const elevations = [];
|
|
417
418
|
const firstStep = Math.ceil(minElevation / interval);
|
|
@@ -464,6 +465,7 @@ var bucketTrianglesByElevation = (triangles, elevations, interval) => {
|
|
|
464
465
|
var getContours = (data, interval = 2, precomputed) => __async(null, null, function* () {
|
|
465
466
|
const { triangles, minElevation, maxElevation } = precomputed != null ? precomputed : precomputeSurfaceData(data);
|
|
466
467
|
const elevations = contourElevations(minElevation, maxElevation, interval);
|
|
468
|
+
if (elevations.length === 0) return constructGeojson([]);
|
|
467
469
|
const trianglesByElevation = bucketTrianglesByElevation(triangles, elevations, interval);
|
|
468
470
|
const elevationPolylines = yield Promise.all(
|
|
469
471
|
elevations.map(
|
|
@@ -526,15 +528,23 @@ var toGeojsonContours = (landXmlString, contourInterval = 2, generateOutline = t
|
|
|
526
528
|
var to_geojson_contours_default = toGeojsonContours;
|
|
527
529
|
|
|
528
530
|
// src/public/reproject-geojson.ts
|
|
529
|
-
import
|
|
531
|
+
import proj from "mproj";
|
|
532
|
+
var NAMED_PROJECTIONS = {
|
|
533
|
+
WGS84: "+proj=longlat +datum=WGS84 +no_defs"
|
|
534
|
+
};
|
|
530
535
|
var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
|
|
531
536
|
const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
|
|
537
|
+
var _a, _b;
|
|
532
538
|
if (Array.isArray(coordinates[0])) {
|
|
533
539
|
coordinates = coordinates.map(
|
|
534
540
|
(subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
|
|
535
541
|
);
|
|
536
542
|
} else {
|
|
537
|
-
coordinates =
|
|
543
|
+
coordinates = proj(
|
|
544
|
+
(_a = NAMED_PROJECTIONS[sourceProjection2]) != null ? _a : sourceProjection2,
|
|
545
|
+
(_b = NAMED_PROJECTIONS[targetProjection2]) != null ? _b : targetProjection2,
|
|
546
|
+
coordinates
|
|
547
|
+
);
|
|
538
548
|
}
|
|
539
549
|
return coordinates;
|
|
540
550
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "landxml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Parse LandXML surfaces on the modern web.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@changesets/cli": "^2.29.6",
|
|
31
31
|
"@types/geojson": "^7946.0.16",
|
|
32
|
-
"@types/proj4": "^2.5.6",
|
|
33
32
|
"@types/sax": "^1.2.7",
|
|
34
33
|
"@types/xml2json": "^0.11.6",
|
|
35
34
|
"jsdom": "^24.0.0",
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
"@gltf-transform/core": "^3.9.0",
|
|
42
41
|
"@vitest/web-worker": "^3.2.4",
|
|
43
42
|
"easy-web-worker": "^6.2.0",
|
|
44
|
-
"
|
|
43
|
+
"mproj": "^0.0.7",
|
|
45
44
|
"sax": "^1.4.1",
|
|
46
45
|
"xml-js": "^1.6.11"
|
|
47
46
|
}
|