onomastigs-ng: respect scaleToMaximum parameter

This commit is contained in:
2022-10-09 06:58:39 +02:00
parent a3e3e368c7
commit 03b6db3153
3 changed files with 14 additions and 4 deletions

View File

@@ -27,14 +27,14 @@ import Servant
import Servant.HTML.Blaze (HTML)
import Text.Blaze (ToMarkup (..))
data Response = Response {color :: [Text], areas :: [Area], statistics :: [(Text, ByArea Double)]}
data Response = Response {color :: [Text], areas :: [Area], statistics :: [(Text, ByArea Double)], svgSettings :: SvgSettings}
deriving (Generic)
instance ToMarkup Response where
toMarkup response =
preEscapedToMarkup $
renderMap
(SvgSettings{scaleToMaximum = Global})
(svgSettings response)
(color response)
(areas response)
(statistics response)
@@ -64,13 +64,14 @@ type OnomapApi =
:> QueryParams "name" Text
:> QueryParam "by" AreaKind
:> QueryParams "color" Text
:> QueryParam "scale" ScaleToMaximum
:> Get '[HTML] Response
app :: Manager -> ([Area], [Area]) -> Application
app manager' (theDistricts, theStates) = serve onomapApi server
where
server :: Server OnomapApi
server = \mode (surnames :: [Text]) maybeAreaKind colors ->
server = \mode (surnames :: [Text]) maybeAreaKind colors scaleTo ->
liftIO $
runStoepel manager' $ do
let areaMode = fromMaybe District maybeAreaKind
@@ -90,6 +91,7 @@ app manager' (theDistricts, theStates) = serve onomapApi server
Response
{ color = colors ++ defaultColorPalette
, areas = theAreas
, svgSettings = SvgSettings{scaleToMaximum = fromMaybe Global scaleTo}
, statistics = zip surnames stats
}
onomapApi :: Proxy OnomapApi