GeocoderOpenCage-0.1: Geocoder and Reverse Geocoding Service Wrapper

CopyrightLicense : GPL-3
Maintainerhahn@geoinfo.tuwien.ac.at
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Geocoder

Description

Requests the http://geocoder.opencagedata.com geocoding service to get latitude and longitude values from an address. Uses Aeson to convert the response from JSON to Haskell types.

Synopsis

Documentation

data QueryParameters Source

data type including all possible parameters OpenCage API offers

Constructors

QueryParameters 

Fields

para_q :: Text

Text to query

para_key :: Text

OpenCage key

para_language :: Maybe Text

language for the result: IETF format language code

para_pretty :: Maybe Text

should the result be pretty printed ?

para_bounds :: Maybe Text

rectangle hint: southwest corner, northeast corner

para_country :: Maybe Text

country hint: ISO 3166-1 Alpha 3

para_fields :: Maybe Text

comma separated list

defaultParams :: QueryParameters Source

minimal example of QueryParameters can be used to create your own parameters

getAPIResponse Source

Arguments

:: TokenToGeocode

token to geocode

-> GeoCageDeveloperKey

OpenCage key

-> IO (Maybe ResponseBody)

if the geocoding was successful there is a ResultBody full of data returned

Minimalistic version to geocode a token returning the whole Response

getAPIResponseWith Source

Arguments

:: QueryParameters

parameters included into the request

-> IO (Maybe ResponseBody)

if the geocoding was successful there is a ResultBody full of data returned

main geocode function, called by all other functions, deals with errors

geocode Source

Arguments

:: TokenToGeocode

token to geocode, empty if an error occured

-> GeoCageDeveloperKey

OpenCage key

-> IO [Result]

list of results

geocodes the token and returns a list of results

geocodeWith Source

Arguments

:: QueryParameters

parameters included into the request

-> IO [Result]

list of results, empty if an error occured

geocodes the token included into the QueryParameters respecting all values set in the QueryParameters returns an empty list if an exception occured or the result was empty

geocodeGeoTokensList Source

Arguments

:: [TokenToGeocode]

list of tokens to geocode

-> GeoCageDeveloperKey

OpenCage key

-> IO ()

prints the result

geocodes a list of tokens and prints the results

createGeocoderParams Source

Arguments

:: QueryParameters

parameters that should be used for all tokens in the list

-> [TokenToGeocode]

list of tokens to geocode

-> [QueryParameters]

list of parameters, for every token one QueryParameter entry is included

packs tokens into QueryParameters and returns this as a list if you want to specify your own parameters use this function

data ResponseBody Source

data type respecting OpenCage response encoded as JSON

data License Source

Constructors

License 

Fields

name :: Text
 
url :: Text
 

data Rate Source

Constructors

Rate 

Instances

data Status Source

Constructors

Status 

Fields

code :: Integer
 
message :: Text
 

data Components Source

Constructors

Components 

Fields

country :: Text
 
country_code :: Text
 
county :: Text
 
state :: Text
 
city :: Text
 
road :: Text
 

Instances

Show Components 
Generic Components 
FromJSON Components

not all components are included into the response, if so there is an empty string as default value

type Rep Components 

data Location Source

Constructors

Location 

Fields

lat :: Double
 
lng :: Double