Skip to content

Commit

Permalink
refactor(config): Re-order some funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Sep 12, 2024
1 parent c251afd commit ecbadf6
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 111 deletions.
16 changes: 16 additions & 0 deletions config/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ type CollectionLinks struct {
// <placeholder>
}

// +kubebuilder:object:generate=true
type DownloadLink struct {
// Name of the provided download
Name string `yaml:"name" json:"name" validate:"required"`

// Full URL to the file to be downloaded
AssetURL *URL `yaml:"assetUrl" json:"assetUrl" validate:"required"`

// Approximate size of the file to be downloaded
// +optional
Size string `yaml:"size,omitempty" json:"size,omitempty"`

// Media type of the file to be downloaded
MediaType MediaType `yaml:"mediaType" json:"mediaType" validate:"required"`
}

// Unique lists all unique GeoSpatialCollections (no duplicate IDs),
// return results in alphabetic order
func (g GeoSpatialCollections) Unique() []GeoSpatialCollection {
Expand Down
206 changes: 95 additions & 111 deletions config/ogcapi_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,108 +13,6 @@ import (
"github.com/docker/go-units"
)

// +kubebuilder:object:generate=true
type CollectionEntryFeatures struct {
// Optional way to explicitly map a collection ID to the underlying table in the datasource.
// +optional
TableName *string `yaml:"tableName,omitempty" json:"tableName,omitempty"`

// Optional collection specific datasources. Mutually exclusive with top-level defined datasources.
// +optional
Datasources *Datasources `yaml:"datasources,omitempty" json:"datasources,omitempty"`

// Filters available for this collection
// +optional
Filters FeatureFilters `yaml:"filters,omitempty" json:"filters,omitempty"`

// Downloads available for this collection through map sheets. Note that 'map sheets' refer to a map
// divided in rectangle areas that can be downloaded individually.
// +optional
MapSheetDownloads *MapSheetDownloads `yaml:"mapSheetDownloads,omitempty" json:"mapSheetDownloads,omitempty"`

// Configuration specifically related to HTML/Web representation
// +optional
Web *WebConfig `yaml:"web,omitempty" json:"web,omitempty"`
}

// +kubebuilder:object:generate=true
type FeatureFilters struct {
// OAF Part 1: filter on feature properties
// https://docs.ogc.org/is/17-069r4/17-069r4.html#_parameters_for_filtering_on_feature_properties
//
// +optional
Properties []PropertyFilter `yaml:"properties,omitempty" json:"properties,omitempty" validate:"dive"`

// OAF Part 3: add config for complex/CQL filters here
// <placeholder>
}

// +kubebuilder:object:generate=true
type DownloadLink struct {
// Name of the provided download
Name string `yaml:"name" json:"name" validate:"required"`

// Full URL to the file to be downloaded
AssetURL *URL `yaml:"assetUrl" json:"assetUrl" validate:"required"`

// Approximate size of the file to be downloaded
// +optional
Size string `yaml:"size,omitempty" json:"size,omitempty"`

// Media type of the file to be downloaded
MediaType MediaType `yaml:"mediaType" json:"mediaType" validate:"required"`
}

// +kubebuilder:object:generate=true
type MapSheetDownloads struct {
// Properties that provide the download details per map sheet. Note that 'map sheets' refer to a map
// divided in rectangle areas that can be downloaded individually.
Properties MapSheetDownloadProperties `yaml:"properties" json:"properties" validate:"required"`
}

// +kubebuilder:object:generate=true
type MapSheetDownloadProperties struct {
// Property/column containing file download URL
AssetURL string `yaml:"assetUrl" json:"assetUrl" validate:"required"`

// Property/column containing file size
Size string `yaml:"size" json:"size" validate:"required"`

// The actual media type (not a property/column) of the download, like application/zip.
MediaType MediaType `yaml:"mediaType" json:"mediaType" validate:"required"`

// Property/column containing the map sheet identifier
MapSheetID string `yaml:"mapSheetId" json:"mapSheetId" validate:"required"`
}

// +kubebuilder:object:generate=true
type WebConfig struct {
// Viewer config for displaying multiple features on a map
// +optional
FeaturesViewer *FeaturesViewer `yaml:"featuresViewer,omitempty" json:"featuresViewer,omitempty"`

// Viewer config for displaying a single feature on a map
// +optional
FeatureViewer *FeaturesViewer `yaml:"featureViewer,omitempty" json:"featureViewer,omitempty"`

// Whether URLs (to external resources) in the HTML representation of features should be rendered as hyperlinks.
// +optional
URLAsHyperlink bool `yaml:"urlAsHyperlink,omitempty" json:"urlAsHyperlink,omitempty"`
}

// +kubebuilder:object:generate=true
type FeaturesViewer struct {
// Maximum initial zoom level of the viewer when rendering features, specified by scale denominator.
// Defaults to 1000 (= scale 1:1000).
// +optional
MinScale int `yaml:"minScale,omitempty" json:"minScale,omitempty" validate:"gt=0" default:"1000"`

// Minimal initial zoom level of the viewer when rendering features, specified by scale denominator
// (not set by default).
// +optional
MaxScale *int `yaml:"maxScale,omitempty" json:"maxScale,omitempty" validate:"omitempty,gt=0,gtefield=MinScale"`
}

// +kubebuilder:object:generate=true
type OgcAPIFeatures struct {
// Basemap to use in embedded viewer on the HTML pages.
Expand Down Expand Up @@ -168,18 +66,27 @@ func (oaf *OgcAPIFeatures) ProjectionsForCollection(collectionID string) []strin
}

// +kubebuilder:object:generate=true
type Limit struct {
// Number of features to return by default.
// +kubebuilder:default=10
// +kubebuilder:validation:Minimum=2
type CollectionEntryFeatures struct {
// Optional way to explicitly map a collection ID to the underlying table in the datasource.
// +optional
Default int `yaml:"default,omitempty" json:"default,omitempty" validate:"gt=1" default:"10"`
TableName *string `yaml:"tableName,omitempty" json:"tableName,omitempty"`

// Max number of features to return. Should be larger than 100 since the HTML interface always offers a 100 limit option.
// +kubebuilder:default=1000
// +kubebuilder:validation:Minimum=100
// Optional collection specific datasources. Mutually exclusive with top-level defined datasources.
// +optional
Max int `yaml:"max,omitempty" json:"max,omitempty" validate:"gte=100" default:"1000"`
Datasources *Datasources `yaml:"datasources,omitempty" json:"datasources,omitempty"`

// Filters available for this collection
// +optional
Filters FeatureFilters `yaml:"filters,omitempty" json:"filters,omitempty"`

// Downloads available for this collection through map sheets. Note that 'map sheets' refer to a map
// divided in rectangle areas that can be downloaded individually.
// +optional
MapSheetDownloads *MapSheetDownloads `yaml:"mapSheetDownloads,omitempty" json:"mapSheetDownloads,omitempty"`

// Configuration specifically related to HTML/Web representation
// +optional
Web *WebConfig `yaml:"web,omitempty" json:"web,omitempty"`
}

// +kubebuilder:object:generate=true
Expand Down Expand Up @@ -385,6 +292,83 @@ func (cache *GeoPackageCloudCache) MaxSizeAsBytes() (int64, error) {
return units.FromHumanSize(cache.MaxSize)
}

// +kubebuilder:object:generate=true
type FeatureFilters struct {
// OAF Part 1: filter on feature properties
// https://docs.ogc.org/is/17-069r4/17-069r4.html#_parameters_for_filtering_on_feature_properties
//
// +optional
Properties []PropertyFilter `yaml:"properties,omitempty" json:"properties,omitempty" validate:"dive"`

// OAF Part 3: add config for complex/CQL filters here
// <placeholder>
}

// +kubebuilder:object:generate=true
type MapSheetDownloads struct {
// Properties that provide the download details per map sheet. Note that 'map sheets' refer to a map
// divided in rectangle areas that can be downloaded individually.
Properties MapSheetDownloadProperties `yaml:"properties" json:"properties" validate:"required"`
}

// +kubebuilder:object:generate=true
type MapSheetDownloadProperties struct {
// Property/column containing file download URL
AssetURL string `yaml:"assetUrl" json:"assetUrl" validate:"required"`

// Property/column containing file size
Size string `yaml:"size" json:"size" validate:"required"`

// The actual media type (not a property/column) of the download, like application/zip.
MediaType MediaType `yaml:"mediaType" json:"mediaType" validate:"required"`

// Property/column containing the map sheet identifier
MapSheetID string `yaml:"mapSheetId" json:"mapSheetId" validate:"required"`
}

// +kubebuilder:object:generate=true
type WebConfig struct {
// Viewer config for displaying multiple features on a map
// +optional
FeaturesViewer *FeaturesViewer `yaml:"featuresViewer,omitempty" json:"featuresViewer,omitempty"`

// Viewer config for displaying a single feature on a map
// +optional
FeatureViewer *FeaturesViewer `yaml:"featureViewer,omitempty" json:"featureViewer,omitempty"`

// Whether URLs (to external resources) in the HTML representation of features should be rendered as hyperlinks.
// +optional
URLAsHyperlink bool `yaml:"urlAsHyperlink,omitempty" json:"urlAsHyperlink,omitempty"`
}

// +kubebuilder:object:generate=true
type FeaturesViewer struct {
// Maximum initial zoom level of the viewer when rendering features, specified by scale denominator.
// Defaults to 1000 (= scale 1:1000).
// +optional
MinScale int `yaml:"minScale,omitempty" json:"minScale,omitempty" validate:"gt=0" default:"1000"`

// Minimal initial zoom level of the viewer when rendering features, specified by scale denominator
// (not set by default).
// +optional
MaxScale *int `yaml:"maxScale,omitempty" json:"maxScale,omitempty" validate:"omitempty,gt=0,gtefield=MinScale"`
}

// +kubebuilder:object:generate=true
type Limit struct {
// Number of features to return by default.
// +kubebuilder:default=10
// +kubebuilder:validation:Minimum=2
// +optional
Default int `yaml:"default,omitempty" json:"default,omitempty" validate:"gt=1" default:"10"`

// Max number of features to return. Should be larger than 100 since the HTML interface always offers a 100 limit option.
// +kubebuilder:default=1000
// +kubebuilder:validation:Minimum=100
// +optional
Max int `yaml:"max,omitempty" json:"max,omitempty" validate:"gte=100" default:"1000"`
}

// +kubebuilder:object:generate=true
type PropertyFilter struct {
// Needs to match with a column name in the feature table (in the configured datasource)
Expand Down

0 comments on commit ecbadf6

Please sign in to comment.