-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple reverse geocoding using OpenStreeMap -- @package reverse-geocoding @version 0.2.1 module Data.Geolocation.Reverse.Types -- | Input types -- -- Latitude : newtype over double newtype Latitude Latitude :: (Maybe Double) -> Latitude -- | Longitude : newtype over double newtype Longitude Longitude :: (Maybe Double) -> Longitude -- | Output types newtype City City :: Text -> City getCity :: City -> Text newtype Suburb Suburb :: Text -> Suburb getSuburb :: Suburb -> Text newtype Street Street :: Text -> Street getStreet :: Street -> Text newtype Postcode Postcode :: Text -> Postcode getPostcode :: Postcode -> Text -- | Parsed Location Info: Country code and city are mandatory, all other -- info is optional data ParsedLocationInfo ParsedLocationInfo :: CountryCode -> City -> Maybe Suburb -> Maybe Street -> Maybe Postcode -> ParsedLocationInfo parsedCountry :: ParsedLocationInfo -> CountryCode parsedCity :: ParsedLocationInfo -> City parsedSuburb :: ParsedLocationInfo -> Maybe Suburb parsedStreet :: ParsedLocationInfo -> Maybe Street parsedPostCode :: ParsedLocationInfo -> Maybe Postcode instance Eq Latitude instance Ord Latitude instance Show Latitude instance Read Latitude instance FromJSON Latitude instance ToJSON Latitude instance Eq Longitude instance Ord Longitude instance Show Longitude instance Read Longitude instance FromJSON Longitude instance ToJSON Longitude instance Eq City instance Ord City instance Show City instance Read City instance FromJSON City instance ToJSON City instance Eq Suburb instance Ord Suburb instance Show Suburb instance Read Suburb instance FromJSON Suburb instance ToJSON Suburb instance Eq Street instance Ord Street instance Show Street instance Read Street instance FromJSON Street instance ToJSON Street instance Eq Postcode instance Ord Postcode instance Show Postcode instance Read Postcode instance FromJSON Postcode instance ToJSON Postcode instance Eq ParsedLocationInfo instance Ord ParsedLocationInfo instance Show ParsedLocationInfo instance FromJSON CountryCode instance ToJSON CountryCode -- | Here we define providers for the Reverse Geocoding feature, namely how -- to format the url, the key under which the results are returned, and -- how to parse the retrived data. -- -- Currently only Open Stree Map is provided, feel free to add others. module Data.Geolocation.Reverse.Providers type ReverseGeoJsonKey = Text type ReverseGeoParser = Object -> Parser ParsedLocationInfo type ReverseGeoProvider = (ReverseGeoJsonKey, ReverseGeoUrl, ReverseGeoParser) openStreetMap :: ReverseGeoProvider -- | This very simple module returns a Maybe Location info for a set of -- coordinates. -- -- Right now only one provider is given (OpenStreeMap), please feel free -- to add more. -- -- We use this for a very coarse geographic categorization, so the -- following equivalences hold: -- -- City : city <|> village <|> town <|> hamlet -- <|> county -- -- Suburb: suburb <|> hamlet <|> postcode <|> town -- -- Street: road <|> street -- -- All contribuitions are welcomed! module Data.Geolocation.Reverse -- | Default reverse geo provider defaultReverseGeoProvider :: ReverseGeoProvider -- | Given a Latitude and Longitude, return a Location Info. getLocationInfo :: Latitude -> Longitude -> ReverseGeoProvider -> IO (Maybe ParsedLocationInfo) -- | Get location info from default provider (right now Open Stree Map) getLocationInfoDef :: Latitude -> Longitude -> IO (Maybe ParsedLocationInfo)