Skip to content

Commit

Permalink
Add default world geography, eez specific geography, add support for …
Browse files Browse the repository at this point in the history
…geography groups, and default to "planning boundary" group
  • Loading branch information
twelch committed Sep 27, 2023
1 parent b94fa67 commit a998fcb
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 8 deletions.
39 changes: 39 additions & 0 deletions packages/base-project/data/default/world.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "World boundary",
"description": "World"
},
"geometry": {
"coordinates": [
[
[
-180,
90
],
[
-180,
-90
],
[
180,
-90
],
[
180,
90
],
[
-180,
90
]
]
],
"type": "Polygon"
}
}
]
}
11 changes: 11 additions & 0 deletions packages/base-project/project/datasources.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,16 @@
"classKeys": [],
"propertiesToKeep": ["UNION"],
"url": "https://d3muy0hbwp5qkl.cloudfront.net"
},
{
"datasourceId": "world",
"geo_type": "vector",
"formats": [
"json"
],
"layerName": "world",
"classKeys": [],
"src": "data/default/world.json",
"propertiesToKeep": []
}
]
7 changes: 6 additions & 1 deletion packages/base-project/project/geographies.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
[]
[{
"geographyId": "world",
"datasourceId": "world",
"display": "World",
"groups": ["project boundary"]
}]
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { geographyConfig } from "../../../src/geographies/config";
* If geographies file not exist then start a new one and ensure directory exists
*/
export function readGeographies(filePath?: string) {
// Start with default
// if planningAreaType is EEZ, then default to external geography for it
let geos: Geographies = [];

// Optional override
Expand Down
2 changes: 1 addition & 1 deletion packages/geoprocessing/scripts/init/createProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export async function createProject(
: metadata.planningAreaId,
geographyProperty: eezDs.idProperty,
propertyValue: metadata.planningAreaId,
groupId: "eez",
groups: ["project boundary"],
},
];

Expand Down
4 changes: 2 additions & 2 deletions packages/geoprocessing/src/types/geographies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const geographySchema = z.object({
/** Optional, defines external layer for visualizing the geography */
layerId: z.string().optional(),
/** Optional, sub-geography identifier. Useful when you have multiple groupings/levels of geographies and want to select for a specific group */
groupId: z.string().optional(),
/** Optional, whether or not precalc should be run for this geography, defaults to true */
groups: z.array(z.string()).optional(),
/** Optional, whether or not precalc should be run for this geography, defaults to true if not present */
precalc: z.boolean().optional(),
});

Expand Down
14 changes: 14 additions & 0 deletions packages/geoprocessing/src/types/geojson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ export const multipolygonSchema = z.object({
type: z.literal('MultiPolygon'),
coordinates: z.array(z.array(z.array(z.array(z.number()))))
}) satisfies z.ZodType<MultiPolygon>

/** 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())
})

/** Zod schema for FeatureCollection containing polygons or multipolygons */
export const fcSchema = z.object({
type: z.literal('FeatureCollection'),
features: z.array(featureSchema)
}) satisfies z.ZodType<FeatureCollection<Polygon | MultiPolygon>>
7 changes: 6 additions & 1 deletion packages/template-blank-project/project/geographies.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
[]
[{
"geographyId": "world",
"datasourceId": "world",
"display": "World",
"groups": ["project boundary"]
}]
9 changes: 8 additions & 1 deletion packages/template-ocean-eez/project/geographies.json
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
[]
[{
"geographyId": "eez",
"datasourceId": "eez_mr_osm",
"geographyProperty": "GEONAME",
"propertyValue": "Micronesian Exclusive Economic Zone",
"display": "Micronesia",
"groups": ["project boundary"]
}]

0 comments on commit a998fcb

Please sign in to comment.