Skip to main content

Tile cache

GC2 (Geo Compute Cloud) serves every layer as tiles as well as through WMS. Tiles are drawn once and kept in a cache, so a map of many layers stays fast however heavy the data behind it is. This page covers the four parts of the tile side:

Tilesets​

A tileset is a named set of tiles. There are two kinds:

TilesetNameHolds
Layerschema.tableImage tiles of one layer. schema.table.mvt and schema.table.json are its vector variants.
SchemaschemaImage tiles of every layer in the schema, drawn together. schema.mvt is the vector variant.

Every tileset has a grid called g20. That is the grid's name; GoogleMapsCompatible is the title of the same grid, as shown in capabilities documents.

Fetch tiles​

Tiles are fetched through a proxy that authorizes each request before it reaches the cache:

https://api.gc2.io/api/v4/mapcache/database/{database}/{path}

It is one of the public routes: it takes an Authorization: Bearer token, HTTP Basic or no credentials, and each tile request is authorized against the tileset's layer. A layer that is open to everyone can be fetched without credentials; a tileset the caller may not read is 403.

The {path} is the service path, and the grid is written differently in each service:

ServicePathGrid
TMStms/1.0.0/{tileset}@{grid}/{z}/{x}/{y}.{ext}@ suffix on the tileset name
XYZgmaps/{tileset}@{grid}/{z}/{x}/{y}.{ext}@ suffix on the tileset name
WMTSwmts/1.0.0/{tileset}/default/{grid}/{z}/{y}/{x}.{ext}Its own path segment
WMTS capabilitieswmts/1.0.0/WMTSCapabilities.xml
An XYZ tile
GET https://api.gc2.io/api/v4/mapcache/database/mydb/gmaps/rockhall.inductees@g20/10/512/340.png HTTP/1.1
The same tile as WMTS, with a token
GET https://api.gc2.io/api/v4/mapcache/database/mydb/wmts/1.0.0/rockhall.inductees/default/g20/10/340/512.png HTTP/1.1
Authorization: Bearer abc123
caution

A tile request whose tileset name cannot be resolved is answered with 403, not 404. Writing the grid with @ in a WMTS path, or as a path segment in a TMS or XYZ path, gives exactly that, so a 403 on a tile is as often a mistake in the URL as a matter of access.

Schema tilesets​

The schema tileset is drawn from all the layers of a schema at once, so a client loads one tile layer instead of one per layer. The layers are drawn by their sort_id, lowest at the bottom.

Because the image shows every layer, every layer is authorized: the strictest layer decides. One layer that needs credentials makes the whole schema tileset unreachable without them, and a signed-in caller needs read access to every layer in it.

Get the settings​

The settings of a schema tileset are read and set on the schema. These requests require an Authorization: Bearer header and are for the super user only. GET returns the values that are in effect, also when nothing has been stored:

Request
GET https://api.gc2.io/api/v4/schemas/rockhall/tile HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Response
{
"schema": "rockhall",
"schema_exists": true,
"cache": "sqlite",
"format": "PNG",
"vector_format": "MVT",
"ttl": 86400,
"auto_expire": null,
"meta_size": 3,
"meta_buffer": 0,
"s3_tile_set": null,
"title": "rockhall",
"abstract": "",
"_stored": {
"ttl": 86400
},
"_defaults": {
"cache": "sqlite",
"format": "PNG",
"ttl": 60,
"auto_expire": null,
"meta_size": 3,
"meta_buffer": 0,
"s3_tile_set": null,
"title": "rockhall",
"abstract": ""
}
}

_stored holds only what has been saved, and _defaults what each setting would be if it were not, so a client can tell a set value from a default one.

Change the settings​

PATCH merges the given settings into the stored ones. An explicit null removes a setting and returns it to its default. The response is 303 See Other with a Location header pointing back to the settings. The schema must exist (404, SCHEMA_NOT_FOUND), and an unknown field is rejected with 400:

Request
PATCH https://api.gc2.io/api/v4/schemas/rockhall/tile HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"cache": "mbtiles",
"format": "jpeg_high",
"ttl": 86400,
"meta_buffer": null
}

DELETE on the same path removes the stored settings and answers 204 No Content, also when there was nothing to remove.

Settings are kept when the schema is dropped, as dropping and recreating a schema is routine in an import. GET and DELETE therefore also work for a schema that is gone (schema_exists is then false); PATCH does not.

Cache backends​

cache names where the tiles are kept. The same values apply to the cache property of a layer:

ValueStores
sqliteTiles in SQLite files.
diskTiles as files in a directory tree.
mbtilesImage tiles in one MBTiles file per grid. An MBTiles cache holds images only, so the vector tilesets (.mvt, .json) of the same layer or schema stay in sqlite.
memcacheTiles in memcached.
s3Tiles as objects in S3-compatible storage.
note

