From 94ee1e454571e5858ccc36fca711d4ce72462e8b Mon Sep 17 00:00:00 2001 From: Baho73 <7726417@gmail.com> Date: Wed, 18 Feb 2026 13:28:29 +0300 Subject: [PATCH] fix: update batch/export to use current Area API - batch.py: replace removed `area.get_coord()` with `area.feature` check - export.py: replace `to_geojson_poly(with_attrs, dumps=False)` with `to_geojson(dumps=False)` (old signature caused TypeError) - export.py: update `_write_csv_row` to extract coords/attrs from `area.feature` instead of removed `get_coord()`/`attrs` - console.py: replace `to_geojson_poly()` with `to_geojson()` These methods were removed in v5.0.0 but callers were not updated. Fixes #100 Co-Authored-By: Claude Opus 4.6 --- rosreestr2coord/batch.py | 2 +- rosreestr2coord/console.py | 2 +- rosreestr2coord/export.py | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/rosreestr2coord/batch.py b/rosreestr2coord/batch.py index 9296f61..30e8b30 100644 --- a/rosreestr2coord/batch.py +++ b/rosreestr2coord/batch.py @@ -27,7 +27,7 @@ def batch_parser( sleep(need_sleep) area = Area(code, with_log=with_log, **kwargs) need_sleep = delay - if len(area.get_coord()): + if area.feature: print(" - ok", end="") success += 1 else: diff --git a/rosreestr2coord/console.py b/rosreestr2coord/console.py index e71b210..929fbf0 100644 --- a/rosreestr2coord/console.py +++ b/rosreestr2coord/console.py @@ -57,7 +57,7 @@ def get_by_code(code, output, display, **kwargs): def process_area(area, output_path, display): - geojson = area.to_geojson_poly() + geojson = area.to_geojson() file_name = code_to_filename(area.file_name) diff --git a/rosreestr2coord/export.py b/rosreestr2coord/export.py index 9c7d5ae..70ecea3 100644 --- a/rosreestr2coord/export.py +++ b/rosreestr2coord/export.py @@ -18,12 +18,11 @@ def make_output(output, file_name, file_format, out_path=""): def _write_csv_row(f, area, header=False): try: - xy = copy.deepcopy(list(area.get_coord())) - for geom in xy: - for poly in geom: - for c in range(len(poly)): - poly[c] = poly[c][::-1] - attrs = getattr(area, "attrs", {}) + if not area.feature: + return + geometry = area.feature.get("geometry", {}) + xy = copy.deepcopy(geometry.get("coordinates", [])) + attrs = area.feature.get("properties", {}) address = attrs.get("address", "") cols = [ {"name": "code", "value": getattr(area, "code")}, @@ -64,7 +63,7 @@ def batch_json_output(output, areas, file_name, with_attrs=True, crs_name="EPSG: } path = make_output(output, file_name, "geojson") for a in areas: - feature = a.to_geojson_poly(with_attrs, dumps=False) + feature = a.to_geojson(dumps=False) if feature: features.append(feature) @@ -74,8 +73,8 @@ def batch_json_output(output, areas, file_name, with_attrs=True, crs_name="EPSG: return path -def area_json_output(output, area, with_attrs=True): - geojson = area.to_geojson_poly(with_attrs) +def area_json_output(output, area): + geojson = area.to_geojson() if geojson: f = open(make_output(output, area.file_name, "geojson"), "w") f.write(geojson)