turn overrides table structure#
The Turn_Overrides table holds information on allowed turn/connection overrides to be used
Overriding the logic that creates the Connections table is done using this table in the following way:
A penalty of -1 means that this turn is prohibited A non-negative penalty means that this turn is allowed
The table is indexed on node
| Field | Type | NULL allowed | Default Value | Foreign key | Description | 
|---|---|---|---|---|---|
| turn_pen* | INTEGER | NO | ID of the override | ||
| link | INTEGER | NO | Link(link) | Movement coming from this link | |
| dir | INTEGER | NO | link direction the movement is coming from | ||
| to_link | INTEGER | NO | Link(to_link) | Movement going to this link | |
| to_dir | INTEGER | NO | link direction the movement is going to | ||
| node | INTEGER | NO | Node(node) | Node where the turn is happening | |
| penalty | INTEGER | NO | -1 | Penalty for the turn. -1 means the turn is blocked | |
| notes | TEXT | YES | User notes, generally why this override was instituted | 
(* - Primary key)
The SQL statement for table and index creation is below.
CREATE TABLE IF NOT EXISTS Turn_Overrides(
    turn_pen  INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    link      INTEGER NOT NULL,
    dir       INTEGER NOT NULL,
    to_link   INTEGER NOT NULL,
    to_dir    INTEGER NOT NULL,
    node      INTEGER NOT NULL,
    penalty   INTEGER NOT NULL DEFAULT -1,
    notes     TEXT,
    CONSTRAINT "link_fk" FOREIGN KEY("link") REFERENCES "Link"("link") DEFERRABLE INITIALLY DEFERRED, -- check
    CONSTRAINT "to_link_fk" FOREIGN KEY("to_link") REFERENCES "Link"("link") DEFERRABLE INITIALLY DEFERRED, -- check
    CONSTRAINT "to_node_fk" FOREIGN KEY("node") REFERENCES "Node"("node") DEFERRABLE INITIALLY DEFERRED
);
create INDEX IF NOT EXISTS idx_polaris_turns_nod ON Turn_Overrides (node);
CREATE UNIQUE INDEX IF NOT EXISTS idx_polaris_turns_link_pair ON Turn_Overrides (link, to_link, node);