Changing cache or format does not move or remove the tiles already made. They stay in the old backend, unused. Delete the cached tiles before switching if you want them gone.

Delete cached tiles​

Tiles that are cached keep the drawing they were made with. After a change of data or styling, delete the tileset's cache:

DELETE https://api.gc2.io/api/v4/mapcache/database/{database}/tileset/{tileset}

This request always needs credentials, whatever the layer's authentication level: a layer tileset needs write access to the layer, and a schema tileset can only be cleared by the super user (403, SUPER_USER_ONLY).

A full delete removes every tile of the tileset:

Request
DELETE https://api.gc2.io/api/v4/mapcache/database/mydb/tileset/rockhall.inductees HTTP/1.1
Authorization: Bearer abc123

A scoped delete removes the tiles within an extent, a zoom range or both. bbox is minx,miny,maxx,maxy in the SRS of the grid, zoom is minzoom,maxzoom or a single zoom level, and grid names the grid (default g20):

Request
DELETE https://api.gc2.io/api/v4/mapcache/database/mydb/tileset/rockhall.inductees?zoom=10,14 HTTP/1.1
Authorization: Bearer abc123

What the answer is depends on the cache backend:

DeleteBackendAnswer
Fullsqlite, mbtiles200 — the tiles are gone when the request returns.
Fulldisk202 — removed in the background.
Fulls3, memcache400 — not supported. Use a scoped delete.
ScopedAny202 — removed by a background job.

Seed a cache​

A tile is drawn the first time someone asks for it, which makes the first view of an area slow. Seeding draws the tiles ahead of time. It is done with jobs: a job is queued, picked up by a worker within about a minute, and then runs until every tile is made.

Jobs require an Authorization: Bearer header. Sub-users are allowed, and need write access to the layer of the tileset (403, INSUFFICIENT_PRIVILEGES). A sub-user sees their own jobs, the super user every job of the database.

Queue a job​

POST queues one job (an object) or several (an array), and answers 202 Accepted with the job. An array is validated and authorized in full before anything is queued:

Request
POST https://api.gc2.io/api/v4/tileseeder/jobs HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"name": "Seed inductees",
"tileset": "rockhall.inductees",
"grid": "g20",
"zoom_start": 0,
"zoom_end": 12,
"extent_layer": "rockhall.states",
"threads": 2
}
Response
{
"uuid": "c4a3797e-ec6b-4dac-9474-ada9083620f3",
"name": "Seed inductees",
"status": "pending",
"stale": false,
"username": "slash",
"tileset": "rockhall.inductees",
"grid": "g20",
"zoom_start": 0,
"zoom_end": 12,
"extent_layer": "rockhall.states",
"threads": 2,
"host": null,
"pid": null,
"created": "2026-12-04T09:15:00+00:00",
"started": null,
"finished": null,
"heartbeat": null,
"cancel_requested": null,
"error": null,
"_links": {
"self": "/api/v4/tileseeder/jobs/c4a3797e-ec6b-4dac-9474-ada9083620f3"
}
}

The number of tiles grows about four times for every zoom level: zoom 0 to 12 is thousands of tiles, zoom 0 to 18 is millions. Before a job that runs for hours, bound the area with extent_layer, and split the high zoom levels into jobs of their own so they can be cancelled one by one.

Follow a job​

GET /api/v4/tileseeder/jobs lists the jobs, newest first. status and tileset filter the list; a value that matches nothing gives an empty array:

Request
GET https://api.gc2.io/api/v4/tileseeder/jobs?status=running HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

GET with a uuid returns one job, with log, the tail of the seed output, which the list leaves out. A comma-separated list of uuids returns an array:

Request
GET https://api.gc2.io/api/v4/tileseeder/jobs/c4a3797e-ec6b-4dac-9474-ada9083620f3 HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

A job goes from pending to running and ends as succeeded, failed or cancelled. stale is true for a job that is running but has not been heard from for ten minutes: the run or its node is gone, and the job should be cancelled and queued again.

Cancel a job​

DELETE with a uuid, or a comma-separated list, asks for the job to stop:

Request
DELETE https://api.gc2.io/api/v4/tileseeder/jobs/c4a3797e-ec6b-4dac-9474-ada9083620f3 HTTP/1.1
Authorization: Bearer abc123
  • 204 No Content when the job was still queued, and is now cancelled, or had already finished.
  • 202 Accepted with "message": "Stopping" when the job is running. The worker stops it shortly after; read the job until its status is cancelled.

A job that ends as succeeded with cancel_requested set finished before the stop reached it.

