landxml 0.8.1 → 0.9.1

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,17 @@
1
1
  # landxml
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e2122a2: Bugfix: WKT string not working with mproj update
8
+
9
+ ## 0.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 604418b: Replaced proj4 dependency with mproj, which has more accurate transformation results.
14
+
3
15
  ## 0.8.1
4
16
 
5
17
  ### Patch 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 `proj4`.
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 `proj4` and works with both WKT strings (exported by Civil 3D when a drawing is geo-referenced) and standard proj4 definition strings.
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,7 +565,16 @@ 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 import_proj4 = __toESM(require("proj4"));
568
+ var import_mproj = __toESM(require("mproj"));
569
+ var NAMED_PROJECTIONS = {
570
+ WGS84: "+proj=longlat +datum=WGS84 +no_defs"
571
+ };
572
+ var toProj4String = (projection) => {
573
+ if (NAMED_PROJECTIONS[projection]) return NAMED_PROJECTIONS[projection];
574
+ if (/^(PROJCS|GEOGCS|COMPD_CS|GEOCCS|VERT_CS|LOCAL_CS)\s*\[/i.test(projection.trim()))
575
+ return import_mproj.default.internal.wkt_to_proj4(projection);
576
+ return projection;
577
+ };
569
578
  var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
570
579
  const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
571
580
  if (Array.isArray(coordinates[0])) {
@@ -573,7 +582,7 @@ var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", k
573
582
  (subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
574
583
  );
575
584
  } else {
576
- coordinates = (0, import_proj4.default)(sourceProjection2, targetProjection2, coordinates);
585
+ coordinates = (0, import_mproj.default)(toProj4String(sourceProjection2), toProj4String(targetProjection2), coordinates);
577
586
  }
578
587
  return coordinates;
579
588
  };
package/dist/index.mjs CHANGED
@@ -528,7 +528,16 @@ 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 proj4 from "proj4";
531
+ import proj from "mproj";
532
+ var NAMED_PROJECTIONS = {
533
+ WGS84: "+proj=longlat +datum=WGS84 +no_defs"
534
+ };
535
+ var toProj4String = (projection) => {
536
+ if (NAMED_PROJECTIONS[projection]) return NAMED_PROJECTIONS[projection];
537
+ if (/^(PROJCS|GEOGCS|COMPD_CS|GEOCCS|VERT_CS|LOCAL_CS)\s*\[/i.test(projection.trim()))
538
+ return proj.internal.wkt_to_proj4(projection);
539
+ return projection;
540
+ };
532
541
  var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
533
542
  const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
534
543
  if (Array.isArray(coordinates[0])) {
@@ -536,7 +545,7 @@ var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", k
536
545
  (subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
537
546
  );
538
547
  } else {
539
- coordinates = proj4(sourceProjection2, targetProjection2, coordinates);
548
+ coordinates = proj(toProj4String(sourceProjection2), toProj4String(targetProjection2), coordinates);
540
549
  }
541
550
  return coordinates;
542
551
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "landxml",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
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
- "proj4": "^2.9.2",
43
+ "mproj": "^0.0.7",
45
44
  "sax": "^1.4.1",
46
45
  "xml-js": "^1.6.11"
47
46
  }