Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Shapely 2.0+ #22

Merged
merged 32 commits into from
Feb 6, 2025
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fd1d56c
Add instructions for testing
joseph-sch Jan 21, 2025
676d999
Fix the check on shapely/GEOS
joseph-sch Jan 21, 2025
3a5c7f9
WIP on base.py - compose instead of inheriting
joseph-sch Jan 21, 2025
1a4a666
12 tests of base and 4 of utils pass
joseph-sch Jan 21, 2025
f478801
Whitespace
joseph-sch Jan 21, 2025
8ca29b6
Fix in plot
joseph-sch Jan 21, 2025
1ddd543
6 utils test pass, with 1 warning
joseph-sch Jan 21, 2025
92bee9d
More adaptations -> 86 passed, 16 failed
joseph-sch Jan 22, 2025
f1386cf
Implemen cache of _geometry for ShadeCollection and PVSegment
joseph-sch Jan 22, 2025
c511b4d
Property coords and iterate over difference geometries 90 vs. 12
joseph-sch Jan 22, 2025
d90f5a7
Add method intersects to BaseSide
joseph-sch Jan 22, 2025
7525d92
Migrate PVRow
joseph-sch Jan 22, 2025
a4746fb
Add centroid property to BaseSurface
joseph-sch Jan 22, 2025
7f9cbe3
Fix plots
joseph-sch Jan 22, 2025
2fabbe4
All tests pass
joseph-sch Jan 22, 2025
7d38df6
Update requirements
joseph-sch Jan 22, 2025
36e39f8
Removed a line
joseph-sch Jan 22, 2025
594b122
Bring README to relevance (links, etc.)
joseph-sch Jan 22, 2025
416af05
Merge branch 'update_readme' into migrate_to_shapely_2.0
joseph-sch Jan 23, 2025
783c451
Use dwithin rather than distance
joseph-sch Jan 23, 2025
ff383e3
Fix all but 3 divide-by-zero RuntimeWarning
joseph-sch Jan 23, 2025
c774861
Fix an error message and README
joseph-sch Jan 27, 2025
0fb57bb
Fix for failing Read the Docs build
joseph-sch Jan 27, 2025
f684812
Fix to fix?
joseph-sch Jan 27, 2025
7317e7c
Restore missing path
joseph-sch Jan 27, 2025
d5f8980
Remove ~=4.0 in sphinx requirement
joseph-sch Jan 27, 2025
90b3128
Fix sphinx exception
joseph-sch Jan 27, 2025
9cedd87
Fix README.rst (solarfactors instead of openfactors)
joseph-sch Jan 30, 2025
4a9011a
Fix README.rst (solarfactors instead of openfactors)
joseph-sch Jan 30, 2025
5789f49
Merge remote-tracking branch 'origin/main' into migrate_to_shapely_2.0
joseph-sch Jan 30, 2025
218085a
Update README.rst
joseph-sch Feb 4, 2025
ca58944
Update README.rst
joseph-sch Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate PVRow
* Remove inheritance from GeometryCollection
* Add length property and intersects function
joseph-sch committed Jan 22, 2025
commit 7525d929fce6d2b437a1b49e84ec42a081bfe7ee
39 changes: 28 additions & 11 deletions pvfactors/geometry/pvrow.py
Original file line number Diff line number Diff line change
@@ -654,9 +654,10 @@ def n_ts_surfaces(self):

class PVRowSide(BaseSide):
"""A PV row side represents the whole surface of one side of a PV row.

At its core it will contain a fixed number of
:py:class:`~pvfactors.geometry.base.PVSegment` objects that will together
constitue one side of a PV row: a PV row side can also be
constitute one side of a PV row: a PV row side can also be
"discretized" into multiple segments"""

def __init__(self, list_segments=[]):
@@ -671,7 +672,7 @@ def __init__(self, list_segments=[]):
super(PVRowSide, self).__init__(list_segments)


class PVRow(GeometryCollection):
class PVRow:
"""A PV row is made of two PV row sides, a front and a back one."""

def __init__(self, front_side=PVRowSide(), back_side=PVRowSide(),
@@ -689,14 +690,34 @@ def __init__(self, front_side=PVRowSide(), back_side=PVRowSide(),
original_linestring : :py:class:`shapely.geometry.LineString`, optional
Full continuous linestring that the PV row will be made of
(Default = None)

"""
self.front = front_side
self.back = back_side
self.index = index
self.original_linestring = original_linestring
self._all_surfaces = None
super(PVRow, self).__init__([self.front, self.back])

@property
def length(self):
"""Length of the PV row."""
return self.front.length + self.back.length

def intersects(self, line):
"""Check if the PV row intersects with a line.

Parameters
----------
line : :py:class:`shapely.geometry.LineString`
Line to check for intersection

Returns
-------
bool
True if the PV row intersects with the line, False otherwise
"""
if self.original_linestring is not None:
return self.original_linestring.intersects(line)
else:
return self.front.intersects(line) or self.back.intersects(line)

@classmethod
def from_linestring_coords(cls, coords, shaded=False, normal_vector=None,
@@ -812,7 +833,7 @@ def plot(self, ax, color_shaded=COLOR_DIC['pvrow_shaded'],

@property
def boundary(self):
"""Boundaries of the PV Row's orginal linestring."""
"""Boundaries of the PV Row's original linestring."""
return self.original_linestring.boundary

@property
@@ -832,11 +853,7 @@ def lowest_point(self):
@property
def all_surfaces(self):
"""List of all the surfaces in the PV row."""
if self._all_surfaces is None:
self._all_surfaces = []
self._all_surfaces += self.front.all_surfaces
self._all_surfaces += self.back.all_surfaces
return self._all_surfaces
return self.front.all_surfaces + self.back.all_surfaces

@property
def surface_indices(self):