kartotherian/kartotherian

Name: kartotherian

Owner: kartotherian

Description: Map Tile Server

Created: 2015-04-16 06:25:34.0

Updated: 2018-05-19 00:23:52.0

Pushed: 2018-05-16 01:01:08.0

Homepage: https://www.mediawiki.org/wiki/Maps

Size: 741

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

Maps Tile service for Wikipedia

This code is cross-hosted at gerrit

Maps nodejs server for vector-based tiles and snapshots, designed for Wikipedia and other sites. It ties together a number of MapBox components for vector and raster rendering based on Mapnik 3, and uses service runner for scalability, performance monitoring and stability.

Serving tiles

Kartotherian can serve vector and raster tiles in multiple formats and optional scaling:

http://.../{source}/{zoom}/{x}/{y}[@{scale}x].{format}
Static map images

Kartotherian supports static image generation. Users may request a PNG or a JPEG snapshot image of any size, scaling, and zoom level:

http://.../img/{source},{zoom},{lat},{lon},{width}x{height}[@{scale}x].{format}

# image centered at 42,-3.14, at zoom level 4, size 800x600
http://.../img/osm-intl,4,42,-3.14,800x600.png

# the same but for higher DPI device with 1.5 scaling
http://.../img/osm-intl,4,42,-3.14,800x600@1.5x.png
Info data

Kartotherian can be used as a source of the PBF data for Mapbox studio. See info about style editing in osm-bright-source. The info data is available at http://.../{style}/pbfinfo.json for pbf source, and http://.../{style}/info.json for the styled image source.

Markers

Kartotherian can generate marker images by wrapping any of the maki icons with a pushpin image, in any color. The URL schema is matched to the one used by the mapbox.js.

http://.../v4/marker/pin-l-cafe+de00ff@2x.png
http://.../v4/marker/ {base} - {size:s|m|l} [-{letter-or-digit-or-icon-name}] + {color} [@2x] .png

At this point, only “pin” is supported for the base. The color is a 3 digit or 6 digit hex number. Optional scaling can only be 2x. Beyond the pre-defined maki icons, you may give a number (0-99), a single letter (a-z), or nothing.

Very quick start
clone https://github.com/kartotherian/kartotherian.git  # Clone the repository
artotherian

install
 server.js -c config.external.yaml

Browse to http://localhost:6533/ The set up inside sources.external.yaml does not use any storage or caching, so it will not be suitable for production. You will need to to set up your own local database as described in osm-bright.tm2source, which is installed in node_modules/osm-bright-source, and configure additional source chains and setup a proper storage to make this into a production system.

Configuration

Inside the conf key:

Components

Kartotherian platform consists of a number of elements, some of which conform to the general specifications established by MapBox, and therefor can reuse components that confirm to the same specification. Also, see Tilerator, an optional stand-alone service to pre-generate tiles. Tilerator is separate from Kartotherian, but it reuses most of the same components.

Components by Wikimedia Foundation
Tile sources Data and Styling
Components by MapBox
Other Relevant Components
In depth step-by-step:

This documentation assumes that you are going to use osm-bright.tm2 and osm-bright.tm2source for a map style.

Install dependencies

Kartotherian requires nodejs and npm. On Ubuntu these can be installed with

 apt-get install git unzip curl build-essential sqlite3 nodejs-legacy npm
Get Kartotherian code
clone https://github.com/kartotherian/kartotherian.git  # Clone the repository
artotherian
install                                                 # install npm dependencies
Source

Set up osm-bright.tm2source as described in its documentation..

osm-bright.tm2source is installed in node_modules/osm-bright-source

Edit Kartotherian configuration - config.yaml
- one instance, 1+ - multi-instance with autorestart, ncpu - multi-instance, one per CPU
workers: 0

st port
: 6533

mment out this line to listen to the web
terface: localhost

ace all variables (e.g. passwords) here - either as a filename, or as sub-items.
ables:

ace all sources you want to serve here - either as a filename, or as sub-items.
e sources.prod.yaml for examples
ces: sources.yaml
Configure Kartotherian

Use one of the config files, or update them, and make a link config.yaml to it.

Add Varnish caching layer (optional)

Might require caching headers added to the source/config.

om https://www.varnish-cache.org/installation/debian
 -Hi
get install apt-transport-https
 https://repo.varnish-cache.org/GPG-key.txt | apt-key add -
 "deb https://repo.varnish-cache.org/debian/ jessie varnish-4.0" >> /etc/apt/sources.list.d/varnish-cache.list
get update
get install varnish

etc/varnish/default.vcl

Change default backend to:

end default {
.host = "localhost";
.port = "6533";

Add this to vcl_deliver (to track hits/misses):

obj.hits > 0) {
set resp.http.X-Cache = "HIT";
se {
set resp.http.X-Cache = "MISS";

Edit /etc/systemd/system/varnish.service - set proper listening port (80) and cache size:

Start=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,4g

In bash:

emctl daemon-reload  # because we changed the .service file
emctl restart varnish.service
emctl status varnish.service  # check the service started with the right params
ishstat  # monitor varnish performance
Run Karthotherian:
start

In browser, navigate to http://localhost:6533/.

Troubleshooting

In a lot of cases when there is an issue with node it helps to recreate the node_modules directory:

r node_modules
install

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.