Skip to content

Commit

Permalink
Merge pull request #7 from fuzailpalnak/refactor
Browse files Browse the repository at this point in the history
save when specified, property to get merged geom values
  • Loading branch information
fuzailpalnak authored Oct 7, 2022
2 parents f497c94 + 4c82669 commit f0ab3dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.1, 25/10/2020
v1.0.3, 07/10/2022
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 17 additions & 13 deletions shape_merge/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

0 comments on commit f0ab3dd

Please sign in to comment.