note

Cancelling a job stops the seeding. It does not remove the tiles the job has made; to do that, delete the cached tiles.

Using the SDK​

The @mapcentia/gc2-sdk covers the tile side with the Mapcache and Tileseeder classes, and the schema tile settings on the admin client:

import { createCentiaClient, createCentiaAdminClient, Mapcache, Tileseeder } from '@mapcentia/gc2-sdk'

const client = createCentiaClient({ baseUrl, auth: { getAccessToken } })

// A tile URL template for a map library — tiles are fetched by the library, not by the SDK
const mapcache = new Mapcache(client)
const url = mapcache.mapcacheUrl('mydb', 'gmaps/rockhall.inductees@g20/{z}/{x}/{y}.png')

// Delete cached tiles: all of them, or a zoom range
await mapcache.deleteMapcacheTileset('mydb', 'rockhall.inductees')
await mapcache.deleteMapcacheTileset('mydb', 'rockhall.inductees', { zoom: '10,14' })

// Queue a seed job and follow it
const seeder = new Tileseeder(client)
const job = await seeder.postSeedJob({
tileset: 'rockhall.inductees',
grid: 'g20',
zoom_start: 0,
zoom_end: 12,
})
const { status, log } = await seeder.getSeedJob(job.uuid)
const running = await seeder.getSeedJobs({ status: 'running' })

// Cancel: null when it was queued or finished, an object when the job is being stopped
await seeder.deleteSeedJob(job.uuid)

// Schema tile settings
const admin = createCentiaAdminClient({ baseUrl, auth: { getAccessToken } })
const settings = await admin.provisioning.schemaTileSettings.getSchemaTileSettings('rockhall')
await admin.provisioning.schemaTileSettings.patchSchemaTileSettings('rockhall', { cache: 'mbtiles' })

Fields​

Schema tile settings​

FieldDescription
cacheThe cache backend: sqlite, disk, mbtiles, memcache or s3.
formatFormat of the image tileset: PNG, jpeg_low, jpeg_medium or jpeg_high.
vector_formatFormat of the .mvt tileset. Always MVT — read-only.
ttlSeconds a tile stays valid. At least 1; a value below 30 behaves as 30. Default 60.
auto_expireSeconds after which an existing tile is drawn again on next access.
meta_sizeMetatile size N: N×N tiles are drawn in one request. 1 to 16, default 3. Image tileset only.
meta_bufferPixels drawn around each metatile and cropped afterwards. 0 to 512, default 0. Image tileset only.
s3_tile_setWith cache set to s3: the object path segment for this schema.
titleShown in the WMTS capabilities. Defaults to the schema name.
abstractShown in the WMTS capabilities.
schema_existsfalse for settings left behind by a dropped schema — read-only.
_storedOnly the settings that are stored — read-only.
_defaultsWhat each setting would be if it were not stored — read-only.

Seed job​

FieldDescription
tilesetThe tileset to seed. Required.
gridThe name of a grid the tileset has, in practice g20. Required.
zoom_startFirst zoom level to seed. Required.
zoom_endLast zoom level to seed. Must be within the zoom levels of the grid. Required.
nameA label for the job.
extent_layerA layer whose features bound the seeded area. The caller must be able to read it.
threadsNumber of seeding threads. Default 1; the server sets the upper limit (4 by default).
uuidServer-assigned id — read-only.
statuspending, running, succeeded, failed or cancelled — read-only.
staletrue when the job is running but has not been heard from for ten minutes — read-only.
usernameThe user who queued the job — read-only.
created, started, finished, heartbeat, cancel_requestedTimestamps of the run — read-only.
errorWhy the job failed, or null — read-only.
logThe tail of the seed output. Only when a single job is read — read-only.

Errors​

StatusCodeWhen
400UNKNOWN_GRIDgrid is not a grid of the tileset. The message lists the grids it has. Sending the title GoogleMapsCompatible instead of the name g20 is the usual cause.
400INVALID_REQUESTA field fails validation, an unknown field was sent, or threads is above the server's limit.
400UNSUPPORTED_BACKENDA full delete of a tileset cached in s3 or memcache.
403INSUFFICIENT_PRIVILEGESThe caller lacks access to the tileset's layer, or to the extent layer.
403SUPER_USER_ONLYA schema tileset is cleared, or schema tile settings are read or set, by anyone but the super user.
403A tile is requested from a tileset the caller may not read, or whose name cannot be resolved.
404SCHEMA_NOT_FOUNDThe schema of a schema tileset, or of the tile settings being changed, does not exist.
404An unknown tileset, extent layer or job uuid.
429TOO_MANY_PENDINGToo many jobs are waiting in the queue.