@mailwoman/spatial 9.4.0 → 10.1.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.
Files changed (156) hide show
  1. package/README.md +2 -2
  2. package/lib/bbox.ts +41 -34
  3. package/lib/{coordinate-bounds.ts → coordinate/bounds.ts} +2 -2
  4. package/lib/{coordinate-formats.ts → coordinate/formats.ts} +11 -28
  5. package/lib/distance.ts +53 -27
  6. package/lib/feature.ts +2 -2
  7. package/lib/geometries/point.ts +41 -33
  8. package/lib/geometries/polygon.ts +24 -128
  9. package/lib/geometries/ring-blob.ts +33 -130
  10. package/lib/google/place-id.ts +4 -2
  11. package/lib/h3/cell.ts +21 -76
  12. package/lib/h3/coverage.ts +11 -7
  13. package/lib/h3/interior-cells.ts +13 -34
  14. package/lib/h3/polygon-cells.ts +59 -165
  15. package/lib/{h3/index.ts → h3.ts} +1 -1
  16. package/lib/index.ts +6 -6
  17. package/lib/objects.ts +6 -6
  18. package/lib/open-location-code.ts +11 -42
  19. package/lib/osgb36.ts +28 -187
  20. package/lib/polyline.ts +5 -3
  21. package/lib/position.ts +20 -4
  22. package/lib/projection/transform.ts +114 -0
  23. package/lib/projection.ts +1 -1
  24. package/lib/well-known-text.ts +8 -8
  25. package/out/bbox.d.ts +16 -13
  26. package/out/bbox.d.ts.map +1 -1
  27. package/out/bbox.js +32 -23
  28. package/out/bbox.js.map +1 -1
  29. package/out/{coordinate-bounds.d.ts → coordinate/bounds.d.ts} +3 -3
  30. package/out/coordinate/bounds.d.ts.map +1 -0
  31. package/out/{coordinate-bounds.js → coordinate/bounds.js} +3 -3
  32. package/out/coordinate/bounds.js.map +1 -0
  33. package/out/{coordinate-formats.d.ts → coordinate/formats.d.ts} +9 -12
  34. package/out/coordinate/formats.d.ts.map +1 -0
  35. package/out/{coordinate-formats.js → coordinate/formats.js} +12 -29
  36. package/out/coordinate/formats.js.map +1 -0
  37. package/out/distance.d.ts +48 -25
  38. package/out/distance.d.ts.map +1 -1
  39. package/out/distance.js +53 -27
  40. package/out/distance.js.map +1 -1
  41. package/out/feature.d.ts +2 -2
  42. package/out/feature.d.ts.map +1 -1
  43. package/out/geometries/point.d.ts +30 -22
  44. package/out/geometries/point.d.ts.map +1 -1
  45. package/out/geometries/point.js +35 -29
  46. package/out/geometries/point.js.map +1 -1
  47. package/out/geometries/polygon.d.ts +23 -122
  48. package/out/geometries/polygon.d.ts.map +1 -1
  49. package/out/geometries/polygon.js +13 -41
  50. package/out/geometries/polygon.js.map +1 -1
  51. package/out/geometries/ring-blob.d.ts +23 -109
  52. package/out/geometries/ring-blob.d.ts.map +1 -1
  53. package/out/geometries/ring-blob.js +29 -115
  54. package/out/geometries/ring-blob.js.map +1 -1
  55. package/out/{geometries/index.js → geometries.d.ts} +1 -1
  56. package/out/geometries.d.ts.map +1 -0
  57. package/out/{geometries/index.d.ts → geometries.js} +1 -1
  58. package/out/geometries.js.map +1 -0
  59. package/out/google/place-id.d.ts +4 -2
  60. package/out/google/place-id.d.ts.map +1 -1
  61. package/out/google/place-id.js.map +1 -1
  62. package/out/{google/index.d.ts → google.d.ts} +1 -1
  63. package/out/google.d.ts.map +1 -0
  64. package/out/{google/index.js → google.js} +1 -1
  65. package/out/google.js.map +1 -0
  66. package/out/h3/cell.d.ts +19 -73
  67. package/out/h3/cell.d.ts.map +1 -1
  68. package/out/h3/cell.js +20 -63
  69. package/out/h3/cell.js.map +1 -1
  70. package/out/h3/coverage.d.ts +11 -7
  71. package/out/h3/coverage.d.ts.map +1 -1
  72. package/out/h3/coverage.js +11 -7
  73. package/out/h3/coverage.js.map +1 -1
  74. package/out/h3/interior-cells.d.ts +9 -28
  75. package/out/h3/interior-cells.d.ts.map +1 -1
  76. package/out/h3/interior-cells.js +13 -32
  77. package/out/h3/interior-cells.js.map +1 -1
  78. package/out/h3/polygon-cells.d.ts +28 -120
  79. package/out/h3/polygon-cells.d.ts.map +1 -1
  80. package/out/h3/polygon-cells.js +48 -146
  81. package/out/h3/polygon-cells.js.map +1 -1
  82. package/out/{h3/index.d.ts → h3.d.ts} +2 -2
  83. package/out/h3.d.ts.map +1 -0
  84. package/out/{h3/index.js → h3.js} +2 -2
  85. package/out/h3.js.map +1 -0
  86. package/out/index.d.ts +6 -6
  87. package/out/index.d.ts.map +1 -1
  88. package/out/index.js +6 -6
  89. package/out/index.js.map +1 -1
  90. package/out/objects.d.ts +6 -6
  91. package/out/objects.d.ts.map +1 -1
  92. package/out/open-location-code.d.ts +11 -22
  93. package/out/open-location-code.d.ts.map +1 -1
  94. package/out/open-location-code.js +9 -40
  95. package/out/open-location-code.js.map +1 -1
  96. package/out/osgb36.d.ts +21 -97
  97. package/out/osgb36.d.ts.map +1 -1
  98. package/out/osgb36.js +12 -165
  99. package/out/osgb36.js.map +1 -1
  100. package/out/polyline.d.ts +5 -3
  101. package/out/polyline.d.ts.map +1 -1
  102. package/out/polyline.js +5 -3
  103. package/out/polyline.js.map +1 -1
  104. package/out/position.d.ts +17 -3
  105. package/out/position.d.ts.map +1 -1
  106. package/out/position.js +2 -2
  107. package/out/position.js.map +1 -1
  108. package/out/projection/transform.d.ts +70 -0
  109. package/out/projection/transform.d.ts.map +1 -0
  110. package/out/{projection-transform.js → projection/transform.js} +15 -17
  111. package/out/projection/transform.js.map +1 -0
  112. package/out/projection.d.ts +1 -1
  113. package/out/projection.d.ts.map +1 -1
  114. package/out/projection.js +1 -1
  115. package/out/regions/codes.d.ts.map +1 -1
  116. package/out/{regions/index.js → regions.d.ts} +1 -1
  117. package/out/regions.d.ts.map +1 -0
  118. package/out/{regions/index.d.ts → regions.js} +1 -1
  119. package/out/regions.js.map +1 -0
  120. package/out/tools/ogr/stream.d.ts +44 -0
  121. package/out/tools/ogr/stream.d.ts.map +1 -0
  122. package/out/tools/{ogr-stream.js → ogr/stream.js} +17 -10
  123. package/out/tools/ogr/stream.js.map +1 -0
  124. package/out/tools/ogr.d.ts +13 -10
  125. package/out/tools/ogr.d.ts.map +1 -1
  126. package/out/tools/ogr.js +18 -14
  127. package/out/tools/ogr.js.map +1 -1
  128. package/out/tools/tsconfig.tsbuildinfo +1 -0
  129. package/out/tsconfig.test.tsbuildinfo +1 -1
  130. package/out/well-known-text.d.ts +8 -8
  131. package/out/well-known-text.js +7 -7
  132. package/package.json +35 -127
  133. package/{lib/tools/ogr-stream.ts → tools/ogr/stream.ts} +25 -14
  134. package/{lib/tools → tools}/ogr.ts +26 -20
  135. package/lib/projection-transform.ts +0 -115
  136. package/out/coordinate-bounds.d.ts.map +0 -1
  137. package/out/coordinate-bounds.js.map +0 -1
  138. package/out/coordinate-formats.d.ts.map +0 -1
  139. package/out/coordinate-formats.js.map +0 -1
  140. package/out/geometries/index.d.ts.map +0 -1
  141. package/out/geometries/index.js.map +0 -1
  142. package/out/google/index.d.ts.map +0 -1
  143. package/out/google/index.js.map +0 -1
  144. package/out/h3/index.d.ts.map +0 -1
  145. package/out/h3/index.js.map +0 -1
  146. package/out/projection-transform.d.ts +0 -67
  147. package/out/projection-transform.d.ts.map +0 -1
  148. package/out/projection-transform.js.map +0 -1
  149. package/out/regions/index.d.ts.map +0 -1
  150. package/out/regions/index.js.map +0 -1
  151. package/out/tools/ogr-stream.d.ts +0 -34
  152. package/out/tools/ogr-stream.d.ts.map +0 -1
  153. package/out/tools/ogr-stream.js.map +0 -1
  154. /package/lib/{geometries/index.ts → geometries.ts} +0 -0
  155. /package/lib/{google/index.ts → google.ts} +0 -0
  156. /package/lib/{regions/index.ts → regions.ts} +0 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file One ogr2ogr harness for every streaming extraction.
