github.com/PDOK/gokoala@v0.50.6/internal/ogc/features/datasources/datasource.go (about)

     1  package datasources
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/PDOK/gokoala/internal/ogc/features/domain"
     8  	"github.com/go-spatial/geom"
     9  )
    10  
    11  // Datasource holds all Features for a single object type in a specific projection.
    12  type Datasource interface {
    13  
    14  	// GetFeatureIDs returns all IDs of Features matching the given criteria, as well as Cursors for pagination.
    15  	// To be used in concert with GetFeaturesByID
    16  	GetFeatureIDs(ctx context.Context, collection string, criteria FeaturesCriteria) ([]int64, domain.Cursors, error)
    17  
    18  	// GetFeaturesByID returns a collection of Features with the given IDs. To be used in concert with GetFeatureIDs
    19  	GetFeaturesByID(ctx context.Context, collection string, featureIDs []int64) (*domain.FeatureCollection, error)
    20  
    21  	// GetFeatures returns all Features matching the given criteria and Cursors for pagination
    22  	GetFeatures(ctx context.Context, collection string, criteria FeaturesCriteria) (*domain.FeatureCollection, domain.Cursors, error)
    23  
    24  	// GetFeature returns a specific Feature
    25  	GetFeature(ctx context.Context, collection string, featureID int64) (*domain.Feature, error)
    26  
    27  	// GetFeatureTableMetadata returns metadata about a feature table associated with the given collection
    28  	GetFeatureTableMetadata(collection string) (FeatureTableMetadata, error)
    29  
    30  	// Close closes (connections to) the datasource gracefully
    31  	Close()
    32  }
    33  
    34  // FeaturesCriteria to select a certain set of Features
    35  type FeaturesCriteria struct {
    36  	// pagination
    37  	Cursor domain.DecodedCursor
    38  	Limit  int
    39  
    40  	// multiple projections support
    41  	InputSRID  int // derived from bbox or filter param when available, or WGS84 as default
    42  	OutputSRID int // derived from crs param when available, or WGS84 as default
    43  
    44  	// filtering by bounding box
    45  	Bbox *geom.Extent
    46  
    47  	// filtering by reference date
    48  	TemporalCriteria TemporalCriteria
    49  
    50  	// filtering by properties
    51  	PropertyFilters map[string]string
    52  
    53  	// filtering by CQL
    54  	Filter     string
    55  	FilterLang string
    56  }
    57  
    58  type TemporalCriteria struct {
    59  	// reference date
    60  	ReferenceDate time.Time
    61  
    62  	// startDate and endDate properties
    63  	StartDateProperty string
    64  	EndDateProperty   string
    65  }
    66  
    67  // FeatureTableMetadata abstraction to access metadata of a feature table (aka attribute table)
    68  type FeatureTableMetadata interface {
    69  
    70  	// ColumnsWithDataType returns a mapping from column names to column data types.
    71  	// Note: data types can be datasource specific.
    72  	ColumnsWithDataType() map[string]string
    73  }