@loaders.gl/schema 5.0.0-alpha.11 → 5.0.0-alpha.12

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.
@@ -0,0 +1,222 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "version": {
6
+ "$ref": "#/definitions/__schema0"
7
+ },
8
+ "primary_column": {
9
+ "$ref": "#/definitions/__schema1"
10
+ },
11
+ "columns": {
12
+ "$ref": "#/definitions/__schema2"
13
+ }
14
+ },
15
+ "required": [
16
+ "version",
17
+ "primary_column",
18
+ "columns"
19
+ ],
20
+ "additionalProperties": {
21
+ "$ref": "#/definitions/__schema4"
22
+ },
23
+ "definitions": {
24
+ "__schema0": {
25
+ "type": "string",
26
+ "minLength": 1
27
+ },
28
+ "__schema1": {
29
+ "type": "string",
30
+ "minLength": 1
31
+ },
32
+ "__schema2": {
33
+ "type": "object",
34
+ "propertyNames": {
35
+ "type": "string"
36
+ },
37
+ "additionalProperties": {
38
+ "type": "object",
39
+ "properties": {
40
+ "encoding": {
41
+ "type": "string",
42
+ "enum": [
43
+ "WKB",
44
+ "wkb",
45
+ "GEOMETRY",
46
+ "geometry",
47
+ "GEOGRAPHY",
48
+ "geography",
49
+ "point",
50
+ "linestring",
51
+ "polygon",
52
+ "multipoint",
53
+ "multilinestring",
54
+ "multipolygon"
55
+ ]
56
+ },
57
+ "geometry_types": {
58
+ "type": "array",
59
+ "items": {
60
+ "$ref": "#/definitions/__schema3"
61
+ }
62
+ },
63
+ "crs": {
64
+ "anyOf": [
65
+ {
66
+ "type": "object",
67
+ "propertyNames": {
68
+ "type": "string"
69
+ },
70
+ "additionalProperties": {}
71
+ },
72
+ {
73
+ "type": "null"
74
+ }
75
+ ]
76
+ },
77
+ "orientation": {
78
+ "type": "string",
79
+ "const": "counterclockwise"
80
+ },
81
+ "bbox": {
82
+ "anyOf": [
83
+ {
84
+ "type": "array",
85
+ "items": [
86
+ {
87
+ "type": "number"
88
+ },
89
+ {
90
+ "type": "number"
91
+ },
92
+ {
93
+ "type": "number"
94
+ },
95
+ {
96
+ "type": "number"
97
+ }
98
+ ],
99
+ "additionalItems": false,
100
+ "minItems": 4,
101
+ "maxItems": 4
102
+ },
103
+ {
104
+ "type": "array",
105
+ "items": [
106
+ {
107
+ "type": "number"
108
+ },
109
+ {
110
+ "type": "number"
111
+ },
112
+ {
113
+ "type": "number"
114
+ },
115
+ {
116
+ "type": "number"
117
+ },
118
+ {
119
+ "type": "number"
120
+ },
121
+ {
122
+ "type": "number"
123
+ }
124
+ ],
125
+ "additionalItems": false,
126
+ "minItems": 6,
127
+ "maxItems": 6
128
+ },
129
+ {
130
+ "type": "array",
131
+ "items": [
132
+ {
133
+ "type": "number"
134
+ },
135
+ {
136
+ "type": "number"
137
+ },
138
+ {
139
+ "type": "number"
140
+ },
141
+ {
142
+ "type": "number"
143
+ },
144
+ {
145
+ "type": "number"
146
+ },
147
+ {
148
+ "type": "number"
149
+ },
150
+ {
151
+ "type": "number"
152
+ },
153
+ {
154
+ "type": "number"
155
+ }
156
+ ],
157
+ "additionalItems": false,
158
+ "minItems": 8,
159
+ "maxItems": 8
160
+ }
161
+ ]
162
+ },
163
+ "edges": {
164
+ "type": "string",
165
+ "enum": [
166
+ "planar",
167
+ "spherical",
168
+ "vincenty",
169
+ "thomas",
170
+ "andoyer",
171
+ "karney"
172
+ ]
173
+ },
174
+ "epoch": {
175
+ "type": "number"
176
+ }
177
+ },
178
+ "required": [
179
+ "encoding",
180
+ "geometry_types"
181
+ ],
182
+ "additionalProperties": {}
183
+ }
184
+ },
185
+ "__schema3": {
186
+ "type": "string",
187
+ "enum": [
188
+ "Point",
189
+ "LineString",
190
+ "Polygon",
191
+ "MultiPoint",
192
+ "MultiLineString",
193
+ "MultiPolygon",
194
+ "GeometryCollection",
195
+ "Point Z",
196
+ "LineString Z",
197
+ "Polygon Z",
198
+ "MultiPoint Z",
199
+ "MultiLineString Z",
200
+ "MultiPolygon Z",
201
+ "GeometryCollection Z",
202
+ "Point M",
203
+ "LineString M",
204
+ "Polygon M",
205
+ "MultiPoint M",
206
+ "MultiLineString M",
207
+ "MultiPolygon M",
208
+ "GeometryCollection M",
209
+ "Point ZM",
210
+ "LineString ZM",
211
+ "Polygon ZM",
212
+ "MultiPoint ZM",
213
+ "MultiLineString ZM",
214
+ "MultiPolygon ZM",
215
+ "GeometryCollection ZM"
216
+ ]
217
+ },
218
+ "__schema4": {}
219
+ },
220
+ "$id": "https://unpkg.com/@loaders.gl/schema/geoparquet.schema.json",
221
+ "title": "loaders.gl GeoParquet metadata"
222
+ }
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // dist/geospatial-metadata-zod-schema.js
21
+ var geospatial_metadata_zod_schema_exports = {};
22
+ __export(geospatial_metadata_zod_schema_exports, {
23
+ GeoArrowMetadataSchema: () => GeoArrowMetadataSchema,
24
+ GeoParquetColumnMetadataSchema: () => GeoParquetColumnMetadataSchema,
25
+ GeoParquetGeometryTypeSchema: () => GeoParquetGeometryTypeSchema,
26
+ GeoParquetMetadataSchema: () => GeoParquetMetadataSchema
27
+ });
28
+ module.exports = __toCommonJS(geospatial_metadata_zod_schema_exports);
29
+ var import_zod = require("zod");
30
+ var GeoParquetGeometryTypeSchema = import_zod.z.enum([
31
+ "Point",
32
+ "LineString",
33
+ "Polygon",
34
+ "MultiPoint",
35
+ "MultiLineString",
36
+ "MultiPolygon",
37
+ "GeometryCollection",
38
+ "Point Z",
39
+ "LineString Z",
40
+ "Polygon Z",
41
+ "MultiPoint Z",
42
+ "MultiLineString Z",
43
+ "MultiPolygon Z",
44
+ "GeometryCollection Z",
45
+ "Point M",
46
+ "LineString M",
47
+ "Polygon M",
48
+ "MultiPoint M",
49
+ "MultiLineString M",
50
+ "MultiPolygon M",
51
+ "GeometryCollection M",
52
+ "Point ZM",
53
+ "LineString ZM",
54
+ "Polygon ZM",
55
+ "MultiPoint ZM",
56
+ "MultiLineString ZM",
57
+ "MultiPolygon ZM",
58
+ "GeometryCollection ZM"
59
+ ]);
60
+ var GeoParquetGeometryTypesSchema = import_zod.z.array(GeoParquetGeometryTypeSchema).refine((geometryTypes) => new Set(geometryTypes).size === geometryTypes.length, {
61
+ message: "GeoParquet geometry_types entries must be unique"
62
+ });
63
+ var PROJJSONCRSSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.unknown());
64
+ var GeoParquetColumnMetadataSchema = import_zod.z.object({
65
+ encoding: import_zod.z.enum([
66
+ "WKB",
67
+ "wkb",
68
+ "GEOMETRY",
69
+ "geometry",
70
+ "GEOGRAPHY",
71
+ "geography",
72
+ "point",
73
+ "linestring",
74
+ "polygon",
75
+ "multipoint",
76
+ "multilinestring",
77
+ "multipolygon"
78
+ ]),
79
+ geometry_types: GeoParquetGeometryTypesSchema,
80
+ crs: import_zod.z.union([PROJJSONCRSSchema, import_zod.z.null()]).optional(),
81
+ orientation: import_zod.z.literal("counterclockwise").optional(),
82
+ bbox: import_zod.z.union([
83
+ import_zod.z.tuple([import_zod.z.number(), import_zod.z.number(), import_zod.z.number(), import_zod.z.number()]),
84
+ import_zod.z.tuple([import_zod.z.number(), import_zod.z.number(), import_zod.z.number(), import_zod.z.number(), import_zod.z.number(), import_zod.z.number()]),
85
+ import_zod.z.tuple([
86
+ import_zod.z.number(),
87
+ import_zod.z.number(),
88
+ import_zod.z.number(),
89
+ import_zod.z.number(),
90
+ import_zod.z.number(),
91
+ import_zod.z.number(),
92
+ import_zod.z.number(),
93
+ import_zod.z.number()
94
+ ])
95
+ ]).optional(),
96
+ edges: import_zod.z.enum(["planar", "spherical", "vincenty", "thomas", "andoyer", "karney"]).optional(),
97
+ epoch: import_zod.z.number().finite().optional()
98
+ }).passthrough();
99
+ var GeoParquetMetadataSchema = import_zod.z.object({
100
+ version: import_zod.z.string().min(1),
101
+ primary_column: import_zod.z.string().min(1),
102
+ columns: import_zod.z.record(import_zod.z.string(), GeoParquetColumnMetadataSchema)
103
+ }).passthrough().refine((metadata) => Boolean(metadata.columns[metadata.primary_column]), {
104
+ message: "GeoParquet primary_column must name an entry in columns",
105
+ path: ["primary_column"]
106
+ }).superRefine((metadata, context) => {
107
+ if (!metadata.version.startsWith("2."))
108
+ return;
109
+ for (const [columnName, column] of Object.entries(metadata.columns)) {
110
+ const encoding = column.encoding.toUpperCase();
111
+ if (encoding !== "WKB" && encoding !== "GEOMETRY" && encoding !== "GEOGRAPHY") {
112
+ context.addIssue({
113
+ code: "custom",
114
+ message: "GeoParquet 2.x geometry columns must use WKB, GEOMETRY, or GEOGRAPHY encoding",
115
+ path: ["columns", columnName, "encoding"]
116
+ });
117
+ }
118
+ }
119
+ });
120
+ var GeoArrowMetadataSchema = import_zod.z.object({
121
+ encoding: import_zod.z.enum([
122
+ "geoarrow.geometry",
123
+ "geoarrow.geometrycollection",
124
+ "geoarrow.multipolygon",
125
+ "geoarrow.polygon",
126
+ "geoarrow.multilinestring",
127
+ "geoarrow.linestring",
128
+ "geoarrow.multipoint",
129
+ "geoarrow.point",
130
+ "geoarrow.box",
131
+ "geoarrow.wkb",
132
+ "geoarrow.wkt"
133
+ ]).optional(),
134
+ crs: import_zod.z.union([PROJJSONCRSSchema, import_zod.z.string()]).optional(),
135
+ crs_type: import_zod.z.enum(["projjson", "wkt2:2019", "authority_code", "srid"]).optional(),
136
+ edges: import_zod.z.enum(["spherical", "vincenty", "thomas", "andoyer", "karney"]).optional(),
137
+ geometry_types: GeoParquetGeometryTypesSchema.optional()
138
+ }).passthrough().superRefine((metadata, context) => {
139
+ const { crs, crs_type: crsType } = metadata;
140
+ const valid = crs === void 0 && crsType === void 0 || typeof crs === "object" && crs !== null && (crsType === void 0 || crsType === "projjson") || typeof crs === "string" && (crsType === void 0 || crsType === "wkt2:2019" || crsType === "authority_code" || crsType === "srid");
141
+ if (!valid) {
142
+ context.addIssue({
143
+ code: "custom",
144
+ message: "GeoArrow crs and crs_type must describe the same CRS representation",
145
+ path: ["crs_type"]
146
+ });
147
+ }
148
+ });
149
+ //# sourceMappingURL=geospatial-metadata-zod-schema.cjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/geospatial-metadata-zod-schema.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAIA,iBAAgB;AAST,IAAM,+BAA+B,aAAE,KAAK;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AAED,IAAM,gCAAgC,aACnC,MAAM,4BAA4B,EAClC,OAAO,mBAAiB,IAAI,IAAI,aAAa,EAAE,SAAS,cAAc,QAAQ;EAC7E,SAAS;CACV;AAEH,IAAM,oBAAoB,aAAE,OAAO,aAAE,OAAM,GAAI,aAAE,QAAO,CAAE;AAGnD,IAAM,iCAAiC,aAC3C,OAAO;EACN,UAAU,aAAE,KAAK;IACf;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACD;EACD,gBAAgB;EAChB,KAAK,aAAE,MAAM,CAAC,mBAAmB,aAAE,KAAI,C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AM,CAAC,WAAW,YAAY,UAAU;OACzC;IACH;EACF;AACF,CAAC;AAGI,IAAM,yBAAyB,aACnC,OAAO;EACN,UAAU,aACP,KAAK;IACJ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACD,EACA,SAAQ;EACX,KAAK,aAAE,MAAM,CAAC,mBAAmB,aAAE,OAAM,CAAE,CAAC,EAAE,SAAQ;EACtD,UAAU,aAAE,KAAK,CAAC,YAAY,aAAa,kBAAkB,MAAM,CAAC,EAAE,SAAQ;EAC9E,OAAO,aAAE,KAAK,CAAC,aAAa,YAAY,UAAU,WAAW,QAAQ,CAAC,EAAE,SAAQ;EAChF,gBAAgB,8BAA8B,SAAQ;CACvD,EACA,YAAW,EACX,YAAY,CAAC,UAAU,YAAW;AACjC,QAAM,EAAC,KAAK,UAAU,QAAO,IAAI;AACjC,QAAM,QACH,QAAQ,UAAa,YAAY,UACjC,OAAO,QAAQ,YACd,QAAQ,SACP,YAAY,UAAa,YAAY,eACvC,OAAO,QAAQ,aACb,YAAY,UACX,YAAY,eACZ,YAAY,oBACZ,YAAY;AAClB,MAAI,CAAC,OAAO;AACV,YAAQ,SAAS;MACf,MAAM;MACN,SAAS;MACT,MAAM,CAAC,UAAU;KAClB;EACH;AACF,CAAC;",
5
+ "names": []
6
+ }
@@ -0,0 +1,44 @@
1
+ import { z } from 'zod';
2
+ import type { GeoArrowMetadata, GeoColumnMetadata } from "./geometry/geoarrow.js";
3
+ /** GeoParquet geometry type names, including optional Z dimensions. */
4
+ export declare const GeoParquetGeometryTypeSchema: z.ZodEnum<{
5
+ Point: "Point";
6
+ LineString: "LineString";
7
+ Polygon: "Polygon";
8
+ MultiPoint: "MultiPoint";
9
+ MultiLineString: "MultiLineString";
10
+ MultiPolygon: "MultiPolygon";
11
+ GeometryCollection: "GeometryCollection";
12
+ "Point Z": "Point Z";
13
+ "LineString Z": "LineString Z";
14
+ "Polygon Z": "Polygon Z";
15
+ "MultiPoint Z": "MultiPoint Z";
16
+ "MultiLineString Z": "MultiLineString Z";
17
+ "MultiPolygon Z": "MultiPolygon Z";
18
+ "GeometryCollection Z": "GeometryCollection Z";
19
+ "Point M": "Point M";
20
+ "LineString M": "LineString M";
21
+ "Polygon M": "Polygon M";
22
+ "MultiPoint M": "MultiPoint M";
23
+ "MultiLineString M": "MultiLineString M";
24
+ "MultiPolygon M": "MultiPolygon M";
25
+ "GeometryCollection M": "GeometryCollection M";
26
+ "Point ZM": "Point ZM";
27
+ "LineString ZM": "LineString ZM";
28
+ "Polygon ZM": "Polygon ZM";
29
+ "MultiPoint ZM": "MultiPoint ZM";
30
+ "MultiLineString ZM": "MultiLineString ZM";
31
+ "MultiPolygon ZM": "MultiPolygon ZM";
32
+ "GeometryCollection ZM": "GeometryCollection ZM";
33
+ }>;
34
+ /** Zod schema for metadata attached to one GeoParquet geometry column. */
35
+ export declare const GeoParquetColumnMetadataSchema: z.ZodType<GeoColumnMetadata>;
36
+ /** Zod schema for the GeoParquet metadata stored in a Parquet file's `geo` key. */
37
+ export declare const GeoParquetMetadataSchema: z.ZodObject<{
38
+ version: z.ZodString;
39
+ primary_column: z.ZodString;
40
+ columns: z.ZodRecord<z.ZodString, z.ZodType<GeoColumnMetadata, unknown, z.core.$ZodTypeInternals<GeoColumnMetadata, unknown>>>;
41
+ }, z.core.$loose>;
42
+ /** Zod schema for metadata stored on one GeoArrow extension field. */
43
+ export declare const GeoArrowMetadataSchema: z.ZodType<GeoArrowMetadata>;
44
+ //# sourceMappingURL=geospatial-metadata-zod-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geospatial-metadata-zod-schema.d.ts","sourceRoot":"","sources":["../src/geospatial-metadata-zod-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAGlB,+BAA4B;AAE7B,uEAAuE;AACvE,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BK,CAAC;AAU/C,0EAA0E;AAC1E,eAAO,MAAM,8BAA8B,EAsCZ,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE5D,mFAAmF;AACnF,eAAO,MAAM,wBAAwB;;;;iBAuBA,CAAC;AAEtC,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,EA0C3B,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,151 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright vis.gl contributors
4
+ import { z } from 'zod';
5
+ /** GeoParquet geometry type names, including optional Z dimensions. */
6
+ export const GeoParquetGeometryTypeSchema = z.enum([
7
+ 'Point',
8
+ 'LineString',
9
+ 'Polygon',
10
+ 'MultiPoint',
11
+ 'MultiLineString',
12
+ 'MultiPolygon',
13
+ 'GeometryCollection',
14
+ 'Point Z',
15
+ 'LineString Z',
16
+ 'Polygon Z',
17
+ 'MultiPoint Z',
18
+ 'MultiLineString Z',
19
+ 'MultiPolygon Z',
20
+ 'GeometryCollection Z',
21
+ 'Point M',
22
+ 'LineString M',
23
+ 'Polygon M',
24
+ 'MultiPoint M',
25
+ 'MultiLineString M',
26
+ 'MultiPolygon M',
27
+ 'GeometryCollection M',
28
+ 'Point ZM',
29
+ 'LineString ZM',
30
+ 'Polygon ZM',
31
+ 'MultiPoint ZM',
32
+ 'MultiLineString ZM',
33
+ 'MultiPolygon ZM',
34
+ 'GeometryCollection ZM'
35
+ ]);
36
+ const GeoParquetGeometryTypesSchema = z
37
+ .array(GeoParquetGeometryTypeSchema)
38
+ .refine(geometryTypes => new Set(geometryTypes).size === geometryTypes.length, {
39
+ message: 'GeoParquet geometry_types entries must be unique'
40
+ });
41
+ const PROJJSONCRSSchema = z.record(z.string(), z.unknown());
42
+ /** Zod schema for metadata attached to one GeoParquet geometry column. */
43
+ export const GeoParquetColumnMetadataSchema = z
44
+ .object({
45
+ encoding: z.enum([
46
+ 'WKB',
47
+ 'wkb',
48
+ 'GEOMETRY',
49
+ 'geometry',
50
+ 'GEOGRAPHY',
51
+ 'geography',
52
+ 'point',
53
+ 'linestring',
54
+ 'polygon',
55
+ 'multipoint',
56
+ 'multilinestring',
57
+ 'multipolygon'
58
+ ]),
59
+ geometry_types: GeoParquetGeometryTypesSchema,
60
+ crs: z.union([PROJJSONCRSSchema, z.null()]).optional(),
61
+ orientation: z.literal('counterclockwise').optional(),
62
+ bbox: z
63
+ .union([
64
+ z.tuple([z.number(), z.number(), z.number(), z.number()]),
65
+ z.tuple([z.number(), z.number(), z.number(), z.number(), z.number(), z.number()]),
66
+ z.tuple([
67
+ z.number(),
68
+ z.number(),
69
+ z.number(),
70
+ z.number(),
71
+ z.number(),
72
+ z.number(),
73
+ z.number(),
74
+ z.number()
75
+ ])
76
+ ])
77
+ .optional(),
78
+ edges: z.enum(['planar', 'spherical', 'vincenty', 'thomas', 'andoyer', 'karney']).optional(),
79
+ epoch: z.number().finite().optional()
80
+ })
81
+ .passthrough();
82
+ /** Zod schema for the GeoParquet metadata stored in a Parquet file's `geo` key. */
83
+ export const GeoParquetMetadataSchema = z
84
+ .object({
85
+ version: z.string().min(1),
86
+ primary_column: z.string().min(1),
87
+ columns: z.record(z.string(), GeoParquetColumnMetadataSchema)
88
+ })
89
+ .passthrough()
90
+ .refine(metadata => Boolean(metadata.columns[metadata.primary_column]), {
91
+ message: 'GeoParquet primary_column must name an entry in columns',
92
+ path: ['primary_column']
93
+ })
94
+ .superRefine((metadata, context) => {
95
+ if (!metadata.version.startsWith('2.'))
96
+ return;
97
+ for (const [columnName, column] of Object.entries(metadata.columns)) {
98
+ const encoding = column.encoding.toUpperCase();
99
+ if (encoding !== 'WKB' && encoding !== 'GEOMETRY' && encoding !== 'GEOGRAPHY') {
100
+ context.addIssue({
101
+ code: 'custom',
102
+ message: 'GeoParquet 2.x geometry columns must use WKB, GEOMETRY, or GEOGRAPHY encoding',
103
+ path: ['columns', columnName, 'encoding']
104
+ });
105
+ }
106
+ }
107
+ });
108
+ /** Zod schema for metadata stored on one GeoArrow extension field. */
109
+ export const GeoArrowMetadataSchema = z
110
+ .object({
111
+ encoding: z
112
+ .enum([
113
+ 'geoarrow.geometry',
114
+ 'geoarrow.geometrycollection',
115
+ 'geoarrow.multipolygon',
116
+ 'geoarrow.polygon',
117
+ 'geoarrow.multilinestring',
118
+ 'geoarrow.linestring',
119
+ 'geoarrow.multipoint',
120
+ 'geoarrow.point',
121
+ 'geoarrow.box',
122
+ 'geoarrow.wkb',
123
+ 'geoarrow.wkt'
124
+ ])
125
+ .optional(),
126
+ crs: z.union([PROJJSONCRSSchema, z.string()]).optional(),
127
+ crs_type: z.enum(['projjson', 'wkt2:2019', 'authority_code', 'srid']).optional(),
128
+ edges: z.enum(['spherical', 'vincenty', 'thomas', 'andoyer', 'karney']).optional(),
129
+ geometry_types: GeoParquetGeometryTypesSchema.optional()
130
+ })
131
+ .passthrough()
132
+ .superRefine((metadata, context) => {
133
+ const { crs, crs_type: crsType } = metadata;
134
+ const valid = (crs === undefined && crsType === undefined) ||
135
+ (typeof crs === 'object' &&
136
+ crs !== null &&
137
+ (crsType === undefined || crsType === 'projjson')) ||
138
+ (typeof crs === 'string' &&
139
+ (crsType === undefined ||
140
+ crsType === 'wkt2:2019' ||
141
+ crsType === 'authority_code' ||
142
+ crsType === 'srid'));
143
+ if (!valid) {
144
+ context.addIssue({
145
+ code: 'custom',
146
+ message: 'GeoArrow crs and crs_type must describe the same CRS representation',
147
+ path: ['crs_type']
148
+ });
149
+ }
150
+ });
151
+ //# sourceMappingURL=geospatial-metadata-zod-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geospatial-metadata-zod-schema.js","sourceRoot":"","sources":["../src/geospatial-metadata-zod-schema.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,gCAAgC;AAEhC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAQtB,uE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": "@loaders.gl/schema",
3
- "version": "5.0.0-alpha.11",
3
+ "version": "5.0.0-alpha.12",
4
4
  "description": "Table format APIs for JSON, CSV, etc...",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,14 @@
