Log-in to your Clockwork Micro account and navigate to the DB2Vector page.
Publish
DB2Vector is split into two sections: tile sources and databases. To create your first tile source, click on the "New Tile Source" button in the top-right corner of the screen.
On the New Tile Source page, enter in a name for your tile source. If you do not have a pre-existing database connection, you will need to enter in database connection parameters. For PostgreSQL/PostGIS databases, use postgres
as the engine. If you have an existing database connection, you can select your connection from the drop-down menu.
After setting your database connection, enter your database query. Below is an example query that reads data from the brazil_states
table.
WITH boundingbox AS(
SELECT
ST_MakeEnvelope(
%(xmin)s,
%(ymin)s,
%(xmax)s,
%(ymax)s,
3857
) AS geom
),
mvtgeom AS (
SELECT
ST_AsMVTGeom(
ST_Transform(sourceTable.geom, 3857),
boundingbox.geom
)
FROM
demo.brazil_states sourceTable,
boundingbox
WHERE
ST_Intersects(
ST_Transform(boundingbox.geom, 4326),
sourceTable.geom
)
)
SELECT
ST_AsMVT(mvtgeom.*)
FROM
mvtgeom;
The query must include the tokens %(xmin)s
, %(ymin)s
, %(xmax)s
, and %(ymax)s
. These tokens will be automatically be interpolated with numerical values when you make a request to the DB2Vector service.
Below the query editor, enter your default viewport parameters. These parameters will be used whenever you preview the vector tiles within a map in DB2Vector and Simple Styler. Finally, click "Publish" to save your new tile source.
Edit
You may want to edit your tile source after publishing it. Click the "Edit" button on the DB2Vector page to edit your tile source. The Edit Tile Source page is a split-screen view of your tile source settings on the left side and your tile source preview on the right side.
After updating your tile source, click "Preview" to view your updated query in the preview window. Clicking "Reset" will discard your draft query and reset it to the currently published query. If you are happy with the changes shown in the preview window, click "Publish" to publish your query live.