packages feed

geojson-types 0.1.1 → 0.1.2

raw patch · 3 files changed

+28/−10 lines, 3 filesdep +bytestringPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring

API changes (from Hackage documentation)

+ Data.GeoJSON: readFeatureCollection :: BaseType t => FilePath -> IO (Either String (FeatureCollection Value t))
+ Data.GeoJSON.Objects: closeLineString :: BaseType t => GeoJSON LineString t -> Maybe (GeoJSON LinearRing t)
+ Data.GeoJSON.Objects: type BoundingBox t = (Position t, Position t)

Files

geojson-types.cabal view
@@ -1,5 +1,5 @@ name:                geojson-types-version:             0.1.1+version:             0.1.2 synopsis:            GeoJSON data types including JSON/BSON conversion. homepage:            https://github.com/alios/geojson-types/ bug-reports:         https://github.com/alios/geojson-types/issues@@ -25,7 +25,7 @@             'Double' to a 'Position', use the '_Position' 'Iso' as a             'Getter' on that pair:             .-            > _Position :: BaseType t => (t, t) -> Position t+            > _Position :: BaseType t => Iso' (t, t) (Position t)             >             > pos :: Position Double             > pos = (57.324, 7.2342) ^. _Position@@ -78,10 +78,11 @@                        ConstraintKinds,                         RankNTypes,                         TypeFamilies-  build-depends:       base >=4.8 && <4.9, -                       lens >=4.14, -                       aeson >=0.11, -                       bson >=0.3, +  build-depends:       aeson >=0.11,+                       base >=4.8 && <4.9,+                       bson >=0.3,+                       bytestring >= 0.10,+                       lens >=4.14,                        text >=1.2   hs-source-dirs:      src   default-language:    Haskell2010
src/Data/GeoJSON.hs view
@@ -1,11 +1,19 @@ module Data.GeoJSON        ( module Data.GeoJSON.Objects,          module Data.GeoJSON.Features,-         module Data.GeoJSON.Classes+         module Data.GeoJSON.Classes,+         readFeatureCollection        ) where  import Data.GeoJSON.Objects import Data.GeoJSON.Features import Data.GeoJSON.Classes+import qualified Data.Aeson as Aeson+import qualified Data.ByteString.Lazy as BL+import Control.Lens.Operators -       ++readFeatureCollection ::+  BaseType t => FilePath -> IO (Either String (FeatureCollection Aeson.Value t))+readFeatureCollection f = Aeson.eitherDecode <$>  BL.readFile f+
src/Data/GeoJSON/Objects.hs view
@@ -32,7 +32,7 @@          -- ** Line String                   LineString, _LineString,          -- ** Linear Ring -         LinearRing, _LinearRing,+         LinearRing, _LinearRing, closeLineString,          -- ** MultiLineString          MultiLineString, _MultiLineString,          -- ** Polygon @@ -44,7 +44,7 @@          -- * Geometry Collection          GeometryCollection, newCollection, insert,          -- * Support types-         HasFlatCoordinates(..), boundingBox,+         HasFlatCoordinates(..), BoundingBox, boundingBox,          GeoJSON, BaseType, GeoJSONObject        ) where @@ -170,6 +170,15 @@           in if (head ps == last ps) && (length ps >= 4)              then pure $ LinearRing ls              else Nothing++-- | create 'LinearRing' from 'LineString' by closing it.+closeLineString ::+  BaseType t => GeoJSON LineString t -> Maybe (GeoJSON LinearRing t)+closeLineString ls =+  let ps = review _LineString ls+  in if head ps == last ps+     then preview _LinearRing ls+     else preview _LineString (last ps : ps) >>= preview _LinearRing   -- | see also: http://geojson.org/geojson-spec.html#multilinestring