{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell #-}
module GIS.Types where
import Control.Lens
import GHC.Generics
import Text.PrettyPrint.ANSI.Leijen
type Point = (Double, Double)
type Polygon = [Point]
type Projection = (Double, Double) -> (Double, Double)
data District = District { _shape :: [Polygon]
, _districtLabel :: String
, _perimeter :: Double
, _area :: [Double]
, _compactness :: Double
} deriving (Generic, Show)
makeLenses ''District
data DbfReadError = NotAPolygon | ShpNull
instance Show DbfReadError where
show NotAPolygon = show $ red (text "Error: ") <> text "Shape not a polygon! Are you sure you're opening a district?"
show ShpNull = show $ red (text "Error: ") <> text ""