27
27
  "types": "./dist/index.d.ts",
28
28
  "import": "./dist/index.js",
29
29
  "require": "./dist/index.cjs"
30
- }
30
+ },
31
+ "./geospatial-metadata-zod-schema": {
32
+ "types": "./dist/geospatial-metadata-zod-schema.d.ts",
33
+ "import": "./dist/geospatial-metadata-zod-schema.js",
34
+ "require": "./dist/geospatial-metadata-zod-schema.cjs"
35
+ },
36
+ "./geoparquet.schema.json": "./dist/geoparquet.schema.json",
37
+ "./geoarrow-metadata.schema.json": "./dist/geoarrow-metadata.schema.json"
31
38
  },
32
39
  "sideEffects": false,
33
40
  "files": [
@@ -36,14 +43,16 @@
36
43
  "README.md"
37
44
  ],
38
45
  "scripts": {
39
- "pre-build": "npm run build-bundle && npm run build-bundle-dev",
46
+ "pre-build": "npm run build-bundle && npm run build-bundle-dev && npm run generate-json-schema",
40
47
  "build-bundle": "ocular-bundle ./bundle.ts --output=dist/dist.min.js",
41
- "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
48
+ "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js",
49
+ "generate-json-schema": "node ../../scripts/generate-json-schema.mjs --schema ./dist/geospatial-metadata-zod-schema.js --export GeoParquetMetadataSchema --output ./dist/geoparquet.schema.json --id https://unpkg.com/@loaders.gl/schema/geoparquet.schema.json --title 'loaders.gl GeoParquet metadata' && node ../../scripts/generate-json-schema.mjs --schema ./dist/geospatial-metadata-zod-schema.js --export GeoArrowMetadataSchema --output ./dist/geoarrow-metadata.schema.json --id https://unpkg.com/@loaders.gl/schema/geoarrow-metadata.schema.json --title 'loaders.gl GeoArrow field metadata'"
42
50
  },
43
51
  "dependencies": {
44
- "@math.gl/types": "5.0.0-alpha.15",
52
+ "@math.gl/types": "5.0.0-alpha.16",
45
53
  "@types/geojson": "^7946.0.7",
46
- "apache-arrow": ">= 17.0.0"
54
+ "apache-arrow": ">= 17.0.0",
55
+ "zod": "^4.1.12"
47
56
  },
48
- "gitHead": "31449661e98c1c3f97bb4f8a7bcba7f19596ac00"
57
+ "gitHead": "8cbff6cb3e55c4eb1305072743992af27ff0c171"
49
58
  }