6
+ */
7
+ import type { PathBuilderLike } from "path-ts";
8
+ export interface OGRProcess {
9
+ stdout: NodeJS.ReadableStream;
10
+ /**
11
+ * Resolves on a clean exit.
12
+ * Rejects with the exit code and the stderr tail otherwise.
13
+ *
14
+ * A truncated stream can look like a shorter, valid feature list.
15
+ * That partial result must raise an error instead of looking like a smaller extract.
16
+ * Consume the stream fully, then await this promise.
17
+ */
18
+ settled: Promise<void>;
19
+ /**
20
+ * Stop the child if it is still running — the `finally` companion for a consumer that throws mid-stream.
21
+ */
22
+ kill: () => void;
23
+ }
24
+ /**
25
+ * Spawn `ogr2ogr` with stderr accumulated for the failure message.
26
+ *
27
+ * The caller owns the stdout format (GeoJSONSeq, CSV, …) and its parsing;
28
+ * {@link ogr2ogrGeoJSONSeq} is the GeoJSONSeq reading over this.
29
+ */
30
+ export declare function spawnOGR2OGR(args: readonly PathBuilderLike[], context: string): OGRProcess;
31
+ /**
32
+ * Stream a GeoJSONSeq extraction as parsed features.
33
+ *
34
+ * Strips the RFC-8142 record separator (U+001E) gdal may prefix records with.
35
+ * `.trim()` leaves U+001E intact.
36
+ *
37
+ * The parser strips it first because `tryParsingJSON` would otherwise skip each RS-prefixed record.
38
+ * If the code skipped every record, an empty extract would look like a real absence.
39
+ *
40
+ * A malformed record is tolerated (skipped) rather than thrown.
41
+ * A non-zero exit throws after the stream drains.
42
+ */
43
+ export declare function ogr2ogrGeoJSONSeq<T>(args: readonly PathBuilderLike[], context: string): AsyncGenerator<T>;
44
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../tools/ogr/stream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM9C,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAA;IAC7B;;;;;;;OAOG;IACH,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAqC1F;AAED;;;;;;;;;;;GAWG;AACH,wBAAuB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAoBhH"}
@@ -10,8 +10,10 @@ import { TextSpliterator } from "spliterator";
10
10
  const RECORD_SEPARATOR = 0x1e;
