How S2 is built and tested

Author

Mohamed Gharbia

Published

October 15, 2026

The values come from PlanX, the QGIS tool I use for the analysis, run on the walking network and the driving network. Each S1 segment takes the values of the analysed lines lying under it, within 1 m. A segment that finds too little gets no value (never a zero) and a written reason.

Blueprint

flowchart TB
  IN1[/"S1 segments<br/>264 segments"/]:::data
  IN2[/"Walking values<br/>47,197 analysed lines"/]:::data
  IN3[/"Vehicle values<br/>47,730 analysed lines"/]:::data
  CFG[/"Settings<br/>a test point every metre, within 1 m<br/>cover 95 % or 50 %"/]:::rule

  IN1 --> R["READ<br/>segments and analysed lines"]:::step
  IN2 --> R
  IN3 --> R
  R --> G["SORT<br/>walking lines into a 20 m grid"]:::step
  G --> W["WALKING MATCH<br/>test points and the same-kind rule,<br/>cover and a mean by length"]:::step
  CFG --> W
  R --> V["VEHICLE MATCH<br/>may cars use it, then the same street"]:::step
  W --> S["STATUS<br/>matched, split,<br/>partial or missing"]:::step
  V --> S
  S --> O1[/"values for every segment"/]:::out
  S --> O2[/"trace of every line used"/]:::out
  O1 --> T["checks"]:::test
  O2 --> T
  T --> X["stress tests"]:::test
  X --> VZ["maps"]:::test
  VZ --> WB["data for the Lab"]:::test

  classDef data fill:none,stroke:#8a8a8a,color:#e6e6e6
  classDef rule fill:none,stroke:#8a8a8a,stroke-dasharray:4 3,color:#a6a6a6
  classDef step fill:none,stroke:#e6e6e6,color:#e6e6e6
  classDef out fill:none,stroke:#e6e6e6,stroke-width:2px,color:#ffffff
  classDef test fill:none,stroke:#fe83cc,color:#fe83cc

The problem

S1 and the walking network were built from the same city lines, and each cut them in its own places. S1 cuts where a park path joins a street. The walking network cuts wherever a bike path joins one. So an S1 segment and an analysed line are often the same street with different ends. Rue des Seigneurs is one S1 segment lying over two analysed pieces with different values. Matching by id alone would hide that. Matching by shape finds both.

The matching rule

A made-up segment and the analysed lines under it.

A made-up segment and the analysed lines under it.

I place a test point about every metre along each S1 segment. Each point looks for the closest analysed line within 1 m, but only among lines of the same kind. A city street looks only at pieces of the same street in the city’s records. A path or connector looks only at its own kind.

The cover is the share of the segment’s length that found a line. The value is the mean of the lines found, each weighted by the metres it shares with the segment. With one line, it is exactly that line’s value. With 95 % cover or more, the segment counts as matched, or as split when its value comes from two lines. Between 50 and 95 % it keeps its value and is marked partial, so the gap stays visible. Below 50 % it gets no value and a written reason. Today no segment is partial.

The same-kind rule matters near junctions. There, a test point at the end of a street also lies within 1 m of the crossing street. Without the rule, a street could take some of its neighbour’s values. The stress tests measure that risk.

Vehicle values

The driving network keeps the city’s lines uncut. So every S1 piece of a street simply takes the vehicle value of the same city street id. First, S2 asks whether cars may use the street, by the same rule S1 uses. Streets closed to cars, and every added path or connector, are marked as not roads, with a written reason. A street open to cars and missing from the analysis would be marked missing. Today there are none.

Tests

Checks

Each check asks a plain question of the result, and all of them pass. The Lab lists the latest run.

Question Answer
Does every S1 segment have exactly one row? Yes
Is a value present exactly when it should be, and is every missing value empty, with a reason? Yes
Can every walking value be rebuilt from the trace of analysed lines behind it? Yes
Is any value invented, or outside the values of its lines? No
Do values come only from the same kind of line, and from the same street for city streets? Yes
Do vehicle values equal the vehicle analysis for the same street? Yes

A seventh check only reports coverage: the numbers under Result.

TipThe trace check caught a real problem

On the first run the trace check failed. The trace rounded the shared metres to two decimals, too coarse to rebuild the values exactly. I now store them to six.

Stress tests

The stress tests ask how easily the result could go wrong. Each one changes one thing on purpose and measures what moves.

Two runs on the same input give identical results. Any matching distance from 5 cm to 10 m gives the same result, and test points every 25 cm or every 5 m move a value by about 0.01 at most. Shaking every S1 point by up to 0.3 m changes one segment: a 15 m connector at Brennan, which then takes part of its value from the next connector. At 0.8 m, six segments change status, mostly paths and connectors along the canal, and no value moves by more than 0.08.

The test that matters most turns the same-kind rule off. With nothing shaken, no segment then takes values from another line. Shaken by 0.8 m, 142 segments do. The worst is the short Smith link, which moves by 0.24 as it takes values from the streets at both its ends.

As the S1 points are shaken further, segments without the same-kind rule start taking values from crossing streets. With the rule, almost nothing moves.

As the S1 points are shaken further, segments without the same-kind rule start taking values from crossing streets. With the rule, almost nothing moves.

Today the match is exact because S1 and the walking network share coordinates, so the matching distance has no effect. If the geometry drifted, for example after someone edits S1 in QGIS, the same-kind rule would keep S2 honest.

The rule test also found a fault upstream. Before a fix, Rue Smith picked up 21 m from a connector lying on top of it. That was the C06 link, which joined Smith to its own other end. I fixed the rule in S1 (C06), and after the new PlanX run no such segment remains.