Skip to content

Commit

Permalink
upgraded shapely to version 2 and increment version to 1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lausdahl committed Dec 18, 2023
1 parent 477a27d commit c41d4e0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# For a discussion on single-sourcing the version across setup.py and the
# project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='1.4.1', # Required
version='1.4.2', # Required

# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
Expand Down Expand Up @@ -142,7 +142,7 @@
#
# For an analysis of "install_requires" vs pip's requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['matplotlib', 'pymap3d>=3.0.1, <4', "shapely>=1.8.5, <3", 'folium'], # Optional
install_requires=['matplotlib', 'pymap3d>=3.0.1, <4', "shapely>=2, <3", 'folium'], # Optional

# List additional groups of dependencies here (e.g. development
# dependencies). Users will be able to install these using the "extras"
Expand Down
6 changes: 4 additions & 2 deletions src/isoxmlviz/LineStringUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def is_point_on_line(a, b, point):
extract line segments from a line and a list of polygon restricting the line to within the polygon. May result in many line segments
'''

def get_coordinates(lines: list[LineString]):
return [l.coords for l in lines]

def extract_lines_within(base_line: LineString, polygons: list[Polygon]):
lines = [base_line]
if len(polygons) == 0:
return lines
return lines

for p in polygons:
lines = [extract_line_within(line, p) for line in lines]
Expand All @@ -62,7 +64,7 @@ def extract_line_within(base_line: LineString, polygon: Polygon):
if type(inter2) is Point:
interpolated_points.append(inter2)
elif type(inter2) is MultiPoint:
for p in inter2:
for p in inter2.geoms:
interpolated_points.append(p)

for a, b in pairwise(base_line.coords):
Expand Down
8 changes: 4 additions & 4 deletions src/isoxmlviz/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from matplotlib.collections import PatchCollection, LineCollection
from shapely.geometry import LineString, JOIN_STYLE, MultiLineString, MultiPoint
import math
from isoxmlviz.LineStringUtil import extract_lines_within
from isoxmlviz.LineStringUtil import extract_lines_within, get_coordinates
from isoxmlviz.webmap import WebMap


Expand Down Expand Up @@ -449,7 +449,7 @@ def filter_pivot_line_ab(line):

base_line_string = LineString(filter_pivot_line_ab(poly.exterior))

patch = LineCollection([base_line_string], linewidths=1.5,
patch = LineCollection([base_line_string.coords], linewidths=1.5,
edgecolors="black", zorder=7)
ax.add_collection(patch)

Expand All @@ -475,7 +475,7 @@ def filter_pivot_line_ab(line):
# if pivot_cutout:
# guidance_lines = [extract_lines_within(line,[ pivot_cutout],invert=True) for line in lines]

patchc = LineCollection([item for sublist in guidance_lines for item in sublist],
patchc = LineCollection(get_coordinates([item for sublist in guidance_lines for item in sublist]),
linewidths=1,
edgecolors="purple", zorder=5, alpha=0.5)

Expand Down Expand Up @@ -619,7 +619,7 @@ def getExtrapoledLine(p1, p2, ext_length, from_start=False):

# plot the baseline
# https://stackoverflow.com/questions/19877666/add-legends-to-linecollection-plot
patch = LineCollection(extract_lines_within(base_line_string, boundary_polygons), linewidths=1.5,
patch = LineCollection(get_coordinates( extract_lines_within(base_line_string, boundary_polygons)), linewidths=1.5,
edgecolors="goldenrod", zorder=7)
ax.add_collection(patch)

Expand Down
2 changes: 1 addition & 1 deletion test/test_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_visualize(filename):
tree = ET.parse(filename)
show_task_file(None, str(Path(filename).name),
tree,
hide=True, save_pdf=True, save_svg=True, use_subplot=False,
hide=False, save_pdf=True, save_svg=True, use_subplot=False,
web_map=web_map,
output_base_name=str(output_dir), groups=web_groups)
web_map.save(str(output_dir / "map.html"))

0 comments on commit c41d4e0

Please sign in to comment.