11
11
  const STDERR_TAIL_CHARS = 800;
12
12
  /**
13
- * Spawn `ogr2ogr` with stderr accumulated for the failure message. The caller owns the stdout format (GeoJSONSeq, CSV,
14
- * …) and its parsing; {@link ogr2ogrGeoJSONSeq} is the GeoJSONSeq reading over this.
13
+ * Spawn `ogr2ogr` with stderr accumulated for the failure message.
14
+ *
15
+ * The caller owns the stdout format (GeoJSONSeq, CSV, …) and its parsing;
16
+ * {@link ogr2ogrGeoJSONSeq} is the GeoJSONSeq reading over this.
15
17
  */
16
18
  export function spawnOGR2OGR(args, context) {
17
19
  const child = spawnProcess("ogr2ogr", [...args], { stdio: ["ignore", "pipe", "pipe"] });
@@ -31,9 +33,10 @@ export function spawnOGR2OGR(args, context) {
31
33
  }
32
34
  });
33
35
  });
34
- // A failed spawn rejects `settled` BEFORE any consumer awaits it — the consumer is still draining the stream on a
35
- // later tick, and a consumer that abandons the stream never awaits it at all — so an unobserved rejection would trip
36
- // the process's unhandled-rejection hook. Observed at birth instead; every consumer still awaits the real verdict.
36
+ // A failed spawn can reject `settled` before a consumer awaits it.
37
+ // A consumer may still be draining stdout on a later tick or may abandon the stream.
38
+ // Attach a handler at birth to prevent an unhandled-rejection event.
39
+ // Every consumer still awaits the real verdict.
37
40
  settled.catch(() => undefined);
