# Map Layer ID Audit

## Key Finding

The JS `layerID` values were never authoritative — they were placeholders. The `layerName` field is the reliable join key between JS and DB: `layerName` in JS corresponds directly to `layer_name` in `public.map_layers`. Where the same `layerName` appears in multiple JS files, it is the same DB record.

The JS `layerID` values are discarded after this migration. All future layer identity is by DB `layer_id`.

---

## Reference & Base Layer Reconciliation

Full mapping of JS `layerName` → DB `layer_id`. These all have DB records; no new rows needed for these.

| DB layer_id | DB layer_name | DB title | JS layerID used | Notes |
|---|---|---|---|---|
| 7 | basemapOS | Ordnance Survey | 30 | |
| 8 | basemapOSM | Open Street Maps | 1 | |
| 9 | basemapGoogle | Google Maps | 2 | |
| 10 | basemapGoogleSat | Google Satellite | 3 | |
| 11 | basemapCartoPositronLight | Carto Positron - Light | 300 | |
| 12 | basemapCartoPositronDark | Carto Positron - Dark | 300 | |
| 1 | bsr_high_rise_register… | BSR High Rise Register | 432 | |
| 2 | bduk_go_list_fmp_work_20251003… | BDUK 10-2025 | 431 | |
| 3 | bduk_go_list_address_view_geom_aug25 | BDUK MDU 08-2025 | 430 | |
| 4 | scci_cfl_mdu_pia_distance… | BDUK MDU - CFL 05-2025 | 43 | |
| 5 | scci_bduk_mdu_geom | BDUK MDU 04-2025 | 40 | |
| 6 | bduk_uk_geom | BDUK National Dataset 03-2025 | 40 | |
| 13 | osCodePointOpen | Postcodes | 4 | JS title was "OS - Code Point Open" — DB title differs |
| 14 | osOpenUPRN | OS - Open UPRN | 5 | |
| 15 | project_meet_me_points | Project Meet Me Points | 31 | projectedit only |
| 16 | PIADuct | PIA Duct | 6 | |
| 17 | PIAStructure | PIA Structures | 7 | |
| 19 | npFTTPProviders | FTTP Provider Count By Postcode | 13 | |
| 20 | npCFLPostcodes | CFL Postcodes | 14 | |
| 21 | npLABoundaries | Local Authorities | 15 | |
| 22 | clfOltLocations | CFL OLT Locations | 16 | inactive in DB — keep disabled |
| 23 | parentChildProjectLinks | Parent/Child Project Links | 17 | |
| 24 | piaBlockages | PIA Blockages (All) | 18 | |
| 25 | stocklist_premises_geom | Stocklist Premises (All) | 42 | reference/read-only layer |
| 26 | vw_toid_building_type_geom | MDU Buildings | 43 | |
| 27 | planned_cables_all_projects | Planned Cables All Projects | 43 | |
| 28 | openreach_exchange_footprints | Openreach Exchange Footprints | — | not yet in any JS file |
| 29 | vw_abp_min | Addresses | 439 | projectedit only |
| 30 | bduk_uprn_tracking_v2 | BDUK UPRN Tracking | — | not yet in any JS file |
| 31 | bduk_go_list_fmp_work_20260217_geom | BDUK 02-2026 | 431 | |
| 32 | vw_cabinet_locations | CFL OLT Locations | — | not in JS — distinct from DB 22 despite same title |
| 33 | projects | Projects (All) | 19 (as "Project Boundaries (All)") | JS title differs from DB |
| 34 | bduk_fmp_work_may_2026_20260601_geom | BDUK 05-2026 | 431 | |

---

## Vector Layer Reconciliation

Only `layer_id 18` (layer_name `ProjectBoundary`) exists as a vector layer in the DB. All others need new records.

### Shared across multiple pages — 1 DB record each

| layer_name | Title | Pages | Editable on | DB layer_id |
|---|---|---|---|---|
| ProjectBoundary | Project Boundary | projectedit, stocklistedit, accountedit | projectedit, accountedit | 18 (exists) |
| StocklistPremises | Stocklist Premises | stocklistedit, accountedit | neither | **NEW** |

### projectedit-only vector layers — all need new DB records

| layer_name | Title | Type | Editable | Allow Create | Snap |
|---|---|---|---|---|---|
| projectNeighbours | Project Neighbours | vectorPoly | false | false | false |
| PlanNetwork | Plan Network | vectorLine | false | false | false |
| PlanEquipment | Plan Equipment | vectorPoint | true | true | true |
| PlanStructures | Plan Structures | vectorPoint | true | true | true |
| PlanCables | Plan Cables | vectorLine | true | true | true |
| PlanDuct | Plan Duct | vectorLine | true | true | true |
| PlanSubDuct | Plan SubDuct | vectorLine | true | true | true |
| projectPIABlockages | PIA Blockages (editable) | vectorPoint | true | true | false |

### opportunityedit-only vector layers — all need new DB records

| layer_name | Title | Type | Editable | Allow Create |
|---|---|---|---|---|
| opportunityProjects | Opportunity Projects | vectorPoly | false | false |
| opportunityRoutes | Opportunity Routes | vectorLine | false | false |
| vw_opportunity_network_points | Opportunity Equipment | vectorPoint | false | false |

### wayleaveedit — 5 layers TBD

layer_name values, geometry types, and editability to be confirmed before creating DB records.

---

## DB Records Needing Title/Status Corrections

| DB layer_id | Current title | Correction | Reason |
|---|---|---|---|
| 32 | CFL OLT Locations | CFL OLT Locations (Cabinet) | Distinguish from DB 22 which shares the same title |

---

## Layers in DB Not in Any JS File

Available to add to pages via the admin UI post-migration — no action needed now.

| DB layer_id | layer_name | Title |
|---|---|---|
| 28 | openreach_exchange_footprints | Openreach Exchange Footprints |
| 30 | bduk_uprn_tracking_v2 | BDUK UPRN Tracking |
| 32 | vw_cabinet_locations | CFL OLT Locations (Cabinet) |

---

## Summary: New DB Records Required

**12 confirmed new records** (+ 5 wayleave TBD):

| # | layer_name | Title | Category | Type |
|---|---|---|---|---|
| 1 | StocklistPremises | Stocklist Premises | project | vectorPoint |
| 2 | projectNeighbours | Project Neighbours | project | vectorPoly |
| 3 | PlanNetwork | Plan Network | project | vectorLine |
| 4 | PlanEquipment | Plan Equipment | project | vectorPoint |
| 5 | PlanStructures | Plan Structures | project | vectorPoint |
| 6 | PlanCables | Plan Cables | project | vectorLine |
| 7 | PlanDuct | Plan Duct | project | vectorLine |
| 8 | PlanSubDuct | Plan SubDuct | project | vectorLine |
| 9 | projectPIABlockages | PIA Blockages (editable) | project | vectorPoint |
| 10 | opportunityProjects | Opportunity Projects | project | vectorPoly |
| 11 | opportunityRoutes | Opportunity Routes | project | vectorLine |
| 12 | vw_opportunity_network_points | Opportunity Equipment | project | vectorPoint |
| 13–17 | TBD | Wayleave layers (×5) | project | TBD |

These go into `db/000_map_layers_corrections.sql` along with the two title corrections above.
