packages feed

hgeos 0.1.7.1 → 0.1.7.2

raw patch · 5 files changed

+42/−12 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

hgeos.cabal view
@@ -1,5 +1,5 @@ name:                 hgeos-version:              0.1.7.1+version:              0.1.7.2 synopsis:             Simple Haskell bindings to GEOS C API description:   Simple Haskell bindings to the <https://trac.osgeo.org/geos/ GEOS>
src/lib/Data/Geolocation/GEOS.hs view
@@ -7,8 +7,9 @@ Stability   : experimental Portability : portable -A high-level API for interoperating with GEOS C API which includes automatic-management of lifetimes of objects such as readers, writers and geometries.+A high-level API for interoperating with Geometry Engine Open Source 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". @@ -160,14 +161,14 @@ -- sequence createLinearRing :: CoordinateSequence -> IO (Maybe Geometry) createLinearRing (CoordinateSequence sr deleteAction h) = do-    untrack sr deleteAction+    untrack sr [deleteAction]     checkAndTrackGeometry sr (\hCtx -> c_GEOSGeom_createLinearRing_r hCtx h)  -- |Returns a polygon 'Geometry' instance from the given shell and optional -- array of holes createPolygon :: Geometry -> [Geometry] -> IO (Maybe Geometry) createPolygon (Geometry sr deleteAction h) holes = do-    untrack sr deleteAction+    untrack sr (deleteAction : map (\(Geometry _ x _) -> x) holes)     withArrayLen (map (\(Geometry _ _ h') -> h') holes) $ \count array ->         checkAndTrackGeometry             sr@@ -339,9 +340,10 @@ setZ :: CoordinateSequence -> Word -> Double -> IO (Maybe ()) setZ = setOrdinateHelper c_GEOSCoordSeq_setZ_r -untrack :: ContextStateRef -> DeleteAction -> IO ()-untrack sr (DeleteAction rawPtr _) =-    modifyIORef' sr $ \p@ContextState{..} -> p { deleteActions = filter (\(DeleteAction r _) -> r /= rawPtr) deleteActions }+untrack :: ContextStateRef -> [DeleteAction] -> IO ()+untrack sr deleteActions = do+    let rawPtrs = map (\(DeleteAction rawPtr _) -> rawPtr) deleteActions+    modifyIORef' sr $ \p@ContextState{..} -> p { deleteActions = filter (\(DeleteAction rawPtr _) -> not (rawPtr `elem` rawPtrs)) deleteActions }  -- |Reports version of GEOS API version :: IO String
src/lib/Data/Geolocation/GEOS/Imports.hs view
@@ -7,10 +7,10 @@ Stability   : experimental Portability : portable -These are low-level FFI bindings for the GEOS C API derived from-<http://geos.osgeo.org/doxygen/geos__c_8h_source.html geos_c.h>. These enable-low-level access to the native functions for parts of the C API for which-high-level wrappers do not yet exist.+These are low-level FFI bindings for the Geometry Engine Open Source C API+derived from <http://geos.osgeo.org/doxygen/geos__c_8h_source.html geos_c.h>.+These enable low-level access to the native functions for parts of the C API+for which high-level wrappers do not yet exist.  For the high-level API, see "Data.Geolocation.GEOS". 
src/lib/Data/Geolocation/GEOS/helpers.c view
@@ -1,3 +1,13 @@+/*+Module      : helpers.c+Description : C helper functions for hgeos+Copyright   : (C) Richard Cook, 2016+Licence     : MIT+Maintainer  : rcook@rcook.org+Stability   : experimental+Portability : portable+*/+ #include <geos_c.h> #include <stdarg.h> #include <stdio.h>
src/test/GEOSTest/TransAPI.hs view
@@ -3,6 +3,7 @@ import Control.Monad import Control.Monad.Trans import Control.Monad.Trans.Maybe+import Data.Geolocation.GEOS (Context, Geometry) import Data.Geolocation.GEOS.Trans import Data.Maybe @@ -10,6 +11,17 @@ check True = return () check False = error "Check failed" +type Coordinate = (Double, Double)++createLinearRing :: Context -> [Coordinate] -> MaybeT IO Geometry+createLinearRing ctx cs = do+    let count = length cs+    coords <- createCoordSeqM ctx (fromIntegral count) 2+    forM_ (zip [0..] cs) $ \(i, (x, y)) -> do+        setXM coords i x+        setYM coords i y+    createLinearRingM coords+ -- Demonstrates use of monad transformer API -- Lifetimes of GEOS objects are automatically managed by the context objects -- which guarantees that they are released when the context goes out of scope@@ -55,6 +67,12 @@         p <- createPolygonM g3 []         str2 <- writeGeometryM writer p         lift $ putStrLn str2++        shell <- createLinearRing ctx [(-10.0, -10.0), (-10.0, 10.0), (10.0, 10.0), (10.0, -10.0), (-10.0, -10.0)]+        hole <- createLinearRing ctx [(-5.0, -5.0), (-5.0, 5.0), (5.0, 5.0), (5.0, -5.0), (-5.0, -5.0)]+        polygon <- createPolygonM shell [hole]+        str3 <- writeGeometryM writer polygon+        lift $ putStrLn str3      case result of          Left m -> error $ "TransAPI.demo failed: " ++ m