Class/Object

com.snowplowanalytics.weather.providers.openweather

OwmCacheClient

Related Docs: object OwmCacheClient | package openweather

Permalink

class OwmCacheClient extends Client[ValidatedWeather] with WeatherCache[History]

Blocking OpenWeatherMap client with history (only) cache Uses AsyncOwmClient under the hood, have same method set, which return Weather instead of Future[Weather]

WARNING. This client uses pro.openweathermap.org for data access, It will not work with free OWM licenses.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OwmCacheClient
  2. WeatherCache
  3. Client
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OwmCacheClient(cacheSize: Int, geoPrecision: Int, asyncClient: OwmAsyncClient, timeout: Int)

    Permalink

    cacheSize

    amount of history requests storing in cache it's better to store whole OWM packet (5000/50000/150000) plus some space for errors (~1%)

    geoPrecision

    nth part of 1 to which latitude and longitude will be rounded stored in cache. For eg. coordinate 45.678 will be rounded to values 46.0, 45.5, 45.7, 45.78 by geoPrecision 1,2,10,100 respectively geoPrecision 1 will give ~60km infelicity if worst case; 2 ~30km etc

    asyncClient

    instance of OwmAsyncClient which will do all underlying work

    timeout

    timeout in seconds after which active request will be considered failed

