geos 0.1.0.0 → 0.1.0.1
raw patch · 5 files changed
+32/−38 lines, 5 files
Files
- cbits/noticehandlers.c +8/−13
- cbits/noticehandlers.h +0/−6
- geos.cabal +16/−8
- src/Data/Geometry/Geos/Raw/Serialize.hs +8/−10
- tests/SpecSampleData.hs +0/−1
cbits/noticehandlers.c view
@@ -4,25 +4,20 @@ #include <geos_c.h> void -geos_notice_handler(const char *fmt, ...)+geos_notice_handler(const char *msg, void *userdata) {- va_list ap;- va_start(ap, fmt);- vprintf(fmt, ap);- va_end(ap);-+#ifdef DEBUG+ puts(msg);+#else+#endif } GEOSContextHandle_t init_GEOS() {--#if GEOS_VERSION_MAJOR > 3 && GEOS_VERSION_MINOR > 4+ void *pVoid; GEOSContextHandle_t handle = GEOS_init_r();- GEOSContext_setNoticeHandler_r(handle, geos_notice_handler);- GEOSContext_setErrorHandler_r(handle, geos_notice_handler);+ GEOSContext_setNoticeMessageHandler_r(handle, geos_notice_handler, pVoid);+ GEOSContext_setErrorMessageHandler_r(handle, geos_notice_handler, pVoid); return handle;-#else- return initGEOS_r(geos_notice_handler, geos_notice_handler);-#endif }
− cbits/noticehandlers.h
@@ -1,6 +0,0 @@-#include <geos_c.h>--void geos_notice_handler(const char *fmt, ...);-void geos_error_handler(const char *fmt, ...);-GEOSContextHandle_t init_GEOS();-
geos.cabal view
@@ -1,6 +1,6 @@ name: geos -version: 0.1.0.0+version: 0.1.0.1 synopsis: Bindings for GEOS. @@ -17,23 +17,26 @@ category: Geometry build-type: Simple-Extra-source-files: cbits/noticehandlers.h cabal-version: >=1.18.0+Flag Debug+ description: Enable Debug logging+ default: False Library Includes: geos_c.h Extra-libraries: geos_c- cc-options: -fPIC+ if flag(debug)+ cc-options: -fPIC -DDEBUG+ else+ cc-options: -fPIC c-sources: cbits/noticehandlers.c include-dirs: cbits- GHC-options: -Wall build-depends: base <= 4.10.1 , bytestring , vector , transformers , mtl- , cassava build-tools: hsc2hs exposed-modules: Data.Geometry.Geos.Topology@@ -63,14 +66,16 @@ , RankNTypes , DataKinds , KindSignatures- --, ScopedTypeVariables-+ GHC-options: -Wall default-language: Haskell2010 test-suite test Includes: geos_c.h Extra-libraries: geos_c- cc-options: -fPIC+ if flag(debug)+ cc-options: -fPIC -DDEBUG+ else+ cc-options: -fPIC c-sources: cbits/noticehandlers.c include-dirs: cbits type:@@ -80,6 +85,7 @@ frameworks: GEOS build-tools: hsc2hs main-is: Main.hs+ build-depends: base , bytestring@@ -103,8 +109,10 @@ , Data.Geometry.Geos.Raw.CoordSeq , Data.Geometry.Geos.Raw.Geometry , Data.Geometry.Geos.Raw.Serialize+ , Data.Geometry.Geos.Raw.Topology , Data.Geometry.Geos.Serialize , Data.Geometry.Geos.Types+ , Data.Geometry.Geos.Topology , ParsingSpec , RawGeometrySpec , SpatialOperationsSpec
src/Data/Geometry/Geos/Raw/Serialize.hs view
@@ -19,7 +19,6 @@ import Foreign.C.String import Foreign.C.Types import qualified Data.ByteString.Char8 as BC-import Control.Exception (onException) newtype Reader = Reader { _unReader :: ForeignPtr I.GEOSWKBReader }@@ -42,15 +41,14 @@ -> Reader -> BC.ByteString -> Geos (Maybe Geom)-read_ f (Reader r) bs = withGeos $ \h ->- onException (readBlock h) (pure Nothing)- where- readBlock h = do- ptr <- withForeignPtr r $ \rp ->- BC.useAsCStringLen bs $- \(cs, l) -> f h rp cs $ fromIntegral l- g <- wrapUpGeom h ptr- pure g+read_ f (Reader r) bs = withGeos readBlock+ where+ readBlock h = do+ ptr <- withForeignPtr r $ \rp ->+ BC.useAsCStringLen bs $+ \(cs, l) -> f h rp cs $ fromIntegral l+ g <- wrapUpGeom h ptr+ pure g wrapUpGeom :: I.GEOSContextHandle_t -> Ptr I.GEOSGeometry -> IO (Maybe Geom) wrapUpGeom h ptr
tests/SpecSampleData.hs view
@@ -7,7 +7,6 @@ import qualified Data.Vector as V import Data.Geometry.Geos.Types import Data.Geometry.Geos.Serialize-import Data.Geometry.Geos.CSV import Data.Maybe (catMaybes) point = PointGeometry (Point $ Coordinate2 36.1 (-119.1)) (Just 4326)