Skip to content

Commit

Permalink
Move geometry type & position into geometry folder
Browse files Browse the repository at this point in the history
  • Loading branch information
reilem committed Oct 22, 2024
1 parent aee3f44 commit 927f766
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 40 deletions.
7 changes: 6 additions & 1 deletion src/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { z } from "zod";
import { GeoJSONBaseSchema } from "./base";
import { GeoJSONGeometryGenericSchema } from "./geometry/geometry";
import { INVALID_BBOX_ISSUE } from "./geometry/validation/bbox";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import {
GeoJSON2DPositionSchema,
GeoJSON3DPositionSchema,
GeoJSONPosition,
GeoJSONPositionSchema,
} from "./geometry/position";
import { GeoJSONTypeSchema } from "./type";
import { validBboxForFeature } from "./validation/bbox";

Expand Down
7 changes: 6 additions & 1 deletion src/feature_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { z } from "zod";
import { GeoJSONBaseSchema } from "./base";
import { GeoJSONFeatureGenericSchema } from "./feature";
import { INVALID_BBOX_ISSUE } from "./geometry/validation/bbox";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import {
GeoJSON2DPositionSchema,
GeoJSON3DPositionSchema,
GeoJSONPosition,
GeoJSONPositionSchema,
} from "./geometry/position";
import { GeoJSONTypeSchema } from "./type";
import { validBboxForFeatureCollection } from "./validation/bbox";
import {
Expand Down
7 changes: 6 additions & 1 deletion src/geojson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { z } from "zod";
import { GeoJSONFeatureGenericSchema } from "./feature";
import { GeoJSONFeatureCollectionGenericSchema } from "./feature_collection";
import { GeoJSONGeometryGenericSchema } from "./geometry/geometry";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import {
GeoJSON2DPositionSchema,
GeoJSON3DPositionSchema,
GeoJSONPosition,
GeoJSONPositionSchema,
} from "./geometry/position";

export const GeoJSONGenericSchema = <P extends GeoJSONPosition>(positionSchema: z.ZodSchema<P>) =>
z.union([
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/geometry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONSimpleGeometryGenericSchema, GeoJSONSimpleGeometryGenericSchemaType } from "./helper/simple";
import {
GeoJSONGeometryCollectionGenericSchema,
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/geometry_collection.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from "zod";
import { GeoJSONGeometryBaseGenericSchemaType } from "./helper/base";
import { GeoJSONSimpleGeometryGenericSchema, GeoJSONSimpleGeometryGenericSchemaType } from "./helper/simple";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { INVALID_BBOX_ISSUE, validBboxForCollection } from "./validation/bbox";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONBaseSchema, GeoJSONBaseSchemaInnerType } from "../base";
import { INVALID_GEOMETRY_COLLECTION_DIMENSION_ISSUE, validDimensionsForCollection } from "./validation/dimension";

Expand Down
2 changes: 1 addition & 1 deletion src/geometry/helper/simple.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { GeoJSONPosition } from "../../position";
import { GeoJSONPosition } from "../position";
import { GeoJSONLineStringGenericSchema, GeoJSONLineStringGenericSchemaType } from "../line_string";
import { GeoJSONMultiLineStringGenericSchema, GeoJSONMultiLineStringGenericSchemaType } from "../multi_line_string";
import { GeoJSONMultiPointGenericSchema, GeoJSONMultiPointGenericSchemaType } from "../multi_point";
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/line_string.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONGeometryBaseGenericSchemaType, GeoJSONGeometryBaseSchema } from "./helper/base";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { INVALID_BBOX_ISSUE, validBboxForPositionList } from "./validation/bbox";
import { INVALID_DIMENSIONS_ISSUE, validDimensionsForPositionList } from "./validation/dimension";

Expand Down
4 changes: 2 additions & 2 deletions src/geometry/multi_line_string.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONGeometryBaseGenericSchemaType, GeoJSONGeometryBaseSchema } from "./helper/base";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { INVALID_BBOX_ISSUE, validBboxForPositionGrid } from "./validation/bbox";
import { INVALID_DIMENSIONS_ISSUE, validDimensionsForPositionGrid } from "./validation/dimension";
import { GeoJSONLineStringGenericSchema, GeoJSONLineStringGenericSchemaInnerType } from "./line_string";
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/multi_point.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONGeometryBaseGenericSchemaType, GeoJSONGeometryBaseSchema } from "./helper/base";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { GeoJSONPointGenericSchemaInnerType } from "./point";
import { INVALID_BBOX_ISSUE, validBboxForPositionList } from "./validation/bbox";
import { INVALID_DIMENSIONS_ISSUE, validDimensionsForPositionList } from "./validation/dimension";
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/multi_polygon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONGeometryBaseGenericSchemaType, GeoJSONGeometryBaseSchema } from "./helper/base";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { GeoJSONPolygonGenericSchema, GeoJSONPolygonGenericSchemaInnerType } from "./polygon";
import { INVALID_BBOX_ISSUE, validBboxForPositionGridList } from "./validation/bbox";
import { INVALID_DIMENSIONS_ISSUE, validDimensionsForPositionGridList } from "./validation/dimension";
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/point.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONGeometryBaseGenericSchemaType, GeoJSONGeometryBaseSchema } from "./helper/base";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { INVALID_BBOX_ISSUE, validBboxForPosition } from "./validation/bbox";

