Skip to content

Commit

Permalink
multiple intersections bug fixed
Browse files Browse the repository at this point in the history
More info about the bug in the corresponding issue in the repo.
  • Loading branch information
AlbertGallegoJimenez committed May 2, 2024
1 parent 815e056 commit 09ba207
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
Binary file modified src/tools/__pycache__/computeIntersections.cpython-39.pyc
Binary file not shown.
16 changes: 4 additions & 12 deletions src/tools/computeIntersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,31 +159,23 @@ def execute(self, parameters, messages):
create_new_fields(shoreOutFeature, fields_to_add, data_type)

"""
Get the keys of shorePoints (dictionary). The keys are tuples with the ids of the transects and shorelines.
Iterate over the shorePoints (dictionary). The keys are tuples with the ids of the transects and shorelines.
If the value is a list, add the key as many times as the length of the list (to match the number of geometries with the number of ids).
"""
shore_keys = []
for key, value in shorePoints.items():
if isinstance(value, list): # The intersection point is a list of points (MultiPoint)
for _ in range(len(value)):
shore_keys.append((key[0], key[1]))
else:
shore_keys.append((key[0], key[1]))

# Fill with the geometries (intersection points) and the transect_id and shore_id
with arcpy.da.InsertCursor(shoreOutFeature, [transectsID, shoreID, "SHAPE@"]) as cursor:
for i, point in enumerate(shorePoints.values()):
for t_id_shore_id, point in shorePoints.items():
if isinstance(point, list): # The intersection point is a list of points (MultiPoint)
for part in point:
# Create the arcgis point
arc_Point = [arcpy.Point(coord[0], coord[1]) for coord in part.coords][0]
# Insert the row with the transect_id and shore_id and the point
cursor.insertRow([shore_keys[i][0], shore_keys[i][1], arc_Point])
cursor.insertRow([t_id_shore_id[0], t_id_shore_id[1], arc_Point])
else:
# Create the arcgis point
arc_Point = [arcpy.Point(coord[0], coord[1]) for coord in point.coords][0]
# Insert the row with the transect_id and shore_id and the point
cursor.insertRow([shore_keys[i][0], shore_keys[i][1], arc_Point])
cursor.insertRow([t_id_shore_id[0], t_id_shore_id[1], arc_Point])

# Add the other fields of the Polyline Shorelines Feature Class
# Get the fields to join
Expand Down
Binary file modified src/tools/utils/__pycache__/intersect_lines.cpython-39.pyc
Binary file not shown.

0 comments on commit 09ba207

Please sign in to comment.