packages feed

geojson 3.0.4 → 4.0.0

raw patch · 8 files changed

+44/−77 lines, 8 filesdep +vectorPVP ok

version bump matches the API change (PVP)

Dependencies added: vector

API changes (from Hackage documentation)

- Data.Geospatial: unBoundingBoxWithoutCrs :: BoundingBoxWithoutCRS -> Seq Double
- Data.Geospatial.Internal.BasicTypes: BoundingBoxWithoutCRS :: Seq Double -> BoundingBoxWithoutCRS
- Data.Geospatial.Internal.BasicTypes: [unBoundingBoxWithoutCrs] :: BoundingBoxWithoutCRS -> Seq Double
- Data.Geospatial.Internal.BasicTypes: newtype BoundingBoxWithoutCRS
+ Data.Geospatial.Internal.BasicTypes: BoundingBoxWithoutCRSXY :: PointXY -> PointXY -> BoundingBoxWithoutCRS
+ Data.Geospatial.Internal.BasicTypes: BoundingBoxWithoutCRSXYZ :: PointXYZ -> PointXYZ -> BoundingBoxWithoutCRS
+ Data.Geospatial.Internal.BasicTypes: BoundingBoxWithoutCRSXYZM :: PointXYZM -> PointXYZM -> BoundingBoxWithoutCRS
+ Data.Geospatial.Internal.BasicTypes: data BoundingBoxWithoutCRS
- Data.Geospatial: bbox :: forall a_aCEj. Lens' (GeoFeature a_aCEj) (Maybe BoundingBoxWithoutCRS)
+ Data.Geospatial: bbox :: forall a_aKGl. Lens' (GeoFeature a_aKGl) (Maybe BoundingBoxWithoutCRS)
- Data.Geospatial: boundingbox :: forall a_aE7k. Lens' (GeoFeatureCollection a_aE7k) (Maybe BoundingBoxWithoutCRS)
+ Data.Geospatial: boundingbox :: forall a_aMg2. Lens' (GeoFeatureCollection a_aMg2) (Maybe BoundingBoxWithoutCRS)
- Data.Geospatial: class HasGeoPositionWithoutCRS c_aj1V
+ Data.Geospatial: class HasGeoPositionWithoutCRS c_anRq
- Data.Geospatial: featureId :: forall a_aCEj. Lens' (GeoFeature a_aCEj) (Maybe FeatureID)
+ Data.Geospatial: featureId :: forall a_aKGl. Lens' (GeoFeature a_aKGl) (Maybe FeatureID)
- Data.Geospatial: geoPositionWithoutCRS :: HasGeoPositionWithoutCRS c_aj1V => Lens' c_aj1V GeoPositionWithoutCRS
+ Data.Geospatial: geoPositionWithoutCRS :: HasGeoPositionWithoutCRS c_anRq => Lens' c_anRq GeoPositionWithoutCRS
- Data.Geospatial: geofeatures :: forall a_aE7k a_aE9T. Lens (GeoFeatureCollection a_aE7k) (GeoFeatureCollection a_aE9T) (Seq (GeoFeature a_aE7k)) (Seq (GeoFeature a_aE9T))
+ Data.Geospatial: geofeatures :: forall a_aMg2 a_aMiB. Lens (GeoFeatureCollection a_aMg2) (GeoFeatureCollection a_aMiB) (Seq (GeoFeature a_aMg2)) (Seq (GeoFeature a_aMiB))
- Data.Geospatial: geometry :: forall a_aCEj. Lens' (GeoFeature a_aCEj) GeospatialGeometry
+ Data.Geospatial: geometry :: forall a_aKGl. Lens' (GeoFeature a_aKGl) GeospatialGeometry
- Data.Geospatial: properties :: forall a_aCEj a_aCLM. Lens (GeoFeature a_aCEj) (GeoFeature a_aCLM) a_aCEj a_aCLM
+ Data.Geospatial: properties :: forall a_aKGl a_aKNO. Lens (GeoFeature a_aKGl) (GeoFeature a_aKNO) a_aKGl a_aKNO
- Data.Geospatial.Internal.BasicTypes: class HasGeoPositionWithoutCRS c_aj1V
+ Data.Geospatial.Internal.BasicTypes: class HasGeoPositionWithoutCRS c_anRq
- Data.Geospatial.Internal.BasicTypes: geoPositionWithoutCRS :: HasGeoPositionWithoutCRS c_aj1V => Lens' c_aj1V GeoPositionWithoutCRS
+ Data.Geospatial.Internal.BasicTypes: geoPositionWithoutCRS :: HasGeoPositionWithoutCRS c_anRq => Lens' c_anRq GeoPositionWithoutCRS
- Data.Geospatial.Internal.GeoFeature: bbox :: forall a_aCEj. Lens' (GeoFeature a_aCEj) (Maybe BoundingBoxWithoutCRS)
+ Data.Geospatial.Internal.GeoFeature: bbox :: forall a_aKGl. Lens' (GeoFeature a_aKGl) (Maybe BoundingBoxWithoutCRS)
- Data.Geospatial.Internal.GeoFeature: featureId :: forall a_aCEj. Lens' (GeoFeature a_aCEj) (Maybe FeatureID)
+ Data.Geospatial.Internal.GeoFeature: featureId :: forall a_aKGl. Lens' (GeoFeature a_aKGl) (Maybe FeatureID)
- Data.Geospatial.Internal.GeoFeature: geometry :: forall a_aCEj. Lens' (GeoFeature a_aCEj) GeospatialGeometry
+ Data.Geospatial.Internal.GeoFeature: geometry :: forall a_aKGl. Lens' (GeoFeature a_aKGl) GeospatialGeometry
- Data.Geospatial.Internal.GeoFeature: properties :: forall a_aCEj a_aCLM. Lens (GeoFeature a_aCEj) (GeoFeature a_aCLM) a_aCEj a_aCLM
+ Data.Geospatial.Internal.GeoFeature: properties :: forall a_aKGl a_aKNO. Lens (GeoFeature a_aKGl) (GeoFeature a_aKNO) a_aKGl a_aKNO
- Data.Geospatial.Internal.GeoFeatureCollection: boundingbox :: forall a_aE7k. Lens' (GeoFeatureCollection a_aE7k) (Maybe BoundingBoxWithoutCRS)
+ Data.Geospatial.Internal.GeoFeatureCollection: boundingbox :: forall a_aMg2. Lens' (GeoFeatureCollection a_aMg2) (Maybe BoundingBoxWithoutCRS)
- Data.Geospatial.Internal.GeoFeatureCollection: geofeatures :: forall a_aE7k a_aE9T. Lens (GeoFeatureCollection a_aE7k) (GeoFeatureCollection a_aE9T) (Seq (GeoFeature a_aE7k)) (Seq (GeoFeature a_aE9T))
+ Data.Geospatial.Internal.GeoFeatureCollection: geofeatures :: forall a_aMg2 a_aMiB. Lens (GeoFeatureCollection a_aMg2) (GeoFeatureCollection a_aMiB) (Seq (GeoFeature a_aMg2)) (Seq (GeoFeature a_aMiB))

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+# 4.0.x++## 3.0.4 -> 4.0.0++- Create a bounding box type that we can all enjoy (XY, XYZ, XYZM instead of Sequence).+ # 3.0.x  ## 2.0.0 -> 3.0.2
README.md view
@@ -2,44 +2,6 @@  A thin GeoJSON Layer above the `aeson` library -## Building the project--Install the dependencies with:--    cabal install --only-dependencies--Optionally add `--enable-tests` if you intend to run the unit tests--The project must be "configured" at least once everytime `geojson.cabal` changes, this can be done with:--    cabal configure--If you wish to run the unit tests you will have to run:--    cabal configure --enable-tests--Then finally build it with:--    cabal build--See `cabal build --help` for more build options.--## Running Unit Tests--**After** running `cabal build`, you can run the unit tests with the command:--    cabal test--## Development: Cabal Dependency Hell?--Cabal's great, but when you are developing a few different projects with their own dependency chains, sometimes installing all your libraries to the same place causes problems,--Consider trying [`cabal-dev`] [cabal-dev]. In terms of using it, all thats required is replacing `cabal` with `cabal-dev` in all the above command lines.--It will download and install all the dependencies for your project and install them in a `cabal-dev/` directory in your project directory, and they will only be used for this project.--Those with newer versions of `cabal` (`>= 1.18` I think) can skip `cabal-dev` and instead run `cabal sandbox init`, and just start runnign the above instructions-as is from `cabal install --only-dependencies`--[cabal-dev]: https://github.com/creswick/cabal-dev "creswick/cabal-dev on GitHub.com"+### Other Projects/Documentation +[Geometry Survival Guide](https://www.gaia-gis.it/spatialite-3.0.0-BETA/GeoNotations.pdf)
geojson.cabal view
@@ -1,17 +1,17 @@ name:                   geojson-version:                3.0.4+version:                4.0.0 license:                BSD3 license-file:           LICENCE author:                 Dom De Re maintainer:             Andrew Newman-copyright:              Copyright (C) 2013-2018+copyright:              Copyright (C) 2013-2019 synopsis:               A thin GeoJSON Layer above the aeson library category:               Data description:            A thin GeoJSON Layer above the aeson library.                         .                         It currently conforms to version 1.0 of the GeoJSON spec which can be found here:                         .-                        <http://geojson.org/geojson-spec.html>+                        <https://tools.ietf.org/html/rfc7946>  homepage:               https://github.com/indicatrix/hs-geojson bug-reports:            https://github.com/indicatrix/hs-geojson/issues@@ -31,7 +31,7 @@  library     hs-source-dirs:     src-    build-depends:      base < 5 &&     >= 4+    build-depends:      base < 5 &&     >= 4.9                     ,   aeson           >= 0.8                     ,   containers      >= 0.5.10.1                     ,   deepseq         >= 1.4@@ -41,6 +41,7 @@                     ,   scientific      >= 0.2.0                     ,   transformers    >= 0.3                     ,   validation      >= 1+                    ,   vector     exposed-modules:    Data.Geospatial                     ,   Data.LinearRing                     ,   Data.LineString@@ -65,7 +66,7 @@     hs-source-dirs:     test     main-is:            Main.hs     type:               exitcode-stdio-1.0-    build-depends:      base < 5 &&     >= 4+    build-depends:      base < 5 &&     >= 4.9                     ,   aeson           >= 0.8                     ,   bytestring      >= 0.10                     ,   containers      >= 0.5.10.1
src/Data/Geospatial.hs view
@@ -48,7 +48,6 @@     ,   unGeoLine     ,   unGeoMultiLine     ,   unGeoMultiPolygon-    ,   unBoundingBoxWithoutCrs     -- ** Feature Lenses     ,   bbox     ,   geometry
src/Data/Geospatial/Internal/BasicTypes.hs view
@@ -41,11 +41,10 @@ import           Control.Lens.TH  (makeClassy) import qualified Data.Aeson       as Aeson import qualified Data.Aeson.Types as AesonTypes-import qualified Data.Foldable    as Foldable import qualified Data.Maybe       as DataMaybe import qualified Data.Scientific  as Scientific-import qualified Data.Sequence    as Sequence import qualified Data.Text        as Text+import qualified Data.Vector      as Vector import           GHC.Generics  type Latitude = Double@@ -149,12 +148,30 @@ -- e.g for WGS84: minLongitude, minLatitude, maxLongitude, maxLatitude -- The spec mentions that it can be part of a geometry object too but doesnt give an example, -- This implementation will ignore bboxes on Geometry objects, they can be added if required.-newtype BoundingBoxWithoutCRS = BoundingBoxWithoutCRS { unBoundingBoxWithoutCrs :: Sequence.Seq Double } deriving (Eq, Show, Generic, NFData)+data BoundingBoxWithoutCRS+  = BoundingBoxWithoutCRSXY PointXY PointXY+  | BoundingBoxWithoutCRSXYZ PointXYZ PointXYZ+  | BoundingBoxWithoutCRSXYZM PointXYZM PointXYZM deriving (Eq, Show, Generic, NFData)  instance Aeson.FromJSON BoundingBoxWithoutCRS where-    parseJSON obj = do-        doubles <- Aeson.parseJSON obj :: AesonTypes.Parser [Double]-        pure . BoundingBoxWithoutCRS $ Sequence.fromList doubles+  parseJSON json = do+    x <- AesonTypes.parseJSON json+    DataMaybe.maybe (fail "Invalid bounding box") pure (_toBoundingBoxWithoutCRS x)  instance Aeson.ToJSON BoundingBoxWithoutCRS where-    toJSON = Aeson.toJSON . Foldable.toList . unBoundingBoxWithoutCrs+  toJSON (BoundingBoxWithoutCRSXY (PointXY bbMinX bbMinY) (PointXY bbMaxX bbMaxY)) =+    Aeson.Array (Vector.fromList $ fmap (Aeson.Number . Scientific.fromFloatDigits) [bbMinX, bbMinY, bbMaxX, bbMaxY])+  toJSON (BoundingBoxWithoutCRSXYZ (PointXYZ bbMinX bbMinY bbMinZ) (PointXYZ bbMaxX bbMaxY bbMaxZ)) =+    Aeson.Array (Vector.fromList $ fmap (Aeson.Number . Scientific.fromFloatDigits) [bbMinX, bbMinY, bbMinZ, bbMaxX, bbMaxY, bbMaxZ])+  toJSON (BoundingBoxWithoutCRSXYZM (PointXYZM bbMinX bbMinY bbMinZ bbMinM) (PointXYZM bbMaxX bbMaxY bbMaxZ bbMaxM)) =+    Aeson.Array (Vector.fromList $ fmap (Aeson.Number . Scientific.fromFloatDigits) [bbMinX, bbMinY, bbMinZ, bbMinM, bbMaxX, bbMaxY, bbMaxZ, bbMaxM])++_toBoundingBoxWithoutCRS :: [Double] -> Maybe BoundingBoxWithoutCRS+_toBoundingBoxWithoutCRS [bbMinX, bbMinY, bbMaxX, bbMaxY] =+  Just $ BoundingBoxWithoutCRSXY (PointXY bbMinX bbMinY) (PointXY bbMaxX bbMaxY)+_toBoundingBoxWithoutCRS [bbMinX, bbMinY, bbMinZ, bbMaxX, bbMaxY, bbMaxZ] =+  Just $ BoundingBoxWithoutCRSXYZ (PointXYZ bbMinX bbMinY bbMinZ) (PointXYZ bbMaxX bbMaxY bbMaxZ)+_toBoundingBoxWithoutCRS [bbMinX, bbMinY, bbMinZ, bbMinM, bbMaxX, bbMaxY, bbMaxZ, bbMaxM] =+  Just $ BoundingBoxWithoutCRSXYZM (PointXYZM bbMinX bbMinY bbMinZ bbMinM) (PointXYZM bbMaxX bbMaxY bbMaxZ bbMaxM)+_toBoundingBoxWithoutCRS _ =+  Nothing
src/Data/LinearRing.hs view
@@ -143,7 +143,7 @@             then               Sequence.empty             else-                (Sequence.zipWith combine <*> SeqHelper.sequenceTail) (c Sequence.<| rest)+              (Sequence.zipWith combine <*> SeqHelper.sequenceTail) (c Sequence.<| rest) {-# INLINE combineToSeq #-}  -- |
test/Data/SeqHelperTests.hs view
@@ -1,17 +1,11 @@ module Data.SeqHelperTests where -import qualified Data.List.NonEmpty                  as ListNonEmpty-import qualified Data.Sequence                       as Sequence-import qualified Data.Validation                     as Validation+import qualified Data.Sequence    as Sequence import           Test.Tasty-import           Test.Tasty.Hspec                    (Spec, context, describe,-                                                      it, shouldBe, testSpec)-import           Test.Tasty.QuickCheck               (Property, property,-                                                      testProperty)+import           Test.Tasty.Hspec (Spec, describe, it, shouldBe, testSpec) -- Local-import           Arbitrary                           ()-import qualified Data.Geospatial.Internal.BasicTypes as BasicTypes-import qualified Data.SeqHelper                      as SeqHelper+import           Arbitrary        ()+import qualified Data.SeqHelper   as SeqHelper  -- Tests 
test/Fixture.hs view
@@ -42,9 +42,6 @@ testNamedCRS :: CRSObject testNamedCRS = NamedCRS "urn:ogc:def:crs:OGC:1.3:CRS84" -mkBoundingBox :: [Double] -> BasicTypes.BoundingBoxWithoutCRS-mkBoundingBox x = BasicTypes.BoundingBoxWithoutCRS $ Sequence.fromList x- -- Bounding Box Data  mkGeoPoint :: Double -> Double -> BasicTypes.GeoPositionWithoutCRS@@ -63,16 +60,7 @@ emptyLineVertices = []  testLatLonBBox :: BasicTypes.BoundingBoxWithoutCRS-testLatLonBBox = mkBoundingBox [-32, 147.5, -29.5, 151.0]--testLatLonBBoxJSON :: BS.ByteString-testLatLonBBoxJSON = "[-32,147.5,-29.5,151]"--testEmptyBBox :: BasicTypes.BoundingBoxWithoutCRS-testEmptyBBox = mkBoundingBox []--testEmptyBBoxJSON :: BS.ByteString-testEmptyBBoxJSON = "[]"+testLatLonBBox = BasicTypes.BoundingBoxWithoutCRSXY (BasicTypes.PointXY (-32) 147.5) (BasicTypes.PointXY (-29.5) 151.0)  -- Geometry Data --