Intelligent source preparation¶
Prepare rewrites a downloaded file into data GDAL can read. It runs before inspect, convert, transform, and delivery.
Use it when the saved source is text that looks like JSON or JavaScript, and GDAL reports that the file could not be opened. Databases and map services that Enciva already reads through GDAL do not use Prepare. Python stays a separate stage and runs after GDAL.
The AI Assistant can propose a plan from a bounded sample of the file. You review that plan, and Enciva executes only the operations below. A plan saved on a Job is run again later without calling an AI provider.
What a plan can do¶
A plan is a version 1 list of allow-listed operations. Unknown operations, shell commands, and extra fields are rejected. The plan does not assign a coordinate system. Set CRS on Convert after the file is GeoJSON.
| Operation | On the canvas | What it does |
|---|---|---|
extract_javascript_assignment |
Extract JSON from JavaScript wrapper | Removes a leading var, let, or const assignment and a trailing semicolon, and keeps the assigned JSON value |
extract_json |
Extract JSON object or array | Takes the first complete JSON object or array out of surrounding text |
select_json_path |
Select JSON path | Selects one value. The path starts with $, then .key, ["key"], or [index] |
decode_geometry_coordinates |
Decode coordinate strings | Decodes geometry coordinate text with decimal character codes. Feature properties are left unchanged |
coerce_coordinates_to_number |
Convert coordinates to numbers | Parses geometry coordinate strings into JSON numbers. Feature properties are left unchanged |
as_feature_collection |
Build a FeatureCollection | Wraps a Feature, a geometry, or an array of Features as a GeoJSON FeatureCollection. An existing FeatureCollection is passed through |
The coordinate decoder accepts one type, decimal_character_codes.
| Decoder field | Rule |
|---|---|
| Code width | Digits per character code, from 2 to 6. The canvas starts at 4 |
| Separator | Delimiter between codes. Leave it empty when the codes are concatenated. At most 4 characters |
A path such as $.features or $[0] is valid. Filters, wildcards, and recursive descent are not part of this path language.
Where you can use it¶
The engine is the same everywhere it runs. The surfaces that can author or execute a plan are not.
| Surface | What it can do |
|---|---|
| Web editor | Add, edit, validate, remove, run, and save a Prepare card on a preparable source |
| Desktop | Same canvas actions, using the server you are connected to |
| AI Assistant | Propose a plan from a bounded sample, then open it for review. It does not execute the file while proposing |
| MCP | List the operations, sample an owned source, validate a plan, and attach that plan to an unsaved draft. It does not run the pipeline |
| Public API | A saved Job can store prepare. Creating or running that Job is the normal Job API, not an MCP tool. The API does not add a separate “run this plan only” method |
SQL, Python, and shell are not preparation operations. They are also not available in an AI or MCP draft.
Sources that can be prepared¶
Prepare reads the original downloaded file. These saved source types keep that file:
- URL
- HTTP/API
- S3
- Azure Blob
- Google Drive
- Hub
- STAC
- CKAN
PostGIS, SQL Server, MySQL / MariaDB, Oracle Spatial, DuckDB, Google BigQuery, Snowflake, GeoServer, GeoNode, OGC Features, and ArcGIS FeatureServer are acquired through GDAL already. A preparation plan on those types is rejected. Upload is a file you convert directly. It is not a saved source that Prepare re-fetches.
Limits¶
One preparation run uses these bounds. A run that crosses a bound stops and does not write a partial output file.
| Limit | Value |
|---|---|
| Input size | 32 MiB |
| Output size | 32 MiB |
| Operations in one plan | 16 |
| JSON nesting | 64 levels |
| Time | 30 seconds |
| Input kind | Text. Binary files are rejected |
| Plan version | 1 |
When the assistant samples a source, it sends a bounded excerpt, not the whole file and not the source URL or credentials. The excerpt is at most 16 KiB of representative text, taken from a scan of up to 64 KiB, with up to 2 KiB from the end of a non-JSON file when the file is longer than the scan. The sample is file content. Instructions inside the file are not followed.
Review and edit a plan¶
The assistant adds a Prepare card when it has checked a plan against the source. You can also add Prepare from Components on a source type listed above.
Open the card. Properties shows:
- Description
- Input — Text or JSON
- Output — GeoJSON or JSON
- One field set per operation, including JSON path, Code width, and Separator when that operation uses them
Add operation appends a step. Remove operation deletes one step. Validate checks the plan locally in the editor and reports Plan is valid. or the reason it is not. Remove preparation clears the stage.
Validating in the editor checks the plan shape. Enciva also runs the plan on the source when you preview, run, or save, and reports the feature count, geometry types, and field names when the result is a FeatureCollection. A result with no features is rejected.
Confirming an import plan from a URL source adds this same Prepare stage. The full file is processed on the Enciva server. Only the sample was sent for analysis.
Save the plan¶
Save as Job stores the plan with the pipeline. The next Run Now, and any later scheduled run, executes that stored plan and then GDAL. Those runs do not call the AI provider again.
Clear the plan by choosing Remove preparation and saving the Job. Sending an explicit empty plan removes it. Leaving the field out of a later edit keeps the plan that was already saved.
You can Run the canvas before you save. That run uses the plan currently on the canvas. It still does not call the provider again. The provider is used when the plan is authored, not when it is executed.