Tilezen tileserver官網簡介

Tilezen tileserver官網:https://github.com/tilezen/tileserver

Tilezen: Open source tiles and libraries, sponsored by Mapzen
Tilezen: 由Mapzen支持的開放原始碼tiles與程式庫


Mapzen Vector Tiles

The Mapzen vector tile service provides worldwide basemap coverage sourced from OpenStreetMap and other open data projects, updated daily.
Gitter

Quick links

Contents of an example vector tile
Vector tiles are square-shaped collections of geographic data that contain the map feature geometry, such as lines and points. Information about how map features are drawn is maintained in a separate stylesheet file. 
For many purposes, vector tiles are more flexible than raster tiles, which are images that already have the visual appearance of the map features pre-drawn. With vector tiles, there is no need to head back to the server and fetch a different set of tiles if you want to filter the output or change the style of a road or color of a building. 基於許多目的,
Vector tiles make real-time rendering possible by sending the underlying data geometry and tags directly to the client, whether that’s a browser or a native mobile app. Buildings and roads can be rendered in different ways, or not at all, when the vector tile is downloaded, and changes happen instantly on the client's side.
With vector tiles you have the power to customize the content and visual appearance of the map. We're excited to see what you build!

Use Mapzen's Vector Tile Service

To start integrating vector tiles to your app, you need a developer API key. API keys come in the pattern: vector-tiles-xxxxxxx.

Requesting tiles

The URL pattern to request tiles is:
https://tile.mapzen.com/mapzen/vector/v1/{layers}/{z}/{x}/{y}.{format}?api_key=vector-tiles-xxxxxxx
Here’s a sample tile in TopoJSON:
https://tile.mapzen.com/mapzen/vector/v1/all/16/19293/24641.topojson?api_key=vector-tiles-xxxxxxx
More information is available about how to use the vector tile service and specify custom layers in the service (though we recommend the default all layer).
Formats
The Mapzen vector tile stack provides tiles in a variety of formats (service docs):
  • Mapbox Vector Tile: use the .mvt extension. This is a compact format using protocol buffers that is used for raster tile rendering in TileMill2 and vector rendering in MapboxGL.
  • TopoJSON: use the .topojson extension. TopoJSON is an optimized form of GeoJSON that saves space by encoding topology and reducing replication of shared geometry.
  • GeoJSON: use the .json extension. GeoJSON is easy to get started with, human-readable, and compatible with many tools.
  • OpenScienceMap-format binary tiles: use the .vtm extension. This is a compact format using protocol buffers that is used in the OpenScienceMap vector rendering library for Android. This legacy format is no longer available in Mapzen's vector tile service.
    We recommend TopoJSON format for desktop web development, and MVT format for native mobile development. The Mapzen vector tile service gzips tiles automatically, so the TopoJSON file format is comparable in file size to MVT over the wire, and it's much friendlier to debug.
Drawing a map
How to draw the tile in a browser is up to the vector-friendly visualization tool, such as SVG, Canvas, or WebGL. The Tangramrendering engine, which uses WebGL, is one way that you can draw the vector tile service in 2D and 3D maps.

How are vector tiles produced?

Vector tiles are served by clipping geometries to the tile bounding box, and then simplified to match the zoom level to avoid unnecessary complexity at lower zoom levels. These geometries and features are also further processed to facilitate styling.
When changes are made to OpenStreetMap or another map data sources, rather than waiting for an image tile to be redrawn, only the geometry coordinates and feature attributes for that particular building or road need to be updated in the vector tile.
Depending on the URL syntax, Mapzen vector tiles can return all of the map data, or just individual layers, or combinations of layers, including water, earth, landuse, roads, buildings and points of interest.

Build from source

If you are interested in setting up your own version of this service, follow these installation instructions, or you can also try this Vagrant VM, which will additionally set up other tile components as well.

Tests

There is a suite of tests which can be run against a tile server to verify query results in well known tiles.

Credits

This is based on the work of Michal Migurski, and extends his OSM.US-hosted vector tile service with additional data and format support.

以上資料出處:https://github.com/tilezen/vector-datasource