38
41
  return {
39
42
  stdout: child.stdout,
@@ -48,10 +51,14 @@ export function spawnOGR2OGR(args, context) {
48
51
  /**
49
52
  * Stream a GeoJSONSeq extraction as parsed features.
50
53
  *
51
- * Strips the RFC-8142 record separator (U+001E) GDAL MAY prefix records with — `.trim()` does not remove it (not
52
- * whitespace), so an RS-framed record would fail to parse and be silently skipped, all of them, and an empty extract
53
- * would read as a real absence. A malformed record is tolerated (skipped) rather than thrown; a non-zero exit throws
54
- * after the stream drains.
54
+ * Strips the RFC-8142 record separator (U+001E) gdal may prefix records with.
55
+ * `.trim()` leaves U+001E intact.
56
+ *
57
+ * The parser strips it first because `tryParsingJSON` would otherwise skip each RS-prefixed record.
58
+ * If the code skipped every record, an empty extract would look like a real absence.
59
+ *
60
+ * A malformed record is tolerated (skipped) rather than thrown.
61
+ * A non-zero exit throws after the stream drains.
55
62
  */
56
63
  export async function* ogr2ogrGeoJSONSeq(args, context) {
57
64
  const proc = spawnOGR2OGR(args, context);
@@ -71,4 +78,4 @@ export async function* ogr2ogrGeoJSONSeq(args, context) {
71
78
  }
72
79
  await proc.settled;
73
80
  }
74
- //# sourceMappingURL=ogr-stream.js.map
81
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../tools/ogr/stream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAC7B,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAmB7B;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAgC,EAAE,OAAe;IAC7E,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;IACvF,IAAI,MAAM,GAAG,EAAE,CAAA;IAEf,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAEhC,KAAK,CAAC,MAAM,CAAC,EAAE,CAA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,MAAM,CAAC,EAAE,CAAC;YAChE,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;YAEjF,IAAI,CAAC,IAAI;gBAAE,SAAQ;YAEnB,MAAM,OAAO,GAAG,cAAc,CAAI,IAAI,CAAC,CAAA;YAEvC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACtB,MAAM,OAAO,CAAA;YACd,CAAC;QACF,CAAC;IACF,CAAC;YAAS,CAAC;QACV,IAAI,CAAC,IAAI,EAAE,CAAA;IACZ,CAAC;IAED,MAAM,IAAI,CAAC,OAAO,CAAA;AACnB,CAAC"}
@@ -6,7 +6,7 @@
6
6
  * What an OGR-readable source declares about itself, read before any feature is — the identity check every
7
7
  * polygon-layer ingest opens with.
8
8
  *
9
- * OGR IS BUILD TOOLING, NEVER A SERVE DEPENDENCY (SCOPE invariant 6). The check refuses a source whose
9
+ * OGR is build tooling, never A serve dependency (scope invariant 6). The check refuses a source whose
10
10
  * declared authority code is not the one the ingest was written for, because reading one projection's
11
11
  * coordinates as another's is silent — and it runs the datum-transformation guard even where no shift is
12
12
  * needed, because skipping it on the reasoning that a source needs no shift makes the guard fire on the day
@@ -34,13 +34,15 @@ export interface ReadOGRLayerIdentityOptions {
34
34
  */
35
35
  path: string;
36
36
  /**
37
- * Layer inside it, asserted against what the source answers. Omitted, the source's first layer answers and only its
38
- * presence is checked.
37
+ * Layer inside it, asserted against what the source answers.
38
+ *
39
+ * Omitted, the source's first layer answers and only its presence is checked.
39
40
  */
40
41
  layer?: string;
41
42
  /**
42
- * The EPSG code the source must declare. A source declaring anything else is a product change, not a variation to
43
- * absorb.
43
+ * The epsg code the source must declare.
44
+ *
45
+ * A source declaring anything else is a product change rather than a variation to absorb.
44
46
  */
45
47
  expectEPSG: number;
46
48
  /**
@@ -64,11 +66,11 @@ export interface ReadOGRLayerIdentityOptions {
64
66
  */
65
67
  messages?: {
66
68
  /**
67
- * After `declares no EPSG authority code — `.
69
+ * After `declares no epsg authority code — `.
68
70
  */
69
71
  noAuthorityCode?: string;
70
72
  /**
71
- * After `expected EPSG:<code> — `.
73
+ * After `expected epsg:<code> — `.
72
74
  */
73
75
  epsgMismatch?: string;
74
76
  /**
@@ -78,10 +80,11 @@ export interface ReadOGRLayerIdentityOptions {
78
80
  };
79
81
  }
80
82
  /**
81
- * Read what the source declares about itself, and refuse a projection the calling ingest was not written for.
83
+ * Read what the source declares about itself.
84
+ * Refuse a projection the calling ingest was not written for.
82
85
  *
83
- * @throws {Error} When the layer is missing, declares no EPSG authority code, declares one other than `expectEPSG`,
84
- * reports no feature count, or fails a `requireExtent`/`requireFields` condition.
86
+ * @throws {Error} When the layer is missing, declares no epsg authority code, declares one other than
87
+ * `expectEPSG`, reports no feature count, or fails a `requireExtent`/`requireFields` condition.
85
88
  */
86
89
  export declare function readOGRLayerIdentity(options: ReadOGRLayerIdentityOptions): Promise<OGRLayerIdentity>;
87
90
  //# sourceMappingURL=ogr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ogr.d.ts","sourceRoot":"","sources":["../../lib/tools/ogr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAClD;AAED,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,K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,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE;QACV;;WAEG;QACH,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB;;WAEG;QACH,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACD;AAgBD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgG1G"}
package/out/tools/ogr.js CHANGED
@@ -6,29 +6,33 @@
6
6
  * What an OGR-readable source declares about itself, read before any feature is — the identity check every
7
7
  * polygon-layer ingest opens with.
8
8
  *
9
- * OGR IS BUILD TOOLING, NEVER A SERVE DEPENDENCY (SCOPE invariant 6). The check refuses a source whose
9
+ * OGR is build tooling, never A serve dependency (scope invariant 6). The check refuses a source whose
10
10
  * declared authority code is not the one the ingest was written for, because reading one projection's
11
11
  * coordinates as another's is silent — and it runs the datum-transformation guard even where no shift is
12
12
  * needed, because skipping it on the reasoning that a source needs no shift makes the guard fire on the day
13
13
  * a source arrives that does.
14
14
  */
15
- import { parseJSONStrict } from "@mailwoman/core/json";
15
+ import { parseJSONStrict, stringifyJSON } from "@mailwoman/core/json";
16
16
  import { runFile } from "@mailwoman/core/process";
17
- import { assertDatumTransformationAvailable } from "#projection-transform";
17
+ import { assertDatumTransformationAvailable } from "#projection/transform";
18
18
  /**
19
- * A summary is small; the ceiling only guards against a pathological driver.
19
+ * A summary is small.
20
+ * The ceiling only guards against a pathological driver.
20
21
  */
21
22
  const OGRINFO_MAX_BUFFER = 32 * 1024 * 1024;
22
23
  /**
23
- * Ordinates in a 2D extent: `minLon, minLat, maxLon, maxLat`. A shorter array is a 3D or degenerate extent this reader
24
- * does not understand, not a 2D one with something missing.
24
+ * Ordinates in a 2D extent: `minLon, minLat, maxLon, maxLat`.
25
+ *
26
+ * A shorter array is a 3D or degenerate extent this reader does not understand
27
+ * rather than a 2D one with something missing.
25
28
  */
26
29
  const EXTENT_ORDINATES = 4;
27
30
  /**
28
- * Read what the source declares about itself, and refuse a projection the calling ingest was not written for.
31
+ * Read what the source declares about itself.
32
+ * Refuse a projection the calling ingest was not written for.
29
33
  *
30
- * @throws {Error} When the layer is missing, declares no EPSG authority code, declares one other than `expectEPSG`,
31
- * reports no feature count, or fails a `requireExtent`/`requireFields` condition.
34
+ * @throws {Error} When the layer is missing, declares no epsg authority code, declares one other than
35
+ * `expectEPSG`, reports no feature count, or fails a `requireExtent`/`requireFields` condition.
32
36
  */
33
37
  export async function readOGRLayerIdentity(options) {
34
38
  const { stdout } = await runFile("ogrinfo", ["-json", "-so", options.path, ...(options.layer === undefined ? [] : [options.layer])], { maxBuffer: OGRINFO_MAX_BUFFER });
@@ -37,19 +41,19 @@ export async function readOGRLayerIdentity(options) {
37
41
  if (!described?.name) {
38
42
  throw new Error(options.layer === undefined
39
43
  ? `${options.context}: ${options.path} carries no readable layer`
40
- : `${options.context}: ${options.path} does not carry a layer named ${JSON.stringify(options.layer)}`);
44
+ : `${options.context}: ${options.path} does not carry a layer named ${stringifyJSON(options.layer)}`);
41
45
  }
42
46
  if (options.layer !== undefined && described.name !== options.layer) {
43
- throw new Error(`${options.context}: ${options.path} does not carry a layer named ${JSON.stringify(options.layer)}`);
47
+ throw new Error(`${options.context}: ${options.path} does not carry a layer named ${stringifyJSON(options.layer)}`);
44
48
  }
45
- // The subject a refusal names: the layer where one was asked for, the dataset itself where the source's own first
46
- // layer answered.
49
+ // The subject a refusal names: the layer where one was asked for, the dataset itself
50
+ // where the source's own first layer answered.
47
51
  const subject = options.layer ?? options.path;
48
52
  const geometry = described.geometryFields?.[0];
49
53
  const code = geometry?.coordinateSystem?.projjson?.id?.code;
50
54
  if (typeof code !== "number") {
51
55
  throw new TypeError(`${options.context}: ${subject} declares no EPSG authority code — ${options.messages?.noAuthorityCode ??
52
- "the projection cannot be checked, and reading its metres as degrees is silent"}`);
56
+ "the projection cannot be checked, and reading its meters as degrees is silent"}`);
53
57
  }
54
58
  if (code !== options.expectEPSG) {
55
59
  throw new Error(`${options.context}: ${subject} declares EPSG:${code}, expected EPSG:${options.expectEPSG} — ${options.messages?.epsgMismatch ??
@@ -1 +1 @@
1
- {"version":3,"file":"ogr.js","sourceRoot":"","sources":["../../lib/tools/ogr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAA;AAqE1E;;GAEG;AACH,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAE3C;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAoC;IAC9E,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,CAC/B,SAAS,EACT,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EACvF,EAAE,SAAS,EAAE,kBAAkB,EAAE,CACjC,CAAA;IAED,MAAM,IAAI,GAAG,eAAe,CAUzB,MAAM,CAAC,CAAA;IAEV,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;IAElC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACd,OAAO,CAAC,KAAK,KAAK,SAAS;YAC1B,CAAC,CAAC,GAAG,OAAO,CAAC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