Skip to content

Commit

Permalink
Balises (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsakifa authored Jun 20, 2024
1 parent 306cc14 commit c24472a
Show file tree
Hide file tree
Showing 24 changed files with 9,505 additions and 7,602 deletions.
27 changes: 16 additions & 11 deletions datamodel/app/vw_sign_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,31 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, support.fk_support_type
, support.fk_support_base_type
, support.geometry::geometry(Point,{srid}) AS support_geometry
, COALESCE(vl_official_sign.directional_sign, vl_user_sign.directional_sign, FALSE) AS directional_sign
, COALESCE(vl_official_sign.directional_sign, vl_user_sign.directional_sign, vl_marker_type.directional_sign, FALSE) AS directional_sign
, CASE
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.value_de
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.value_de
ELSE vl_official_sign.value_de
END AS _symbol_value_de
, CASE
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.value_fr
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.value_fr
ELSE vl_official_sign.value_fr
END AS _symbol_value_fr
, CASE
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.value_it
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.value_it
ELSE vl_official_sign.value_it
END AS _symbol_value_it
, CASE
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.value_ro
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.value_ro
ELSE vl_official_sign.value_ro
END AS _symbol_value_ro
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_de
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_de
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_de
Expand All @@ -69,7 +73,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_fr
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_fr
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_fr
Expand All @@ -78,7 +82,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_it
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_it
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_it
Expand All @@ -87,7 +91,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_ro
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_ro
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_ro
Expand All @@ -96,7 +100,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_de_right
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_de_right
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_de_right
Expand All @@ -105,7 +109,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_fr_right
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_fr_right
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_fr_right
Expand All @@ -114,7 +118,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_it_right
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_it_right
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_it_right
Expand All @@ -123,7 +127,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 'complex.svg'::text
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_ro_right
WHEN sign.fk_sign_type = 12 THEN 'marker.svg'::text
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_ro_right
WHEN sign.fk_sign_type = 13 THEN 'mirror'||CASE WHEN sign.fk_mirror_shape=12 THEN '-circular' ELSE '' END||CASE WHEN NOT mirror_red_frame THEN '-noframe' ELSE '' END || '.svg'::text
WHEN sign.fk_sign_type = 14 THEN 'street-plate.svg'::text
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_ro_right
Expand All @@ -132,7 +136,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 106
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_height
WHEN sign.fk_sign_type = 12 THEN 130
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_height
WHEN sign.fk_sign_type = 13 THEN 80
WHEN sign.fk_sign_type = 14 THEN 50
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_height
Expand All @@ -141,7 +145,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
, CASE
WHEN sign.complex IS TRUE THEN 121
WHEN sign.fk_sign_type = 11 THEN vl_official_sign.img_width
WHEN sign.fk_sign_type = 12 THEN 70
WHEN sign.fk_sign_type = 12 THEN vl_marker_type.img_width
WHEN sign.fk_sign_type = 13 THEN 100
WHEN sign.fk_sign_type = 14 THEN 100
WHEN sign.fk_sign_type = 15 THEN vl_user_sign.img_width
Expand All @@ -153,6 +157,7 @@ def vw_sign_symbol(srid: int, pg_service: str = None):
LEFT JOIN signalo_db.support ON support.id = azimut.fk_support
LEFT JOIN signalo_db.vl_official_sign ON vl_official_sign.id = sign.fk_official_sign
LEFT JOIN signalo_db.vl_user_sign ON vl_user_sign.id = sign.fk_user_sign
LEFT JOIN signalo_db.vl_marker_type ON vl_marker_type.id = sign.fk_marker_type
),
Expand Down
101 changes: 101 additions & 0 deletions datamodel/changelogs/0101/0101_01_balises.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
--Disable triggers in signalo_db.sign before changes
ALTER TABLE signalo_db.sign DISABLE TRIGGER ALL;

--Disable foreign keys
ALTER TABLE signalo_db.sign
DROP CONSTRAINT fkey_vl_marker_type;

DROP TABLE IF EXISTS signalo_db.vl_marker_type;

CREATE TABLE signalo_db.vl_marker_type (
id text,
active boolean,
value_de text,
value_fr text,
value_it text,
value_ro text,
description_de text,
description_fr text,
description_it text,
description_ro text,
img_de text,
img_fr text,
img_it text,
img_ro text,
img_height integer DEFAULT 100,
img_width integer DEFAULT 100,
no_dynamic_inscription integer DEFAULT 0,
default_inscription1 text,
default_inscription2 text,
default_inscription3 text,
default_inscription4 text,
directional_sign boolean,
img_de_right text,
img_fr_right text,
img_it_right text,
img_ro_right text);

ALTER TABLE signalo_db.sign
ALTER COLUMN fk_marker_type TYPE text USING fk_marker_type::text;

