Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfriend committed Aug 4, 2022
1 parent c8a0683 commit 80c3f4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 4 additions & 8 deletions src/h3/_cy/cells.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ cpdef int distance(H3int h1, H3int h2) except -1:

check_for_error(
h3lib.gridDistance(h1, h2, &distance)
) # todo: should this raise a distance error?

# s = 'Cells are too far apart to compute distance: {} and {}'
)

return distance

Expand Down Expand Up @@ -260,8 +258,6 @@ cpdef H3int[:] uncompact(const H3int[:] hc, int res):
)
)

# todo: again! doesn't work if i have this before the error check!
# why isn't hmm.to_mv() robust to failures before it?
mv = hmm.to_mv()

return mv
Expand Down Expand Up @@ -318,7 +314,7 @@ cpdef double cell_area(H3int h, unit='km^2') except -1:
return area


cdef could_not_find_line(err, start, end):
cdef _could_not_find_line(err, start, end):
msg = "Couldn't find line between cells {} and {}"
msg = msg.format(hex(start), hex(end))

Expand All @@ -333,12 +329,12 @@ cpdef H3int[:] line(H3int start, H3int end):
# probably applies to all size/work pairs of functions...
err = h3lib.gridPathCellsSize(start, end, &n)

could_not_find_line(err, start, end)
_could_not_find_line(err, start, end)

hmm = H3MemoryManager(n)
err = h3lib.gridPathCells(start, end, hmm.ptr)

could_not_find_line(err, start, end)
_could_not_find_line(err, start, end)

# todo: probably here too?
mv = hmm.to_mv()
Expand Down
8 changes: 5 additions & 3 deletions src/h3/_cy/edges.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ cpdef double edge_length(H3int e, unit='km') except -1:
double length

if unit == 'rads':
check_for_error(h3lib.exactEdgeLengthRads(e, &length))
err = h3lib.exactEdgeLengthRads(e, &length)
elif unit == 'km':
check_for_error(h3lib.exactEdgeLengthKm(e, &length))
err = h3lib.exactEdgeLengthKm(e, &length)
elif unit == 'm':
check_for_error(h3lib.exactEdgeLengthM(e, &length))
err = h3lib.exactEdgeLengthM(e, &length)
else:
raise ValueError('Unknown unit: {}'.format(unit))

check_for_error(err)

return length

0 comments on commit 80c3f4d

Please sign in to comment.