Type Members

  1. type Cache = SynchronizedLruMap[CacheKey, Either[WeatherError, History]]

    Permalink
    Definition Classes
    WeatherCache

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. val cache: Cache

    Permalink
    Attributes
    protected
    Definition Classes
    WeatherCache
  6. val cacheSize: Int

    Permalink

    amount of history requests storing in cache it's better to store whole OWM packet (5000/50000/150000) plus some space for errors (~1%)

    amount of history requests storing in cache it's better to store whole OWM packet (5000/50000/150000) plus some space for errors (~1%)

    Definition Classes
    OwmCacheClientWeatherCache
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def currentByCoords(lat: Float, lon: Float): ValidatedWeather[Current]

    Permalink

    Get current weather data by city coordinates Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_weather#2-By-geographic-coordinate

    Get current weather data by city coordinates Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_weather#2-By-geographic-coordinate

    lat

    latitude

    lon

    longitude

    returns

    either error or current weather wrapped in Response

    Definition Classes
    Client
  9. def currentById(id: Int): ValidatedWeather[Current]

    Permalink

    Get current weather data by city id Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_weather#3-By-city-ID

    Get current weather data by city id Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_weather#3-By-city-ID

    id

    id of the city

    returns

    either error or current weather wrapped in Response

    Definition Classes
    Client
  10. def currentByName(name: String, country: OptArg[String], cnt: OptArg[Int] = None): ValidatedWeather[Current]

    Permalink

    Get 5 day/3 hour forecast data by city name Docs: http://openweathermap.org/forecast#5days

    Get 5 day/3 hour forecast data by city name Docs: http://openweathermap.org/forecast#5days

    name

    name of the city

    country

    optional two-letter code

    cnt

    count of returned data

    returns

    either error or forecast wrapped in Response

    Definition Classes
    Client
  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def eventToCacheKey(timestamp: Timestamp, position: Position): CacheKey

    Permalink

    Round position and timestamp (event) to produce cache key

    Round position and timestamp (event) to produce cache key

    timestamp

    timestamp in seconds

    position

    latitude & longitude

    returns

    cache key

    Definition Classes
    WeatherCache
  14. def extractWeather[W](response: JValue)(implicit arg0: Manifest[W]): Either[WeatherError, W]

    Permalink

    Transform JSON into parseable format and try to extract specified response

    Transform JSON into parseable format and try to extract specified response

    W

    specific response case class from com.snowplowanalytics.weather.providers.openweather.Responses

    response

    either of previous or JSON

    returns

    either error string or response case class

    Attributes
    protected[com.snowplowanalytics.weather.providers.openweather]
    Definition Classes
    Client
  15. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def forecastByCoords(lat: Float, lon: Float, cnt: OptArg[Int] = None): ValidatedWeather[Weather]

    Permalink

    Get forecast data for coordinates

    Get forecast data for coordinates

    lat

    latitude

    lon

    longitude

    returns

    either error or forecast wrapped in Response

    Definition Classes
    Client
  17. def forecastById(id: Int, cnt: OptArg[Int] = None): ValidatedWeather[Forecast]

    Permalink

    Get forecast data by city id Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_forecast#Get-forecast-by-city-id

    Get forecast data by city id Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_forecast#Get-forecast-by-city-id

    id

    id of the city

    returns

    either error or forecast wrapped in Response

    Definition Classes
    Client
  18. def forecastByName(name: String, country: OptArg[String], cnt: OptArg[Int] = None): ValidatedWeather[Forecast]

    Permalink

    Get 5 day/3 hour forecast data by city name Docs: http://openweathermap.org/forecast#5days

    Get 5 day/3 hour forecast data by city name Docs: http://openweathermap.org/forecast#5days

    name

    name of the city

    country

    optional two-letter code

    cnt

    count of returned data

    returns

    either error or forecast wrapped in Response

    Definition Classes
    Client
  19. val geoPrecision: Int

    Permalink

    nth part of 1 to which latitude and longitude will be rounded stored in cache.

    nth part of 1 to which latitude and longitude will be rounded stored in cache. For eg. coordinate 45.678 will be rounded to values 46.0, 45.5, 45.7, 45.78 by geoPrecision 1,2,10,100 respectively geoPrecision 1 will give ~60km infelicity if worst case; 2 ~30km etc

    Definition Classes
    OwmCacheClientWeatherCache
  20. def getCachedOrRequest(latitude: Float, longitude: Float, timestamp: DateTime): Either[WeatherError, Weather]

    Permalink

    Overloaded getCachedOrRequest method with Joda DateTime instead of Unix epoch timestamp

  21. def getCachedOrRequest(latitude: Float, longitude: Float, timestamp: Int): Either[WeatherError, Weather]

    Permalink

    Search history in cache and if not found request and await it from server and put to the cache.

    Search history in cache and if not found request and await it from server and put to the cache. If timeout error was taken from cache, do request again

    latitude

    event's latitude

    longitude

    event's longitude

    timestamp

    event's timestamp

    returns

    weather stamp immediately taken from cache or requested from server

  22. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  23. def getStartOfDay(timestamp: Timestamp): Day

    Permalink

    Get timestamp for beginning of the day

    Get timestamp for beginning of the day

    timestamp

    event's timestamp

    returns

    timestamp for beginning of day of this event

    Definition Classes
    WeatherCache
  24. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  25. def historyByCoords(lat: Float, lon: Float, start: OptArg[Int] = None, end: OptArg[Int] = None, cnt: OptArg[Int] = None, measure: OptArg[Api.Measures.Value] = None): ValidatedWeather[History]

    Permalink

    Get historical data by city name Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_history#By-city-name

    Get historical data by city name Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_history#By-city-name

    lat

    lattitude

    lon

    longitude

    start

    start (unix time, UTC)

    end

    end (unix time, UTC)

    cnt

    count of returned data

    measure

    one of predefined Api.Measures to constrain accuracy

    returns

    either error or history wrapped in Response

    Definition Classes
    Client
  26. def historyById(id: Int, start: OptArg[Int] = None, end: OptArg[Int] = None, cnt: OptArg[Int] = None, measure: OptArg[Api.Measures.Value] = None): ValidatedWeather[History]

    Permalink

    Get historical data by city id Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_history#By-city-id

    Get historical data by city id Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_history#By-city-id

    id

    id of the city

    start

    start (unix time, UTC)

    end

    end (unix time, UTC)

    cnt

    count of returned data

    measure

    one of predefined Api.Measures to constrain accuracy

    returns

    either error or history wrapped in Response

    Definition Classes
    Client
  27. def historyByName(name: String, country: OptArg[String] = None, start: OptArg[Int] = None, end: OptArg[Int] = None, cnt: OptArg[Int] = None, measure: OptArg[Api.Measures.Value] = None): ValidatedWeather[History]

    Permalink

    Get historical data by city name Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_history#By-city-name

    Get historical data by city name Docs: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_history#By-city-name

    name

    name of the city

    country

    optional two-letter code

    start

    start (unix time, UTC)

    end

    end (unix time, UTC)

    cnt

    count of returned data

    measure

    one of predefined Api.Measures to constrain accuracy

    returns

    either error or history wrapped in Response

    Definition Classes
    Client
  28. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  29. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. def receive[W <: OwmResponse](request: OwmRequest)(implicit arg0: Manifest[W]): Either[WeatherError, W]

    Permalink

    Main client logic for Request => Response function, where Response is wrappeed in tparam Response

    Main client logic for Request => Response function, where Response is wrappeed in tparam Response

    W

    type of weather response to extract

    returns

    extracted either error or weather

    Definition Classes
    OwmCacheClientClient
  33. def roundCoordinate(coordinate: Float): Float

    Permalink

    Round coordinate by geoPrecision Scale value to tenths to prevent values to be long like 1.333334

    Round coordinate by geoPrecision Scale value to tenths to prevent values to be long like 1.333334

    coordinate

    latitude or longitude

    returns

    rounded coordinate

    Definition Classes
    WeatherCache
  34. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  35. val timeout: Int

    Permalink

    timeout in seconds after which active request will be considered failed

  36. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from WeatherCache[History]

Inherited from Client[ValidatedWeather]

Inherited from AnyRef

Inherited from Any

Ungrouped