Write icon
Size icon
Assert icon
Script icon
Docker icon
Queries icon
Sequential icon
Query icon
If icon
Pause icon
Log icon
Webhook icon

Repair PostGIS Polygon Batches with Quarantine and Approved Publication

Stage and repair GeoJSON polygons in PostGIS, quarantine unsuitable features and approve a fingerprinted report before publishing a snapshot.

Categories
Data

Repair GeoJSON polygons in real PostGIS.

How it works

  1. Validate input; stage originals and ST_MakeValid candidates. Quarantine whole features with unsuitable repairs.
  2. Export one report with originals, candidates and reasons. PREVIEW stops here.
  3. REVIEW_AND_PUBLISH pauses for 24 hours. Require the fingerprint, a note and acknowledgement for partial batches.
  4. Recheck the stored report fingerprint, age and eligibility in SQL, then save one snapshot per execution. Finally remove that execution’s stage.

What you get

  • Report: {{ outputs.review_report.uri }}; fingerprint: {{ outputs.stage.row.manifest_sha256 }}.
  • Receipt: {{ outputs.publication_receipt.uri }} after publication.
  • GeoJSON snapshots in blueprint_polygon_review.published, keyed by batch_id. Retries return the same snapshot; no live dataset is replaced.

Who it's for

GIS and data engineers reviewing service zones or delivery boundaries before downstream use.

Why orchestrate this with Kestra

Separate tasks make human review visible and retries recoverable.

Prerequisites

PostgreSQL/PostGIS, a dedicated non-superuser allowed to create this schema, and Docker on the worker. Set role statement_timeout=30s and lock_timeout=5s. Use a fresh schema for this example.

Secrets

  • POSTGRES_JDBC_URL, POSTGRES_USERNAME, POSTGRES_PASSWORD: database connection.
  • POSTGIS_REVIEW_WEBHOOK_KEY: keyed preview webhook.

Quick start

  1. Configure secrets; execute with defaults: optional FILE geojson, STRING dataset_id=service-zones-demo, SELECT mode=PREVIEW (or REVIEW_AND_PUBLISH), BOOL allow_partial=false.
  2. Inspect the report. The example yields two eligible and two quarantined features. To publish, run REVIEW_AND_PUBLISH with allow_partial=true.
  3. Resume with approved=true, reviewed_manifest_sha256 copied from stage outputs, acknowledge_partial=true and a nonempty review_note. Rejection defaults false; no snapshot is saved.
  4. Query published by batch_id=execution.id. Webhook JSON {"geojson": } previews only; manual FILE takes precedence.

How to extend

Limits: 1 MiB input, 100 features, 10,000 positions; eligible repairs have at most 20,000 vertices. Malformed rings fail validation; null/unsupported geometries and non-polygon repairs are quarantined. Report length is capped before export. Validity does not certify intended boundaries. Add downstream promotion separately. Keep exported reports. Killed runs may leave stage rows; clean these by batch_id. Define snapshot retention.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.