jord-2.0.0.0: Geographical Position Calculations

Copyright(c) 2020 Cedric Liegeois
LicenseBSD3
MaintainerCedric Liegeois <ofmooseandmen@yahoo.fr>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.Geo.Jord.Polygon

Contents

Description

Types and functions for working with polygons at the surface of a spherical celestial body.

In order to use this module you should start with the following imports:

import qualified Data.Geo.Jord.Geodetic as Geodetic
import qualified Data.Geo.Jord.Polygon as Polygon
Synopsis

The Polygon type

data Polygon a Source #

A polygon whose vertices are horizontal geodetic positions.

Instances
Model a => Eq (Polygon a) Source # 
Instance details

Defined in Data.Geo.Jord.Polygon

Methods

(==) :: Polygon a -> Polygon a -> Bool #

(/=) :: Polygon a -> Polygon a -> Bool #

Spherical a => Show (Polygon a) Source # 
Instance details

Defined in Data.Geo.Jord.Polygon

Methods

showsPrec :: Int -> Polygon a -> ShowS #

show :: Polygon a -> String #

showList :: [Polygon a] -> ShowS #

vertices :: Polygon a -> [HorizontalPosition a] Source #

vertices of the polygon in clockwise order.

edges :: Polygon a -> [MinorArc a] Source #

edges of the polyon in clockwise order.

concave :: Polygon a -> Bool Source #

whether the polygon is concave.

smart constructors

data Error Source #

Error returned when attempting to create a polygon from invalid data.

Constructors

NotEnoughVertices

less than 3 vertices were supplied.

InvalidEdge

2 consecutives vertices are antipodal or equal.

InvalidRadius

radius of circle or arc is <= 0.

EmptyArcRange

arc start angle == end angle.

SeflIntersectingEdge

2 edges of the polygon intersect.

Instances
Eq Error Source # 
Instance details

Defined in Data.Geo.Jord.Polygon

Methods

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

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

Show Error Source # 
Instance details

Defined in Data.Geo.Jord.Polygon

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

simple :: Spherical a => [HorizontalPosition a] -> Either Error (Polygon a) Source #

Simple polygon (outer ring only and not self-intersecting) from given vertices. Returns an error (Left) if:

  • less than 3 vertices are given.
  • the given vertices defines self-intersecting edges.
  • the given vertices contains duplicated positions or antipodal positions.

circle :: Spherical a => HorizontalPosition a -> Length -> Int -> Either Error (Polygon a) Source #

Circle from given centre and radius. The resulting polygon contains nb vertices equally distant from one another. Returns an error (Left) if:

  • given radius is 0
  • given number of positions is less than 3

arc :: Spherical a => HorizontalPosition a -> Length -> Angle -> Angle -> Int -> Either Error (Polygon a) Source #

Arc from given centre, radius and given start/end angles. The resulting polygon contains nb vertices equally distant from one another. Returns an error (Left) if:

  • given radius is 0
  • given number of positions is less than 3
  • difference between start and end angle is 0

calculations

contains :: Spherical a => Polygon a -> HorizontalPosition a -> Bool Source #

contains poly p returns True if position p is enclosed by the vertices of polygon poly - see enclosedBy.

triangulate :: Spherical a => Polygon a -> [Triangle a] Source #

Triangulates the given polygon using the ear clipping method.

May return an empty list if the algorithm fails to find an ear (which probably indicates a bug in the implementation).