Mapzen Vector Tile Service



See info about the hosted version of this service here:

Installation Guide

  • Tested under Ubuntu 14.04.
  • We've had reports that Ubuntu 16 has issues.

1. Install

Install dependencies

# install misc tools
sudo apt-get install git unzip python-yaml
# install postgres / postgis
sudo apt-get install postgresql postgresql-contrib postgis postgresql-9.3-postgis-2.1
# Install jinja2
sudo apt-get install python-jinja2
# install tilezen fork of osm2pgsql
sudo apt-add-repository ppa:tilezen
sudo apt-get update
sudo apt-get install osm2pgsql

2. Load data

Download mapzen/vector-datasource:

This repo contains the supplementary data to load and the queries that are issued to the database for each layer.
git clone https://github.com/mapzen/vector-datasource.git
cd vector-datasource
# now checkout the latest tagged release (see warning below), for example:
# git checkout v1.4.0
WARNING: If you are standing up your own instance of the Tilezen stack (rather than doing development), it's best practice to checkout the latest tagged release rather than running off master. At the time of this writing that is v1.4.0, so you'd git checkout v1.4.0 to be on the same code base as the production Mapzen Vector Tile service. Similarly, you'd need to pin yourself against the related project's versions, e.g.: Requires: tileserver v2.1.0 and tilequeue v1.8.0 and mapbox-vector-tile v1.2.0 mentioned in the release notes in the sections below.

Set up database

If you are setting up PostgreSQL for a single-user install, you may want to create a new database user (i.e: whoami). You can skip this next step if you already have your database roles established.
sudo -u postgres psql
CREATE USER [your username] SUPERUSER PASSWORD 'your password here';
First, create the database. We use the database name 'osm' here, but you can use any, e.g. 'gis'.
createdb -E UTF-8 -T template0 osm
psql -d osm -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;'
Next, download the OpenStreetMap source data. You can use any PBF, but we use a Mapzen metro extract here to get started.
wget https://s3.amazonaws.com/metro-extracts.mapzen.com/new-york_new-york.osm.pbf

Load PBF data

osm2pgsql -s -C 1024 -S vector-datasource/osm2pgsql.style -j path/to/pbf -d osm -H localhost
You may also need to pass in other options, like -U or -W, to ensure that you connect to the database with a user that has the appropriate permissions. For more details, visit the osm2pgsql wiki page and the postgresql docs for creating a user. You may need to check your connection permissions too, which can be found in the pg_hba.conf file.
Note that if you import the planet, the process can take several days, and can consume over 1TB (2TB is preferred cause need more space to prepare the database) of disk space at the time of writing. The OSM planet gets bigger every week, so it might be necessary to do a few trial runs to find out what it takes today. Have a look at some performance tuning docs for recommendations.

Load additional data and update database

The vector-datasource/data directory contains scripts to load additional data and update the database to match our expected schema.
# Go to data directory, assumes you already changed directories into vector-datasource (above)
cd data
# Build the Makefiles that we'll use in the next steps
python bootstrap.py
# Download external data
make -f Makefile-import-data
# Import shapefiles into postgis
./import-shapefiles.sh | psql -d osm
# Add indexes and any required database updates
./perform-sql-updates.sh -d osm
# Clean up local shape files
make -f Makefile-import-data clean
Note that you may have to pass in a username/password to these scripts for them to connect to the database. Anywhere -d osm is specified, you may need to also pass in -U <username> and perhaps set a password too. For example, if my username is "foo" and my password is "bar", here's what I would do:
export PGPASSWORD=bar
./import-shapefiles.sh | psql -d osm -U foo
./perform-sql-updates.sh -d osm -U foo

3. Serve vector tiles

Install dependencies

# dev packages for building
sudo apt-get install build-essential autoconf libtool pkg-config
# dev packages for python and dependencies
sudo apt-get install python-dev python-virtualenv libgeos-dev libpq-dev python-pip python-pil libmapnik2.2 libmapnik-dev mapnik-utils python-mapnik

Download Tileserver

git clone https://github.com/mapzen/tileserver.git

Prepare a virtualenv

