diff --git a/internal/ogc/features/domain/cursor.go b/internal/ogc/features/domain/cursor.go index 2f609b43..056bd12c 100644 --- a/internal/ogc/features/domain/cursor.go +++ b/internal/ogc/features/domain/cursor.go @@ -55,8 +55,8 @@ func encodeCursor(fid int64, filtersChecksum []byte) EncodedCursor { return EncodedCursor(base64.RawURLEncoding.EncodeToString(fidAsBytes) + string(separator) + base64.RawURLEncoding.EncodeToString(filtersChecksum)) } -// Decode turns encoded cursor into DecodedCursor and verifies the -// that the checksum of query params that act as filters hasn't changed +// Decode turns encoded cursor into DecodedCursor and verifies that +// the checksum of query params that act as filters hasn't changed func (c EncodedCursor) Decode(filtersChecksum []byte) DecodedCursor { value, err := neturl.QueryUnescape(string(c)) if err != nil || value == "" { diff --git a/internal/ogc/features/main.go b/internal/ogc/features/main.go index a5874697..73c5ccfb 100644 --- a/internal/ogc/features/main.go +++ b/internal/ogc/features/main.go @@ -279,23 +279,22 @@ func configurePropertyFiltersWithAllowedValues(datasources map[DatasourceKey]ds. collections map[string]config.GeoSpatialCollection) map[string]ds.PropertyFiltersWithAllowedValues { result := make(map[string]ds.PropertyFiltersWithAllowedValues) - nrOfFilters := 0 for k, datasource := range datasources { - filters := datasource.GetPropertyFiltersWithAllowedValues(k.collectionID) - result[k.collectionID] = filters - nrOfFilters += len(filters) + result[k.collectionID] = datasource.GetPropertyFiltersWithAllowedValues(k.collectionID) } // sanity check to make sure datasources return all configured property filters. - nrOfExpectedFilters := 0 for _, collection := range collections { + actual := len(result[collection.ID]) if collection.Features != nil && collection.Features.Filters.Properties != nil { - nrOfExpectedFilters += len(collection.Features.Filters.Properties) + expected := len(collection.Features.Filters.Properties) + if expected != actual { + log.Fatalf("number of property filters received from datasource for collection '%s' does not "+ + "match the number of configured property filters. Expected filters: %d, got from datasource: %d", + collection.ID, expected, actual) + } } } - if nrOfExpectedFilters != nrOfFilters { - log.Fatal("number of property filters received from datasource does not match the number of configured property filters") - } return result }