spherical 0.1.2.2 → 0.1.3.0
raw patch · 4 files changed
+62/−32 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Math.Geometry.Spherical: lambertAzimuthal :: Floating a => a -> a -> (a, a) -> (a, a)
Files
- CHANGELOG.md +5/−0
- LICENSE +1/−1
- spherical.cabal +26/−26
- src/Math/Geometry/Spherical.hs +30/−5
CHANGELOG.md view
@@ -1,5 +1,10 @@ # spherical +## 0.1.3.0++ * Add Lambert azimuthal projection+ * Add `areaPolygonGeneral` in case they want it+ ## 0.1.2.2 * Documentation improvements
LICENSE view
@@ -1,4 +1,4 @@-Copyright Vanessa McHale (c) 2018+Copyright Vanessa McHale (c) 2018, 2020 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
spherical.cabal view
@@ -1,37 +1,36 @@-cabal-version: 1.18-name: spherical-version: 0.1.2.2-license: BSD3-license-file: LICENSE-copyright: Copyright: (c) 2018 Vanessa McHale-maintainer: vanessa.mchale@iohk.io-author: Vanessa McHale-synopsis: Geometry on a sphere+cabal-version: 1.18+name: spherical+version: 0.1.3.0+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2018, 2020 Vanessa McHale+maintainer: vamchale@gmail.com+author: Vanessa McHale+synopsis: Geometry on a sphere description: Functions in pure Haskell for geometric computations on the surface of a sphere.-category: Math-build-type: Simple-extra-source-files:- cabal.project.local-extra-doc-files: README.md- CHANGELOG.md +category: Math+build-type: Simple+extra-source-files: cabal.project.local+extra-doc-files:+ README.md+ CHANGELOG.md+ source-repository head- type: git+ type: git location: https://github.com/vmchale/spherical flag development- description:- Enable `-Werror`- default: False- manual: True+ description: Enable `-Werror`+ default: False+ manual: True library- exposed-modules:- Math.Geometry.Spherical- hs-source-dirs: src+ exposed-modules: Math.Geometry.Spherical+ hs-source-dirs: src default-language: Haskell98- ghc-options: -Wall+ ghc-options: -Wall build-depends: base >=4.3 && <5, composition-prelude -any@@ -40,8 +39,9 @@ ghc-options: -Werror if impl(ghc >=8.0)- ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates- -Wredundant-constraints -Widentities+ ghc-options:+ -Wincomplete-uni-patterns -Wincomplete-record-updates+ -Wredundant-constraints -Widentities if impl(ghc >=8.4) ghc-options: -Wmissing-export-lists
src/Math/Geometry/Spherical.hs view
@@ -16,6 +16,7 @@ , winkel3 , mercator , bonne+ , lambertAzimuthal -- * Reference points , washingtonDC , mecca@@ -86,6 +87,18 @@ e = (long - meridian) * cos lat / rho cot = (1/) . tan +-- | See+-- [here](https://mathworld.wolfram.com/LambertAzimuthalEqual-AreaProjection.html).+--+-- @since 0.1.3.0+lambertAzimuthal :: Floating a+ => a -- ^ Standard parallel+ -> a -- ^ Central longitude+ -> (a, a)+ -> (a, a)+lambertAzimuthal phi1 lambda0 (long, lat) = (k' * cos lat * sin (long - lambda0), k' * cos phi1 * sin lat - sin phi1 * cos lat * cos (long - lambda0)) -- lambda corresponds to long, phi to lat on mathworld+ where k' = sqrt (2 / (1 + sin phi1 * sin lat + cos phi1 * cos lat * cos (long - lambda0)))+ -- | Albers projection for a given reference point. -- -- > ablers washingtonDC@@ -145,16 +158,28 @@ where stepArea point (sum', base) = (sum' + areaTriangle r base1 base point, point) areaConvex _ _ = error "attempted to take area of polygon with < 3 points" --- | Uses areal projection; then finds area of the polygon by the shoelace--- method.------ This is morally dubious in that it uses the Bonne projection centered around+-- | This is morally dubious in that it uses the Bonne projection centered around -- DC, so it will blow up in some cases. areaPolygon :: Floating a => a -- ^ Radius of sphere -> [(a, a)] -- ^ Polygon on the sphere, with points given in degrees. -> a-areaPolygon r = (*factor) . areaPolyRectangular . fmap (bonne (radians 25) (snd washingtonDC) . toRadians)+areaPolygon r = areaPolygonGeneral r (snd washingtonDC)+++-- | Uses areal projection; then finds area of the polygon by the shoelace+-- method.+--+-- This is morally dubious in that it uses the Bonne projection so it will blow+-- up in some cases.+--+-- @since 0.1.3.0+areaPolygonGeneral :: Floating a+ => a -- ^ Radius of sphere+ -> a -- ^ Central meridian+ -> [(a, a)] -- ^ Polygon on the sphere, with points given in degrees.+ -> a+areaPolygonGeneral r meridian = (*factor) . areaPolyRectangular . fmap (bonne (radians 25) meridian . toRadians) where factor = 1717856/4.219690791828533e-2 * ((r / 6371) ^ (2 :: Int)) perimeterPolygon :: Floating a