landxml 0.8.1 → 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 +6 -0
- package/README.md +2 -2
- package/dist/index.js +10 -2
- package/dist/index.mjs +10 -2
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
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
|
@@ -565,15 +565,23 @@ var toGeojsonContours = (landXmlString, contourInterval = 2, generateOutline = t
|
|
|
565
565
|
var to_geojson_contours_default = toGeojsonContours;
|
|
566
566
|
|
|
567
567
|
// src/public/reproject-geojson.ts
|
|
568
|
-
var
|
|
568
|
+
var import_mproj = __toESM(require("mproj"));
|
|
569
|
+
var NAMED_PROJECTIONS = {
|
|
570
|
+
WGS84: "+proj=longlat +datum=WGS84 +no_defs"
|
|
571
|
+
};
|
|
569
572
|
var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
|
|
570
573
|
const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
|
|
574
|
+
var _a, _b;
|
|
571
575
|
if (Array.isArray(coordinates[0])) {
|
|
572
576
|
coordinates = coordinates.map(
|
|
573
577
|
(subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
|
|
574
578
|
);
|
|
575
579
|
} else {
|
|
576
|
-
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
|
+
);
|
|
577
585
|
}
|
|
578
586
|
return coordinates;
|
|
579
587
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -528,15 +528,23 @@ var toGeojsonContours = (landXmlString, contourInterval = 2, generateOutline = t
|
|
|
528
528
|
var to_geojson_contours_default = toGeojsonContours;
|
|
529
529
|
|
|
530
530
|
// src/public/reproject-geojson.ts
|
|
531
|
-
import
|
|
531
|
+
import proj from "mproj";
|
|
532
|
+
var NAMED_PROJECTIONS = {
|
|
533
|
+
WGS84: "+proj=longlat +datum=WGS84 +no_defs"
|
|
534
|
+
};
|
|
532
535
|
var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
|
|
533
536
|
const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
|
|
537
|
+
var _a, _b;
|
|
534
538
|
if (Array.isArray(coordinates[0])) {
|
|
535
539
|
coordinates = coordinates.map(
|
|
536
540
|
(subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
|
|
537
541
|
);
|
|
538
542
|
} else {
|
|
539
|
-
coordinates =
|
|
543
|
+
coordinates = proj(
|
|
544
|
+
(_a = NAMED_PROJECTIONS[sourceProjection2]) != null ? _a : sourceProjection2,
|
|
545
|
+
(_b = NAMED_PROJECTIONS[targetProjection2]) != null ? _b : targetProjection2,
|
|
546
|
+
coordinates
|
|
547
|
+
);
|
|
540
548
|
}
|
|
541
549
|
return coordinates;
|
|
542
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
|
}
|