landxml 0.9.0 → 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,11 @@
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
+
3
9
  ## 0.9.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.js CHANGED
@@ -569,19 +569,20 @@ var import_mproj = __toESM(require("mproj"));
569
569
  var NAMED_PROJECTIONS = {
570
570
  WGS84: "+proj=longlat +datum=WGS84 +no_defs"
571
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
+ };
572
578
  var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
573
579
  const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
574
- var _a, _b;
575
580
  if (Array.isArray(coordinates[0])) {
576
581
  coordinates = coordinates.map(
577
582
  (subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
578
583
  );
579
584
  } else {
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
- );
585
+ coordinates = (0, import_mproj.default)(toProj4String(sourceProjection2), toProj4String(targetProjection2), coordinates);
585
586
  }
586
587
  return coordinates;
587
588
  };
package/dist/index.mjs CHANGED
@@ -532,19 +532,20 @@ import proj from "mproj";
532
532
  var NAMED_PROJECTIONS = {
533
533
  WGS84: "+proj=longlat +datum=WGS84 +no_defs"
534
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
+ };
535
541
  var reprojectGeoJson = (geojson, sourceProjection, targetProjection = "WGS84", keepOriginalGeometryAsFeatureProperty = true) => {
536
542
  const transformCoordinates = (coordinates, sourceProjection2, targetProjection2) => {
537
- var _a, _b;
538
543
  if (Array.isArray(coordinates[0])) {
539
544
  coordinates = coordinates.map(
540
545
  (subCoordinates) => transformCoordinates(subCoordinates, sourceProjection2, targetProjection2)
541
546
  );
542
547
  } else {
543
- coordinates = proj(
544
- (_a = NAMED_PROJECTIONS[sourceProjection2]) != null ? _a : sourceProjection2,
545
- (_b = NAMED_PROJECTIONS[targetProjection2]) != null ? _b : targetProjection2,
546
- coordinates
547
- );
548
+ coordinates = proj(toProj4String(sourceProjection2), toProj4String(targetProjection2), coordinates);
548
549
  }
549
550
  return coordinates;
550
551
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "landxml",
3
- "version": "0.9.0",
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",