Skip to content

kartotherian/meddo

Repository files navigation

meddo

Data source for Wikipedia maps from OSM data

Install

This style requires an osm2pgsql database loaded with https://github.com/ClearTables/ClearTables and ocean data.

Requirements

  • ClearTables v0.1.0. If you're intending to use this with the Kartotherian Geoshapes service, you'll want the v0.1.0.wikidata.1 tag.
  • Mapnik 3.0.0 or later
  • Software that can interpret YAML style definitions like Kosmtik or Mapbox Studio Classic
  • osm2pgsql 0.90.1 or later with Lua support. Early C++ versions > 0.86.0 may still work with some bugs or missing data.
  • PostgreSQL 9.3 or later. 9.4 or later is recommended as earlier versions are not adequately tested with the style.
  • PostGIS 2.0 or later. 2.3 or later is recommended as earlier versions are not adequately tested with the style.
  • Python 3.4 or later

Load the data with ClearTables

See the ClearTables documentation for details and load into the database ct, with the command-line option -G

git clone -b v0.1.0 git://github.com/ClearTables/ClearTables.git
pushd ClearTables
createdb ct
psql -d ct -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore; CREATE EXTENSION unaccent; CREATE EXTENSION fuzzystrmatch;'
make # Create cleartables files
cat sql/types/*.sql | psql -1Xq -d ct # Load SQL types
osm2pgsql -E 3857 -G -d ct --number-processes 2 --output multi --style cleartables.json ~/path/to/extract # Load OSM data
cat sql/post/*.sql | psql -1Xq -d ct # Add post-import SQL
popd

Other osm2pgsql flags for performance or updates can be added, and will be necessary for large imports. See the osm2pgsql documentation for more details. Flags that might be needed include

  • --slim
  • --cache
  • --flat-nodes

Slim mode is not required by this style, so --slim --drop can be safely used if updates are not required.

If PostgreSQL max_connections is increased from the default, --number-processes can be increased. If --number-processes is omitted, osm2pgsql will attempt to use as many processes as hardware threads. osm2pgsql will need aproximatelly number-processes * (number rendering tables + 3), Where the number of rendering tables is ~42.

Load coastline data

Meddo uses data from OSMCoastline, hosted on OpenStreetMapData, and from Natural Earth. The data used is documented in full in external-data.yml

psql -d ct -c 'CREATE SCHEMA loading;'
./get-external-data.py

get-external-data.py should be re-run periodically, and the command options can be obtained with ./get-external-data.py -h

Load admin data

Meddo uses data generated by OSMBorder for administrative boundaries.

Generate the borders with OSMBorder then run the SQL

CREATE TABLE osmborder_lines (
  osm_id bigint,
  admin_level int,
  dividing_line bool,
  disputed bool,
  maritime bool,
  way Geometry(LineString, 3857));

\copy osmborder_lines FROM osmborder_lines.csv

CREATE INDEX osmborder_lines_way_idx ON osmborder_lines USING gist (way) WITH (fillfactor=100);
CLUSTER osmborder_lines USING osmborder_lines_way_idx;
CREATE INDEX osmborder_lines_way_low_idx ON osmborder_lines USING gist (way) WITH (fillfactor=100) WHERE admin_level <= 4;

Install required functions

Meddo requires some standard stylesheet-independent functions

psql -d ct -f functions.sql

Usage

Development

A suitable design program like Kosmtik or Mapbox Studio Classic is needed. If Kosmtik is installed, kosmtik serve data.yml will start Kosmtik, and the Data Inspector can be used. For Mapbox Studio, the entire repository is a tm2source project.

Production

It might be necessary to compile the project to Mapnik XML for production, which can be done in many ways. One way is kosmtik export data.yml --format xml --output meddo.xml

Schema

TBD.

Why "meddo"?

Meddo is a type of Polynesian stick chart which contains only a section of the island chain, and meddo creates vector tiles from a larger database. It's also based on the same language as "wiki".

License

The code is licensed under the MIT License. If used as directed, use ODbL licensed OpenStreetMap data.