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

@@ -101,11 +101,14 @@ func (r *stubDatasetRepo) SaveMapping(_ context.Context, id uuid.UUID, kato stri
return d, nil
}
func (r *stubDatasetRepo) MarkReady(_ context.Context, id uuid.UUID) error {
func (r *stubDatasetRepo) MarkReady(_ context.Context, id uuid.UUID, geometry []byte) error {
d, ok := r.store[id]
if !ok {
return domain.ErrNotFound
}
if len(geometry) > 0 {
d.Geometry = geometry
}
d.Status = domain.DatasetStatusReady
r.store[id] = d
return nil
@@ -765,7 +768,9 @@ func TestDatasetService_Extract(t *testing.T) {
}
rows := []map[string]string{{"като": "751010000", "F_2023": "100"}}
rp := RowParser(func(string, []byte) ([]map[string]string, error) { return rows, nil })
svc := NewDatasetService(repo, &stubStore{}, stubCategoryReader{exists: true}, &stubEnqueuer{}, noopParser, rp, &stubConverter{})
geom := []byte(`{"type":"GeometryCollection","geometries":[]}`)
conv := &stubConverter{vectorGeom: geom}
svc := NewDatasetService(repo, &stubStore{}, stubCategoryReader{exists: true}, &stubEnqueuer{}, noopParser, rp, conv)
if err := svc.Extract(context.Background(), id); err != nil {
t.Fatalf("unexpected error: %v", err)
@@ -773,6 +778,9 @@ func TestDatasetService_Extract(t *testing.T) {
if repo.store[id].Status != domain.DatasetStatusReady {
t.Fatalf("want ready, got %q", repo.store[id].Status)
}
if string(repo.store[id].Geometry) != string(geom) {
t.Fatalf("want geometry %s, got %s", geom, repo.store[id].Geometry)
}
got := repo.observations[id]
if len(got) != 1 || got[0].KatoCode != "751010000" || got[0].Value == nil || *got[0].Value != 100 {
t.Fatalf("unexpected observations: %+v", got)