fix(site-finder): robust is_residential_zone detection for NSPD zone codes (#1353) #1681

Merged
lekss361 merged 1 commit from fix/residential-zone-detect-1353 into main 2026-06-17 17:55:03 +00:00
Owner

Проблема (#1353)

gate_verdict.py is_residential_zone: prefix-проверка Ж-/Ж1… на zone_code и «жил» в zone_name — но из NSPD (layer 875838) оба поля всегда None (reg_numb_border лежит в options, top-level zone_code/zone_name нет). → каждый NSPD-участок получал PZZ_NOT_RESIDENTIAL.

Решение (3-уровневый детект)

  1. regex ^[Жж] на zone_code (PKK6/pzz_zones_ekb данные)
  2. raw_props["subcategory"] in {2,3} — основной дискриминатор NSPD (2=жилые 221 об., 3=смешанное 126; subcat=1 ИЖС исключён)
  3. «жил» в zone_name — fallback

compute_gate_verdict теперь прокидывает nspd_zoning["raw_props"].

Verify

ruff clean; pytest (gate/zone/verdict) → 170 passed, 3 skipped.

Closes #1353

## Проблема (#1353) `gate_verdict.py` `is_residential_zone`: prefix-проверка `Ж-`/`Ж1…` на `zone_code` и «жил» в `zone_name` — но из NSPD (layer 875838) оба поля **всегда None** (`reg_numb_border` лежит в `options`, top-level `zone_code`/`zone_name` нет). → каждый NSPD-участок получал `PZZ_NOT_RESIDENTIAL`. ## Решение (3-уровневый детект) 1. regex `^[Жж]` на `zone_code` (PKK6/pzz_zones_ekb данные) 2. `raw_props["subcategory"] in {2,3}` — основной дискриминатор NSPD (2=жилые 221 об., 3=смешанное 126; subcat=1 ИЖС исключён) 3. «жил» в `zone_name` — fallback `compute_gate_verdict` теперь прокидывает `nspd_zoning["raw_props"]`. ## Verify `ruff` clean; `pytest` (gate/zone/verdict) → **170 passed, 3 skipped**. Closes #1353
lekss361 added 1 commit 2026-06-17 17:45:28 +00:00
fix(site-finder): robust is_residential_zone detection for NSPD zone codes (#1353)
Some checks failed
CI / changes (push) Successful in 11s
CI / changes (pull_request) Successful in 6s
CI / backend-tests (push) Has been skipped
CI / frontend-tests (push) Has been skipped
CI / openapi-codegen-check (push) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 1m47s
CI / backend-tests (pull_request) Failing after 9m15s
3fd06228ff
NSPD quarter-dump territorial_zones (layer 875838) does NOT store ПЗЗ letter
codes in properties — zone_code receives the cadastral reg number ("66:41-7.14")
or None, never a "Ж-1" style code. The old prefix check (startswith "Ж-"/"Ж1" …)
therefore never matched real NSPD data, silently marking every dump-sourced parcel
as non-residential (PZZ_NOT_RESIDENTIAL blocker).

Fix: three-tier detection in is_residential_zone:
1. Regex ^Ж on zone_code — handles PKK6/pzz_zones_ekb sources ("Ж-1", "Жс")
2. NSPD subcategory from raw_props — subcategory=2 (Жилые зоны, 221 ЕКБ objects)
   and subcategory=3 (Смешанное использование, 126 objects) → residential;
   subcategory=1 (ИЖС) excluded — МКД not permitted there
3. zone_name substring "жил" — fallback for non-standard sources

compute_gate_verdict now passes nspd_zoning["raw_props"] to is_residential_zone.
lekss361 merged commit e075f01870 into main 2026-06-17 17:55:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1681
No description provided.