Skip to content

Commit

Permalink
Refactored IDs to be unique
Browse files Browse the repository at this point in the history
  * aerodrome_label.osm_ids
  * housenumber.osm_ids
  * mountain_linestring.osm_ids
  * mountain_peak_point.osm_ids
  * place_city.osm_ids
  * place_continent_point.osm_ids
  * place_country.osm_ids
  * place_island_point.osm_ids
  * place_island_polygon.osm_ids
  * place_state.osm_ids
  * poi_polygon.osm_ids
  * water_name_marine.osm_ids
  • Loading branch information
benedikt-brandtner-bikemap committed Nov 2, 2022
1 parent 4cb65b0 commit 94b35ad
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 74 deletions.
8 changes: 2 additions & 6 deletions layers/aerodrome_label/update_aerodrome_label_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CREATE SCHEMA IF NOT EXISTS aerodrome_label;

CREATE TABLE IF NOT EXISTS aerodrome_label.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_aerodrome_label_point -> osm_aerodrome_label_point
Expand Down Expand Up @@ -48,11 +48,7 @@ SELECT update_aerodrome_label_point(true);
CREATE OR REPLACE FUNCTION aerodrome_label.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO aerodrome_label.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO aerodrome_label.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO aerodrome_label.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/housenumber/housenumber_centroid.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS housenumber;

CREATE TABLE IF NOT EXISTS housenumber.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_housenumber_point -> osm_housenumber_point
Expand All @@ -31,11 +31,7 @@ SELECT convert_housenumber_point(true);
CREATE OR REPLACE FUNCTION housenumber.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO housenumber.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO housenumber.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO housenumber.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/mountain_peak/update_mountain_linestring.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS mountain_linestring;

CREATE TABLE IF NOT EXISTS mountain_linestring.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_mountain_linestring -> osm_mountain_linestring
Expand All @@ -26,11 +26,7 @@ SELECT update_osm_mountain_linestring(true);
CREATE OR REPLACE FUNCTION mountain_linestring.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO mountain_linestring.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO mountain_linestring.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO mountain_linestring.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/mountain_peak/update_peak_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS mountain_peak_point;

CREATE TABLE IF NOT EXISTS mountain_peak_point.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_peak_point -> osm_peak_point
Expand All @@ -26,11 +26,7 @@ SELECT update_osm_peak_point(true);
CREATE OR REPLACE FUNCTION mountain_peak_point.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO mountain_peak_point.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO mountain_peak_point.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO mountain_peak_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/place/update_city_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE SCHEMA IF NOT EXISTS place_city;

CREATE TABLE IF NOT EXISTS place_city.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

CREATE OR REPLACE FUNCTION update_osm_city_point(full_update boolean) RETURNS void AS
Expand Down Expand Up @@ -56,11 +56,7 @@ CREATE INDEX IF NOT EXISTS osm_city_point_rank_idx ON osm_city_point ("rank");
CREATE OR REPLACE FUNCTION place_city.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_city.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_city.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_city.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/place/update_continent_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_continent_point;

CREATE TABLE IF NOT EXISTS place_continent_point.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_continent_point -> osm_continent_point
Expand All @@ -26,11 +26,7 @@ SELECT update_osm_continent_point(true);
CREATE OR REPLACE FUNCTION place_continent_point.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_continent_point.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_continent_point.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_continent_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/place/update_country_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_country;

CREATE TABLE IF NOT EXISTS place_country.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: ne_10m_admin_0_countries -> osm_country_point
Expand Down Expand Up @@ -105,11 +105,7 @@ CREATE INDEX IF NOT EXISTS osm_country_point_rank_idx ON osm_country_point ("ran
CREATE OR REPLACE FUNCTION place_country.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_country.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_country.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_country.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/place/update_island_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_island_point;

CREATE TABLE IF NOT EXISTS place_island_point.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_island_point -> osm_island_point
Expand All @@ -26,11 +26,7 @@ SELECT update_osm_island_point(true);
CREATE OR REPLACE FUNCTION place_island_point.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_island_point.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_island_point.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_island_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/place/update_island_polygon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_island_polygon;

CREATE TABLE IF NOT EXISTS place_island_polygon.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_island_polygon -> osm_island_polygon
Expand All @@ -33,11 +33,7 @@ SELECT update_osm_island_polygon(true);
CREATE OR REPLACE FUNCTION place_island_polygon.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_island_polygon.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_island_polygon.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_island_polygon.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/place/update_state_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_state;

CREATE TABLE IF NOT EXISTS place_state.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: ne_10m_admin_1_states_provinces -> osm_state_point
Expand Down Expand Up @@ -67,11 +67,7 @@ CREATE INDEX IF NOT EXISTS osm_state_point_rank_idx ON osm_state_point ("rank");
CREATE OR REPLACE FUNCTION place_state.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_state.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_state.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_state.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
8 changes: 2 additions & 6 deletions layers/poi/update_poi_polygon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS poi_polygon;

CREATE TABLE IF NOT EXISTS poi_polygon.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

-- etldoc: osm_poi_polygon -> osm_poi_polygon
Expand Down Expand Up @@ -51,11 +51,7 @@ SELECT update_poi_polygon(true);
CREATE OR REPLACE FUNCTION poi_polygon.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO poi_polygon.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO poi_polygon.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO poi_polygon.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down
3 changes: 1 addition & 2 deletions layers/transportation_name/update_transportation_name.sql
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ CREATE SCHEMA IF NOT EXISTS transportation_name;

CREATE TABLE IF NOT EXISTS transportation_name.network_changes
(
osm_id bigint,
UNIQUE (osm_id)
osm_id bigint PRIMARY KEY
);

CREATE OR REPLACE FUNCTION transportation_name.route_member_store() RETURNS trigger AS
Expand Down
8 changes: 2 additions & 6 deletions layers/water_name/update_marine_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS water_name_marine;

CREATE TABLE IF NOT EXISTS water_name_marine.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);

CREATE OR REPLACE FUNCTION update_osm_marine_point(full_update boolean) RETURNS void AS
Expand Down Expand Up @@ -45,11 +45,7 @@ CREATE INDEX IF NOT EXISTS osm_marine_point_rank_idx ON osm_marine_point ("rank"
CREATE OR REPLACE FUNCTION water_name_marine.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO water_name_marine.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO water_name_marine.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO water_name_marine.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
Expand Down

0 comments on commit 94b35ad

Please sign in to comment.