@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
39 lines • 1.2 kB
JavaScript
import { z } from "zod";
// zod schemas
export const box2dSchema = z.tuple([
z.number(),
z.number(),
z.number(),
z.number(),
]);
export const box3dSchema = z.tuple([
z.number(),
z.number(),
z.number(),
z.number(),
z.number(),
z.number(),
]);
export const bboxSchema = box2dSchema.or(box3dSchema);
export const polygonSchema = z.object({
type: z.literal("Polygon"),
coordinates: z.array(z.array(z.array(z.number()))),
});
export const multipolygonSchema = z.object({
type: z.literal("MultiPolygon"),
coordinates: z.array(z.array(z.array(z.array(z.number())))),
});
/** Zod schema for Feature containing Polygon or MultiPolygon */
export const featureSchema = z.object({
type: z.literal("Feature"),
geometry: polygonSchema.or(multipolygonSchema),
id: z.string().or(z.number()).optional(),
properties: z.record(z.any()).or(z.null()).nullable(),
});
export const featuresSchema = z.array(featureSchema);
/** Zod schema for FeatureCollection containing polygons or multipolygons */
export const fcSchema = z.object({
type: z.literal("FeatureCollection"),
features: z.array(featureSchema),
});
//# sourceMappingURL=geojson.js.map