@loaders.gl/flatgeobuf 4.4.0-alpha.13 → 4.4.0-alpha.15

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/dist/dist.dev.js CHANGED
@@ -269,6 +269,328 @@ var __exports__ = (() => {
269
269
  return self;
270
270
  }
271
271
 
272
+ // ../../node_modules/wkt-parser/PROJJSONBuilderBase.js
273
+ var PROJJSONBuilderBase = class {
274
+ static getId(node) {
275
+ const idNode = node.find((child) => Array.isArray(child) && child[0] === "ID");
276
+ if (idNode && idNode.length >= 3) {
277
+ return {
278
+ authority: idNode[1],
279
+ code: parseInt(idNode[2], 10)
280
+ };
281
+ }
282
+ return null;
283
+ }
284
+ static convertUnit(node, type = "unit") {
285
+ if (!node || node.length < 3) {
286
+ return { type, name: "unknown", conversion_factor: null };
287
+ }
288
+ const name = node[1];
289
+ const conversionFactor = parseFloat(node[2]) || null;
290
+ const idNode = node.find((child) => Array.isArray(child) && child[0] === "ID");
291
+ const id = idNode ? {
292
+ authority: idNode[1],
293
+ code: parseInt(idNode[2], 10)
294
+ } : null;
295
+ return {
296
+ type,
297
+ name,
298
+ conversion_factor: conversionFactor,
299
+ id
300
+ };
301
+ }
302
+ static convertAxis(node) {
303
+ const name = node[1] || "Unknown";
304
+ let direction;
305
+ const abbreviationMatch = name.match(/^\((.)\)$/);
306
+ if (abbreviationMatch) {
307
+ const abbreviation = abbreviationMatch[1].toUpperCase();
308
+ if (abbreviation === "E")
309
+ direction = "east";
310
+ else if (abbreviation === "N")
311
+ direction = "north";
312
+ else if (abbreviation === "U")
313
+ direction = "up";
314
+ else
315
+ throw new Error(`Unknown axis abbreviation: ${abbreviation}`);
316
+ } else {
317
+ direction = node[2] ? node[2].toLowerCase() : "unknown";
318
+ }
319
+ const orderNode = node.find((child) => Array.isArray(child) && child[0] === "ORDER");
320
+ const order = orderNode ? parseInt(orderNode[1], 10) : null;
321
+ const unitNode = node.find(
322
+ (child) => Array.isArray(child) && (child[0] === "LENGTHUNIT" || child[0] === "ANGLEUNIT" || child[0] === "SCALEUNIT")
323
+ );
324
+ const unit = this.convertUnit(unitNode);
325
+ return {
326
+ name,
327
+ direction,
328
+ // Use the valid PROJJSON direction value
329
+ unit,
330
+ order
331
+ };
332
+ }
333
+ static extractAxes(node) {
334
+ return node.filter((child) => Array.isArray(child) && child[0] === "AXIS").map((axis) => this.convertAxis(axis)).sort((a, b) => (a.order || 0) - (b.order || 0));
335
+ }
336
+ static convert(node, result = {}) {
337
+ switch (node[0]) {
338
+ case "PROJCRS":
339
+ result.type = "ProjectedCRS";
340
+ result.name = node[1];
341
+ result.base_crs = node.find((child) => Array.isArray(child) && child[0] === "BASEGEOGCRS") ? this.convert(node.find((child) => Array.isArray(child) && child[0] === "BASEGEOGCRS")) : null;
342
+ result.conversion = node.find((child) => Array.isArray(child) && child[0] === "CONVERSION") ? this.convert(node.find((child) => Array.isArray(child) && child[0] === "CONVERSION")) : null;
343
+ const csNode = node.find((child) => Array.isArray(child) && child[0] === "CS");
344
+ if (csNode) {
345
+ result.coordinate_system = {
346
+ type: csNode[1],
347
+ axis: this.extractAxes(node)
348
+ };
349
+ }
350
+ const lengthUnitNode = node.find((child) => Array.isArray(child) && child[0] === "LENGTHUNIT");
351
+ if (lengthUnitNode) {
352
+ const unit2 = this.convertUnit(lengthUnitNode);
353
+ result.coordinate_system.unit = unit2;
354
+ }
355
+ result.id = this.getId(node);
356
+ break;
357
+ case "BASEGEOGCRS":
358
+ case "GEOGCRS":
359
+ result.type = "GeographicCRS";
360
+ result.name = node[1];
361
+ const datumOrEnsembleNode = node.find(
362
+ (child) => Array.isArray(child) && (child[0] === "DATUM" || child[0] === "ENSEMBLE")
363
+ );
364
+ if (datumOrEnsembleNode) {
365
+ const datumOrEnsemble = this.convert(datumOrEnsembleNode);
366
+ if (datumOrEnsembleNode[0] === "ENSEMBLE") {
367
+ result.datum_ensemble = datumOrEnsemble;
368
+ } else {
369
+ result.datum = datumOrEnsemble;
370
+ }
371
+ const primem = node.find((child) => Array.isArray(child) && child[0] === "PRIMEM");
372
+ if (primem && primem[1] !== "Greenwich") {
373
+ datumOrEnsemble.prime_meridian = {
374
+ name: primem[1],
375
+ longitude: parseFloat(primem[2])
376
+ };
377
+ }
378
+ }
379
+ result.coordinate_system = {
380
+ type: "ellipsoidal",
381
+ axis: this.extractAxes(node)
382
+ };
383
+ result.id = this.getId(node);
384
+ break;
385
+ case "DATUM":
386
+ result.type = "GeodeticReferenceFrame";
387
+ result.name = node[1];
388
+ result.ellipsoid = node.find((child) => Array.isArray(child) && child[0] === "ELLIPSOID") ? this.convert(node.find((child) => Array.isArray(child) && child[0] === "ELLIPSOID")) : null;
389
+ break;
390
+ case "ENSEMBLE":
391
+ result.type = "DatumEnsemble";
392
+ result.name = node[1];
393
+ result.members = node.filter((child) => Array.isArray(child) && child[0] === "MEMBER").map((member) => ({
394
+ type: "DatumEnsembleMember",
395
+ name: member[1],
396
+ id: this.getId(member)
397
+ // Extract ID as { authority, code }
398
+ }));
399
+ const accuracyNode = node.find((child) => Array.isArray(child) && child[0] === "ENSEMBLEACCURACY");
400
+ if (accuracyNode) {
401
+ result.accuracy = parseFloat(accuracyNode[1]);
402
+ }
403
+ const ellipsoidNode = node.find((child) => Array.isArray(child) && child[0] === "ELLIPSOID");
404
+ if (ellipsoidNode) {
405
+ result.ellipsoid = this.convert(ellipsoidNode);
406
+ }
407
+ result.id = this.getId(node);
408
+ break;
409
+ case "ELLIPSOID":
410
+ result.type = "Ellipsoid";
411
+ result.name = node[1];
412
+ result.semi_major_axis = parseFloat(node[2]);
413
+ result.inverse_flattening = parseFloat(node[3]);
414
+ const units = node.find((child) => Array.isArray(child) && child[0] === "LENGTHUNIT") ? this.convert(node.find((child) => Array.isArray(child) && child[0] === "LENGTHUNIT"), result) : null;
415
+ break;
416
+ case "CONVERSION":
417
+ result.type = "Conversion";
418
+ result.name = node[1];
419
+ result.method = node.find((child) => Array.isArray(child) && child[0] === "METHOD") ? this.convert(node.find((child) => Array.isArray(child) && child[0] === "METHOD")) : null;
420
+ result.parameters = node.filter((child) => Array.isArray(child) && child[0] === "PARAMETER").map((param) => this.convert(param));
421
+ break;
422
+ case "METHOD":
423
+ result.type = "Method";
424
+ result.name = node[1];
425
+ result.id = this.getId(node);
426
+ break;
427
+ case "PARAMETER":
428
+ result.type = "Parameter";
429
+ result.name = node[1];
430
+ result.value = parseFloat(node[2]);
431
+ result.unit = this.convertUnit(
432
+ node.find(
433
+ (child) => Array.isArray(child) && (child[0] === "LENGTHUNIT" || child[0] === "ANGLEUNIT" || child[0] === "SCALEUNIT")
434
+ )
435
+ );
436
+ result.id = this.getId(node);
437
+ break;
438
+ case "BOUNDCRS":
439
+ result.type = "BoundCRS";
440
+ const sourceCrsNode = node.find((child) => Array.isArray(child) && child[0] === "SOURCECRS");
441
+ if (sourceCrsNode) {
442
+ const sourceCrsContent = sourceCrsNode.find((child) => Array.isArray(child));
443
+ result.source_crs = sourceCrsContent ? this.convert(sourceCrsContent) : null;
444
+ }
445
+ const targetCrsNode = node.find((child) => Array.isArray(child) && child[0] === "TARGETCRS");
446
+ if (targetCrsNode) {
447
+ const targetCrsContent = targetCrsNode.find((child) => Array.isArray(child));
448
+ result.target_crs = targetCrsContent ? this.convert(targetCrsContent) : null;
449
+ }
450
+ const transformationNode = node.find((child) => Array.isArray(child) && child[0] === "ABRIDGEDTRANSFORMATION");
451
+ if (transformationNode) {
452
+ result.transformation = this.convert(transformationNode);
453
+ } else {
454
+ result.transformation = null;
455
+ }
456
+ break;
457
+ case "ABRIDGEDTRANSFORMATION":
458
+ result.type = "Transformation";
459
+ result.name = node[1];
460
+ result.method = node.find((child) => Array.isArray(child) && child[0] === "METHOD") ? this.convert(node.find((child) => Array.isArray(child) && child[0] === "METHOD")) : null;
461
+ result.parameters = node.filter((child) => Array.isArray(child) && (child[0] === "PARAMETER" || child[0] === "PARAMETERFILE")).map((param) => {
462
+ if (param[0] === "PARAMETER") {
463
+ return this.convert(param);
464
+ } else if (param[0] === "PARAMETERFILE") {
465
+ return {
466
+ name: param[1],
467
+ value: param[2],
468
+ id: {
469
+ "authority": "EPSG",
470
+ "code": 8656
471
+ }
472
+ };
473
+ }
474
+ });
475
+ if (result.parameters.length === 7) {
476
+ const scaleDifference = result.parameters[6];
477
+ if (scaleDifference.name === "Scale difference") {
478
+ scaleDifference.value = Math.round((scaleDifference.value - 1) * 1e12) / 1e6;
479
+ }
480
+ }
481
+ result.id = this.getId(node);
482
+ break;
483
+ case "AXIS":
484
+ if (!result.coordinate_system) {
485
+ result.coordinate_system = { type: "unspecified", axis: [] };
486
+ }
487
+ result.coordinate_system.axis.push(this.convertAxis(node));
488
+ break;
489
+ case "LENGTHUNIT":
490
+ const unit = this.convertUnit(node, "LinearUnit");
491
+ if (result.coordinate_system && result.coordinate_system.axis) {
492
+ result.coordinate_system.axis.forEach((axis) => {
493
+ if (!axis.unit) {
494
+ axis.unit = unit;
495
+ }
496
+ });
497
+ }
498
+ if (unit.conversion_factor && unit.conversion_factor !== 1) {
499
+ if (result.semi_major_axis) {
500
+ result.semi_major_axis = {
501
+ value: result.semi_major_axis,
502
+ unit
503
+ };
504
+ }
505
+ }
506
+ break;
507
+ default:
508
+ result.keyword = node[0];
509
+ break;
510
+ }
511
+ return result;
512
+ }
513
+ };
514
+ var PROJJSONBuilderBase_default = PROJJSONBuilderBase;
515
+
516
+ // ../../node_modules/wkt-parser/PROJJSONBuilder2015.js
517
+ var PROJJSONBuilder2015 = class extends PROJJSONBuilderBase_default {
518
+ static convert(node, result = {}) {
519
+ super.convert(node, result);
520
+ if (result.coordinate_system && result.coordinate_system.subtype === "Cartesian") {
521
+ delete result.coordinate_system;
522
+ }
523
+ if (result.usage) {
524
+ delete result.usage;
525
+ }
526
+ return result;
527
+ }
528
+ };
529
+ var PROJJSONBuilder2015_default = PROJJSONBuilder2015;
530
+
531
+ // ../../node_modules/wkt-parser/PROJJSONBuilder2019.js
532
+ var PROJJSONBuilder2019 = class extends PROJJSONBuilderBase_default {
533
+ static convert(node, result = {}) {
534
+ super.convert(node, result);
535
+ const csNode = node.find((child) => Array.isArray(child) && child[0] === "CS");
536
+ if (csNode) {
537
+ result.coordinate_system = {
538
+ subtype: csNode[1],
539
+ axis: this.extractAxes(node)
540
+ };
541
+ }
542
+ const usageNode = node.find((child) => Array.isArray(child) && child[0] === "USAGE");
543
+ if (usageNode) {
544
+ const scope = usageNode.find((child) => Array.isArray(child) && child[0] === "SCOPE");
545
+ const area = usageNode.find((child) => Array.isArray(child) && child[0] === "AREA");
546
+ const bbox = usageNode.find((child) => Array.isArray(child) && child[0] === "BBOX");
547
+ result.usage = {};
548
+ if (scope) {
549
+ result.usage.scope = scope[1];
550
+ }
551
+ if (area) {
552
+ result.usage.area = area[1];
553
+ }
554
+ if (bbox) {
555
+ result.usage.bbox = bbox.slice(1);
556
+ }
557
+ }
558
+ return result;
559
+ }
560
+ };
561
+ var PROJJSONBuilder2019_default = PROJJSONBuilder2019;
562
+
563
+ // ../../node_modules/wkt-parser/buildPROJJSON.js
564
+ function detectWKT2Version(root) {
565
+ if (root.find((child) => Array.isArray(child) && child[0] === "USAGE")) {
566
+ return "2019";
567
+ }
568
+ if (root.find((child) => Array.isArray(child) && child[0] === "CS")) {
569
+ return "2015";
570
+ }
571
+ if (root[0] === "BOUNDCRS" || root[0] === "PROJCRS" || root[0] === "GEOGCRS") {
572
+ return "2015";
573
+ }
574
+ return "2015";
575
+ }
576
+ function buildPROJJSON(root) {
577
+ const version = detectWKT2Version(root);
578
+ const builder = version === "2019" ? PROJJSONBuilder2019_default : PROJJSONBuilder2015_default;
579
+ return builder.convert(root);
580
+ }
581
+
582
+ // ../../node_modules/wkt-parser/detectWKTVersion.js
583
+ function detectWKTVersion(wkt) {
584
+ const normalizedWKT = wkt.toUpperCase();
585
+ if (normalizedWKT.includes("PROJCRS") || normalizedWKT.includes("GEOGCRS") || normalizedWKT.includes("BOUNDCRS") || normalizedWKT.includes("VERTCRS") || normalizedWKT.includes("LENGTHUNIT") || normalizedWKT.includes("ANGLEUNIT") || normalizedWKT.includes("SCALEUNIT")) {
586
+ return "WKT2";
587
+ }
588
+ if (normalizedWKT.includes("PROJCS") || normalizedWKT.includes("GEOGCS") || normalizedWKT.includes("LOCAL_CS") || normalizedWKT.includes("VERT_CS") || normalizedWKT.includes("UNIT")) {
589
+ return "WKT1";
590
+ }
591
+ return "WKT1";
592
+ }
593
+
272
594
  // ../../node_modules/wkt-parser/parser.js
273
595
  var parser_default = parseString;
274
596
  var NEUTRAL = 1;
@@ -511,6 +833,19 @@ var __exports__ = (() => {
511
833
  sExpr(v[3], obj[key]);
512
834
  }
513
835
  return;
836
+ case "EDATUM":
837
+ case "ENGINEERINGDATUM":
838
+ case "LOCAL_DATUM":
839
+ case "DATUM":
840
+ case "VERT_CS":
841
+ case "VERTCRS":
842
+ case "VERTICALCRS":
843
+ v[0] = ["name", v[0]];
844
+ mapit(obj, key, v);
845
+ return;
846
+ case "COMPD_CS":
847
+ case "COMPOUNDCRS":
848
+ case "FITTED_CS":
514
849
  case "PROJECTEDCRS":
515
850
  case "PROJCRS":
516
851
  case "GEOGCS":
@@ -520,20 +855,11 @@ var __exports__ = (() => {
520
855
  case "GEODCRS":
521
856
  case "GEODETICCRS":
522
857
  case "GEODETICDATUM":
523
- case "EDATUM":
524
- case "ENGINEERINGDATUM":
525
- case "VERT_CS":
526
- case "VERTCRS":
527
- case "VERTICALCRS":
528
- case "COMPD_CS":
529
- case "COMPOUNDCRS":
530
- case "ENGINEERINGCRS":
531
858
  case "ENGCRS":
532
- case "FITTED_CS":
533
- case "LOCAL_DATUM":
534
- case "DATUM":
859
+ case "ENGINEERINGCRS":
535
860
  v[0] = ["name", v[0]];
536
861
  mapit(obj, key, v);
862
+ obj[key].type = key;
537
863
  return;
538
864
  default:
539
865
  i = -1;
@@ -546,8 +872,276 @@ var __exports__ = (() => {
546
872
  }
547
873
  }
548
874
 
549
- // ../../node_modules/wkt-parser/index.js
875
+ // ../../node_modules/wkt-parser/util.js
550
876
  var D2R2 = 0.017453292519943295;
877
+ function d2r(input) {
878
+ return input * D2R2;
879
+ }
880
+ function applyProjectionDefaults(wkt) {
881
+ const normalizedProjName = (wkt.projName || "").toLowerCase().replace(/_/g, " ");
882
+ if (!wkt.long0 && wkt.longc && (normalizedProjName === "albers conic equal area" || normalizedProjName === "lambert azimuthal equal area")) {
883
+ wkt.long0 = wkt.longc;
884
+ }
885
+ if (!wkt.lat_ts && wkt.lat1 && (normalizedProjName === "stereographic south pole" || normalizedProjName === "polar stereographic (variant b)")) {
886
+ wkt.lat0 = d2r(wkt.lat1 > 0 ? 90 : -90);
887
+ wkt.lat_ts = wkt.lat1;
888
+ delete wkt.lat1;
889
+ } else if (!wkt.lat_ts && wkt.lat0 && (normalizedProjName === "polar stereographic" || normalizedProjName === "polar stereographic (variant a)")) {
890
+ wkt.lat_ts = wkt.lat0;
891
+ wkt.lat0 = d2r(wkt.lat0 > 0 ? 90 : -90);
892
+ delete wkt.lat1;
893
+ }
894
+ }
895
+
896
+ // ../../node_modules/wkt-parser/transformPROJJSON.js
897
+ function processUnit(unit) {
898
+ let result = { units: null, to_meter: void 0 };
899
+ if (typeof unit === "string") {
900
+ result.units = unit.toLowerCase();
901
+ if (result.units === "metre") {
902
+ result.units = "meter";
903
+ }
904
+ if (result.units === "meter") {
905
+ result.to_meter = 1;
906
+ }
907
+ } else if (unit && unit.name) {
908
+ result.units = unit.name.toLowerCase();
909
+ if (result.units === "metre") {
910
+ result.units = "meter";
911
+ }
912
+ result.to_meter = unit.conversion_factor;
913
+ }
914
+ return result;
915
+ }
916
+ function toValue(valueOrObject) {
917
+ if (typeof valueOrObject === "object") {
918
+ return valueOrObject.value * valueOrObject.unit.conversion_factor;
919
+ }
920
+ return valueOrObject;
921
+ }
922
+ function calculateEllipsoid(value, result) {
923
+ if (value.ellipsoid.radius) {
924
+ result.a = value.ellipsoid.radius;
925
+ result.rf = 0;
926
+ } else {
927
+ result.a = toValue(value.ellipsoid.semi_major_axis);
928
+ if (value.ellipsoid.inverse_flattening !== void 0) {
929
+ result.rf = value.ellipsoid.inverse_flattening;
930
+ } else if (value.ellipsoid.semi_major_axis !== void 0 && value.ellipsoid.semi_minor_axis !== void 0) {
931
+ result.rf = result.a / (result.a - toValue(value.ellipsoid.semi_minor_axis));
932
+ }
933
+ }
934
+ }
935
+ function transformPROJJSON(projjson, result = {}) {
936
+ if (!projjson || typeof projjson !== "object") {
937
+ return projjson;
938
+ }
939
+ if (projjson.type === "BoundCRS") {
940
+ transformPROJJSON(projjson.source_crs, result);
941
+ if (projjson.transformation) {
942
+ if (projjson.transformation.method && projjson.transformation.method.name === "NTv2") {
943
+ result.nadgrids = projjson.transformation.parameters[0].value;
944
+ } else {
945
+ result.datum_params = projjson.transformation.parameters.map((param) => param.value);
946
+ }
947
+ }
948
+ return result;
949
+ }
950
+ Object.keys(projjson).forEach((key) => {
951
+ const value = projjson[key];
952
+ if (value === null) {
953
+ return;
954
+ }
955
+ switch (key) {
956
+ case "name":
957
+ if (result.srsCode) {
958
+ break;
959
+ }
960
+ result.name = value;
961
+ result.srsCode = value;
962
+ break;
963
+ case "type":
964
+ if (value === "GeographicCRS") {
965
+ result.projName = "longlat";
966
+ } else if (value === "ProjectedCRS" && projjson.conversion && projjson.conversion.method) {
967
+ result.projName = projjson.conversion.method.name;
968
+ }
969
+ break;
970
+ case "datum":
971
+ case "datum_ensemble":
972
+ if (value.ellipsoid) {
973
+ result.ellps = value.ellipsoid.name;
974
+ calculateEllipsoid(value, result);
975
+ }
976
+ if (value.prime_meridian) {
977
+ result.from_greenwich = value.prime_meridian.longitude * Math.PI / 180;
978
+ }
979
+ break;
980
+ case "ellipsoid":
981
+ result.ellps = value.name;
982
+ calculateEllipsoid(value, result);
983
+ break;
984
+ case "prime_meridian":
985
+ result.long0 = (value.longitude || 0) * Math.PI / 180;
986
+ break;
987
+ case "coordinate_system":
988
+ if (value.axis) {
989
+ result.axis = value.axis.map((axis) => {
990
+ const direction = axis.direction;
991
+ if (direction === "east")
992
+ return "e";
993
+ if (direction === "north")
994
+ return "n";
995
+ if (direction === "west")
996
+ return "w";
997
+ if (direction === "south")
998
+ return "s";
999
+ throw new Error(`Unknown axis direction: ${direction}`);
1000
+ }).join("") + "u";
1001
+ if (value.unit) {
1002
+ const { units, to_meter } = processUnit(value.unit);
1003
+ result.units = units;
1004
+ result.to_meter = to_meter;
1005
+ } else if (value.axis[0] && value.axis[0].unit) {
1006
+ const { units, to_meter } = processUnit(value.axis[0].unit);
1007
+ result.units = units;
1008
+ result.to_meter = to_meter;
1009
+ }
1010
+ }
1011
+ break;
1012
+ case "id":
1013
+ if (value.authority && value.code) {
1014
+ result.title = value.authority + ":" + value.code;
1015
+ }
1016
+ break;
1017
+ case "conversion":
1018
+ if (value.method && value.method.name) {
1019
+ result.projName = value.method.name;
1020
+ }
1021
+ if (value.parameters) {
1022
+ value.parameters.forEach((param) => {
1023
+ const paramName = param.name.toLowerCase().replace(/\s+/g, "_");
1024
+ const paramValue = param.value;
1025
+ if (param.unit && param.unit.conversion_factor) {
1026
+ result[paramName] = paramValue * param.unit.conversion_factor;
1027
+ } else if (param.unit === "degree") {
1028
+ result[paramName] = paramValue * Math.PI / 180;
1029
+ } else {
1030
+ result[paramName] = paramValue;
1031
+ }
1032
+ });
1033
+ }
1034
+ break;
1035
+ case "unit":
1036
+ if (value.name) {
1037
+ result.units = value.name.toLowerCase();
1038
+ if (result.units === "metre") {
1039
+ result.units = "meter";
1040
+ }
1041
+ }
1042
+ if (value.conversion_factor) {
1043
+ result.to_meter = value.conversion_factor;
1044
+ }
1045
+ break;
1046
+ case "base_crs":
1047
+ transformPROJJSON(value, result);
1048
+ result.datumCode = value.id ? value.id.authority + "_" + value.id.code : value.name;
1049
+ break;
1050
+ default:
1051
+ break;
1052
+ }
1053
+ });
1054
+ if (result.latitude_of_false_origin !== void 0) {
1055
+ result.lat0 = result.latitude_of_false_origin;
1056
+ }
1057
+ if (result.longitude_of_false_origin !== void 0) {
1058
+ result.long0 = result.longitude_of_false_origin;
1059
+ }
1060
+ if (result.latitude_of_standard_parallel !== void 0) {
1061
+ result.lat0 = result.latitude_of_standard_parallel;
1062
+ result.lat1 = result.latitude_of_standard_parallel;
1063
+ }
1064
+ if (result.latitude_of_1st_standard_parallel !== void 0) {
1065
+ result.lat1 = result.latitude_of_1st_standard_parallel;
1066
+ }
1067
+ if (result.latitude_of_2nd_standard_parallel !== void 0) {
1068
+ result.lat2 = result.latitude_of_2nd_standard_parallel;
1069
+ }
1070
+ if (result.latitude_of_projection_centre !== void 0) {
1071
+ result.lat0 = result.latitude_of_projection_centre;
1072
+ }
1073
+ if (result.longitude_of_projection_centre !== void 0) {
1074
+ result.longc = result.longitude_of_projection_centre;
1075
+ }
1076
+ if (result.easting_at_false_origin !== void 0) {
1077
+ result.x0 = result.easting_at_false_origin;
1078
+ }
1079
+ if (result.northing_at_false_origin !== void 0) {
1080
+ result.y0 = result.northing_at_false_origin;
1081
+ }
1082
+ if (result.latitude_of_natural_origin !== void 0) {
1083
+ result.lat0 = result.latitude_of_natural_origin;
1084
+ }
1085
+ if (result.longitude_of_natural_origin !== void 0) {
1086
+ result.long0 = result.longitude_of_natural_origin;
1087
+ }
1088
+ if (result.longitude_of_origin !== void 0) {
1089
+ result.long0 = result.longitude_of_origin;
1090
+ }
1091
+ if (result.false_easting !== void 0) {
1092
+ result.x0 = result.false_easting;
1093
+ }
1094
+ if (result.easting_at_projection_centre) {
1095
+ result.x0 = result.easting_at_projection_centre;
1096
+ }
1097
+ if (result.false_northing !== void 0) {
1098
+ result.y0 = result.false_northing;
1099
+ }
1100
+ if (result.northing_at_projection_centre) {
1101
+ result.y0 = result.northing_at_projection_centre;
1102
+ }
1103
+ if (result.standard_parallel_1 !== void 0) {
1104
+ result.lat1 = result.standard_parallel_1;
1105
+ }
1106
+ if (result.standard_parallel_2 !== void 0) {
1107
+ result.lat2 = result.standard_parallel_2;
1108
+ }
1109
+ if (result.scale_factor_at_natural_origin !== void 0) {
1110
+ result.k0 = result.scale_factor_at_natural_origin;
1111
+ }
1112
+ if (result.scale_factor_at_projection_centre !== void 0) {
1113
+ result.k0 = result.scale_factor_at_projection_centre;
1114
+ }
1115
+ if (result.scale_factor_on_pseudo_standard_parallel !== void 0) {
1116
+ result.k0 = result.scale_factor_on_pseudo_standard_parallel;
1117
+ }
1118
+ if (result.azimuth !== void 0) {
1119
+ result.alpha = result.azimuth;
1120
+ }
1121
+ if (result.azimuth_at_projection_centre !== void 0) {
1122
+ result.alpha = result.azimuth_at_projection_centre;
1123
+ }
1124
+ if (result.angle_from_rectified_to_skew_grid) {
1125
+ result.rectified_grid_angle = result.angle_from_rectified_to_skew_grid;
1126
+ }
1127
+ applyProjectionDefaults(result);
1128
+ return result;
1129
+ }
1130
+
1131
+ // ../../node_modules/wkt-parser/index.js
1132
+ var knownTypes = [
1133
+ "PROJECTEDCRS",
1134
+ "PROJCRS",
1135
+ "GEOGCS",
1136
+ "GEOCCS",
1137
+ "PROJCS",
1138
+ "LOCAL_CS",
1139
+ "GEODCRS",
1140
+ "GEODETICCRS",
1141
+ "GEODETICDATUM",
1142
+ "ENGCRS",
1143
+ "ENGINEERINGCRS"
1144
+ ];
551
1145
  function rename(obj, params) {
552
1146
  var outName = params[0];
553
1147
  var inName = params[1];
@@ -558,10 +1152,25 @@ var __exports__ = (() => {
558
1152
  }
559
1153
  }
560
1154
  }
561
- function d2r(input) {
562
- return input * D2R2;
563
- }
564
1155
  function cleanWKT(wkt) {
1156
+ var keys = Object.keys(wkt);
1157
+ for (var i = 0, ii = keys.length; i < ii; ++i) {
1158
+ var key = keys[i];
1159
+ if (knownTypes.indexOf(key) !== -1) {
1160
+ setPropertiesFromWkt(wkt[key]);
1161
+ }
1162
+ if (typeof wkt[key] === "object") {
1163
+ cleanWKT(wkt[key]);
1164
+ }
1165
+ }
1166
+ }
1167
+ function setPropertiesFromWkt(wkt) {
1168
+ if (wkt.AUTHORITY) {
1169
+ var authority = Object.keys(wkt.AUTHORITY)[0];
1170
+ if (authority && authority in wkt.AUTHORITY) {
1171
+ wkt.title = authority + ":" + wkt.AUTHORITY[authority];
1172
+ }
1173
+ }
565
1174
  if (wkt.type === "GEOGCS") {
566
1175
  wkt.projName = "longlat";
567
1176
  } else if (wkt.type === "LOCAL_CS") {
@@ -623,7 +1232,7 @@ var __exports__ = (() => {
623
1232
  if (wkt.datumCode.slice(0, 2) === "d_") {
624
1233
  wkt.datumCode = wkt.datumCode.slice(2);
625
1234
  }
626
- if (wkt.datumCode === "new_zealand_geodetic_datum_1949" || wkt.datumCode === "new_zealand_1949") {
1235
+ if (wkt.datumCode === "new_zealand_1949") {
627
1236
  wkt.datumCode = "nzgd49";
628
1237
  }
629
1238
  if (wkt.datumCode === "wgs_1984" || wkt.datumCode === "world_geodetic_system_1984") {
@@ -632,13 +1241,7 @@ var __exports__ = (() => {
632
1241
  }
633
1242
  wkt.datumCode = "wgs84";
634
1243
  }
635
- if (wkt.datumCode.slice(-6) === "_ferro") {
636
- wkt.datumCode = wkt.datumCode.slice(0, -6);
637
- }
638
- if (wkt.datumCode.slice(-8) === "_jakarta") {
639
- wkt.datumCode = wkt.datumCode.slice(0, -8);
640
- }
641
- if (~wkt.datumCode.indexOf("belge")) {
1244
+ if (wkt.datumCode === "belge_1972") {
642
1245
  wkt.datumCode = "rnb72";
643
1246
  }
644
1247
  if (geogcs.DATUM && geogcs.DATUM.SPHEROID) {
@@ -671,6 +1274,9 @@ var __exports__ = (() => {
671
1274
  if (wkt.b && !isFinite(wkt.b)) {
672
1275
  wkt.b = wkt.a;
673
1276
  }
1277
+ if (wkt.rectified_grid_angle) {
1278
+ wkt.rectified_grid_angle = d2r(wkt.rectified_grid_angle);
1279
+ }
674
1280
  function toMeter(input) {
675
1281
  var ratio = wkt.to_meter || 1;
676
1282
  return input * ratio;
@@ -716,27 +1322,23 @@ var __exports__ = (() => {
716
1322
  ["srsCode", "name"]
717
1323
  ];
718
1324
  list.forEach(renamer);
719
- if (!wkt.long0 && wkt.longc && (wkt.projName === "Albers_Conic_Equal_Area" || wkt.projName === "Lambert_Azimuthal_Equal_Area")) {
720
- wkt.long0 = wkt.longc;
721
- }
722
- if (!wkt.lat_ts && wkt.lat1 && (wkt.projName === "Stereographic_South_Pole" || wkt.projName === "Polar Stereographic (variant B)")) {
723
- wkt.lat0 = d2r(wkt.lat1 > 0 ? 90 : -90);
724
- wkt.lat_ts = wkt.lat1;
725
- } else if (!wkt.lat_ts && wkt.lat0 && wkt.projName === "Polar_Stereographic") {
726
- wkt.lat_ts = wkt.lat0;
727
- wkt.lat0 = d2r(wkt.lat0 > 0 ? 90 : -90);
728
- }
1325
+ applyProjectionDefaults(wkt);
729
1326
  }
730
1327
  function wkt_parser_default(wkt) {
1328
+ if (typeof wkt === "object") {
1329
+ return transformPROJJSON(wkt);
1330
+ }
1331
+ const version = detectWKTVersion(wkt);
731
1332
  var lisp = parser_default(wkt);
732
- var type = lisp.shift();
733
- var name = lisp.shift();
734
- lisp.unshift(["name", name]);
735
- lisp.unshift(["type", type]);
1333
+ if (version === "WKT2") {
1334
+ const projjson = buildPROJJSON(lisp);
1335
+ return transformPROJJSON(projjson);
1336
+ }
1337
+ var type = lisp[0];
736
1338
  var obj = {};
737
1339
  sExpr(lisp, obj);
738
1340
  cleanWKT(obj);
739
- return obj;
1341
+ return obj[type];
740
1342
  }
741
1343
 
742
1344
  // ../../node_modules/proj4/lib/defs.js