geo-resolver-0.1.0.1: Performs geo location lookups and parses the results

Copyright(c) 2015, Markenwerk, Jan Greve
LicenseMIT
Maintainerjg@markenwerk.net
Safe HaskellNone
LanguageHaskell2010

Network.Google.GeoResolver.Parser

Contents

Description

 

Synopsis

Data type definition for parsed types

data Status Source

Represents the status of the operation returned by google. Constructors represent possible String values according to googles documentation.

data GoogleAnswer r Source

Represents the answer google returned.

Constructors

GoogleAnswer 

Fields

status :: Status

The Status returned by google.

errorMessage :: Maybe String

An optional error message.

results :: Maybe [r]

Optional list of actual GoogleResult values.

data GoogleResult Source

A single Result from the list of results from google.

Constructors

GoogleResult 

Fields

addressComponents :: [Component]

List of Component values for this result

formattedAddress :: String

The formatted address google returned

geometry :: Geometry

The Geometry value for this result

placeId :: String

The google places ID for this result

types :: [String]

Some list of strings. Goole says:

The types[] array indicates the type of the returned result. This array contains a set of zero or more tags identifying the type of feature returned in the result. For example, a geocode of Chicago returns "locality" which indicates that Chicago is a city, and also returns "political" which indicates it is a political entity.

partialMatch :: Maybe Bool

If present, hinting that this result only partially matches the requested entity.

data Component Source

A part of the address in a GoogleResult

Constructors

Component 

Fields

longName :: String

A long name for the component

shortName :: String

A short name for the component

cTypes :: [String]

indicating the type of the address component.

data Geometry Source

Holds geometry information about a GoogleResult

Constructors

Geometry 

Fields

location :: Location

The result's location

locationType :: String

The kind of location. As of 20151007, the following values are to be expected. For future compatibility, no Enum type is introduced to map this.

  • ROOFTOP indicates that the returned result is a precise geocode for which we have location information accurate down to street address precision.
  • RANGE_INTERPOLATED indicates that the returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.
  • GEOMETRIC_CENTER indicates that the returned result is the geometric center of a result such as a polyline (for example, a street) or polygon (region).
  • APPROXIMATE indicates that the returned result is approximate.
viewport :: GoogleBoundingBox

contains the recommended viewport for displaying the returned result. Generally the viewport is used to frame a result when displaying it to a user.

bounds :: Maybe GoogleBoundingBox

If viewport is not applicable, bounds contain a more sensible bounding box.

data GoogleBoundingBox Source

A Bounding box for a location.

Constructors

GoogleBoundingBox 

Fields

northeast :: Location

The north east location of the bounding box

southwest :: Location

The south west location of the bounding box

data Location Source

Abstraction of a geo location

Constructors

Location 

Fields

latitude :: Double

Latitude of the location

longitude :: Double

Longitude of the location

parsing

parseAnswer :: ByteString -> Either String (GoogleAnswer GoogleResult) Source

Parses a Lazy ByteString into a GoogleAnswer or returns an error describing the problem.

convenience functions

getLocation :: GoogleAnswer GoogleResult -> Either String (Double, Double) Source

Gets the location from a GoogleAnswer, or returns an error.

getAddress :: GoogleAnswer GoogleResult -> Either String String Source

Gets the formatted address from a GoogleAnswer (or an error)

getProperty Source

Arguments

:: GoogleAnswer r

The answer to process.

-> (r -> a)

The function to be applied to the first (if any) result.

-> Either String a

Error or result of the function application

Takes a GoogleAnswer and applies the function to the first GoogleResult. Returns a Left with an error description if anything unexpected happens.

For example, getLocation uses this with ((latitude &&& longitude) . location . geometry)

Typeclasses