Class SqlWeatherSource

All Implemented Interfaces:
DataSource, WeatherSource

public class SqlWeatherSource extends SqlDataSource<TimeBasedValue<WeatherValue>> implements WeatherSource
SQL source for weather data
  • Constructor Details

    • SqlWeatherSource

      public SqlWeatherSource(SqlConnector connector, IdCoordinateSource idCoordinateSource, String schemaName, String weatherTableName, TimeBasedWeatherValueFactory weatherFactory)
      Initializes a new SqlWeatherSource
      Parameters:
      connector - the connector needed for database connection
      idCoordinateSource - a coordinate source to map ids to points
      schemaName - the database schema to use
      weatherTableName - the name of the table containing weather data
      weatherFactory - instance of a time based weather value factory
  • Method Details

    • getWeather

      public Map<org.locationtech.jts.geom.Point,IndividualTimeSeries<WeatherValue>> getWeather(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval)
      Description copied from interface: WeatherSource
      Return the weather for the given time interval
      Specified by:
      getWeather in interface WeatherSource
      Parameters:
      timeInterval - Queried time interval
      Returns:
      weather data for the specified time range, sorted by coordinate
    • getWeather

      public Map<org.locationtech.jts.geom.Point,IndividualTimeSeries<WeatherValue>> getWeather(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, Collection<org.locationtech.jts.geom.Point> coordinates)
      Description copied from interface: WeatherSource
      Return the weather for the given time interval AND coordinates
      Specified by:
      getWeather in interface WeatherSource
      Parameters:
      timeInterval - Queried time interval
      coordinates - Queried coordinates
      Returns:
      weather data for the specified time range and coordinates, sorted by coordinate
    • getWeather

      public Optional<TimeBasedValue<WeatherValue>> getWeather(ZonedDateTime date, org.locationtech.jts.geom.Point coordinate)
      Description copied from interface: WeatherSource
      Return the weather for the given time date AND coordinate
      Specified by:
      getWeather in interface WeatherSource
      Parameters:
      date - Queried date time
      coordinate - Queried coordinate
      Returns:
      weather data for the specified time and coordinate
    • createEntity

      protected Optional<TimeBasedValue<WeatherValue>> createEntity(Map<String,String> fieldMap)
      Converts a field to value map into a TimeBasedValue, removes the "tid"
      Specified by:
      createEntity in class SqlDataSource<TimeBasedValue<WeatherValue>>
      Parameters:
      fieldMap - the field to value map for one TimeBasedValue
      Returns:
      an Optional of that TimeBasedValue