Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ats_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,37 @@ func TestATSAnnexARoutesAreClassRoutes(t *testing.T) {
t.Fatal("Annex A holds no route row, so this test would assert nothing")
}
}

// Each class is declared as its standard publishes it, and a class published
// under https:// also under http://, the identifier OGC's test suite and the
// standard's OpenAPI document compare (#conformsTo). A class published under
// http:// alone gains no https:// spelling.
func TestConformanceNamesEachClassAsPublished(t *testing.T) {
declared := declaredClasses(t)
for _, c := range []string{
// ets-ogcapi-coverages10, ConformanceClass.CORE
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/core",
// the Coverages draft, OGC 19-087 1.0.0rc4, clause 2
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/core",
// OGC API - Common - Part 2, OGC 20-024, clause 2
"https://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections",
// its OpenAPI document, rConformance.yaml
"http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections",
// OGC API - Common - Part 1, OGC 19-072, which writes http:// alone
"http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core",
} {
if !declared[c] {
t.Errorf("the conformance declaration does not name %s", c)
}
}
for c := range declared {
if rest, ok := strings.CutPrefix(c, "https://"); ok && !declared["http://"+rest] {
t.Errorf("%s is declared and its http:// spelling is not", c)
}
}
for _, c := range []string{confMFCommon, confMovingFeatures, confCommonCore, edrConformance} {
if declared["https://"+strings.TrimPrefix(c, "http://")] {
t.Errorf("%s is published under http:// alone and is declared under https://", c)
}
}
}
5 changes: 4 additions & 1 deletion edr.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import (
)

// The conformance class of EDR the tier declares: the core, which
// /req/core/conformance names; the queries carry no class of their own in 1.1.
// /req/core/conformance names. The class queries of 1.1 holds eight queries, each
// one a server MAY answer, and the tier answers four; the class covjson of 1.1
// names CoverageJSON application/prs.coverage+json, where the tier writes
// application/vnd.cov+json, the type OGC CoverageJSON (OGC 21-069r2) defines.
const edrConformance = "http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/core"

// The queries a raster collection answers, with the WKT geometry each reads.
Expand Down
26 changes: 23 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const (
confMovingFeatures = "http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/movingfeatures"
confCQuery = "http://www.opengis.net/spec/ogcapi-movingfeatures-4/1.0/conf/cquery"
confCommonCore = "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core"
confCommonCollections = "http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections"
confCommonCollections = "https://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections"
)

// extension marks a route that is a requirement of no class the tier declares:
Expand Down Expand Up @@ -374,10 +374,30 @@ func landing(w http.ResponseWriter, r *http.Request) {
// conformance writes the conformance declaration, beside #landing: the classes
// of OGC API - Moving Features and Common the tier implements, and the
// #coverageConformance classes of OGC API - Coverages its raster collections do.
//
// Each class is named as its standard publishes it. OGC API - Common - Part 2
// and the Coverages draft publish their identifiers under https:// in their
// text, while their OpenAPI documents and OGC's test suite (ets-ogcapi-
// coverages10) write them under http://, the scheme OGC's naming policy (OGC
// 10-103r1) roots specification elements at. A reader compares identifiers as
// strings, so a class published under https:// is declared under both.
func conformance(w http.ResponseWriter, r *http.Request) {
writeJSON(w, 200, map[string]any{"conformsTo": append([]string{
writeJSON(w, 200, map[string]any{"conformsTo": conformsTo()})
}

// conformsTo answers the identifiers the conformance declaration lists.
func conformsTo() []string {
classes := append([]string{
confMFCommon, confMFCollection, confMovingFeatures, confCQuery, confCommonCore, confCommonCollections,
}, append(coverageConformance, edrConformance)...)})
}, append(coverageConformance, edrConformance)...)
var out []string
for _, c := range classes {
out = append(out, c)
if rest, ok := strings.CutPrefix(c, "https://"); ok {
out = append(out, "http://"+rest)
}
}
return out
}
func listCollections(w http.ResponseWriter, r *http.Request) {
rows, err := db.Query(r.Context(), `SELECT id, title, description, item_type, crs FROM collections ORDER BY id`)
Expand Down
7 changes: 7 additions & 0 deletions samples/conformance-declaration.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
"http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/movingfeatures",
"http://www.opengis.net/spec/ogcapi-movingfeatures-4/1.0/conf/cquery",
"http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core",
"https://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections",
"http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections",
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/core",
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/core",
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/subsetting-spatial",
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/subsetting-spatial",
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/subsetting-temporal",
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/subsetting-temporal",
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/field-selection",
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/field-selection",
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/geotiff",
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/geotiff",
"https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/coveragejson",
"http://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/coveragejson",
"http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/core"
]
}
Expand Down