packages feed

geos 0.2.1 → 0.2.2

raw patch · 8 files changed

+39/−34 lines, 8 files

Files

geos.cabal view
@@ -1,6 +1,7 @@+cabal-version:       2.2 name:                geos -version:             0.2.1+version:             0.2.2  synopsis:  Bindings for GEOS. @@ -18,7 +19,6 @@   build-type:          Simple-cabal-version:       >=1.18.0 Extra-Source-Files:  cbits/noticehandlers.h  Flag Debug@@ -114,6 +114,7 @@     , Data.Geometry.Geos.Raw.Serialize     , Data.Geometry.Geos.Raw.Topology     , Data.Geometry.Geos.Raw.STRTree+    , Data.Geometry.Geos.Relatable     , Data.Geometry.Geos.Serialize     , Data.Geometry.Geos.Topology     , Data.Geometry.Geos.STRTree
src/Data/Geometry/Geos/Geometry.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE LambdaCase, ScopedTypeVariables #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -15,6 +16,7 @@   , MultiLineString(..)   , MultiPolygon(..)   , Some(..)+  , Coordinate(..)   , SRID   , binaryPredicate   , convertGeometryFromRaw@@ -50,7 +52,9 @@ import Data.Geometry.Geos.Raw.Base import Control.Monad import Control.Applicative ((<*>))+import GHC.Generics (Generic) +-- | In all geometry types, SRID is used for compatability and is NOT used in calculations. For example, the `distance` between two PointGeometry with an SRID of `Just 4326` will return a distance between two points in Euclidean space in the units the PointGeometry is initialized with. It will not calculate the distance on a spheroid. type SRID = Maybe Int  data Some :: (* -> *) -> * where@@ -78,7 +82,8 @@  data Coordinate =     Coordinate2 {-# UNPACK #-} !Double {-# UNPACK #-} !Double-  | Coordinate3 {-# UNPACK #-} !Double {-# UNPACK #-} !Double {-# UNPACK #-} !Double  deriving (Read, Ord, Show, Eq, Data, Typeable)+  | Coordinate3 {-# UNPACK #-} !Double {-# UNPACK #-} !Double {-# UNPACK #-} !Double+  deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)   dimensionsCoordinate :: Coordinate -> Int@@ -90,11 +95,11 @@ dimensionsCoordinateSequence = dimensionsCoordinate . V.head  newtype Point = Point Coordinate- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  -- A LinearRing is a LineString that is closed newtype LinearRing = LinearRing CoordinateSequence- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  instance Sem.Semigroup LinearRing where   (<>) (LinearRing a) (LinearRing b) =  LinearRing (a <> b)@@ -103,7 +108,7 @@   mempty  = LinearRing V.empty  newtype LineString = LineString CoordinateSequence- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  instance Sem.Semigroup LineString where   (<>) (LineString a) (LineString b) =  LineString (a <> b)@@ -113,10 +118,10 @@  -- | In a polygon, the fist LinearRing is the shell, and any following are holes. newtype Polygon = Polygon (V.Vector LinearRing)- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  newtype MultiPoint = MultiPoint (V.Vector Point)- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  instance Sem.Semigroup MultiPoint where   (<>) (MultiPoint a) (MultiPoint b) =  MultiPoint (a <> b)@@ -125,10 +130,10 @@   mempty  = MultiPoint V.empty  newtype MultiLineString = MultiLineString (V.Vector LineString)- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  newtype MultiPolygon = MultiPolygon (V.Vector Polygon)- deriving (Read, Ord, Show, Eq, Data, Typeable)+ deriving (Read, Ord, Show, Eq, Data, Typeable, Generic)  -- | Returns the distance from the origin of LineString to the point projected on the geometry (that is to a point of the line the closest to the given point). project :: Geometry LineString -> Geometry Point -> Double
src/Data/Geometry/Geos/Prepared.hs view
@@ -21,7 +21,7 @@   , overlaps   , touches   , within-) where +) where  import qualified Data.Geometry.Geos.Raw.Prepared as RP import qualified Data.Geometry.Geos.Raw.Geometry as RG@@ -35,22 +35,22 @@   RP.prepare r  -queryPrepared :: (RP.PreparedGeometry -> RG.GeomConst -> Geos Bool) +queryPrepared :: (RP.PreparedGeometry -> RG.GeomConst -> Geos Bool)               -> RP.PreparedGeometry               -> Geometry b-              -> Bool -queryPrepared f pg g = runGeos $ convertGeometryToRaw g >>= (f pg)+              -> Bool+queryPrepared f pg g = runGeos $ convertGeometryToRaw g >>= f pg  instance Relatable (RP.PreparedGeometry) where-  contains = queryPrepared RP.contains-  coveredBy = queryPrepared RP.coveredBy -  covers = queryPrepared RP.covers -  crosses = queryPrepared RP.crosses -  disjoint = queryPrepared RP.disjoint -  intersects = queryPrepared RP.intersects -  overlaps = queryPrepared RP.overlaps-  touches = queryPrepared RP.touches -  within = queryPrepared RP.within +  contains   = queryPrepared RP.contains+  coveredBy  = queryPrepared RP.coveredBy+  covers     = queryPrepared RP.covers+  crosses    = queryPrepared RP.crosses+  disjoint   = queryPrepared RP.disjoint+  intersects = queryPrepared RP.intersects+  overlaps   = queryPrepared RP.overlaps+  touches    = queryPrepared RP.touches+  within     = queryPrepared RP.within  {-| The containsProperly predicate has the following equivalent definitions:@@ -65,5 +65,5 @@  containsProperly :: RP.PreparedGeometry                   -> Geometry a-                  -> Bool +                  -> Bool containsProperly = queryPrepared RP.containsProperly
tests/Main.hs view
@@ -1,10 +1,9 @@-{-# LANGUAGE OverloadedStrings, LambdaCase, ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables #-}  module Main where import qualified Data.ByteString as BS import Test.Hspec import Control.Exception-import Data.Geometry.Geos.Types import Data.Geometry.Geos.Serialize import Data.Geometry.Geos.Raw.Base import Data.Geometry.Geos.Geometry
tests/ParsingSpec.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, LambdaCase, ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}  module ParsingSpec where @@ -6,7 +6,7 @@ import qualified Data.ByteString as BS import Test.Hspec import Control.Exception-import Data.Geometry.Geos.Types+import Data.Geometry.Geos.Relatable import Data.Geometry.Geos.Serialize import Data.Geometry.Geos.Raw.Base import Data.Geometry.Geos.Geometry
tests/RawGeometrySpec.hs view
@@ -1,10 +1,10 @@-{-# LANGUAGE OverloadedStrings, LambdaCase, ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} module RawGeometrySpec where  import qualified Data.ByteString as BS import Test.Hspec import Control.Exception-import Data.Geometry.Geos.Types+import Data.Geometry.Geos.Relatable import Data.Geometry.Geos.Serialize import Data.Geometry.Geos.Raw.Base import Data.Geometry.Geos.Geometry
tests/SpatialOperationsSpec.hs view
@@ -8,8 +8,8 @@ import qualified Data.ByteString as BS import qualified Data.Vector as V import Data.Geometry.Geos.Raw.Base-import Data.Geometry.Geos.Types import Data.Geometry.Geos.Geometry+import Data.Geometry.Geos.Relatable import Data.Geometry.Geos.Topology import qualified Data.Geometry.Geos.STRTree as STR import Data.Word
tests/SpecSampleData.hs view
@@ -5,16 +5,16 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BS8 import qualified Data.Vector as V-import Data.Geometry.Geos.Types import Data.Geometry.Geos.Serialize+import Data.Geometry.Geos.Geometry import Data.Maybe (catMaybes)  point = PointGeometry (Point $ Coordinate2 36.1 (-119.1)) (Just 4326) makePoint (c1, c2) = Point $ Coordinate2 c1 c2 makePointGeo c = PointGeometry (makePoint c) Nothing-makeLinearRing cs = LinearRing . V.map (uncurry Coordinate2) . V.fromList $ cs+makeLinearRing = LinearRing . V.map (uncurry Coordinate2) . V.fromList makeLinearRingGeo cs = LinearRingGeometry (makeLinearRing cs) Nothing-makeLineString cs = LineString . V.map (uncurry Coordinate2) . V.fromList $ cs+makeLineString = LineString . V.map (uncurry Coordinate2) . V.fromList makeLineStringGeo cs = LineStringGeometry  (makeLineString cs ) Nothing makePolygon = Polygon . V.fromList . (fmap makeLinearRing) makePolygonGeo cs = PolygonGeometry (makePolygon cs) Nothing