fix: Fix vector with KATO geometry

This commit is contained in:
2026-06-28 18:48:24 +05:00
parent 4fdd12e9a3
commit f364ce4c6e
3 changed files with 34 additions and 11 deletions

View File

@@ -166,11 +166,22 @@ func (r *DatasetRepository) SetProperties(ctx context.Context, id uuid.UUID, pro
return nil
}
// MarkReady sets the dataset status to ready and clears any error.
func (r *DatasetRepository) MarkReady(ctx context.Context, id uuid.UUID) error {
// MarkReady sets the dataset status to ready, stores the dissolved feature
// geometry (GeoJSON in EPSG:4326; nil keeps the existing geometry, reduced to
// the union of all features via ST_UnaryUnion), and clears any error.
func (r *DatasetRepository) MarkReady(ctx context.Context, id uuid.UUID, geometry []byte) error {
var geom any // nil -> SQL NULL -> CASE keeps existing geometry
if len(geometry) > 0 {
geom = string(geometry)
}
tag, err := r.pool.Exec(ctx,
`UPDATE datasets SET status = $2, parse_error = NULL, updated_at = now() WHERE id = $1`,
id, domain.DatasetStatusReady,
`UPDATE datasets
SET status = $2,
geometry = CASE WHEN $3::text IS NULL THEN geometry
ELSE ST_UnaryUnion(ST_SetSRID(ST_GeomFromGeoJSON($3), 4326)) END,
parse_error = NULL, updated_at = now()
WHERE id = $1`,
id, domain.DatasetStatusReady, geom,
)
if err != nil {
return mapError(err)