hgis 0.1.3.5 → 0.1.3.6
raw patch · 7 files changed
+131/−201 lines, 7 filesdep ~Chartdep ~Chart-cairodep ~Chart-diagramsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Chart, Chart-cairo, Chart-diagrams, ansi-wl-pprint, base, binary, bytestring, colour, composition, data-binary-ieee754, data-default, directory, filepath, hgis, hspec, lens, monad-loops, optparse-applicative, transformers
API changes (from Hackage documentation)
Files
- Justfile +4/−0
- cabal.project.local +5/−0
- docs/manual.pdf binary
- hgis.cabal +81/−93
- src/GIS/Hylo.hs +30/−30
- stack.yaml +0/−67
- test/Spec.hs +11/−11
+ Justfile view
@@ -0,0 +1,4 @@+upload:+ rm -rf dist/+ cabal sdist+ cabal upload --publish $(fd '\.tar\.gz$')
+ cabal.project.local view
@@ -0,0 +1,5 @@+with-compiler: ghc-8.2.1+optimization: 2+documentation: True+haddock-hoogle: True+haddock-internal: True
− docs/manual.pdf
binary file changed (98118 → absent bytes)
hgis.cabal view
@@ -1,100 +1,88 @@-name: hgis-version: 0.1.3.5-cabal-version: >=1.10-build-type: Simple-license: BSD3-license-file: LICENSE-copyright: Copyright: (c) 2016 Vanessa McHale-maintainer: tmchale@wisc.edu-homepage: https://github.com/vmchale/hgis#readme-synopsis: Package and command-line for GIS with Haskell-description:- Package containting functions to make graphs, read- shapefiles, and compute areas/perimeters of- geographic features.-category: Web-author: Vanessa McHale-extra-source-files:- README.md- stack.yaml- docs/manual.tex- docs/manual.pdf- src/depends/readshp/LICENSE- LICENSE-readshp--source-repository head- type: git- location: https://github.com/vmchale/hgis+name: hgis+version: 0.1.3.6+synopsis: Package and command-line for GIS with Haskell+description: Package containting functions to make graphs, read + shapefiles, and compute areas/perimeters of+ geographic features. +homepage: https://github.com/vmchale/hgis#readme+license: BSD3+license-file: LICENSE+author: Vanessa McHale+maintainer: tmchale@wisc.edu+copyright: Copyright: (c) 2016 Vanessa McHale+category: Web+build-type: Simple+extra-source-files: README.md, cabal.project.local, docs/manual.tex, src/depends/readshp/LICENSE, LICENSE-readshp, Justfile+cabal-version: >=1.10 -flag llvm-fast- description:- Enable build with llvm backend- default: False+Flag llvm-fast {+ Description: Enable build with llvm backend+ Default: False+} library- exposed-modules:- GIS.Exe.Opt- GIS.Exe.OptCairo- GIS.Math.Spherical- GIS.Graphics.PlotPNG- GIS.Graphics.PlotSVG- GIS.Hylo- GIS.Math.Projections- build-depends:- base >=4.7 && <5,- optparse-applicative >=0.13.2.0 && <0.14,- Chart >=1.8.2 && <1.9,- Chart-cairo >=1.8.2 && <1.9,- Chart-diagrams >=1.8.2 && <1.9,- lens >=4.15.1 && <4.16,- composition >=1.0.2.1 && <1.1,- ansi-wl-pprint >=0.6.7.3 && <0.7,- transformers >=0.5.2.0 && <0.6,- directory >=1.3.0.0 && <1.4,- colour >=2.3.3 && <2.4,- data-default >=0.7.1.1 && <0.8,- binary >=0.8.3.0 && <0.9,- bytestring >=0.10.8.1 && <0.11,- data-binary-ieee754 >=0.4.4 && <0.5,- filepath >=1.4.1.1 && <1.5,- monad-loops >=0.4.3 && <0.5- default-language: Haskell2010- default-extensions: DeriveGeneric OverloadedStrings- hs-source-dirs: src src/depends/readshp- other-modules:- GIS.Math.Utils- GIS.Utils- GIS.Graphics.Plot- GIS.Graphics.Types- GIS.Types- GIS.Exe.Parser- Geometry.Shapefile- Geometry.Shapefile.MergeShpDbf- Geometry.Shapefile.ReadDbf- Geometry.Shapefile.ReadShp- Geometry.Shapefile.Types- Geometry.Shapefile.Internal+ hs-source-dirs: src, src/depends/readshp+ exposed-modules: GIS.Exe.Opt+ , GIS.Exe.OptCairo+ , GIS.Math.Spherical+ , GIS.Graphics.PlotPNG+ , GIS.Graphics.PlotSVG+ , GIS.Hylo+ , GIS.Math.Projections+ other-modules: GIS.Math.Utils+ , GIS.Utils+ , GIS.Graphics.Plot+ , GIS.Graphics.Types+ , GIS.Types+ , GIS.Exe.Parser+ , Geometry.Shapefile+ , Geometry.Shapefile.MergeShpDbf+ , Geometry.Shapefile.ReadDbf+ , Geometry.Shapefile.ReadShp+ , Geometry.Shapefile.Types+ , Geometry.Shapefile.Internal+ build-depends: base >= 4.7 && < 5+ , optparse-applicative+ , Chart+ , Chart-cairo+ , Chart-diagrams+ , lens+ , composition+ , ansi-wl-pprint+ , transformers+ , directory+ , colour+ , data-default+ , binary+ , bytestring+ , data-binary-ieee754+ , filepath+ , monad-loops+ default-language: Haskell2010+ default-extensions: DeriveGeneric+ , OverloadedStrings executable hgis- - if flag(llvm-fast)- ghc-options: -threaded -rtsopts -with-rtsopts=-N -fllvm -optlo-O3 -O3- else- ghc-options: -threaded -rtsopts -with-rtsopts=-N- main-is: MainPng.hs- build-depends:- base >=4.9.1.0 && <4.10,- hgis >=0.1.3.5 && <0.2- default-language: Haskell2010- hs-source-dirs: app+ hs-source-dirs: app+ main-is: MainPng.hs+ if flag(llvm-fast)+ ghc-options: -threaded -rtsopts -with-rtsopts=-N -fllvm -optlo-O3 -O3+ else+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends: base+ , hgis+ default-language: Haskell2010 test-suite hgis-test- type: exitcode-stdio-1.0- main-is: Spec.hs- build-depends:- base >=4.9.1.0 && <4.10,- hgis >=0.1.3.5 && <0.2,- hspec >=2.4.3 && <2.5- default-language: Haskell2010- hs-source-dirs: test- ghc-options: -threaded -rtsopts -with-rtsopts=-N+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Spec.hs+ build-depends: base+ , hgis+ , hspec+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ default-language: Haskell2010++source-repository head+ type: git+ location: https://github.com/vmchale/hgis
src/GIS/Hylo.hs view
@@ -2,24 +2,24 @@ -- | Module to transform shapefiles. module GIS.Hylo where -import Geometry.Shapefile.MergeShpDbf-import Geometry.Shapefile.ReadShp-import Geometry.Shapefile.Types-import Data.List-import Data.Char-import Data.Maybe-import Data.Monoid-import GIS.Math.Projections-import GIS.Math.Spherical-import GIS.Utils-import Control.Lens.Tuple-import Control.Lens-import Control.Monad-import GIS.Types-import GIS.Graphics.Types-import Data.Default-import System.Directory-import Data.Composition+import Control.Lens+import Control.Lens.Tuple+import Control.Monad+import Data.Char+import Data.Composition+import Data.Default+import Data.List+import Data.Maybe+import Data.Monoid+import Geometry.Shapefile.MergeShpDbf+import Geometry.Shapefile.ReadShp+import Geometry.Shapefile.Types+import GIS.Graphics.Types+import GIS.Math.Projections+import GIS.Math.Spherical+import GIS.Types+import GIS.Utils+import System.Directory -- | Get the areas of various objects and return a string suitable for printing districtArea :: [District] -> String@@ -47,11 +47,11 @@ -- | Given a list of districts, draw a map, with labels determined by a lens. districtToMapLens :: (Show a) => Lens' District a -> [District] -> Map districtToMapLens lens districts = labelledDistricts .~ dist $ def- where dist = zip (fmap (_shape) districts) (map (show . view lens) districts)+ where dist = zip (fmap _shape districts) (fmap (show . view lens) districts) -- | Given a list of districts, draw a map. districtToMap :: [District] -> Map-districtToMap = districtToMapLens districtLabel +districtToMap = districtToMapLens districtLabel -- | Given a projection and list of districts, return a list of maps. districtToMapFilesP :: Projection -> [District] -> [Map]@@ -59,22 +59,22 @@ -- | Given a list of districts, return a list of maps. districtToMapFiles :: [District] -> [Map]-districtToMapFiles = map (\(District polygons label _ area _) -> title .~ label ++ "-" ++ (show . sum $ area) $ labelledDistricts .~ (pure (polygons,"")) $ def)+districtToMapFiles = fmap (\(District polygons label _ area _) -> title .~ label ++ "-" ++ (show . sum $ area) $ labelledDistricts .~ pure (polygons,"") $ def) -- | Given the path to a shapefile, return a list of districts getDistricts :: FilePath -> IO [District] getDistricts filepath = do dbfExists <- doesFileExist (stripExt filepath <> ".dbf") file <- if dbfExists then readShpWithDbf filepath else readShpFile filepath- let districtLabels = fromJust $ (fmap labels) $ mapM (shpRecLabel) . shpRecs $ file -- labels + field descriptions?- let shapes = (map (getPolygon . fromJust . shpRecContents)) . shpRecs $ file- let perimeters = map (totalPerimeter . getPolygon . fromJust . shpRecContents) . shpRecs $ file- let areas = map (fmap areaPolygon . getPolygon . fromJust . shpRecContents) . shpRecs $ file- let compacticity = map (relativeCompactness . concat . getPolygon . fromJust . shpRecContents) . shpRecs $ file- pure $ zipWith5 (\a b c d e -> District a b c d e) shapes districtLabels perimeters areas compacticity+ let districtLabels = fromJust $ fmap labels $ mapM shpRecLabel . shpRecs $ file -- labels + field descriptions?+ let shapes = fmap (getPolygon . fromJust . shpRecContents) . shpRecs $ file+ let perimeters = fmap (totalPerimeter . getPolygon . fromJust . shpRecContents) . shpRecs $ file+ let areas = fmap (fmap areaPolygon . getPolygon . fromJust . shpRecContents) . shpRecs $ file+ let compacticity = fmap (relativeCompactness . concat . getPolygon . fromJust . shpRecContents) . shpRecs $ file+ pure $ zipWith5 District shapes districtLabels perimeters areas compacticity -- | Helper function for extracting from shapefiles. getPolygon :: RecContents -> [Polygon]-getPolygon (RecPolygon { recPolPoints = pt }) = pt-getPolygon (RecPolygonM { recPolMPoints = pt }) = pt-getPolygon (RecPolygonZ { recPolZPoints = pt }) = pt+getPolygon RecPolygon{ recPolPoints = pt } = pt+getPolygon RecPolygonM{ recPolMPoints = pt } = pt+getPolygon RecPolygonZ{ recPolZPoints = pt } = pt
− stack.yaml
@@ -1,67 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# http://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-# resolver: ghcjs-0.1.0_ghc-7.10.2-# resolver:-# name: custom-snapshot-# location: "./custom-snapshot.yaml"-#resolver: lts-8.5-resolver: lts-8.18--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# extra-dep: true-# subdirs:-# - auto-update-# - wai-#-# A package marked 'extra-dep: true' will only be built if demanded by a-# non-dependency (i.e. a user package), and its test suites and benchmarks-# will not be run. This is useful for tweaking upstream packages.-packages:-- '.'-# Dependency packages to be pulled from upstream that are not in the resolver-# (e.g., acme-missiles-0.3)-extra-deps: []--# Override default flag values for local packages and extra-deps-flags: {}--# Extra package databases containing global packages-extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.4"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor
test/Spec.hs view
@@ -1,18 +1,18 @@-import Test.Hspec-import GIS.Math.Spherical-import GIS.Hylo-import GIS.Graphics.PlotSVG-import GIS.Graphics.PlotPNG-import GIS.Math.Projections+import GIS.Graphics.PlotPNG+import GIS.Graphics.PlotSVG+import GIS.Hylo+import GIS.Math.Projections+import GIS.Math.Spherical+import Test.Hspec main :: IO () main = hspec $ do describe "distance" $ do- parallel $ it "computes distances along geodesics" $ do+ it "computes distances along geodesics" $ do distance ((-74.0059), 40.7128) ((-118.2347), 34.0522) `shouldBe` 3934.997673163554 describe "mercatorFullPng" $ do- parallel $ it "Reads a map and writes a .png with the mercator projection" $ do+ it "Reads a map and writes a .png with the mercator projection" $ do (mkMapPng "test/testmap.png" =<< districtToMapP bonne <$> getDistricts "test/data/worldmap/TM_WORLD_BORDERS-0.3.shp") >>= (`shouldBe` ())- --describe "mercatorFullSVG" $ do- -- parallel $ it "Reads a map and writes a .svg with the mercator projection" $ do- -- (mkMapSVG "test/testmap.svg" =<< districtToMapP bonne <$> getDistricts "test/data/worldmap/TM_WORLD_BORDERS-0.3.shp") >>= (`shouldBe` ())+ describe "mercatorFullSVG" $ do+ it "Reads a map and writes a .svg with the mercator projection" $ do+ (mkMapSVG "test/testmap.svg" =<< districtToMapP bonne <$> getDistricts "test/data/worldmap/TM_WORLD_BORDERS-0.3.shp") >>= (`shouldBe` ())