Add Static Dataset
Adds a new static dataset folder to app/scripts/StaticDatasets/geojson. The /geojson folder is a symlink.
When to Use
- User wants to add a new GeoJSON dataset
- User mentions adding static data, geojson files, "uploads", or datasets
- User provides a geojson file path and wants it integrated
Required Information
Extract from user prompt or ask if missing:
- Group folder (e.g.,
region-berlin,region-bb) - parent folder name - Sub-folder name (e.g.,
berlin-bezirke) - dataset folder name (must be valid slug). Must include region/group prefix: forregion-berlinuseberlin-<name>, not just<name> - GeoJSON file path - absolute path to source file on disk
- Regions - array of region slugs (e.g.,
['infravelo'],['berlin']) - Optional: transformation needs, style preferences, category, attribution, license
Process
1. Create Folder Structure
bash1app/scripts/StaticDatasets/geojson/<GROUP_FOLDER>/<SUB_FOLDER>/
Important: /geojson is a symlink. Create folders in app/scripts/StaticDatasets/geojson/ path.
Create directory if group folder doesn't exist. Ensure sub-folder name follows naming convention (see Required Information above).
2. Move GeoJSON File
- Move source file to
<SUB_FOLDER>/<FILENAME>.geojson - Run prettier from
app/directory (prettier config is in app/):cd app && bunx prettier --write scripts/StaticDatasets/geojson/<GROUP_FOLDER>/<SUB_FOLDER>/<FILENAME>.geojson
3. Create transform.ts (if needed)
Only if transformation required. Use helpers from app/scripts/StaticDatasets/geojson/_utils:
transformUtils.ts- property transformationsdefaultLayerStyles.ts- default styling helperstranslateUtils.ts- translation helpers
Example:
typescript1import { FeatureCollection } from "geojson"; 2 3export const transform = (data: FeatureCollection) => { 4 // Use helper functions from _utils when possible 5 return data; 6};
4. Create meta.ts
Critical: Research similar datasets in same group folder first.
Before writing meta.ts:
- List all datasets in
<GROUP_FOLDER>/directory - Read 2-3 similar
meta.tsfiles (similar geometry type, similar purpose) - Infer patterns:
- Category from similar datasets
- Attribution patterns
- License conventions
- Style patterns
- Inspector settings
- If unclear, ask user to confirm or provide missing data
Required fields (from app/scripts/StaticDatasets/types.ts):
regions: RegionSlug[] (required)public: boolean (required)dataSourceType: 'local' (required)configs: Array with at least one config (required)
Config required fields:
name: stringattributionHtml: stringinspector: { enabled: boolean, ... } or { enabled: false }layers: Layer[] (required)
Config optional fields:
category: StaticDatasetCategoryKey | nullupdatedAt: stringdescription: stringdataSourceMarkdown: stringlicence: License type (see types.ts)licenceOsmCompatible: 'licence' | 'waiver' | 'no'legends: Legend[]
Style/Legend: If not specified, make best guess:
- Use
defaultLayerStyles()from_utils/defaultLayerStyles.tsfor simple cases - For polygons: fill + outline
- For lines: colored line with width
- For points: circle markers
- Create appropriate legend entries
Example structure:
typescript1import { MetaData } from "../../../types"; 2import { defaultLayerStyles } from "../../_utils/defaultLayerStyles"; 3 4export const data: MetaData = { 5 regions: ["infravelo"], // From user or infer from group folder 6 public: true, 7 dataSourceType: "local", 8 configs: [ 9 { 10 name: "Dataset Name", 11 category: "berlin/misc", // Infer from similar datasets 12 attributionHtml: "Source Name", // Ask if unclear 13 licence: "DL-DE/ZERO-2.0", // Infer from similar datasets 14 inspector: { enabled: false }, // Default unless specified 15 layers: defaultLayerStyles(), // Or custom layers 16 }, 17 ], 18};
5. Verify Command
Check app/scripts/StaticDatasets/updateStaticDatasets.ts for correct params:
--folder-filter=<SUB_FOLDER_NAME>(matches full path, so sub-folder name works)--env=dev(or staging/production, required)
One-click command (replace <SUB_FOLDER_NAME> with actual folder name):
bash1bun --env-file=.env ./scripts/StaticDatasets/updateStaticDatasets.ts --folder-filter=<SUB_FOLDER_NAME> --env=dev
Note: updateDownloadSources.ts is for WFS downloads (requires downloadConfig.ts). Use updateStaticDatasets.ts for local GeoJSON files.
6. Verify TypeScript Compilation
Always run this after creating or modifying TypeScript files (meta.ts, transform.ts, or any imports):
bash1npm run type-check:deploy
This temporarily removes the geojson symlink, runs TypeScript type-checking, and restores the symlink. It simulates the Docker build environment where symlinks aren't available, ensuring your code will compile correctly during builds.
Validation
Before completing:
- ✅ Folder structure created
- ✅ GeoJSON file moved and prettier run
- ✅ transform.ts created only if needed
- ✅ meta.ts follows type structure (check with TypeScript)
- ✅ Similar datasets in group folder reviewed for patterns
- ✅ Command verified and provided as one-click action
- ✅
npm run type-check:deployrun successfully (see Step 6)
References
- Types:
app/scripts/StaticDatasets/types.ts - Examples:
app/scripts/StaticDatasets/geojson/region-berlin/*/meta.ts - Utils:
app/scripts/StaticDatasets/geojson/_utils/ - Docs:
docs/Features-Parameter-Deeplinks.md,docs/Regional-Masks.md - Update script:
app/scripts/StaticDatasets/updateStaticDatasets.ts