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)