From 4c826690ae618c9ff66e7b91f655da883d172ed8 Mon Sep 17 00:00:00 2001 From: fuzailpalnak Date: Fri, 7 Oct 2022 09:00:54 +0200 Subject: [PATCH] save when specified, property to get merged geom values --- CHANGES.txt | 2 +- setup.py | 2 +- shape_merge/merge.py | 30 +++++++++++++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ac48fc7..d69b3c8 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1 +1 @@ -v1.0.1, 25/10/2020 +v1.0.3, 07/10/2022 diff --git a/setup.py b/setup.py index 26b2139..cbc1d0f 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="shape_merge", - version="1.0.2", + version="1.0.3", author="Fuzail Palnak", author_email="fuzailpalnak@gmail.com", url="https://github.com/fuzailpalnak/ShapeMerge", diff --git a/shape_merge/merge.py b/shape_merge/merge.py index 87d1fc8..9d2fd91 100755 --- a/shape_merge/merge.py +++ b/shape_merge/merge.py @@ -46,6 +46,10 @@ def geometry_type(self): def geometry_type(self, value): self._geometry_type = value + @property + def merged_geom(self): + return self._combined_geometries + def populate_index_by_geojson(self, geo_json_path: str): obj = geojson.loads(open(geo_json_path).read()) if "features" not in obj: @@ -115,8 +119,6 @@ def populate_index_by_feature(self, feature: dict): tag_data=f"{feature_id}", tag_color="cyan", ) - if self._save is None: - self._save = SaveGeoJson() def _simplify_intersecting_ids(self, potential_neighbour_ids, merged_ids) -> list: """ @@ -190,7 +192,7 @@ def _is_neighbour(potential_neighbour_geometry, current_geometry) -> bool: :param current_geometry: ongoing geometry, for which neighbour are to be found :return: True if intersects else False """ - return potential_neighbour_geometry.intersects(current_geometry) + return potential_neighbour_geometry.touches(current_geometry) def _new_neighbours( self, @@ -307,13 +309,15 @@ def merge_geometries(self) -> OrderedDict: return self._combined_geometries def save_geometries(self): - if self._save is not None: - one_liner.one_line( - tag="Saving InProgress", - tag_data=f"{self._save.__class__.__name__}", - tag_color="cyan", - tag_data_color="red", - to_reset_data=True, - to_new_line_data=True, - ) - self._save.save(self._combined_geometries) + if self._save is None: + self._save = SaveGeoJson() + + one_liner.one_line( + tag="Saving InProgress", + tag_data=f"{self._save.__class__.__name__}", + tag_color="cyan", + tag_data_color="red", + to_reset_data=True, + to_new_line_data=True, + ) + self._save.save(self._combined_geometries)