reanimate-1.1.3.0: Animation library based on SVGs.
CopyrightWritten by David Himmelstrup
LicenseUnlicense
Maintainerlemmih@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Reanimate.GeoProjection

Description

This module provides functions for mapping the surface of a sphere on to a 2D plane. It also has convenience functions for loading GeoJSON data.

Synopsis

Documentation

data Projection Source #

Projections are named bi-directional mappings between a sphere and a 2D plane.

Constructors

Projection 

Fields

data XYCoord Source #

XY coordinates on a 2D plane. Valid ranges go from 0 to 1, inclusive.

Constructors

XYCoord !Double !Double 

Instances

Instances details
Eq XYCoord Source # 
Instance details

Defined in Reanimate.GeoProjection

Methods

(==) :: XYCoord -> XYCoord -> Bool #

(/=) :: XYCoord -> XYCoord -> Bool #

Ord XYCoord Source # 
Instance details

Defined in Reanimate.GeoProjection

Read XYCoord Source # 
Instance details

Defined in Reanimate.GeoProjection

Show XYCoord Source # 
Instance details

Defined in Reanimate.GeoProjection

data LonLat Source #

Longitude and latitude. Valid range for longitude is -pi to +pi. Valid range for latitude is -pi2 to +pi2.

Constructors

LonLat !Double !Double 

Instances

Instances details
Eq LonLat Source # 
Instance details

Defined in Reanimate.GeoProjection

Methods

(==) :: LonLat -> LonLat -> Bool #

(/=) :: LonLat -> LonLat -> Bool #

Ord LonLat Source # 
Instance details

Defined in Reanimate.GeoProjection

Read LonLat Source # 
Instance details

Defined in Reanimate.GeoProjection

Show LonLat Source # 
Instance details

Defined in Reanimate.GeoProjection

Hashable LonLat Source # 
Instance details

Defined in Reanimate.GeoProjection

Methods

hashWithSalt :: Int -> LonLat -> Int #

hash :: LonLat -> Int #

project :: Image PixelRGBA8 -> Projection -> Image PixelRGBA8 Source #

Apply on an image in equirectangular format. The source image therfore must have an aspect ratio of 2:1.

interpP :: Image PixelRGBA8 -> Projection -> Projection -> Double -> Image PixelRGBA8 Source #

Interpolate between two projections and apply the result to an image in equirectangular format. The source image must have an aspect ratio of 2:1.

interpBBP :: Image PixelRGBA8 -> Projection -> Projection -> (Double, Double, Double, Double) -> (Double, Double, Double, Double) -> Double -> Image PixelRGBA8 Source #

Interpolate between two projections and apply the result to an image in equirectangular format. The source image must have an aspect ratio of 2:1. Only the areas inside of the two bounding boxes (applying to the source and target projection, respectively) are mapped. Pixels outside of these bounding-boxes are undefined.

mergeP :: Projection -> Projection -> Double -> Projection Source #

Attempt to smoothly interpolate two projections. The result may not be continuous and interpP may give prettier results.

isValidP :: Projection -> Bool Source #

Returns True iff a projection is consistent and complete.

scaleP :: Double -> Double -> Projection -> Projection Source #

Scale X and Y axis of projection.

flipYAxisP :: Projection -> Projection Source #

Invert the Y axis of projection.

moveBottomP :: Double -> Projection -> Projection Source #

Translate the lower-most point of a projection by an offset.

moveTopP :: Double -> Projection -> Projection Source #

Translate the top-most point of a projection by an offset.

Projections

GeoJSON helpers

drawFeatureCollection :: GeoFeatureCollection a -> (a -> SVG -> SVG) -> SVG Source #

Map for all features and render the geometry.

loadFeatureCollection :: FromJSON a => FilePath -> (a -> SVG -> SVG) -> SVG Source #

Load GeoJSON from a filepath and render the geometry.

applyProjection :: Projection -> SVG -> SVG Source #

Apply a projection to an SVG image. This is a lossy transformation but the default tolerance is low enough that inaccuracies should not be visible.

applyProjection' :: Double -> Projection -> SVG -> SVG Source #

Apply a projection to an SVG image with a specified tolerance. Projections may turn straight lines into disjointed curves and the tolerance argument determined the accuracy of this transformation.

renderGeometry :: GeospatialGeometry -> SVG Source #

Render GeoJSON geometry as SVG.