module H3.Hierarchy
( cellToParent
, cellToCenterChild
, cellToChildPos
, childPosToCell
, cellToChildren
, compactCells
, uncompactCells
) where
import Data.Int (Int64)
import H3.Internal.H3Api
( H3ErrorCodes
, H3Index
, c2hs_cellToParent
, c2hs_cellToCenterChild
, c2hs_cellToChildPos
, c2hs_childPosToCell
)
import H3.Internal.FFI
( hsCellToChildren
, hsCompactCells
, hsUncompactCells
)
import H3.Internal.Utils (toEither)
cellToParent :: H3Index
-> Int
-> Either H3ErrorCodes H3Index
cellToParent :: H3Index -> Int -> Either H3ErrorCodes H3Index
cellToParent H3Index
cell = (H3Error, H3Index) -> Either H3ErrorCodes H3Index
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, H3Index) -> Either H3ErrorCodes H3Index)
-> (Int -> (H3Error, H3Index))
-> Int
-> Either H3ErrorCodes H3Index
forall b c a. (b -> c) -> (a -> b) -> a -> c
. H3Index -> Int -> (H3Error, H3Index)
c2hs_cellToParent H3Index
cell
cellToCenterChild :: H3Index
-> Int
-> Either H3ErrorCodes H3Index
cellToCenterChild :: H3Index -> Int -> Either H3ErrorCodes H3Index
cellToCenterChild H3Index
cell = (H3Error, H3Index) -> Either H3ErrorCodes H3Index
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, H3Index) -> Either H3ErrorCodes H3Index)
-> (Int -> (H3Error, H3Index))
-> Int
-> Either H3ErrorCodes H3Index
forall b c a. (b -> c) -> (a -> b) -> a -> c
. H3Index -> Int -> (H3Error, H3Index)
c2hs_cellToCenterChild H3Index
cell
cellToChildPos :: H3Index
-> Int
-> Either H3ErrorCodes Int64
cellToChildPos :: H3Index -> Int -> Either H3ErrorCodes Int64
cellToChildPos H3Index
child = (H3Error, Int64) -> Either H3ErrorCodes Int64
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, Int64) -> Either H3ErrorCodes Int64)
-> (Int -> (H3Error, Int64)) -> Int -> Either H3ErrorCodes Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. H3Index -> Int -> (H3Error, Int64)
c2hs_cellToChildPos H3Index
child
childPosToCell :: Int64
-> H3Index
-> Int
-> Either H3ErrorCodes H3Index
childPosToCell :: Int64 -> H3Index -> Int -> Either H3ErrorCodes H3Index
childPosToCell Int64
childPos H3Index
parent = (H3Error, H3Index) -> Either H3ErrorCodes H3Index
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, H3Index) -> Either H3ErrorCodes H3Index)
-> (Int -> (H3Error, H3Index))
-> Int
-> Either H3ErrorCodes H3Index
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> H3Index -> Int -> (H3Error, H3Index)
c2hs_childPosToCell Int64
childPos H3Index
parent
cellToChildren :: H3Index
-> Int
-> Either H3ErrorCodes [H3Index]
cellToChildren :: H3Index -> Int -> Either H3ErrorCodes [H3Index]
cellToChildren H3Index
cell = (H3Error, [H3Index]) -> Either H3ErrorCodes [H3Index]
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, [H3Index]) -> Either H3ErrorCodes [H3Index])
-> (Int -> (H3Error, [H3Index]))
-> Int
-> Either H3ErrorCodes [H3Index]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. H3Index -> Int -> (H3Error, [H3Index])
hsCellToChildren H3Index
cell
compactCells :: [H3Index]
-> Either H3ErrorCodes [H3Index]
compactCells :: [H3Index] -> Either H3ErrorCodes [H3Index]
compactCells = (H3Error, [H3Index]) -> Either H3ErrorCodes [H3Index]
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, [H3Index]) -> Either H3ErrorCodes [H3Index])
-> ([H3Index] -> (H3Error, [H3Index]))
-> [H3Index]
-> Either H3ErrorCodes [H3Index]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [H3Index] -> (H3Error, [H3Index])
hsCompactCells
uncompactCells :: [H3Index]
-> Int
-> Either H3ErrorCodes [H3Index]
uncompactCells :: [H3Index] -> Int -> Either H3ErrorCodes [H3Index]
uncompactCells [H3Index]
compactedSet = (H3Error, [H3Index]) -> Either H3ErrorCodes [H3Index]
forall a. (H3Error, a) -> Either H3ErrorCodes a
toEither ((H3Error, [H3Index]) -> Either H3ErrorCodes [H3Index])
-> (Int -> (H3Error, [H3Index]))
-> Int
-> Either H3ErrorCodes [H3Index]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [H3Index] -> Int -> (H3Error, [H3Index])
hsUncompactCells [H3Index]
compactedSet