export type GeoJSONPointGenericSchemaInnerType<P extends GeoJSONPosition> = {
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/polygon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "../position";
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position";
import { GeoJSONGeometryBaseGenericSchemaType, GeoJSONGeometryBaseSchema } from "./helper/base";
import { GeoJSONGeometryTypeSchema } from "./helper/type";
import { GeoJSONGeometryTypeSchema } from "./type";
import { INVALID_BBOX_ISSUE, validBboxForPositionGrid } from "./validation/bbox";
import { INVALID_DIMENSIONS_ISSUE, validDimensionsForPositionGrid } from "./validation/dimension";
import { INVALID_POLYGON_LINEAR_RING_MESSAGE, validPolygonRings } from "./validation/linear_ring";
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/geometry/validation/bbox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GeoJSONPosition } from "../../position";
import { GeoJSONPosition } from "../position";
import {
ValidatableCollection,
ValidatableCoordinate,
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/validation/dimension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GeoJSONPosition } from "../../position";
import { GeoJSONPosition } from "../position";
import { ValidatableCollection, ValidatableGeometry } from "./types";

export const INVALID_DIMENSIONS_ISSUE = {
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/validation/linear_ring.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GeoJSONPosition } from "../../position";
import { GeoJSONPosition } from "../position";

export const INVALID_POLYGON_LINEAR_RING_MESSAGE = {
code: "custom" as const,
Expand Down
4 changes: 2 additions & 2 deletions src/geometry/validation/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GeoJSONBbox } from "../../bbox";
import { GeoJSONPosition } from "../../position";
import { GeoJSONGeometryEnumType } from "../helper/type";
import { GeoJSONPosition } from "../position";
import { GeoJSONGeometryEnumType } from "../type";

/**
* The bare essential types required to validate geometries
Expand Down
26 changes: 11 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
// TODO: Add negative typing examples for all types (like in point tests)
// TODO: Make sure each exposed type & schema is tested

export {
GeoJSONGeometryTypeSchema,
type GeoJSONGeometryEnumType,
type GeoJSONGeometryType,
} from "./geometry/helper/type";

export {
GeoJSONGeometryGenericSchema,
GeoJSONGeometrySchema,
Expand Down Expand Up @@ -88,6 +82,17 @@ export {
type GeoJSON3DPolygon,
} from "./geometry/polygon";

export {
GeoJSONPositionSchema,
type GeoJSONPosition,
GeoJSON2DPositionSchema,
type GeoJSON2DPosition,
GeoJSON3DPositionSchema,
type GeoJSON3DPosition,
} from "./geometry/position";

export { GeoJSONGeometryTypeSchema, type GeoJSONGeometryEnumType, type GeoJSONGeometryType } from "./geometry/type";

export { GeoJSONBboxSchema, type GeoJSONBbox } from "./bbox";

export {
Expand Down Expand Up @@ -120,13 +125,4 @@ export {
type GeoJSON3D,
} from "./geojson";

export {
GeoJSONPositionSchema,
type GeoJSONPosition,
GeoJSON2DPositionSchema,
type GeoJSON2DPosition,
GeoJSON3DPositionSchema,
type GeoJSON3DPosition,
} from "./position";

export { GeoJSONTypeSchema, type GeoJSONType } from "./type";
2 changes: 1 addition & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// GeoJSON types and Geometry type (see 1.4)
import { z } from "zod";
import { GeoJSONGeometryTypeSchema } from "./geometry/helper/type";
import { GeoJSONGeometryTypeSchema } from "./geometry/type";

export const GeoJSONTypeSchema = z.enum(["Feature", "FeatureCollection", ...GeoJSONGeometryTypeSchema.options]);

Expand Down

0 comments on commit 927f766

Please sign in to comment.