INSERT INTO signalo_db.vl_marker_type (
id, active, value_de, value_fr, img_de, img_fr, img_it, img_ro, img_height, img_width, directional_sign, img_de_right, img_fr_right, img_it_right, img_ro_right)
VALUES
('m-1', true, 'unbekannt', 'inconnu', NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL, NULL, NULL),
('m-2', true, 'andere', 'autre', NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL, NULL, NULL),
('m-3', true, 'zu bestimmen', 'à déterminer', NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL, NULL, NULL),
('m-11', true, 'Einfacher Leitpfeil', 'Flèche de balisage simple', 'm-11-l.svg', 'm-11-l.svg', 'm-11-l.svg', 'm-11-l.svg', 100, 100, true, 'm-11-r.svg', 'm-11-r.svg', 'm-11-r.svg', 'm-11-r.svg'),
('m-12', true, 'Mehrfacher Leitpfeil', 'Flèche de balisage multiple', 'm-12-l.svg', 'm-12-l.svg', 'm-12-l.svg', 'm-12-l.svg', 50, 200, true, 'm-12-r.svg', 'm-12-r.svg','m-12-r.svg', 'm-12-r.svg'),
('m-13', true, 'Verkehrsteiler vom Typ B', 'Séparateur de trafic de type B', 'm-13.svg', 'm-13.svg', 'm-13.svg', 'm-13.svg', 50, 200, false, NULL, NULL, NULL, NULL),
('m-14', true, 'Leitbake (Richtung)', 'Balise de guidage (direction)', 'm-14-l.svg', 'm-14-l.svg', 'm-14-l.svg', 'm-14-l.svg', 200, 50, true, 'm-14-r.svg', 'm-14-r.svg','m-14-r.svg', 'm-14-r.svg'),
('m-15', true, 'Leitbake mittig', 'Balisage de guidage milieu', 'm-15.svg', 'm-15.svg', 'm-15.svg', 'm-15.svg', 200, 50, false, NULL, NULL, NULL, NULL),
('m-16', true, 'Leitstreifen', 'Bande de balisage', 'm-16.svg', 'm-16.svg', 'm-16.svg', 'm-16.svg', 16, 200, false, NULL, NULL, NULL, NULL);

UPDATE signalo_db.sign
SET fk_marker_type = 'm-1'
WHERE fk_marker_type = '1';

UPDATE signalo_db.sign
SET fk_marker_type = 'm-2'
WHERE fk_marker_type = '2';

UPDATE signalo_db.sign
SET fk_marker_type = 'm-3'
WHERE fk_marker_type = '3';

-- If former type was just "balise"
UPDATE signalo_db.sign
SET fk_marker_type = 'm-3'
WHERE fk_marker_type = '11';

UPDATE signalo_db.sign
SET fk_marker_type = 'm-11'
WHERE fk_marker_type = '12';

UPDATE signalo_db.sign
SET fk_marker_type = 'm-16'
WHERE fk_marker_type = '13';

UPDATE signalo_db.sign
SET fk_marker_type = 'm-14'
WHERE fk_marker_type = '14';

-- If former type was in fact referencing a support type, not a marker-sign (borne d'îlot)
UPDATE signalo_db.sign
SET fk_marker_type = 'm-3'
WHERE fk_marker_type = '15';

UPDATE signalo_db.sign
SET fk_marker_type = 'm-13'
WHERE fk_marker_type = '16';

-- Set primary key constraint in signalo_db.vl_marker_type
ALTER TABLE ONLY signalo_db.vl_marker_type
ADD CONSTRAINT marker_type_pkey PRIMARY KEY (id);

-- Set foreign key for user signs in signalo_db.sign
ALTER TABLE ONLY signalo_db.sign
ADD CONSTRAINT fkey_vl_marker_type FOREIGN KEY (fk_marker_type) REFERENCES signalo_db.vl_marker_type(id) MATCH FULL;

-- Enable triggers in signalo_db.sign
ALTER TABLE signalo_db.sign ENABLE TRIGGER ALL;
1 change: 1 addition & 0 deletions datamodel/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -v SRID=${SRID} -f ${DIR}/changel
psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -v SRID=${SRID} -f ${DIR}/changelogs/0100/0100_08_477_signs.sql
psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -v SRID=${SRID} -f ${DIR}/changelogs/0100/0100_09_exceptes.sql
psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -v SRID=${SRID} -f ${DIR}/changelogs/0100/0100_10_dms.sql
psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -v SRID=${SRID} -f ${DIR}/changelogs/0101/0101_01_balises.sql

if [[ $demo_data == True ]]; then
echo "*** inserting demo_data"
Expand Down
55 changes: 55 additions & 0 deletions project/images/marker/editable/m-11-l.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions project/images/marker/editable/m-11-r.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c24472a

Please sign in to comment.