fix(site-finder): WKT LINESTRING needs commas + rosreestr_deals real column names
This commit is contained in:
parent
232c81eae9
commit
7900dc5238
2 changed files with 9 additions and 6 deletions
|
|
@ -413,13 +413,14 @@ def analyze_parcel(
|
|||
db.execute(
|
||||
text("""
|
||||
WITH district_deals AS (
|
||||
SELECT d.deal_date, d.price_per_m2
|
||||
SELECT d.period_start_date AS deal_date,
|
||||
d.price_per_sqm AS price_per_m2
|
||||
FROM rosreestr_deals d
|
||||
WHERE d.region_code = 66
|
||||
AND d.doc_type = 'ДДУ'
|
||||
AND d.realestate_type_code = '002001003000'
|
||||
AND d.price_per_m2 BETWEEN 30000 AND 500000
|
||||
AND d.deal_date > NOW() - INTERVAL '12 months'
|
||||
AND d.price_per_sqm BETWEEN 30000 AND 500000
|
||||
AND d.period_start_date > NOW() - INTERVAL '12 months'
|
||||
AND ST_DWithin(
|
||||
(SELECT ST_Centroid(geom)
|
||||
FROM cad_quarters_geom
|
||||
|
|
|
|||
|
|
@ -96,10 +96,12 @@ def _way_to_linestring_wkt(nodes: list[dict]) -> str | None:
|
|||
"""
|
||||
if len(nodes) < 2:
|
||||
return None
|
||||
parts = " ".join(f"{n['lon']} {n['lat']}" for n in nodes if "lon" in n and "lat" in n)
|
||||
if not parts or parts.count(" ") < 1:
|
||||
# WKT LINESTRING требует запятую между парами точек: "lon1 lat1, lon2 lat2".
|
||||
# Раньше joined через пробел → "lon1 lat1 lon2 lat2" → invalid geometry.
|
||||
points = [f"{n['lon']} {n['lat']}" for n in nodes if "lon" in n and "lat" in n]
|
||||
if len(points) < 2:
|
||||
return None
|
||||
return f"LINESTRING({parts})"
|
||||
return f"LINESTRING({', '.join(points)})"
|
||||
|
||||
|
||||
def sync_noise_sources_to_db() -> dict[str, int]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue