Skip to content

userVF/mvt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is example of generating, displaying and data change tracking of vector tiles (Mapbox Vector Tile format).

Prerequisites

  • PostgreSQL with PostGIS
  • Node.js

Database setup

Initialize database

psql -v ON_ERROR_STOP=ON -U postgres -f db/init.sql

Create tables, load data and create triggers

psql --single-transaction -v ON_ERROR_STOP=ON -U tileset -c '\i db/tables.sql' -c '\i db/data.sql' -c '\i db/triggers.sql'

Adjust connection

  • Replace <YOUR_DB_HOST> placeholder in .env file with your own value.
  • Replace <YOUR DB_PASSWORD> placeholder in .env file with your own value, if your database setting requires password authentication and change password:
psql -U tileset -c "ALTER ROLE tileset WITH PASSWORD '<YOUR DB_PASSWORD>'"

The data in the database is stored as follows:
db

Code setup

Install dependencies

npm ci

Build bundles

npm run build

Relationships between CTEs and style layers: code

Live example

Run application server

node ./server/app-server.js

Run static server (in new terminal tab)

node ./server/static-server.js

Open in a browser

http://localhost:3000

The map should looks like this: live-example

Full example: Topohub.kz

Changed tiles

Changes in the data are tracked. Based on a specific tileset and zoom range of a layer, the tiles impacted by these changes are calculated.

The tiles that affected by data changes: tile-changes