packages feed

wkt-geom 0.0.9 → 0.0.10

raw patch · 5 files changed

+59/−3 lines, 5 files

Files

CHANGELOG.md view
@@ -1,7 +1,7 @@ # Changelog All notable changes to this project will be documented in this file. -## [0.0.8] - 2019-05-09+## [0.0.10] - 2019-05-09 ### Added - WKT parsing of BOX. 
+ src/Data/Internal/Wkt/Box.hs view
@@ -0,0 +1,18 @@+module Data.Internal.Wkt.Box+  ( box ) where++import qualified Data.Geospatial         as Geospatial+import qualified Text.Trifecta           as Trifecta++import qualified Data.Internal.Wkt.Line  as Line+import qualified Data.Internal.Wkt.Point as Point++box :: Trifecta.Parser Geospatial.BoundingBoxWithoutCRS+box = do+  _ <- Trifecta.string "box"+  _ <- Trifecta.spaces+  _ <- Trifecta.spaces >> Trifecta.char '(' >> Trifecta.spaces+  (Geospatial.GeoPointXY first) <- Point.justPointsXY+  (Geospatial.GeoPointXY second) <- Line.commandPoint Point.justPointsXY+  _ <- Trifecta.char ')' >> Trifecta.spaces+  pure $ Geospatial.BoundingBoxWithoutCRSXY first second
src/Data/Wkt.hs view
@@ -8,6 +8,7 @@   , parseString   , WktGeometryCollection.geometryCollection   , WktGeometryCollection.emptyGeometryCollection+  , WktBox.box   , WktLine.emptyLine   , WktLine.emptyMultiLine   , WktLine.lineString@@ -28,6 +29,7 @@ import qualified Text.Trifecta                        as Trifecta import qualified Text.Trifecta.Delta                  as TrifectaDelta +import qualified Data.Internal.Wkt.Box                as WktBox import qualified Data.Internal.Wkt.GeometryCollection as WktGeometryCollection import qualified Data.Internal.Wkt.Line               as WktLine import qualified Data.Internal.Wkt.Point              as WktPoint
+ test/Data/Internal/Wkt/BoxSpec.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE OverloadedStrings #-}++module Data.Internal.Wkt.BoxSpec where++import           Control.Lens    ((^?), (^?!))+import qualified Data.Geospatial as Geospatial+import qualified Data.Maybe      as Maybe+import           Test.Hspec      (Spec, describe, expectationFailure, it,+                                  shouldBe, shouldSatisfy)+import qualified Text.Trifecta   as Trifecta++import qualified Data.Wkt        as Wkt++spec :: Spec+spec =+  testBoxes++testBoxes :: Spec+testBoxes =+  describe "boxes" $ do+    it "Parse incomplete" $+      Wkt.parseString Wkt.box "box" `shouldSatisfy` (Maybe.isJust . flip (^?) Trifecta._Failure)+    it "Parse not box" $+      Wkt.parseString Wkt.box "box (abc)" `shouldSatisfy` (Maybe.isJust . flip (^?) Trifecta._Failure)+    it "Parse something" $ do+      let x = Wkt.parseString Wkt.box "box(145.1145 -37.7948, 145.1372 -37.7767)"+      case x of+        Trifecta.Success a -> a `shouldBe` exampleBox+        Trifecta.Failure f -> expectationFailure (show f)+    it "Parse spaces" $+      Wkt.parseString Wkt.box "box(145.1145  -37.7948,145.1372 -37.7767)" ^?! Trifecta._Success `shouldBe` exampleBox++exampleBox :: Geospatial.BoundingBoxWithoutCRS+exampleBox = Geospatial.BoundingBoxWithoutCRSXY (Geospatial.PointXY 145.1145 (-37.7948)) (Geospatial.PointXY 145.1372 (-37.7767))
wkt-geom.cabal view
@@ -1,5 +1,5 @@ name:                  wkt-geom-version:               0.0.9+version:               0.0.10 synopsis:              A parser of WKT, WKB and eWKB. description:           Well Known Text (WKT), Well Known Binary (WKB) and the PostgreSQL extension Extended Well Know Binary (eWKB) are vector geometry representations.                      .@@ -37,6 +37,7 @@                      , Data.Internal.Wkb.Point                      , Data.Internal.Wkb.Polygon                      , Data.Internal.Wkt.Common+                     , Data.Internal.Wkt.Box                      , Data.Internal.Wkt.Line                      , Data.Internal.Wkt.Point                      , Data.Internal.Wkt.Polygon@@ -70,6 +71,7 @@                      , Data.Internal.Wkb.LineSpec                      , Data.Internal.Wkb.PointSpec                      , Data.Internal.Wkb.PolygonSpec+                     , Data.Internal.Wkt.BoxSpec                      , Data.Internal.Wkt.GeometryCollectionSpec                      , Data.Internal.Wkt.LineSpec                      , Data.Internal.Wkt.PointSpec@@ -114,4 +116,4 @@ source-repository this   type:     git   location: https://github.com/indicatrix/wkt-geom.git-  tag:      0.0.9+  tag:      0.0.10