fix(geo): parcels (thematic_id=1) come from rosreestr2coord in WGS84 — drop ST_Transform
This commit is contained in:
parent
81cd7499f6
commit
d08d06d8a8
1 changed files with 8 additions and 2 deletions
|
|
@ -208,7 +208,13 @@ def _save_building(db: Session, payload: dict, cad_num: str) -> int:
|
|||
|
||||
|
||||
def _save_parcel(db: Session, payload: dict, cad_num: str) -> int:
|
||||
"""Парсит NSPD-response для земельного участка и UPSERT'ит в cad_parcels_geom."""
|
||||
"""Парсит NSPD-response для земельного участка и UPSERT'ит в cad_parcels_geom.
|
||||
|
||||
NB: rosreestr2coord для area_type=1 (parcel) отдаёт GeoJSON уже в WGS84
|
||||
(EPSG:4326, degrees). Просто ST_SetSRID — без ST_Transform, иначе геометрия
|
||||
сжимается до точки в районе (0,0) на острове Null. Quarters/buildings —
|
||||
другой path, у них Mercator (3857) и нужен ST_Transform.
|
||||
"""
|
||||
feats = (payload.get("data") or {}).get("features") or []
|
||||
if not feats:
|
||||
return 0
|
||||
|
|
@ -220,7 +226,7 @@ def _save_parcel(db: Session, payload: dict, cad_num: str) -> int:
|
|||
text(
|
||||
"""
|
||||
INSERT INTO cad_parcels_geom (cad_num, geom, raw_props, fetched_at)
|
||||
VALUES (:cad, ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(:g), 3857), 4326),
|
||||
VALUES (:cad, ST_SetSRID(ST_GeomFromGeoJSON(:g), 4326),
|
||||
CAST(:props AS jsonb), NOW())
|
||||
ON CONFLICT (cad_num) DO UPDATE
|
||||
SET geom = EXCLUDED.geom,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue