Skip to content

Commit

Permalink
This commit updates OGC map tiles api to support additional image for…
Browse files Browse the repository at this point in the history
…mats beyond PNG/JPG as well as enables content negotiation.

In our case, the motivating factor is we have map tiles that are stored as GeoTiffs which we would like to share via the OGC Tile API. Tiffs are one of the six predefined encodings allowed in an implementation - see https://docs.ogc.org/is/20-057/20-057.html#toc69.

As part of these changes, collections which do not specify a image type are now supported via content negoation (see https://docs.ogc.org/is/20-057/20-057.html#toc28).

For example, previously this command used to fail and now succeeds.

gdalinfo "OGCAPI:https://test.cubewerx.com/cubewerx/cubeserv/demo/ogcapi/Daraa/collections/AgricultureSrf?f=json"

The reason for failure is the link with a "rel" value of "http://www.opengis.net/def/rel/ogc/1.0/tilesets-map" did not specify a type field. And thus the old code did not recognize it as JPEG or PNG and ignored it.

Finally, this commit removes the hard-coded value of nbands (3 for JPEG and 4 for PNG). Instead, it tries to download a tile and read the actual number of bands. It tries to read tile 0,0,0. Perhaps that is too brittle? But the hard-coded band numbers weren't really correct, at least for JPEG, and definitely not for TIFF.
  • Loading branch information
cfisoi committed Feb 20, 2024
1 parent fb3667f commit 124a759
Show file tree
Hide file tree
Showing 9 changed files with 1,003 additions and 74 deletions.
195 changes: 195 additions & 0 deletions autotest/gdrivers/data/ogcapi/request_collections_blueMarble.http_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
HTTP/1.1 200 OK
Date: Wed, 14 Feb 2024 05:33:24 GMT
Server: Apache/2.4.52 (Ubuntu)
Expires: Tue, 11 Feb 2025 05:49:25 GMT
Access-Control-Allow-Origin: *
Vary: Accept,Accept-Encoding,Prefer
Content-Length: 7564
Access-Control-Allow-Headers: x-requested-with, Content-Type, origin, authorization, acc$
Age: 171838
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json

{
"links" : [
{
"rel" : "self",
"type" : "application/json",
"title" : "Information about the Blue Marble Next Generation (2004) data (as JSON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble?f=json"
},
{
"rel" : "alternate",
"type" : "text/plain",
"title" : "Information about the Blue Marble Next Generation (2004) data (as ECON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble?f=econ"
},
{
"rel" : "alternate",
"type" : "text/mapml",
"title" : "Information about the Blue Marble Next Generation (2004) data (as MapML)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble?f=mapml"
},
{
"rel" : "alternate",
"type" : "text/html",
"title" : "Information about the Blue Marble Next Generation (2004) data (as HTML)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble?f=html"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/dggs-list",
"title" : "Discrete Global Grid Systems for Blue Marble Next Generation (2004)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/dggs"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/schema",
"type" : "application/json",
"title" : "Schema (as JSON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/schema?f=json"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/schema",
"type" : "text/plain",
"title" : "Schema (as ECON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/schema?f=econ"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/schema",
"type" : "text/html",
"title" : "Schema (as HTML)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/schema?f=html"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/queryables",
"type" : "application/json",
"title" : "Queryables (as JSON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/queryables?f=json"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/queryables",
"type" : "text/plain",
"title" : "Queryables (as ECON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/queryables?f=econ"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/queryables",
"type" : "text/html",
"title" : "Queryables (as HTML)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/queryables?f=html"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/coverage",
"type" : "image/png",
"title" : "Blue Marble Next Generation (2004) (as PNG; Note: requesting large extent may result in generalized data)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/coverage?f=png"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/coverage",
"type" : "image/tiff; application=geotiff",
"title" : "Blue Marble Next Generation (2004) (as GeoTIFF; Note: requesting large extent may result in generalized data)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/coverage?f=tif"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/coverage-domainset",
"type" : "application/json",
"title" : "Blue Marble Next Generation (2004) (domain set of the coverage for this collection)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/coverage/domainset?f=json"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/coverage-rangetype",
"type" : "application/json",
"title" : "Blue Marble Next Generation (2004) (range type of the coverage for this collection)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/coverage/rangetype?f=json"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/map",
"type" : "image/png",
"title" : "Default map (as PNG)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map.png"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/map",
"type" : "image/jpeg",
"title" : "Default map (as JPG)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map.jpg"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/map",
"type" : "image/tif",
"title" : "Default map (as GeoTIFF)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map.tif"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-map",
"type" : "application/json",
"title" : "Map tilesets available for this dataset (as JSON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles?f=json"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-map",
"type" : "text/plain",
"title" : "Map tilesets available for this dataset (as ECON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles?f=econ"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-map",
"type" : "text/html",
"title" : "Map tilesets available for this dataset (as HTML)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles?f=html"
},
{
"rel" : "styles",
"type" : "text/html",
"title" : "Styles for Blue Marble Next Generation (2004) (as HTML)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/styles?f=html"
},
{
"rel" : "styles",
"type" : "application/json",
"title" : "Styles for Blue Marble Next Generation (2004) (as JSON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/styles?f=json"
},
{
"rel" : "styles",
"type" : "text/plain",
"title" : "Styles for Blue Marble Next Generation (2004) (as ECON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/styles?f=econ"
}
],
"title" : "Blue Marble Next Generation (2004)",
"extent" : {
"spatial" : {
"bbox" : [ [ -180, -90, 180, 90 ] ],
"grid" : [
{
"cellsCount" : 131072,
"resolution" : 0.0027465820312
},
{
"cellsCount" : 65536,
"resolution" : 0.0027465820312
}
]
},
"temporal" : {
"interval" : [ [ "2004-01", "2004-12" ] ],
"grid" : {
"cellsCount" : 12,
"resolution" : "P1M"
}
}
},
"crs" : [
"http://www.opengis.net/def/crs/OGC/1.3/CRS84",
"http://www.opengis.net/def/crs/EPSG/0/4326",
"http://www.opengis.net/def/crs/EPSG/0/3857",
"http://www.opengis.net/def/crs/EPSG/0/3395"
],
"storageCrs" : "http://www.opengis.net/def/crs/OGC/1.3/CRS84",
"id" : "blueMarble",
"dataType" : "map",
"attribution" : "NASA Earth Observatory",
"minScaleDenominator" : 1091957.5469310893677,
"minCellSize" : 0.0027465820312
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
HTTP/1.1 200 OK
Date: Wed, 14 Feb 2024 05:33:25 GMT
Server: Apache/2.4.52 (Ubuntu)
Expires: Thu, 13 Feb 2025 04:01:39 GMT
Access-Control-Allow-Origin: *
Vary: Accept,Accept-Encoding,Prefer
Content-Length: 5775
Access-Control-Allow-Headers: x-requested-with, Content-Type, origin, authorization, acc$
Age: 5505
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json

{
"title" : "Blue Marble Next Generation (2004)",
"tileMatrixSetURI" : "http://www.opengis.net/def/tilematrixset/OGC/1.0/WorldMercatorWGS84Quad",
"crs" : "http://www.opengis.net/def/crs/EPSG/0/3395",
"dataType" : "map",
"tileMatrixSetLimits" : [
{ "tileMatrix" : "0", "minTileRow" : 0, "maxTileRow" : 0, "minTileCol" : 0, "maxTileCol" : 0 },
{ "tileMatrix" : "1", "minTileRow" : 0, "maxTileRow" : 1, "minTileCol" : 0, "maxTileCol" : 1 },
{ "tileMatrix" : "2", "minTileRow" : 0, "maxTileRow" : 3, "minTileCol" : 0, "maxTileCol" : 3 },
{ "tileMatrix" : "3", "minTileRow" : 0, "maxTileRow" : 7, "minTileCol" : 0, "maxTileCol" : 7 },
{ "tileMatrix" : "4", "minTileRow" : 0, "maxTileRow" : 15, "minTileCol" : 0, "maxTileCol" : 15 },
{ "tileMatrix" : "5", "minTileRow" : 0, "maxTileRow" : 31, "minTileCol" : 0, "maxTileCol" : 31 },
{ "tileMatrix" : "6", "minTileRow" : 0, "maxTileRow" : 63, "minTileCol" : 0, "maxTileCol" : 63 },
{ "tileMatrix" : "7", "minTileRow" : 0, "maxTileRow" : 127, "minTileCol" : 0, "maxTileCol" : 127 },
{ "tileMatrix" : "8", "minTileRow" : 0, "maxTileRow" : 255, "minTileCol" : 0, "maxTileCol" : 255 },
{ "tileMatrix" : "9", "minTileRow" : 0, "maxTileRow" : 511, "minTileCol" : 0, "maxTileCol" : 511 }
],
"links" : [
{
"rel" : "self",
"type" : "application/json",
"title" : "The JSON representation of the WorldMercatorWGS84Quad map tileset for blueMarble",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad?f=json"
},
{
"rel" : "alternate",
"type" : "text/plain",
"title" : "The ECON representation of the WorldMercatorWGS84Quad map tileset for blueMarble",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad?f=econ"
},
{
"rel" : "alternate",
"type" : "text/html",
"title" : "The HTML representation of the WorldMercatorWGS84Quad map tileset for blueMarble",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad?=html"
},
{
"rel" : "alternate",
"type" : "application/json+tile",
"title" : "The TileJSON representation of the WorldMercatorWGS84Quad map tileset for blueMarble",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad?f=tilejson"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme",
"type" : "application/json",
"title" : "WorldMercatorWGS84QuadTileMatrixSet definition (as JSON)",
"href" : "http://127.0.0.1:8080/fakeogcapi/tileMatrixSets/WorldMercatorWGS84Quad"
},
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/geodata",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble"
},
{
"rel" : "item",
"type" : "application/vnd.gnosis-map-tile",
"title" : "WorldMercatorWGS84Quad map tiles for blueMarble (as GNOSIS Map Tiles)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad/{tileMatrix}/{tileRow}/{tileCol}.gmt",
"templated" : true
},
{
"rel" : "item",
"type" : "image/png",
"title" : "WorldMercatorWGS84Quad map tiles for blueMarble (as PNG)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad/{tileMatrix}/{tileRow}/{tileCol}.png",
"templated" : true
},
{
"rel" : "item",
"type" : "image/jpeg",
"title" : "WorldMercatorWGS84Quad map tiles for blueMarble (as JPG)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad/{tileMatrix}/{tileRow}/{tileCol}.jpg",
"templated" : true
},
{
"rel" : "item",
"type" : "image/tiff; application=geotiff",
"title" : "WorldMercatorWGS84Quad map tiles for blueMarble (as GeoTIFF)",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble/map/tiles/WorldMercatorWGS84Quad/{tileMatrix}/{tileRow}/{tileCol}.tif",
"templated" : true
}
],
"layers" : [
{
"id" : "blueMarble",
"dataType" : "map",
"minScaleDenominator" : 1091957.5469310893677,
"minCellSize" : 305.748113140705,
"maxTileMatrix" : "9",
"links" : [
{
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/geodata",
"href" : "http://127.0.0.1:8080/fakeogcapi/collections/blueMarble"
}
],
"propertiesSchema" : {
"$schema" : "https://json-schema.org/draft/2020-12/schema",
"type" : "object",
"properties" : { "a" : {
"title" : "Alpha channel",
"type" : "integer",
"x-ogc-property-seq" : 4
}, "b" : {
"title" : "Blue channel",
"type" : "integer",
"x-ogc-property-seq" : 3
}, "g" : {
"title" : "Green channel",
"type" : "integer",
"x-ogc-property-seq" : 2
}, "r" : {
"title" : "Red channel",
"type" : "integer",
"x-ogc-property-seq" : 1
} }
}
}
],
"centerPoint" : {
"coordinates" : [ 0, 0 ],
"tileMatrix" : "4",
"scaleDenominator" : 34942641.501794859767,
"cellSize" : 9783.9396205025605,
"crs" : "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
}
}
Loading

0 comments on commit 124a759

Please sign in to comment.