# Create a virtualenv called 'env'. This can be named anything, and can be in the tileserver directory or anywhere on your system.
virtualenv env
source env/bin/activate

Install Python dependencies

Install dependencies for tileserver
pip install -U -r tileserver/requirements.txt
(cd tileserver && python setup.py develop)
# optionally checkout the latest tagged release instead (see warning above), for example:
# git checkout v2.1.0
Install tilequeue in development mode
git clone https://github.com/tilezen/tilequeue.git
(cd tilequeue && python setup.py develop)
# optionally checkout the latest tagged release instead (see warning above), for example:
# git checkout v1.8.0
Finally, there's some code in vector-datasource as well, which needs to be installed.
(cd vector-datasource && python setup.py develop)

Configure

cd ../tileserver
cp config.yaml.sample config.yaml
# update configuration as necessary
edit config.yaml

Load Who's on First neighbourhood data

Finally, neighbourhood data is required to be loaded from Who's on First.
wget https://s3.amazonaws.com/mapzen-tiles-assets/wof/dev/wof_neighbourhoods.pgdump
pg_restore --clean -d osm -O wof_neighbourhoods.pgdump
This will load a snapshot of the neighbourhoods data.
You should periodically update the Who's On First neighbourhoods data by running the following:
wget https://raw.githubusercontent.com/mapzen/tilequeue/master/config.yaml.sample -O tilequeue-config.yaml
wget https://raw.githubusercontent.com/mapzen/tilequeue/master/logging.conf.sample
tilequeue wof-process-neighbourhoods --config tilequeue-config.yaml

Run

python tileserver/__init__.py config.yaml

Contribute!

You're ready to help us improve the Tilezen project! Please read our CONTRIBUTING.md document to understand how to contribute code.

Tests

Need to confirm your configuration? A test suite is included which can be run against a tile server.
Sample test URLs

Keeping up to date with osm data

OpenStreetMap data is constantly changing, and OpenStreetMap produces diffs for consumers to keep up to date. Mapzen uses osmosis and osm2pgsql to pull down the latest changes and apply them.
Generally speaking, tile service providers make the trade-off to prefer generating stale tiles over serving the request on demand more slowly. Mapzen also makes this trade-off.
A lot of factors go into choosing how to support a system that remains up to date. For example, existing infrastructure, tolerance for request latency and stale tiles, expected number of users, and cost can all play roles in coming up with a strategy for remaining current with OpenStreetMap changes.

Tracking releases

If you are on a particular release and would like to migrate your database to a newer one, you'll want to run the appropriate migrations. Database migrations are required when the database queries & functions that select what map content should be included in tiles change.
Note that the migration for each release in between will need to be run individually. For example, if you are on v0.5.0 and would like to upgrade to v0.7.0, you'll want to run the v0.6.0 and v0.7.0 migrations (we don't provide "combo" migrations).
# in this example, we're on v0.5.0 - checkout the migration to v0.6.0
git checkout v0.6.0
bash data/migrations/run_migrations.sh -d osm

# now our database reflects v0.6.0 - checkout the migration to v0.7.0
git checkout v0.7.0
bash data/migrations/run_migrations.sh -d osm

# now our database reflects v0.7.0
以上資料出處:https://github.com/tilezen/vector-datasource/wiki/Mapzen-Vector-Tile-Service

tileserver

A lightweight tileserver to share code paths with tilequeue for tile generation.

Installation

We recommend following the vector-datasource installation instructions.
There is a requirements file that can be used to install.
pip install -Ur requirements.txt
Then:
python setup.py develop

Installation (detailed)

In addition to the dependencies in requirements.txt, tileserver requires
  • PostgreSQL client-side development library and headers (for psycopg)
  • GEOS library
These can be installed on Debian-based systems with
sudo apt-get install libpq-dev libgeos-c1v5
Then install the python requirements with
pip install -Ur requirements.txt
Then:
python setup.py develop

Usage

cp config.yaml.sample config.yaml
python tileserver/__init__.py config.yaml




留言

這個網誌中的熱門文章

QGIS-Python程式設計入門

向量圖磚伺服器比較