fix: Fix vector with KATO geometry
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user