Skip to content

Commit

Permalink
chore: move date/time func
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Oct 15, 2024
1 parent 58a0b7d commit 4605ebc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions config/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func (c *GeoSpatialCollection) UnmarshalJSON(b []byte) error {
return yaml.Unmarshal(b, c)
}

// HasDateTime true when collection has temporal support, false otherwise
func (c *GeoSpatialCollection) HasDateTime() bool {
return c.Metadata != nil && c.Metadata.TemporalProperties != nil
}

// +kubebuilder:object:generate=true
type GeoSpatialCollectionMetadata struct {
// Human friendly title of this collection. When no title is specified the collection ID is used.
Expand Down
8 changes: 2 additions & 6 deletions internal/ogc/features/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (f *Features) Features() http.HandlerFunc {
return
}
url := featureCollectionURL{*cfg.BaseURL.URL, r.URL.Query(), cfg.OgcAPI.Features.Limit,
f.configuredPropertyFilters[collectionID], hasDateTime(collection)}
f.configuredPropertyFilters[collectionID], collection.HasDateTime()}
encodedCursor, limit, inputSRID, outputSRID, contentCrs, bbox, referenceDate, propertyFilters, err := url.parse()
if err != nil {
engine.RenderProblem(engine.ProblemBadRequest, w, err.Error())
Expand Down Expand Up @@ -402,15 +402,11 @@ func querySingleDatasource(input domain.SRID, output domain.SRID, bbox *geom.Ext

func getTemporalCriteria(collection config.GeoSpatialCollection, referenceDate time.Time) ds.TemporalCriteria {
var temporalCriteria ds.TemporalCriteria
if hasDateTime(collection) {
if collection.HasDateTime() {
temporalCriteria = ds.TemporalCriteria{
ReferenceDate: referenceDate,
StartDateProperty: collection.Metadata.TemporalProperties.StartDate,
EndDateProperty: collection.Metadata.TemporalProperties.EndDate}
}
return temporalCriteria
}

func hasDateTime(collection config.GeoSpatialCollection) bool {
return collection.Metadata != nil && collection.Metadata.TemporalProperties != nil
}

0 comments on commit 4605ebc

Please sign in to comment.