Add osm id
This commit is contained in:
parent
030e1e3204
commit
7ac0fb66d6
@ -29,13 +29,13 @@ CREATE OR REPLACE FUNCTION ne_highway(type VARCHAR) RETURNS VARCHAR AS $$
|
|||||||
$$ LANGUAGE SQL IMMUTABLE;
|
$$ LANGUAGE SQL IMMUTABLE;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS ne_10m_global_roads AS (
|
CREATE TABLE IF NOT EXISTS ne_10m_global_roads AS (
|
||||||
SELECT geom AS geometry, scalerank, ne_highway(type) AS highway, NULL::boolean AS is_tunnel, NULL::boolean AS is_bridge, 0::int as z_order
|
SELECT NULL::bigint as osm_id, geom AS geometry, scalerank, ne_highway(type) AS highway, NULL::boolean AS is_tunnel, NULL::boolean AS is_bridge, 0::int as z_order
|
||||||
FROM ne_10m_roads
|
FROM ne_10m_roads
|
||||||
WHERE continent <> 'North America'
|
WHERE continent <> 'North America'
|
||||||
AND featurecla = 'Road'
|
AND featurecla = 'Road'
|
||||||
AND type IN ('Major Highway', 'Secondary Highway', 'Road')
|
AND type IN ('Major Highway', 'Secondary Highway', 'Road')
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geom AS geometry, scalerank, ne_highway(type) AS highway, NULL::boolean AS is_tunnel, NULL::boolean AS is_bridge, 0::int as z_order
|
SELECT NULL::bigint as osm_id, geom AS geometry, scalerank, ne_highway(type) AS highway, NULL::boolean AS is_tunnel, NULL::boolean AS is_bridge, 0::int as z_order
|
||||||
FROM ne_10m_roads_north_america
|
FROM ne_10m_roads_north_america
|
||||||
WHERE type IN ('Major Highway', 'Secondary Highway', 'Road')
|
WHERE type IN ('Major Highway', 'Secondary Highway', 'Road')
|
||||||
);
|
);
|
||||||
@ -44,51 +44,51 @@ CREATE INDEX IF NOT EXISTS ne_10m_global_roads_geometry_idx ON ne_10m_global_roa
|
|||||||
CREATE INDEX IF NOT EXISTS ne_10m_global_roads_scalerank_idx ON ne_10m_global_roads(scalerank);
|
CREATE INDEX IF NOT EXISTS ne_10m_global_roads_scalerank_idx ON ne_10m_global_roads(scalerank);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z4 AS (
|
CREATE OR REPLACE VIEW highway_z4 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM ne_10m_global_roads
|
FROM ne_10m_global_roads
|
||||||
WHERE scalerank <= 5
|
WHERE scalerank <= 5
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z5 AS (
|
CREATE OR REPLACE VIEW highway_z5 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM ne_10m_global_roads
|
FROM ne_10m_global_roads
|
||||||
WHERE scalerank <= 6
|
WHERE scalerank <= 6
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z6 AS (
|
CREATE OR REPLACE VIEW highway_z6 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM ne_10m_global_roads
|
FROM ne_10m_global_roads
|
||||||
WHERE scalerank <= 7
|
WHERE scalerank <= 7
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z8 AS (
|
CREATE OR REPLACE VIEW highway_z8 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring_gen4
|
FROM osm_highway_linestring_gen4
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z9 AS (
|
CREATE OR REPLACE VIEW highway_z9 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring_gen3
|
FROM osm_highway_linestring_gen3
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z10 AS (
|
CREATE OR REPLACE VIEW highway_z10 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring_gen2
|
FROM osm_highway_linestring_gen2
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z11 AS (
|
CREATE OR REPLACE VIEW highway_z11 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring_gen1
|
FROM osm_highway_linestring_gen1
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z12 AS (
|
CREATE OR REPLACE VIEW highway_z12 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring
|
FROM osm_highway_linestring
|
||||||
WHERE highway IN ('motorway','trunk','primary', 'secondary', 'tertiary', 'minor')
|
WHERE highway IN ('motorway','trunk','primary', 'secondary', 'tertiary', 'minor')
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z13 AS (
|
CREATE OR REPLACE VIEW highway_z13 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring
|
FROM osm_highway_linestring
|
||||||
WHERE highway IN (
|
WHERE highway IN (
|
||||||
'motorway',
|
'motorway',
|
||||||
@ -109,13 +109,13 @@ CREATE OR REPLACE VIEW highway_z13 AS (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW highway_z14 AS (
|
CREATE OR REPLACE VIEW highway_z14 AS (
|
||||||
SELECT geometry, highway, is_tunnel, is_bridge, z_order
|
SELECT osm_id, geometry, highway, is_tunnel, is_bridge, z_order
|
||||||
FROM osm_highway_linestring
|
FROM osm_highway_linestring
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_highway(bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_highway(bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(geometry geometry, class text, subclass text) AS $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text) AS $$
|
||||||
SELECT geometry, highway_class(highway) AS class, highway AS subclass FROM (
|
SELECT osm_id, geometry, highway_class(highway) AS class, highway AS subclass FROM (
|
||||||
SELECT * FROM highway_z4 WHERE zoom_level BETWEEN 4 AND 5
|
SELECT * FROM highway_z4 WHERE zoom_level BETWEEN 4 AND 5
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT * FROM highway_z5 WHERE zoom_level = 5
|
SELECT * FROM highway_z5 WHERE zoom_level = 5
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
CREATE TABLE IF NOT EXISTS country_label AS (
|
CREATE TABLE IF NOT EXISTS country_label AS (
|
||||||
SELECT topoint(geom) AS geometry,
|
SELECT topoint(geom) AS geometry,
|
||||||
|
NULL::bigint AS osm_id,
|
||||||
name,
|
name,
|
||||||
adm0_a3, abbrev, postal,
|
adm0_a3, abbrev, postal,
|
||||||
scalerank, labelrank,
|
scalerank, labelrank,
|
||||||
@ -30,8 +31,8 @@ CREATE OR REPLACE VIEW country_z5 AS (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_country(bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_country(bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(geometry geometry, name text, abbrev text, postal text, scalerank int, labelrank int) AS $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, name text, abbrev text, postal text, scalerank int, labelrank int) AS $$
|
||||||
SELECT geometry, name, abbrev, postal, scalerank::int, labelrank::int FROM (
|
SELECT osm_id, geometry, name, abbrev, postal, scalerank::int, labelrank::int FROM (
|
||||||
SELECT * FROM country_z0
|
SELECT * FROM country_z0
|
||||||
WHERE zoom_level = 0
|
WHERE zoom_level = 0
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|||||||
@ -1,64 +1,64 @@
|
|||||||
CREATE OR REPLACE VIEW place_z2 AS (
|
CREATE OR REPLACE VIEW place_z2 AS (
|
||||||
SELECT geometry, name, name_en, place, scalerank, population
|
SELECT osm_id, geometry, name, name_en, place, scalerank, population
|
||||||
FROM osm_important_place_point
|
FROM osm_important_place_point
|
||||||
WHERE scalerank <= 0
|
WHERE scalerank <= 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z3 AS (
|
CREATE OR REPLACE VIEW place_z3 AS (
|
||||||
SELECT geometry, name, name_en, place, scalerank, population
|
SELECT osm_id, geometry, name, name_en, place, scalerank, population
|
||||||
FROM osm_important_place_point
|
FROM osm_important_place_point
|
||||||
WHERE scalerank <= 2
|
WHERE scalerank <= 2
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z4 AS (
|
CREATE OR REPLACE VIEW place_z4 AS (
|
||||||
SELECT geometry, name, name_en, place, scalerank, population
|
SELECT osm_id, geometry, name, name_en, place, scalerank, population
|
||||||
FROM osm_important_place_point
|
FROM osm_important_place_point
|
||||||
WHERE scalerank <= 5
|
WHERE scalerank <= 5
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z5 AS (
|
CREATE OR REPLACE VIEW place_z5 AS (
|
||||||
SELECT geometry, name, name_en, place, scalerank, population
|
SELECT osm_id, geometry, name, name_en, place, scalerank, population
|
||||||
FROM osm_important_place_point
|
FROM osm_important_place_point
|
||||||
WHERE scalerank <= 6
|
WHERE scalerank <= 6
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z6 AS (
|
CREATE OR REPLACE VIEW place_z6 AS (
|
||||||
SELECT geometry, name, name_en, place, scalerank, population
|
SELECT osm_id, geometry, name, name_en, place, scalerank, population
|
||||||
FROM osm_important_place_point
|
FROM osm_important_place_point
|
||||||
WHERE scalerank <= 7
|
WHERE scalerank <= 7
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z7 AS (
|
CREATE OR REPLACE VIEW place_z7 AS (
|
||||||
SELECT geometry, name, name_en, place, scalerank, population
|
SELECT osm_id, geometry, name, name_en, place, scalerank, population
|
||||||
FROM osm_important_place_point
|
FROM osm_important_place_point
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z8 AS (
|
CREATE OR REPLACE VIEW place_z8 AS (
|
||||||
SELECT geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
SELECT osm_id, geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
WHERE place IN ('city', 'town')
|
WHERE place IN ('city', 'town')
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z10 AS (
|
CREATE OR REPLACE VIEW place_z10 AS (
|
||||||
SELECT geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
SELECT osm_id, geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
WHERE place IN ('city', 'town', 'village') OR place='subregion'
|
WHERE place IN ('city', 'town', 'village') OR place='subregion'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z11 AS (
|
CREATE OR REPLACE VIEW place_z11 AS (
|
||||||
SELECT geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
SELECT osm_id, geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW place_z13 AS (
|
CREATE OR REPLACE VIEW place_z13 AS (
|
||||||
SELECT geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
SELECT osm_id, geometry, name, name_en, place, NULL::integer AS scalerank, population FROM osm_place_point
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric)
|
CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric)
|
||||||
RETURNS TABLE(geometry geometry, name text, name_en text, place text, abbrev text, postal text, scalerank int) AS $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, place text, abbrev text, postal text, scalerank int) AS $$
|
||||||
SELECT geometry, name, name AS name_en, 'country' AS place, abbrev, postal, scalerank FROM layer_country(bbox, zoom_level)
|
SELECT osm_id, geometry, name, name AS name_en, 'country' AS place, abbrev, postal, scalerank FROM layer_country(bbox, zoom_level)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geometry, name, name_en, 'state' AS place, abbrev, postal, scalerank FROM layer_state(bbox, zoom_level)
|
SELECT osm_id, geometry, name, name_en, 'state' AS place, abbrev, postal, scalerank FROM layer_state(bbox, zoom_level)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geometry, name, name_en, place, NULL AS abbrev, NULL AS postal, scalerank FROM (
|
SELECT osm_id, geometry, name, name_en, place, NULL AS abbrev, NULL AS postal, scalerank FROM (
|
||||||
SELECT geometry, name, name_en, place, scalerank,
|
SELECT osm_id, geometry, name, name_en, place, scalerank,
|
||||||
row_number() OVER (
|
row_number() OVER (
|
||||||
PARTITION BY LabelGrid(geometry, 150 * pixel_width)
|
PARTITION BY LabelGrid(geometry, 150 * pixel_width)
|
||||||
ORDER BY scalerank ASC NULLS LAST,
|
ORDER BY scalerank ASC NULLS LAST,
|
||||||
|
|||||||
@ -8,6 +8,7 @@ $$ LANGUAGE plpgsql IMMUTABLE;
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS state_label AS (
|
CREATE TABLE IF NOT EXISTS state_label AS (
|
||||||
SELECT topoint(geom) AS geometry,
|
SELECT topoint(geom) AS geometry,
|
||||||
|
NULL::bigint AS osm_id,
|
||||||
name_local, fix_win1252_shp_encoding(name) AS name_en,
|
name_local, fix_win1252_shp_encoding(name) AS name_en,
|
||||||
abbrev, postal,
|
abbrev, postal,
|
||||||
scalerank, labelrank,
|
scalerank, labelrank,
|
||||||
@ -28,8 +29,8 @@ CREATE OR REPLACE VIEW state_z4 AS (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_state(bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_state(bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(geometry geometry, name text, name_en text, abbrev text, postal text, scalerank int, labelrank int) AS $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, abbrev text, postal text, scalerank int, labelrank int) AS $$
|
||||||
SELECT geometry,
|
SELECT osm_id, geometry,
|
||||||
COALESCE(name_local, name_en) AS name_local, name_en,
|
COALESCE(name_local, name_en) AS name_local, name_en,
|
||||||
abbrev, postal, scalerank::int, labelrank::int FROM (
|
abbrev, postal, scalerank::int, labelrank::int FROM (
|
||||||
SELECT * FROM state_z3
|
SELECT * FROM state_z3
|
||||||
|
|||||||
@ -23,8 +23,8 @@ CREATE OR REPLACE VIEW railway_z14 AS (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_railway(bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_railway(bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(geometry geometry, class text, subclass text, brunnel text) AS $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, brunnel text) AS $$
|
||||||
SELECT geometry,
|
SELECT osm_id, geometry,
|
||||||
railway_class(railway, service) AS class,
|
railway_class(railway, service) AS class,
|
||||||
railway AS subclass,
|
railway AS subclass,
|
||||||
railway_brunnel(is_bridge, is_tunnel) AS brunnel
|
railway_brunnel(is_bridge, is_tunnel) AS brunnel
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user