| Copyright | (C) Richard Cook, 2016 |
|---|---|
| License | MIT |
| Maintainer | rcook@rcook.org |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Geolocation.GEOS
Description
A high-level API for interoperating with GEOS C API which includes automatic management of lifetimes of objects such as readers, writers and geometries.
For the low-level FFI bindings, see Data.Geolocation.GEOS.Imports.
Documentation
intersection :: Geometry -> Geometry -> IO Geometry Source
Returns the Geometry instance representing the intersection of the two
supplied Geometry instances:
withContext $ ctx -> do
reader <- mkReader ctx
g0 <- readGeometry reader "POLYGON (( 10 10, 10 20, 20 20, 20 10, 10 10 ))"
g1 <- readGeometry reader "POLYGON (( 11 11, 11 12, 12 12, 12 11, 11 11 ))"
g2 <- intersection g0 g1
-- Use geometry
putStrLn str
The geometry is associated with the Context and released when the Context
is released.
readGeometry :: Reader -> String -> IO Geometry Source
Deserializes a Geometry instance from the given String using the
supplied Reader:
withContext $ ctx -> do
reader <- mkReader ctx
geometry <- readGeometry read "POLYGON (( 10 10, 10 20, 20 20, 20 10, 10 10 ))"
-- Use geometry
return ()
The geometry is associated with the Context and released when the Context
is released.
withContext :: (Context -> IO a) -> IO a Source
Creates a GEOS context, passes it to a block and releases the context and all associated objects such as readers, writers and geometries at the end:
withContext $ ctx -> do
-- Use context
return ()
writeGeometry :: Writer -> Geometry -> IO String Source
Serializes a Geometry instance to a String using the supplied Writer:
withContext $ ctx -> do
reader <- mkReader ctx
geometry <- readGeometry read "POLYGON (( 10 10, 10 20, 20 20, 20 10, 10 10 ))"
writer <- mkWriter ctx
str <- writeGeometry writer geometry
-- Use string
return ()
The geometry is associated with the Context and released when the Context
is released.