Merge branch 'master' into quickstart_v2

pull/32/head
ImreSamu 2016-12-06 14:10:22 +01:00
commit 344891c432
22 zmienionych plików z 56 dodań i 46 usunięć

Wyświetl plik

@ -100,6 +100,8 @@ To work on OpenMapTiles you need Docker and Python.
Build the tileset.
```bash
git clone git@github.com:openmaptiles/openmaptiles.git
cd openmaptiles
# Build the imposm mapping, the tm2source project and collect all SQL scripts
make
# You can also run the build process inside a Docker container
@ -144,15 +146,6 @@ you can limit the bounding box and zoom levels of what you want to generate (`do
docker-compose run generate-vectortiles
```
To look at the vector tiles you can start up Mapbox Studio Classic in a container
and visit `localhost:3000` and open the vector source project under `/projects`.
```bash
docker-compose up mapbox-studio
```
![Develop on OSM2VectorTiles with Mapbox Studio Classic](./mapbox_studio_classic.gif)
## License
All code in this repository is under the [MIT license](./LICENSE) and the cartography decisions encoded in the schema and SQL is licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

Wyświetl plik

@ -10,7 +10,7 @@ services:
- "5432"
env_file: .env
import-natural-earth:
image: "openmaptiles/import-natural-earth:1.0"
image: "openmaptiles/import-natural-earth:1.1"
env_file: .env
links:
- postgres

Wyświetl plik

@ -4,15 +4,15 @@
CREATE OR REPLACE FUNCTION layer_aeroway(bbox geometry, zoom_level int)
RETURNS TABLE(geometry geometry, class text) AS $$
SELECT geometry, aeroway AS class FROM (
-- etldoc: aeroway_z12 -> layer_aeroway:z12
-- etldoc: osm_aeroway_polygon_gen2 -> layer_aeroway:z12
SELECT geometry, aeroway
FROM osm_aeroway_polygon_gen2 WHERE zoom_level = 12
UNION ALL
-- etldoc: aeroway_z13 -> layer_aeroway:z13
-- etldoc: osm_aeroway_polygon_gen1 -> layer_aeroway:z13
SELECT geometry, aeroway
FROM osm_aeroway_polygon_gen1 WHERE zoom_level = 13
UNION ALL
-- etldoc: aeroway_z14 -> layer_aeroway:z14_
-- etldoc: osm_aeroway_polygon -> layer_aeroway:z14_
SELECT geometry, aeroway
FROM osm_aeroway_polygon WHERE zoom_level >= 14
) AS zoom_levels

Wyświetl plik

@ -1,5 +1,5 @@
generalized_tables:
# etldoc: imposm3 -> osm_landcover_polygon_gen2
# etldoc: imposm3 -> osm_aeroway_polygon_gen2
aeroway_polygon_gen2:
source: aeroway_polygon_gen1
sql_filter: area>240000

Wyświetl plik

@ -115,7 +115,7 @@ CREATE OR REPLACE VIEW boundary_z12 AS (
);
-- etldoc: layer_boundary[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="<sql> layer_boundary |<z0> z0 |<z1_2> z1_2 | <z3> z3 | <z4> z4 | <z5> z5 || <z6> z6 || <z7> z7 | <z8> z8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13+"]
-- etldoc: label="<sql> layer_boundary |<z0> z0 |<z1_2> z1_2 | <z3> z3 | <z4> z4 | <z5> z5 | <z6> z6 | <z7> z7 | <z8> z8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13+"]
CREATE OR REPLACE FUNCTION layer_boundary (bbox geometry, zoom_level int)
RETURNS TABLE(geometry geometry, admin_level int) AS $$

Wyświetl plik

@ -1,5 +1,5 @@
-- etldoc: layer_building[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_building | <z13> z13 | <z14_> z14_ " ] ;
-- etldoc: label="layer_building | <z13> z13 | <z14_> z14+ " ] ;
CREATE OR REPLACE FUNCTION layer_building(bbox geometry, zoom_level int)
RETURNS TABLE(geom geometry, osm_id bigint, render_height int, render_min_height int) AS $$

Wyświetl plik

@ -1,6 +1,6 @@
-- etldoc: layer_housenumber[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_housenumber | <z14_> z14_" ] ;
-- etldoc: label="layer_housenumber | <z14_> z14+" ] ;
CREATE OR REPLACE FUNCTION layer_housenumber(bbox geometry, zoom_level integer)
RETURNS TABLE(osm_id bigint, geometry geometry, housenumber text) AS $$

Wyświetl plik

@ -77,7 +77,7 @@ CREATE OR REPLACE VIEW landcover_z14 AS (
);
-- etldoc: layer_landcover[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_landcover | <z0_1> z0-z1 | <z2_4> z2-z4 | <z5_7> z5-z7 | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14+" ] ;
-- etldoc: label="layer_landcover | <z0_1> z0-z1 | <z2_4> z2-z4 | <z5_7> z5-z7 | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14+" ] ;
CREATE OR REPLACE FUNCTION layer_landcover(bbox geometry, zoom_level int)
RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text) AS $$

Wyświetl plik

@ -17,7 +17,7 @@ CREATE OR REPLACE VIEW landuse_z6 AS (
FROM ne_10m_urban_areas
);
-- etldoc: osm_landuse_polygon_gen4 -> landuse_z10
-- etldoc: osm_landuse_polygon_gen4 -> landuse_z9
CREATE OR REPLACE VIEW landuse_z9 AS (
SELECT osm_id, geometry, landuse, amenity, leisure, NULL::int as scalerank
FROM osm_landuse_polygon_gen4

Wyświetl plik

@ -1,6 +1,6 @@
-- etldoc: layer_city[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_city | <z2_14> z2-z14" ] ;
-- etldoc: label="layer_city | <z2_14> z2-z14+" ] ;
-- etldoc: osm_city_point -> layer_city:z2_14
CREATE OR REPLACE FUNCTION layer_city(bbox geometry, zoom_level int, pixel_width numeric)

Wyświetl plik

@ -1,28 +1,33 @@
-- etldoc: layer_place[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_place | <zall> z0-z14_ " ] ;
-- etldoc: osm_continent_point -> layer_place
-- etldoc: osm_country_point -> layer_place
-- etldoc: osm_state_point -> layer_place
-- etldoc: osm_island_point -> layer_place
-- etldoc: osm_island_polygon -> layer_place
-- etldoc: layer_city -> layer_place
-- etldoc: label="layer_place | <z0_3> z0-3|<z4_7> z4-7|<z8_11> z8-11| <z12_14> z12-z14+" ] ;
CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric)
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, "rank" int, capital INT) AS $$
-- etldoc: osm_continent_point -> layer_place:z0_3
SELECT
osm_id, geometry, name, name_en,
'continent' AS class, 1 AS "rank", NULL::int AS capital
FROM osm_continent_point
WHERE geometry && bbox AND zoom_level < 4
UNION ALL
-- etldoc: osm_country_point -> layer_place:z0_3
-- etldoc: osm_country_point -> layer_place:z4_7
-- etldoc: osm_country_point -> layer_place:z8_11
-- etldoc: osm_country_point -> layer_place:z12_14
SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'country' AS class, "rank", NULL::int AS capital
FROM osm_country_point
WHERE geometry && bbox AND "rank" <= zoom_level AND name <> ''
UNION ALL
-- etldoc: osm_state_point -> layer_place:z0_3
-- etldoc: osm_state_point -> layer_place:z4_7
-- etldoc: osm_state_point -> layer_place:z8_11
-- etldoc: osm_state_point -> layer_place:z12_14
SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'state' AS class, "rank", NULL::int AS capital
@ -34,13 +39,18 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t
is_in_country IN ('United Kingdom', 'USA', 'Россия', 'Brasil', 'China', 'India') OR
is_in_country_code IN ('AU', 'CN', 'IN', 'BR', 'US'))
UNION ALL
-- etldoc: osm_island_point -> layer_place:z12_14
SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'island' AS class, 7 AS "rank", NULL::int AS capital
FROM osm_island_point
WHERE zoom_level BETWEEN 12 AND 14
WHERE zoom_level >= 12
AND geometry && bbox
UNION ALL
-- etldoc: osm_island_polygon -> layer_place:z8_11
-- etldoc: osm_island_polygon -> layer_place:z12_14
SELECT
osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en,
'island' AS class, island_rank(area) AS "rank", NULL::int AS capital
@ -50,6 +60,11 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t
OR (zoom_level = 9 AND island_rank(area) <= 4)
OR (zoom_level >= 10))
UNION ALL
-- etldoc: layer_city -> layer_place:z0_3
-- etldoc: layer_city -> layer_place:z4_7
-- etldoc: layer_city -> layer_place:z8_11
-- etldoc: layer_city -> layer_place:z12_14
SELECT
osm_id, geometry, name, name_en,
place::text AS class, "rank", capital

Wyświetl plik

@ -1,6 +1,6 @@
-- etldoc: layer_poi[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_poi | <z14_> z14_" ] ;
-- etldoc: label="layer_poi | <z14_> z14+" ] ;
CREATE OR REPLACE FUNCTION layer_poi(bbox geometry, zoom_level integer, pixel_width numeric)
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, subclass text, "rank" int) AS $$
@ -10,12 +10,12 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t
ORDER BY CASE WHEN name = '' THEN 2000 ELSE poi_class_rank(poi_class(subclass)) END ASC
)::int AS "rank"
FROM (
-- etldoc: osm_poi_point -> layer_poi:z14
-- etldoc: osm_poi_point -> layer_poi:z14_
SELECT * FROM osm_poi_point
WHERE geometry && bbox
AND zoom_level >= 14
UNION ALL
-- etldoc: osm_poi_polygon -> layer_poi:z14
-- etldoc: osm_poi_polygon -> layer_poi:z14_
SELECT * FROM osm_poi_polygon
WHERE geometry && bbox
AND zoom_level >= 14

Wyświetl plik

@ -200,7 +200,7 @@ tables:
- pedestrian
# TODO: Future table for joining networks
# etldoc: imposm3 -> osm_route_member
# etldoc: imposm3 -> osm_route_member -> "!!!todo:Networks!!!"
route_member:
type: relation_member
columns:

Wyświetl plik

@ -8,7 +8,7 @@ layer:
It contains all roads from motorways to primary, secondary and
tertiary roads to residential roads and
foot paths. Styling the roads is the most essential part of the map.
The `highway` layer also contains polygons for things like plazas.
The `transportation` layer also contains polygons for things like plazas.
buffer_size: 4
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
fields:

Wyświetl plik

@ -1,6 +1,6 @@
-- etldoc: layer_transportation_name[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_transportation_name | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14_" ] ;
-- etldoc: label="layer_transportation_name | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14+" ] ;
CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer)
RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, network text, class text) AS $$

Wyświetl plik

@ -3,7 +3,7 @@
-- to allow for nice label rendering
-- Because this works well for roads that do not have relations as well
-- etldoc: osm_transportation_linestring -> osm_transportation_name_linestring
-- etldoc: osm_highway_linestring -> osm_transportation_name_linestring
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring AS (
SELECT
(ST_Dump(geometry)).geom AS geometry,

Wyświetl plik

@ -117,7 +117,7 @@ CREATE OR REPLACE VIEW water_z14 AS (
);
-- etldoc: layer_water [shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_water |<z0> z0|<z1>z1|<z2>z2|<z3>z3 |<z4> z4|<z5>z5|<z6>z6|<z7>z7| <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14_" ] ;
-- etldoc: label="layer_water |<z0> z0|<z1>z1|<z2>z2|<z3>z3 |<z4> z4|<z5>z5|<z6>z6|<z7>z7| <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14+" ] ;
CREATE OR REPLACE FUNCTION layer_water (bbox geometry, zoom_level int)
RETURNS TABLE(geom geometry, class text) AS $$

Wyświetl plik

@ -12,6 +12,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t
AND ((zoom_level BETWEEN 9 AND 13 AND LineLabel(zoom_level, NULLIF(name, ''), geometry))
OR (zoom_level >= 14))
-- etldoc: osm_water_point -> layer_water_name:z9_13
-- etldoc: osm_water_point -> layer_water_name:z14_
UNION ALL
SELECT osm_id, geometry, name, name_en, 'lake'::text AS class
FROM osm_water_point

Wyświetl plik

@ -1,5 +1,5 @@
-- etldoc: osm_water_polygon -> osm_water_lakeline
-- etldoc: custom_lakeline -> osm_water_lakeline
-- etldoc: lake_centerline -> osm_water_lakeline
CREATE TABLE IF NOT EXISTS osm_water_lakeline AS (
SELECT wp.osm_id,
ll.wkb_geometry AS geometry,

Wyświetl plik

@ -1,4 +1,5 @@
-- etldoc: osm_water_polygon -> osm_water_lakeline
-- etldoc: osm_water_polygon -> osm_water_point
-- etldoc: lake_centerline -> osm_water_point
CREATE TABLE IF NOT EXISTS osm_water_point AS (
SELECT
wp.osm_id, topoint(wp.geometry) AS geometry,

Wyświetl plik

@ -1,33 +1,33 @@
-- etldoc: ne_110m_rivers_lake_centerlines -> waterway_z3
CREATE OR REPLACE VIEW waterway_z3 AS (
SELECT geom AS geometry, 'river'::text AS class, NULL AS name FROM ne_110m_rivers_lake_centerlines
SELECT geom AS geometry, 'river'::text AS class, NULL::text AS name FROM ne_110m_rivers_lake_centerlines
WHERE featurecla = 'River'
);
-- etldoc: ne_50m_rivers_lake_centerlines -> waterway_z4
CREATE OR REPLACE VIEW waterway_z4 AS (
SELECT geom AS geometry, 'river'::text AS class, NULL AS name FROM ne_50m_rivers_lake_centerlines
SELECT geom AS geometry, 'river'::text AS class, NULL::text AS name FROM ne_50m_rivers_lake_centerlines
WHERE featurecla = 'River'
);
-- etldoc: ne_10m_rivers_lake_centerlines -> waterway_z6
CREATE OR REPLACE VIEW waterway_z6 AS (
SELECT geom AS geometry, 'river'::text AS class, NULL AS name FROM ne_10m_rivers_lake_centerlines
SELECT geom AS geometry, 'river'::text AS class, NULL::text AS name FROM ne_10m_rivers_lake_centerlines
WHERE featurecla = 'River'
);
-- etldoc: osm_waterway_linestring_gen3 -> waterway_z9
-- etldoc: osm_important_waterway_linestring_gen3 -> waterway_z9
CREATE OR REPLACE VIEW waterway_z9 AS (
SELECT geometry, 'river'::text AS class, name FROM osm_important_waterway_linestring_gen3
);
-- etldoc: osm_waterway_linestring_gen2 -> waterway_z10
-- etldoc: osm_important_waterway_linestring_gen2 -> waterway_z10
CREATE OR REPLACE VIEW waterway_z10 AS (
SELECT geometry, 'river'::text AS class, name FROM osm_important_waterway_linestring_gen2
);
-- etldoc: osm_waterway_linestring_gen1 -> waterway_z11
-- etldoc:osm_important_waterway_linestring_gen1 -> waterway_z11
CREATE OR REPLACE VIEW waterway_z11 AS (
SELECT geometry, 'river'::text AS class, name FROM osm_important_waterway_linestring_gen1
);
@ -50,7 +50,7 @@ CREATE OR REPLACE VIEW waterway_z14 AS (
);
-- etldoc: layer_waterway[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_waterway | <z3> z3 |<z4_5> z4-z5 |<z6_8> z6-8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14> z14" ];
-- etldoc: label="layer_waterway | <z3> z3 |<z4_5> z4-z5 |<z6_8> z6-8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14> z14+" ];
CREATE OR REPLACE FUNCTION layer_waterway(bbox geometry, zoom_level int)
RETURNS TABLE(geometry geometry, class text, name text) AS $$

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.6 MiB