Skip to main content

No project description provided

Project description

A lightweight PostGIS based dynamic vector tile server.

Test Coverage Package version License


Documentation: https://developmentseed.org/timvt/

Source Code: https://github.com/developmentseed/timvt


TiMVT, pronounced tee-MVT, is a python package which helps creating lightweight Vector Tiles service from PostGIS Database.

Built on top of the modern and fast FastAPI framework, titiler is written in Python using async/await asynchronous code to improve the performances and handle heavy loads.

timvt is mostly inspired from the awesome urbica/martin and CrunchyData projects.

Features

  • Multiple TileMatrixSets via morecantile. Default is set to WebMercatorQuad which is the usual Web Mercator projection used in most of Wep Map libraries.)
  • Built with FastAPI
  • Table and Function layers
  • Async API

Requirements and Setup

Python Requirements

  • FastAPI: Modern, fast (high-performance), web framework for building APIs
  • Morecantile: Construct and use map tile grids (a.k.a TileMatrixSet / TMS)
  • asyncpg A fast PostgreSQL Database Client Library for Python/asyncio

PostGIS/Postgres

timvt rely mostly on ST_AsMVT function and will need PostGIS >= 2.5.

If you want more info about ST_AsMVT function or on the subject of creating Vector Tile from PostGIS, please read this great article from Paul Ramsey: https://info.crunchydata.com/blog/dynamic-vector-tiles-from-postgis

Minimal Application

from timvt.db import close_db_connection, connect_to_db
from timvt.factory import VectorTilerFactory
from fastapi import FastAPI, Request

# Create Application.
app = FastAPI()

# Register Start/Stop application event handler to setup/stop the database connection
@app.on_event("startup")
async def startup_event():
    """Application startup: register the database connection and create table list."""
    await connect_to_db(app)


@app.on_event("shutdown")
async def shutdown_event():
    """Application shutdown: de-register the database connection."""
    await close_db_connection(app)

# Register endpoints.
mvt_tiler = VectorTilerFactory(
    with_tables_metadata=True,
    with_functions_metadata=True,  # add Functions metadata endpoints (/functions.json, /{function_name}.json)
    with_viewer=True,
)
app.include_router(mvt_tiler.router, tags=["Tiles"])

Configuration

To be able to create Vector Tile, the application will need access to the PostGIS database. timvt uses starlette's configuration pattern which make use of environment variable and/or .env file to pass variable to the application.

Example of .env file can be found in .env.example

POSTGRES_USER=username
POSTGRES_PASS=password
POSTGRES_DBNAME=postgis
POSTGRES_HOST=0.0.0.0
POSTGRES_PORT=5432

# Or you can also define the DATABASE_URL directly
DATABASE_URL=postgresql://username:password@0.0.0.0:5432/postgis

Default Application

While we encourage users to write their own application using timvt package, we also provide a default production ready application:

$ git clone https://github.com/developmentseed/timvt.git && cd timvt

# Install timvt dependencies and Uvicorn (a lightning-fast ASGI server)
$ pip install -e .["server"]

# Launch Demo Application
$ uvicorn timvt.main:app --reload

:endpoint:/docs

Contribution & Development

See CONTRIBUTING.md

License

See LICENSE

Authors

Created by Development Seed

Changes

See CHANGES.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timvt-0.1.0.tar.gz (23.0 kB view details)

Uploaded Source

File details

Details for the file timvt-0.1.0.tar.gz.

File metadata

  • Download URL: timvt-0.1.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for timvt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58c6868348c51699bf9fe4142fff136e98c99f9d4cb0be568a961cb24571d083
MD5 db1cf2b670042a3aaa8fd3abe2606ddf
BLAKE2b-256 9e11541ff6f2d0a4df937ac65a5774c21aa9c63fb229046ff814794cefbddc34

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page