Editing and consistency#
Differently from the previous Polaris network editor, this new version separates the several needed editing features in three different groups based on their implementation.
Trigger-based, always-on, editing features
Manually-trigger editing
Available only in the QGIS interface
Hands-on in a nutshell#
There are three possible scenarios for network editing:
Editing the network after opening it with the QGIS plugin (with gracious shutdown)
Editing the network using the Python library (with gracious shutdown)
All other cases
Cases 1 and 2 result in continuous internal consistency for the network, and if your editing networks falls within the 3rd case, just open the network with the Python plugin or with the QGIS plugin and things will be taken care for you.
Editing tools#
The main idea of this new network editing framework is to leverage the GIS editing and visualization capabilities of specialized soft5ware (i.e. QGIS), instead of re-implementing them for the sole purpose of editing Polaris Networks.
In that sense, the design goal for this tool is to allow the user to use the GIS or database manipulation tool of their choice for their regular network editing tasks and to ensure internal network consistency. Ideally, enforcing internal consistency would be done entirely through the use of database triggers, which would result in a “virtually incorruptible” network.
The challenge of creating a network editing piece of software based solely on database tools is not trivial, but it mostly possible. However, SQLite does not have the necessary trigger capabilities of full-blown databases required for a sensible implementation. As a consequence, operations like updating the walk_link for locations and parkings in the event of a deletion in the Transit_Walk table results can take up to a whole second per update, making it inadequate for implementation as a trigger.
For this reason, internal network consistency is ensured through a mix of database triggers and Python code. On that note, there are two types of database triggers. The first type is the one that executes required changes to the database at the time an edit occurs (e.g. adds new nodes to the network when a new link is added to the network when required), and the second type of trigger records the changes executed to a backlog so an external tool (this Python package) can identify such changes and execute the required changes to the network.
This backlog is implemented as a table called editing_table in the standard model database.
Executing changes in the backlog#
Following the principle of enforcing internal network consistency without the need for user intervention, processing the backlog is done with by simply opening that network with this package.
from polaris.network.network import Network
net = Network()
net.open('path/to/file')
net.close()
It is also possible not to process the list of edits in the queue when opening a database (below), but that is strongly advised against.
from polaris.network.network import Network
net = Network()
net.open('path/to/file', process_backlog=False)
net.close()
Internal network consistency#
Here we list all behaviors covered by the junction grouped by the table where consequential changes happen, the type of change and by the type of consistency mechanism (instant change or creation of a backlog).
EV_Charging_Stations#
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter Latitude |
Enforces Y from geo |
. |
Latitude |
||
Alter Longitude |
Enforces X from geo |
. |
Longitude |
||
Deletes a charging station |
Deletes corresponding records from EV_Charging_Station_Plugs and EV_Charging_Station_Plugs |
. |
Link#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Alter bearing_a |
Enforces bearing_a from geo |
. |
bearing_a |
||
2 |
Alter bearing_b |
Enforces bearing_b from geo |
. |
bearing_b |
||
3 |
Alter length |
Enforces length from geo |
. |
length |
||
4 |
Set lanes_* = 0 |
speed, capacity or fspd to ZERO |
lanes_* |
|||
5 |
Set lanes_* = 0 |
Remove connections for link/dir |
. |
lanes_* |
||
6 |
Set lanes_* (>0) |
Re-evaluate Connections for dir * |
lanes_* |
|||
7 |
Add/remove links from Transit_Walk |
. |
. |
|||
8 |
Set speed_* = 0 |
Revert when lanes_* > 0 |
. |
speed_* |
||
9 |
Set fspd_* = 0 |
Revert when lanes_* > 0 |
. |
fspd_* |
||
10 |
Set capacity_* = 0 |
Revert when lanes_* > 0 |
. |
capacity_* |
||
11 |
Set speed_* > 0 |
Reverts to zero when lanes_* = 0 |
. |
speed_* |
||
12 |
Set fspd_* > 0 |
Reverts to zero when lanes_* = 0 |
. |
fspd_* |
||
13 |
Set capacity_* > 0 |
Reverts to zero when lanes_* = 0 |
. |
capacity_* |
||
14 |
Add/remove nodes if needed |
. |
||||
15 |
Updates a_node/b_node. |
. |
||||
16 |
Update Parking table |
. |
type, lanes_* |
|||
17 |
Update Connection table |
. |
||||
18 |
Update Location table |
. |
type, lanes_* |
|||
19 |
Update Location_Links table |
. |
||||
20 |
Update Pocket table |
. |
. |
|||
21 |
Update Sign table |
. |
. |
|||
22 |
No change when toll_counterpart |
. |
||||
23 |
toll_counterpart |
Reverts to zero when lanes_* = 0 |
link |
Details#
Some of the changes above might not be obvious, so they are further detailed below
Re-evaluates all connections at the link’s node_a and node_b
Instant changes#
Re-evaluates if a_node & b_node are still necessary after link deletion. Deletes them if not needed
Removes incoming/outgoing connections from the Connection table
Removes corresponding walk_link from the Transit_Walk table
Backlog#
Re-evaluates entries from Connection table for all previously connected links
Adding#
Adding a link has a number of geo-related and data related implications
Instant changes#
Creates nodes if needed
Populates geo-related fields
length
bearing_a
bearing_b
Backlog#
Consistency check for number of lanes/speed/fspd/capacity
Adds only if record lacks consistency
Changing geometry#
Instant changes#
Recomputes geometry-related fields:
length/distance
bearing_a
bearing_b
Changes a_node/b_node if required
Re-evaluates if old node_a & node_b are still necessary. Deletes them if not needed
Backlog#
Re-evaluates connections on both ends
Editing data fields#
Some fields require other fields to also change in order to remain consistent.
Instant changes#
length
It reverts back to the geometry-computed (glength(geo)) value
bearing_a
It reverts back to the geometry-computed value
bearing_b
It reverts back to the geometry-computed value
lanes (ab or ba) to zero
speed, fspd and capacity (same direction) are also set to zero. No warning is raised.
Removes Connections from that direction
speed, capacity or fspd (ab or ba) to zero
If there are lanes in that direction, the change is reversed
speed, capacity or fspd (ab or ba) to positive value
If there are no lanes in that direction, reverts to zero
Backlog#
type (link_type)
If changing from NOT walk-enabled to walk-enabled, copies link to Transit_Walk
If changing from walk-enabled to NOT walk-enabled, deletes corresponding link from Transit_Walk
lanes (ab or ba)
evaluate the Connection table entries involving both nodes A and B for the link
Location#
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter X/geo |
Enforces X from geo |
. |
x |
||
Alter Y/geo |
Enforces Y from geo |
. |
y |
||
Alter setback/geo |
Enforces setback from geo/link |
. |
setback |
||
Alter Zone/geo |
Recomputes from geo |
. |
zone |
||
Alter area_type |
Recomputes/enforces from zone |
. |
area_type |
||
Alter link/geo |
Recomputes from geo/link |
. |
link setback |
||
geo |
Recomputes from geo |
. |
walk_link, walk_offset |
||
Alter walk_offset |
Enforces from walk_link |
walk_offset |
|||
Change in set |
Update Location_Links table |
. |
|||
Change in set |
Update Location_Parking table |
. |
|||
Change in set |
Update EV_Charging_Stations table |
. |
|||
Alter zone |
Update area_type field |
. |
area_type |
Parking#
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter setback/geo |
Enforces setback from geo/link |
. |
setback |
||
Alter Zone/geo |
Recomputes from geo |
. |
zone |
||
Alter area_type |
Recomputes/enforces from zone |
. |
area_type |
||
Alter link/geo |
Recomputes from geo |
. |
link setback |
||
geo |
Recomputes from geo/link |
. |
walk_link, walk_offset |
||
Alter walk_offset |
Enforces from walk_link |
walk_offset |
|||
Change in set |
Update Location_Parking table |
. |
|||
Alter zone |
Update area_type field |
. |
area_type |
Node#
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter geo |
Moves links’s ends to new position |
. |
x, y |
||
Delete node |
Controlled by link deletion |
||||
Add node |
Controlled by link creation/edit |
: x, y |
|||
Change to X field |
Enforce from Geometry |
x |
|||
Change to Y field |
Enforce from Geometry |
y |
Traffic Signals and signs#
The traffic signal information necessary for Polaris to work is stored in six different table: Signal, Signal_Nested_Records, Phasing, Phasing_Nested_Records, Timing and Timing_Nested_Records. As very little manual editing is expected to be done to all of these tables, the number of automatic consistency mechanisms involving these tables is very small, and involve mostly propagation on data deletion and summary of table data on their parents.
Sign#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Deletes a sign |
Sets control_type to ‘’ on table nodes |
. |
control_type |
||
2 |
Adds a sign |
Sets control_type to ‘all_stop’ or stop_sign on table nodes. Removes corresponding record from table Signal |
. |
control_type signal |
Signal#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Deletes a signal |
Clears related tables: Phasing Timing and Signal_Nested_Records Sets control_type to ‘’ on table nodes |
. |
control_type |
||
2 |
Adds a signal |
Sets control_type to ‘signal’ on table nodes. Removes corresponding record from table Sign |
|
control_type sign |
||
3 |
Changes data |
Enforces data on “times” field |
times |
Signal_Nested_Records#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Changes number of records |
Updates the field ‘times’ in the table Signal |
. |
Phasing#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Deletes a Phasing record |
Clear related table: Phasing_Nested_Records |
. |
|||
2 |
Changes data |
Enforces data on “movements” field |
movements |
Phasing_Nested_Records#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Changes number of records |
Updates the field ‘movements’ in the table Phasing |
. |
Timing#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Deletes a Timing record |
Clear related table: Timing_Nested_Records |
. |
|||
2 |
Changes data |
Atempts to change data in the table |
cycle, phases |
Timing_Nested_Records#
Index |
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
|||
1 |
Change times for any phase |
Updates the field ‘cycle’ in the table Timing |
. |
value_maximum, value_red, value_yellow |
||
2 |
Change number of records |
Updates the field ‘times’ in the the table Timing |
. |
Transit_Bike#
To some extent, the Transit_Bike network could be managed like the roadway network. However, this network is an abstraction built on top of the roadway network AND transit layer, so it is not reasonable to have this network manually edited.
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter bearing_a |
Enforces bearing_a from geo |
. |
bearing_a |
||
Alter bearing_b |
Enforces bearing_b from geo |
. |
bearing_b |
||
Change in set |
Re-evaluates need for bike stop |
. |
|||
Change in set/data |
walk_link on Location & Parking |
. |
bike_link |
Transit_Stops#
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter X |
Enforces X from geo |
. |
x |
||
Alter Y |
Enforces Y from geo |
. |
y |
||
Alter Zone |
Recomputes from geo |
. |
zone |
||
Change in set |
Update Transit_Links geometry |
. |
|||
Change in set |
Update Transit_Walk geometry |
. |
Besides the above operations, there are also restrictions on addition and deletion that are in place. These constraints are:
A stop cannot be deleted if a route is using it (i.e. it is referred to on transit_pattern_stops or Transit_Pattern_Mapping)
A stop can only be added to the database if a route already refers to this stop (i.e. it is referred to on transit_pattern_stops or Transit_Pattern_Mapping)
Transit_Walk#
To some extent, the Transit_Walk network could be managed like the roadway network. However, this network is an abstraction built on top of the roadway network AND transit layer, so it is not reasonable to have this network manually edited.
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter bearing_a |
Enforces bearing_a from geo |
. |
bearing_a |
||
Alter bearing_b |
Enforces bearing_b from geo |
. |
bearing_b |
||
Change in set |
Re-evaluates need for walk stop |
. |
|||
Change in set/data |
walk_link on Location & Parking |
. |
walk_link |
Zone#
What happens |
Expected change |
When it happens |
|||
---|---|---|---|---|---|
Delete |
Add |
Edit geo |
Edit data |
||
Alter X |
Enforces X from geo |
. |
x |
||
Alter Y |
Enforces Y from geo |
. |
y |
||
Update table ev_charging_stations |
Updating zone on relevant records |
. |
zone |
||
Update Location table |
Updating zone on relevant records |
. |
zone |
||
Update Node table |
Updating zone on relevant records |
. |
zone |
||
Update Parking table |
Updating zone on relevant records |
. |
zone |
||
Update Transit_Stops |
Updating zone on relevant records |
. |
zone |