zod-geojson 1.6.4 → 1.7.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.
@@ -1,10 +1,10 @@
1
1
  import * as z from "zod";
2
2
  import { GeoJSONBaseSchemaShape } from "./base.mjs";
3
3
  import { GeoJSONFeatureGenericSchemaType } from "./feature.mjs";
4
+ import { GeoJSONGeometryGeneric } from "./geometry/geometry.mjs";
4
5
  import { GeoJSONAnyPosition } from "./geometry/position.mjs";
5
6
  import { GeoJSONProperties } from "./properties.mjs";
6
7
  import { GeoJSONType } from "./type.mjs";
7
- import { GeoJSONGeometryGeneric } from "./geometry/geometry.mjs";
8
8
  export type GeoJSONFeatureCollectionGenericSchemaType<P extends GeoJSONAnyPosition, R extends GeoJSONProperties | null, G extends GeoJSONGeometryGeneric<P> | null> = z.ZodObject<GeoJSONBaseSchemaShape<P> & {
9
9
  type: z.ZodLiteral<typeof GeoJSONType.FeatureCollection>;
10
10
  features: z.ZodArray<GeoJSONFeatureGenericSchemaType<P, R, G>>;
@@ -1,10 +1,10 @@
1
1
  import * as z from "zod";
2
2
  import { GeoJSONBaseSchemaShape } from "./base.js";
3
3
  import { GeoJSONFeatureGenericSchemaType } from "./feature.js";
4
+ import { GeoJSONGeometryGeneric } from "./geometry/geometry.js";
4
5
  import { GeoJSONAnyPosition } from "./geometry/position.js";
5
6
  import { GeoJSONProperties } from "./properties.js";
6
7
  import { GeoJSONType } from "./type.js";
7
- import { GeoJSONGeometryGeneric } from "./geometry/geometry.js";
8
8
  export type GeoJSONFeatureCollectionGenericSchemaType<P extends GeoJSONAnyPosition, R extends GeoJSONProperties | null, G extends GeoJSONGeometryGeneric<P> | null> = z.ZodObject<GeoJSONBaseSchemaShape<P> & {
9
9
  type: z.ZodLiteral<typeof GeoJSONType.FeatureCollection>;
10
10
  features: z.ZodArray<GeoJSONFeatureGenericSchemaType<P, R, G>>;
@@ -37,13 +37,12 @@ exports.GeoJSON3DFeatureCollectionSchema = exports.GeoJSON2DFeatureCollectionSch
37
37
  const z = __importStar(require("zod"));
38
38
  const base_1 = require("./base.js");
39
39
  const feature_1 = require("./feature.js");
40
+ const geometry_1 = require("./geometry/geometry.js");
40
41
  const position_1 = require("./geometry/position.js");
41
42
  const bbox_1 = require("./geometry/validation/bbox.js");
42
43
  const properties_1 = require("./properties.js");
43
44
  const type_1 = require("./type.js");
44
45
  const bbox_2 = require("./validation/bbox.js");
45
- const dimension_1 = require("./validation/dimension.js");
46
- const geometry_1 = require("./geometry/geometry.js");
47
46
  const GeoJSONFeatureCollectionGenericSchema = (positionSchema, propertiesSchema, geometrySchema) => z
48
47
  .looseObject({
49
48
  ...(0, base_1.GeoJSONBaseSchema)(positionSchema).shape,
@@ -58,10 +57,6 @@ const GeoJSONFeatureCollectionGenericSchema = (positionSchema, propertiesSchema,
58
57
  if (!ctx.value.features.length) {
59
58
  return;
60
59
  }
61
- if (!(0, dimension_1.validDimensionsForFeatureCollection)(ctx.value)) {
62
- ctx.issues.push((0, dimension_1.getInvalidFeatureCollectionDimensionsIssue)(ctx));
63
- return;
64
- }
65
60
  if (!(0, bbox_2.validBBoxForFeatureCollection)(ctx.value)) {
66
61
  ctx.issues.push((0, bbox_1.getInvalidBBoxIssue)(ctx));
67
62
  return;
@@ -1,13 +1,12 @@
1
1
  import * as z from "zod";
2
2
  import { GeoJSONBaseSchema } from "./base.mjs";
3
3
  import { GeoJSONFeatureGenericSchema } from "./feature.mjs";
4
+ import { GeoJSON2DGeometrySchema, GeoJSON3DGeometrySchema, GeoJSONGeometrySchema, } from "./geometry/geometry.mjs";
4
5
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./geometry/position.mjs";
5
6
  import { getInvalidBBoxIssue } from "./geometry/validation/bbox.mjs";
6
7
  import { GeoJSONPropertiesSchema } from "./properties.mjs";
7
8
  import { GeoJSONTypeSchema } from "./type.mjs";
8
9
  import { validBBoxForFeatureCollection } from "./validation/bbox.mjs";
9
- import { getInvalidFeatureCollectionDimensionsIssue, validDimensionsForFeatureCollection, } from "./validation/dimension.mjs";
10
- import { GeoJSON2DGeometrySchema, GeoJSON3DGeometrySchema, GeoJSONGeometrySchema, } from "./geometry/geometry.mjs";
11
10
  export const GeoJSONFeatureCollectionGenericSchema = (positionSchema, propertiesSchema, geometrySchema) => z
12
11
  .looseObject({
13
12
  ...GeoJSONBaseSchema(positionSchema).shape,
@@ -22,10 +21,6 @@ export const GeoJSONFeatureCollectionGenericSchema = (positionSchema, properties
22
21
  if (!ctx.value.features.length) {
23
22
  return;
24
23
  }
25
- if (!validDimensionsForFeatureCollection(ctx.value)) {
26
- ctx.issues.push(getInvalidFeatureCollectionDimensionsIssue(ctx));
27
- return;
28
- }
29
24
  if (!validBBoxForFeatureCollection(ctx.value)) {
30
25
  ctx.issues.push(getInvalidBBoxIssue(ctx));
31
26
  return;
@@ -45,7 +45,6 @@ const polygon_1 = require("./polygon.js");
45
45
  const position_1 = require("./position.js");
46
46
  const type_1 = require("./type.js");
47
47
  const bbox_1 = require("./validation/bbox.js");
48
- const dimension_1 = require("./validation/dimension.js");
49
48
  const GeoJSONGeometryCollectionGenericSchema = (positionSchema) => z
50
49
  .looseObject({
51
50
  ...(0, base_1.GeoJSONBaseSchema)(positionSchema).shape,
@@ -67,9 +66,6 @@ const GeoJSONGeometryCollectionGenericSchema = (positionSchema) => z
67
66
  if (!ctx.value.geometries.length) {
68
67
  return;
69
68
  }
70
- if (!(0, dimension_1.validDimensionsForCollection)(ctx.value)) {
71
- ctx.issues.push((0, dimension_1.getInvalidGeometryCollectionDimensionIssue)(ctx));
72
- }
73
69
  if (!(0, bbox_1.validBBoxForCollection)(ctx.value)) {
74
70
  ctx.issues.push((0, bbox_1.getInvalidBBoxIssue)(ctx));
75
71
  }
@@ -9,7 +9,6 @@ import { GeoJSONPolygonGenericSchema } from "./polygon.mjs";
9
9
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./position.mjs";
10
10
  import { GeoJSONGeometryTypeSchema } from "./type.mjs";
11
11
  import { getInvalidBBoxIssue, validBBoxForCollection } from "./validation/bbox.mjs";
12
- import { getInvalidGeometryCollectionDimensionIssue, validDimensionsForCollection } from "./validation/dimension.mjs";
13
12
  export const GeoJSONGeometryCollectionGenericSchema = (positionSchema) => z
14
13
  .looseObject({
15
14
  ...GeoJSONBaseSchema(positionSchema).shape,
@@ -31,9 +30,6 @@ export const GeoJSONGeometryCollectionGenericSchema = (positionSchema) => z
31
30
  if (!ctx.value.geometries.length) {
32
31
  return;
33
32
  }
34
- if (!validDimensionsForCollection(ctx.value)) {
35
- ctx.issues.push(getInvalidGeometryCollectionDimensionIssue(ctx));
36
- }
37
33
  if (!validBBoxForCollection(ctx.value)) {
38
34
  ctx.issues.push(getInvalidBBoxIssue(ctx));
39
35
  }
@@ -39,7 +39,6 @@ const base_1 = require("./helper/base.js");
39
39
  const position_1 = require("./position.js");
40
40
  const type_1 = require("./type.js");
41
41
  const bbox_1 = require("./validation/bbox.js");
42
- const dimension_1 = require("./validation/dimension.js");
43
42
  const GeoJSONLineStringGenericSchema = (positionSchema) => z
44
43
  .looseObject({
45
44
  ...(0, base_1.GeoJSONGeometryBaseSchema)(positionSchema).shape,
@@ -53,10 +52,6 @@ const GeoJSONLineStringGenericSchema = (positionSchema) => z
53
52
  if (!ctx.value.coordinates.length) {
54
53
  return;
55
54
  }
56
- if (!(0, dimension_1.validDimensionsForPositionList)(ctx.value)) {
57
- ctx.issues.push((0, dimension_1.getInvalidDimensionIssue)(ctx));
58
- return;
59
- }
60
55
  if (!(0, bbox_1.validBBoxForPositionList)(ctx.value)) {
61
56
  ctx.issues.push((0, bbox_1.getInvalidBBoxIssue)(ctx));
62
57
  return;
@@ -3,7 +3,6 @@ import { GeoJSONGeometryBaseSchema } from "./helper/base.mjs";
3
3
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./position.mjs";
4
4
  import { GeoJSONGeometryTypeSchema } from "./type.mjs";
5
5
  import { getInvalidBBoxIssue, validBBoxForPositionList } from "./validation/bbox.mjs";
6
- import { getInvalidDimensionIssue, validDimensionsForPositionList } from "./validation/dimension.mjs";
7
6
  export const GeoJSONLineStringGenericSchema = (positionSchema) => z
8
7
  .looseObject({
9
8
  ...GeoJSONGeometryBaseSchema(positionSchema).shape,
@@ -17,10 +16,6 @@ export const GeoJSONLineStringGenericSchema = (positionSchema) => z
17
16
  if (!ctx.value.coordinates.length) {
18
17
  return;
19
18
  }
20
- if (!validDimensionsForPositionList(ctx.value)) {
21
- ctx.issues.push(getInvalidDimensionIssue(ctx));
22
- return;
23
- }
24
19
  if (!validBBoxForPositionList(ctx.value)) {
25
20
  ctx.issues.push(getInvalidBBoxIssue(ctx));
26
21
  return;
@@ -40,7 +40,6 @@ const line_string_1 = require("./line_string.js");
40
40
  const position_1 = require("./position.js");
41
41
  const type_1 = require("./type.js");
42
42
  const bbox_1 = require("./validation/bbox.js");
43
- const dimension_1 = require("./validation/dimension.js");
44
43
  const GeoJSONMultiLineStringGenericSchema = (positionSchema) => z
45
44
  .looseObject({
46
45
  ...(0, base_1.GeoJSONGeometryBaseSchema)(positionSchema).shape,
@@ -55,10 +54,6 @@ const GeoJSONMultiLineStringGenericSchema = (positionSchema) => z
55
54
  if (!ctx.value.coordinates.length) {
56
55
  return;
57
56
  }
58
- if (!(0, dimension_1.validDimensionsForPositionGrid)(ctx.value)) {
59
- ctx.issues.push((0, dimension_1.getInvalidDimensionIssue)(ctx));
60
- return;
61
- }
62
57
  if (!(0, bbox_1.validBBoxForPositionGrid)(ctx.value)) {
63
58
  ctx.issues.push((0, bbox_1.getInvalidBBoxIssue)(ctx));
64
59
  return;
@@ -4,7 +4,6 @@ import { GeoJSONLineStringGenericSchema } from "./line_string.mjs";
4
4
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./position.mjs";
5
5
  import { GeoJSONGeometryTypeSchema } from "./type.mjs";
6
6
  import { getInvalidBBoxIssue, validBBoxForPositionGrid } from "./validation/bbox.mjs";
7
- import { getInvalidDimensionIssue, validDimensionsForPositionGrid } from "./validation/dimension.mjs";
8
7
  export const GeoJSONMultiLineStringGenericSchema = (positionSchema) => z
9
8
  .looseObject({
10
9
  ...GeoJSONGeometryBaseSchema(positionSchema).shape,
@@ -19,10 +18,6 @@ export const GeoJSONMultiLineStringGenericSchema = (positionSchema) => z
19
18
  if (!ctx.value.coordinates.length) {
20
19
  return;
21
20
  }
22
- if (!validDimensionsForPositionGrid(ctx.value)) {
23
- ctx.issues.push(getInvalidDimensionIssue(ctx));
24
- return;
25
- }
26
21
  if (!validBBoxForPositionGrid(ctx.value)) {
27
22
  ctx.issues.push(getInvalidBBoxIssue(ctx));
28
23
  return;
@@ -39,7 +39,6 @@ const base_1 = require("./helper/base.js");
39
39
  const position_1 = require("./position.js");
40
40
  const type_1 = require("./type.js");
41
41
  const bbox_1 = require("./validation/bbox.js");
42
- const dimension_1 = require("./validation/dimension.js");
43
42
  const GeoJSONMultiPointGenericSchema = (positionSchema) => z
44
43
  .looseObject({
45
44
  ...(0, base_1.GeoJSONGeometryBaseSchema)(positionSchema).shape,
@@ -54,10 +53,6 @@ const GeoJSONMultiPointGenericSchema = (positionSchema) => z
54
53
  if (!ctx.value.coordinates.length) {
55
54
  return;
56
55
  }
57
- if (!(0, dimension_1.validDimensionsForPositionList)(ctx.value)) {
58
- ctx.issues.push((0, dimension_1.getInvalidDimensionIssue)(ctx));
59
- return;
60
- }
61
56
  if (!(0, bbox_1.validBBoxForPositionList)(ctx.value)) {
62
57
  ctx.issues.push((0, bbox_1.getInvalidBBoxIssue)(ctx));
63
58
  return;
@@ -3,7 +3,6 @@ import { GeoJSONGeometryBaseSchema } from "./helper/base.mjs";
3
3
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./position.mjs";
4
4
  import { GeoJSONGeometryTypeSchema } from "./type.mjs";
5
5
  import { getInvalidBBoxIssue, validBBoxForPositionList } from "./validation/bbox.mjs";
6
- import { getInvalidDimensionIssue, validDimensionsForPositionList } from "./validation/dimension.mjs";
7
6
  export const GeoJSONMultiPointGenericSchema = (positionSchema) => z
8
7
  .looseObject({
9
8
  ...GeoJSONGeometryBaseSchema(positionSchema).shape,
@@ -18,10 +17,6 @@ export const GeoJSONMultiPointGenericSchema = (positionSchema) => z
18
17
  if (!ctx.value.coordinates.length) {
19
18
  return;
20
19
  }
21
- if (!validDimensionsForPositionList(ctx.value)) {
22
- ctx.issues.push(getInvalidDimensionIssue(ctx));
23
- return;
24
- }
25
20
  if (!validBBoxForPositionList(ctx.value)) {
26
21
  ctx.issues.push(getInvalidBBoxIssue(ctx));
27
22
  return;
@@ -40,7 +40,6 @@ const polygon_1 = require("./polygon.js");
40
40
  const position_1 = require("./position.js");
41
41
  const type_1 = require("./type.js");
42
42
  const bbox_1 = require("./validation/bbox.js");
43
- const dimension_1 = require("./validation/dimension.js");
44
43
  const linear_ring_1 = require("./validation/linear_ring.js");
45
44
  const GeoJSONMultiPolygonGenericSchema = (positionSchema) => z
46
45
  .looseObject({
@@ -56,10 +55,6 @@ const GeoJSONMultiPolygonGenericSchema = (positionSchema) => z
56
55
  if (!ctx.value.coordinates.length) {
57
56
  return;
58
57
  }
59
- if (!(0, dimension_1.validDimensionsForPositionGridList)(ctx.value)) {
60
- ctx.issues.push((0, dimension_1.getInvalidDimensionIssue)(ctx));
61
- return;
62
- }
63
58
  if (!(0, linear_ring_1.validMultiPolygonLinearRings)(ctx.value)) {
64
59
  ctx.issues.push((0, linear_ring_1.getInvalidMultiPolygonLinearRingIssue)(ctx));
65
60
  return;
@@ -4,7 +4,6 @@ import { GeoJSONPolygonGenericSchema } from "./polygon.mjs";
4
4
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./position.mjs";
5
5
  import { GeoJSONGeometryTypeSchema } from "./type.mjs";
6
6
  import { getInvalidBBoxIssue, validBBoxForPositionGridList } from "./validation/bbox.mjs";
7
- import { getInvalidDimensionIssue, validDimensionsForPositionGridList } from "./validation/dimension.mjs";
8
7
  import { getInvalidMultiPolygonLinearRingIssue, validMultiPolygonLinearRings } from "./validation/linear_ring.mjs";
9
8
  export const GeoJSONMultiPolygonGenericSchema = (positionSchema) => z
10
9
  .looseObject({
@@ -20,10 +19,6 @@ export const GeoJSONMultiPolygonGenericSchema = (positionSchema) => z
20
19
  if (!ctx.value.coordinates.length) {
21
20
  return;
22
21
  }
23
- if (!validDimensionsForPositionGridList(ctx.value)) {
24
- ctx.issues.push(getInvalidDimensionIssue(ctx));
25
- return;
26
- }
27
22
  if (!validMultiPolygonLinearRings(ctx.value)) {
28
23
  ctx.issues.push(getInvalidMultiPolygonLinearRingIssue(ctx));
29
24
  return;
@@ -39,7 +39,6 @@ const base_1 = require("./helper/base.js");
39
39
  const position_1 = require("./position.js");
40
40
  const type_1 = require("./type.js");
41
41
  const bbox_1 = require("./validation/bbox.js");
42
- const dimension_1 = require("./validation/dimension.js");
43
42
  const linear_ring_1 = require("./validation/linear_ring.js");
44
43
  const GeoJSONPolygonGenericSchema = (positionSchema) => z
45
44
  .looseObject({
@@ -56,10 +55,6 @@ const GeoJSONPolygonGenericSchema = (positionSchema) => z
56
55
  if (!ctx.value.coordinates.length) {
57
56
  return;
58
57
  }
59
- if (!(0, dimension_1.validDimensionsForPositionGrid)(ctx.value)) {
60
- ctx.issues.push((0, dimension_1.getInvalidDimensionIssue)(ctx));
61
- return;
62
- }
63
58
  if (!(0, linear_ring_1.validPolygonRings)(ctx.value)) {
64
59
  ctx.issues.push((0, linear_ring_1.getInvalidPolygonLinearRingIssue)(ctx));
65
60
  return;
@@ -3,7 +3,6 @@ import { GeoJSONGeometryBaseSchema } from "./helper/base.mjs";
3
3
  import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPositionSchema, } from "./position.mjs";
4
4
  import { GeoJSONGeometryTypeSchema } from "./type.mjs";
5
5
  import { getInvalidBBoxIssue, validBBoxForPositionGrid } from "./validation/bbox.mjs";
6
- import { getInvalidDimensionIssue, validDimensionsForPositionGrid } from "./validation/dimension.mjs";
7
6
  import { getInvalidPolygonLinearRingIssue, validPolygonRings } from "./validation/linear_ring.mjs";
8
7
  export const GeoJSONPolygonGenericSchema = (positionSchema) => z
9
8
  .looseObject({
@@ -20,10 +19,6 @@ export const GeoJSONPolygonGenericSchema = (positionSchema) => z
20
19
  if (!ctx.value.coordinates.length) {
21
20
  return;
22
21
  }
23
- if (!validDimensionsForPositionGrid(ctx.value)) {
24
- ctx.issues.push(getInvalidDimensionIssue(ctx));
25
- return;
26
- }
27
22
  if (!validPolygonRings(ctx.value)) {
28
23
  ctx.issues.push(getInvalidPolygonLinearRingIssue(ctx));
29
24
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-geojson",
3
- "version": "1.6.4",
3
+ "version": "1.7.0",
4
4
  "description": "Zod schemas for GeoJSON",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,32 +32,32 @@
32
32
  "LICENSE"
33
33
  ],
34
34
  "devDependencies": {
35
- "@jest/globals": "^30.0.2",
36
- "@turf/helpers": "~7.3.1",
35
+ "@jest/globals": "^30.4.1",
36
+ "@turf/helpers": "~7.3.5",
37
37
  "@types/geojson": "^7946.0.16",
38
- "@types/node": "~24.6.2",
39
- "jest": "^30.0.2",
38
+ "@types/node": "~25.9.1",
39
+ "jest": "^30.4.2",
40
40
  "madge": "^8.0.0",
41
- "prettier": "^3.2.5",
42
- "rimraf": "^6.0.1",
43
- "ts-jest": "^29.1.2",
44
- "typescript": "~5.9.2",
45
- "zod": "~4.1.13",
46
- "zshy": "^0.4.1"
41
+ "prettier": "^3.8.3",
42
+ "rimraf": "^6.1.3",
43
+ "ts-jest": "^29.4.11",
44
+ "typescript": "~6.0.3",
45
+ "zod": "~4.4.3",
46
+ "zshy": "~0.7.2"
47
47
  },
48
48
  "peerDependencies": {
49
- "zod": ">=3.25.0"
49
+ "zod": ">=4.0.0"
50
50
  },
51
51
  "scripts": {
52
- "test": "jest && pnpm test:esm && pnpm test:cjs",
52
+ "test": "jest && pnpm test:esm && pnpm test:cjs && pnpm test:bundled",
53
53
  "test:esm": "pnpm -C tests/esm-testing i --frozen-lockfile && pnpm -C tests/esm-testing start",
54
54
  "test:cjs": "pnpm -C tests/cjs-testing i --frozen-lockfile && pnpm -C tests/cjs-testing start",
55
55
  "test:bundled": "pnpm -C tests/bundled-testing i --frozen-lockfile && pnpm -C tests/bundled-testing start",
56
56
  "clean": "rimraf lib",
57
- "build": "pnpm clean && pnpm zshy",
57
+ "build": "pnpm clean && pnpm zshy -p tsconfig.build.json",
58
58
  "typecheck": "tsc",
59
59
  "prettiercheck": "prettier -c .",
60
60
  "circularcheck": "madge --circular --extensions ts ./src",
61
- "checks": "pnpm typecheck && pnpm build && pnpm prettiercheck && pnpm circularcheck && pnpm test"
61
+ "checks": "pnpm build && pnpm typecheck && pnpm prettiercheck && pnpm circularcheck && pnpm test"
62
62
  }
63
63
  }
@@ -1,15 +0,0 @@
1
- import * as z from "zod";
2
- import { ValidatableCollection, ValidatableGeometry } from "./types.mjs";
3
- export declare const getInvalidDimensionIssue: (ctx: z.core.ParsePayload) => z.core.$ZodRawIssue;
4
- export declare const getInvalidGeometryCollectionDimensionIssue: (ctx: z.core.ParsePayload) => z.core.$ZodRawIssue;
5
- export declare function validDimensionsForPositionList({ coordinates }: {
6
- coordinates: number[][];
7
- }): boolean;
8
- export declare function validDimensionsForPositionGrid({ coordinates }: {
9
- coordinates: number[][][];
10
- }): boolean;
11
- export declare function validDimensionsForPositionGridList({ coordinates }: {
12
- coordinates: number[][][][];
13
- }): boolean;
14
- export declare function validDimensionsForCollection({ geometries }: ValidatableCollection): boolean;
15
- export declare function getDimensionForGeometry(geometry: ValidatableGeometry): number;
@@ -1,15 +0,0 @@
1
- import * as z from "zod";
2
- import { ValidatableCollection, ValidatableGeometry } from "./types.js";
3
- export declare const getInvalidDimensionIssue: (ctx: z.core.ParsePayload) => z.core.$ZodRawIssue;
4
- export declare const getInvalidGeometryCollectionDimensionIssue: (ctx: z.core.ParsePayload) => z.core.$ZodRawIssue;
5
- export declare function validDimensionsForPositionList({ coordinates }: {
6
- coordinates: number[][];
7
- }): boolean;
8
- export declare function validDimensionsForPositionGrid({ coordinates }: {
9
- coordinates: number[][][];
10
- }): boolean;
11
- export declare function validDimensionsForPositionGridList({ coordinates }: {
12
- coordinates: number[][][][];
13
- }): boolean;
14
- export declare function validDimensionsForCollection({ geometries }: ValidatableCollection): boolean;
15
- export declare function getDimensionForGeometry(geometry: ValidatableGeometry): number;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInvalidGeometryCollectionDimensionIssue = exports.getInvalidDimensionIssue = void 0;
4
- exports.validDimensionsForPositionList = validDimensionsForPositionList;
5
- exports.validDimensionsForPositionGrid = validDimensionsForPositionGrid;
6
- exports.validDimensionsForPositionGridList = validDimensionsForPositionGridList;
7
- exports.validDimensionsForCollection = validDimensionsForCollection;
8
- exports.getDimensionForGeometry = getDimensionForGeometry;
9
- const getInvalidDimensionIssue = (ctx) => ({
10
- code: "custom",
11
- message: "Invalid dimensions. All positions in the geometry must have the same dimension.",
12
- input: ctx.value,
13
- continue: true,
14
- });
15
- exports.getInvalidDimensionIssue = getInvalidDimensionIssue;
16
- const getInvalidGeometryCollectionDimensionIssue = (ctx) => ({
17
- code: "custom",
18
- message: "Invalid geometry collection dimensions. All geometries must have the same dimension.",
19
- input: ctx.value,
20
- continue: true,
21
- });
22
- exports.getInvalidGeometryCollectionDimensionIssue = getInvalidGeometryCollectionDimensionIssue;
23
- function validDimensionsForPositionList({ coordinates }) {
24
- const dimension = coordinates[0].length;
25
- return sameDimensionsForPositions(dimension)(coordinates);
26
- }
27
- function validDimensionsForPositionGrid({ coordinates }) {
28
- let dimension = coordinates[0][0].length;
29
- return sameDimensionsForPositionGrid(dimension)(coordinates);
30
- }
31
- function validDimensionsForPositionGridList({ coordinates }) {
32
- let dimension = coordinates[0][0][0].length;
33
- return sameDimensionsForPositionGrids(dimension)(coordinates);
34
- }
35
- function validDimensionsForCollection({ geometries }) {
36
- if (geometries == null)
37
- return false;
38
- let dimension = getDimensionForGeometry(geometries[0]);
39
- return geometries.slice(1).every((geometry) => getDimensionForGeometry(geometry) === dimension);
40
- }
41
- function getDimensionForGeometry(geometry) {
42
- var _a, _b, _c, _d, _e, _f, _g, _h;
43
- switch (geometry.type) {
44
- case "Point":
45
- return (_b = (_a = geometry.coordinates) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
46
- case "MultiPoint":
47
- case "LineString":
48
- return (_d = (_c = geometry.coordinates) === null || _c === void 0 ? void 0 : _c[0].length) !== null && _d !== void 0 ? _d : 0;
49
- case "MultiLineString":
50
- case "Polygon":
51
- return (_f = (_e = geometry.coordinates) === null || _e === void 0 ? void 0 : _e[0][0].length) !== null && _f !== void 0 ? _f : 0;
52
- case "MultiPolygon":
53
- return (_h = (_g = geometry.coordinates) === null || _g === void 0 ? void 0 : _g[0][0][0].length) !== null && _h !== void 0 ? _h : 0;
54
- case "GeometryCollection":
55
- return getDimensionForGeometry(geometry.geometries[0]);
56
- }
57
- }
58
- function sameDimensionsForPosition(dimension) {
59
- return (position) => position.length === dimension;
60
- }
61
- function sameDimensionsForPositions(dimension) {
62
- return (positions) => positions.every(sameDimensionsForPosition(dimension));
63
- }
64
- function sameDimensionsForPositionGrid(dimension) {
65
- return (positionGrid) => positionGrid.every(sameDimensionsForPositions(dimension));
66
- }
67
- function sameDimensionsForPositionGrids(dimension) {
68
- return (positionGrids) => positionGrids.every(sameDimensionsForPositionGrid(dimension));
69
- }
@@ -1,59 +0,0 @@
1
- export const getInvalidDimensionIssue = (ctx) => ({
2
- code: "custom",
3
- message: "Invalid dimensions. All positions in the geometry must have the same dimension.",
4
- input: ctx.value,
5
- continue: true,
6
- });
7
- export const getInvalidGeometryCollectionDimensionIssue = (ctx) => ({
8
- code: "custom",
9
- message: "Invalid geometry collection dimensions. All geometries must have the same dimension.",
10
- input: ctx.value,
11
- continue: true,
12
- });
13
- export function validDimensionsForPositionList({ coordinates }) {
14
- const dimension = coordinates[0].length;
15
- return sameDimensionsForPositions(dimension)(coordinates);
16
- }
17
- export function validDimensionsForPositionGrid({ coordinates }) {
18
- let dimension = coordinates[0][0].length;
19
- return sameDimensionsForPositionGrid(dimension)(coordinates);
20
- }
21
- export function validDimensionsForPositionGridList({ coordinates }) {
22
- let dimension = coordinates[0][0][0].length;
23
- return sameDimensionsForPositionGrids(dimension)(coordinates);
24
- }
25
- export function validDimensionsForCollection({ geometries }) {
26
- if (geometries == null)
27
- return false;
28
- let dimension = getDimensionForGeometry(geometries[0]);
29
- return geometries.slice(1).every((geometry) => getDimensionForGeometry(geometry) === dimension);
30
- }
31
- export function getDimensionForGeometry(geometry) {
32
- var _a, _b, _c, _d, _e, _f, _g, _h;
33
- switch (geometry.type) {
34
- case "Point":
35
- return (_b = (_a = geometry.coordinates) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
36
- case "MultiPoint":
37
- case "LineString":
38
- return (_d = (_c = geometry.coordinates) === null || _c === void 0 ? void 0 : _c[0].length) !== null && _d !== void 0 ? _d : 0;
39
- case "MultiLineString":
40
- case "Polygon":
41
- return (_f = (_e = geometry.coordinates) === null || _e === void 0 ? void 0 : _e[0][0].length) !== null && _f !== void 0 ? _f : 0;
42
- case "MultiPolygon":
43
- return (_h = (_g = geometry.coordinates) === null || _g === void 0 ? void 0 : _g[0][0][0].length) !== null && _h !== void 0 ? _h : 0;
44
- case "GeometryCollection":
45
- return getDimensionForGeometry(geometry.geometries[0]);
46
- }
47
- }
48
- function sameDimensionsForPosition(dimension) {
49
- return (position) => position.length === dimension;
50
- }
51
- function sameDimensionsForPositions(dimension) {
52
- return (positions) => positions.every(sameDimensionsForPosition(dimension));
53
- }
54
- function sameDimensionsForPositionGrid(dimension) {
55
- return (positionGrid) => positionGrid.every(sameDimensionsForPositions(dimension));
56
- }
57
- function sameDimensionsForPositionGrids(dimension) {
58
- return (positionGrids) => positionGrids.every(sameDimensionsForPositionGrid(dimension));
59
- }
@@ -1,4 +0,0 @@
1
- import * as z from "zod";
2
- import { ValidatableFeatureCollection } from "./types.mjs";
3
- export declare const getInvalidFeatureCollectionDimensionsIssue: (ctx: z.core.ParsePayload) => z.core.$ZodRawIssue;
4
- export declare function validDimensionsForFeatureCollection(collection: ValidatableFeatureCollection): boolean;
@@ -1,4 +0,0 @@
1
- import * as z from "zod";
2
- import { ValidatableFeatureCollection } from "./types.js";
3
- export declare const getInvalidFeatureCollectionDimensionsIssue: (ctx: z.core.ParsePayload) => z.core.$ZodRawIssue;
4
- export declare function validDimensionsForFeatureCollection(collection: ValidatableFeatureCollection): boolean;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInvalidFeatureCollectionDimensionsIssue = void 0;
4
- exports.validDimensionsForFeatureCollection = validDimensionsForFeatureCollection;
5
- const dimension_1 = require("../geometry/validation/dimension.js");
6
- const types_1 = require("./types.js");
7
- const getInvalidFeatureCollectionDimensionsIssue = (ctx) => ({
8
- code: "custom",
9
- message: "Invalid dimensions. All features in feature collection must have the same dimension.",
10
- input: ctx.value,
11
- continue: true,
12
- });
13
- exports.getInvalidFeatureCollectionDimensionsIssue = getInvalidFeatureCollectionDimensionsIssue;
14
- function validDimensionsForFeatureCollection(collection) {
15
- const geometries = (0, types_1.getGeometries)(collection);
16
- if (geometries.length === 0)
17
- return true;
18
- const dimension = (0, dimension_1.getDimensionForGeometry)(geometries[0]);
19
- return geometries.slice(1).every((geometry) => (0, dimension_1.getDimensionForGeometry)(geometry) === dimension);
20
- }
@@ -1,15 +0,0 @@
1
- import { getDimensionForGeometry } from "../geometry/validation/dimension.mjs";
2
- import { getGeometries } from "./types.mjs";
3
- export const getInvalidFeatureCollectionDimensionsIssue = (ctx) => ({
4
- code: "custom",
5
- message: "Invalid dimensions. All features in feature collection must have the same dimension.",
6
- input: ctx.value,
7
- continue: true,
8
- });
9
- export function validDimensionsForFeatureCollection(collection) {
10
- const geometries = getGeometries(collection);
11
- if (geometries.length === 0)
12
- return true;
13
- const dimension = getDimensionForGeometry(geometries[0]);
14
- return geometries.slice(1).every((geometry) => getDimensionForGeometry(geometry) === dimension);
15
- }