Skip to content

Commit bd2034f

Browse files
authored
Update bounds.py align_to_cell_lines() to match FUSION alignment
Modified code to align cell centers with multiple of resolution. It might be better to add an option to the database for pixel-is-point or pixel-is-cell and rename the new version of align_to_cell_lines() to align_to_cell_centers(). There are just a few places where the function is called that would need to add code to use the db option.
1 parent 1eb8de6 commit bd2034f

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/silvimetric/resources/bounds.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,30 @@ def adjust_to_cell_lines(self, resolution):
134134
ymaxdif = self.maxy % resolution
135135
ymindif = self.miny % resolution
136136

137-
if xmindif:
138-
self.minx = self.minx - xmindif
139-
if xmaxdif:
140-
self.maxx = self.maxx + (resolution - xmaxdif)
141-
if ymindif:
142-
self.miny = self.miny - ymindif
143-
if ymaxdif:
144-
self.maxy = self.maxy + (resolution - ymaxdif)
137+
if xmindif > resolution / 2.0:
138+
self.minx -= (xmindif - resolution / 2.0)
139+
elif xmindif < resolution / 2.0:
140+
self.minx -= (xmindif + resolution / 2.0)
141+
else:
142+
pass
143+
if ymindif > resolution / 2.0:
144+
self.miny -= (ymindif - resolution / 2.0)
145+
elif ymindif < resolution / 2.0:
146+
self.miny -= (ymindif + resolution / 2.0)
147+
else:
148+
pass
149+
if xmaxdif > resolution / 2.0:
150+
self.maxx += resolution / 2.0 + (resolution - xmaxdif)
151+
elif xmaxdif < resolution / 2.0:
152+
self.maxx += resolution / 2.0 - xmaxdif
153+
else:
154+
pass
155+
if ymaxdif > resolution / 2.0:
156+
self.maxy += resolution / 2.0 + (resolution - ymaxdif)
157+
elif ymaxdif < resolution / 2.0:
158+
self.maxy += resolution / 2.0 - ymaxdif
159+
else:
160+
pass
145161

146162
@staticmethod
147163
def shared_bounds(first, second):

0 commit comments

Comments
 (0)