Package edu.ie3.datamodel.io.source.sql
Class SqlWeatherSource
java.lang.Object
edu.ie3.datamodel.io.source.sql.SqlDataSource<TimeBasedValue<WeatherValue>>
edu.ie3.datamodel.io.source.sql.SqlWeatherSource
- All Implemented Interfaces:
DataSource
,WeatherSource
public class SqlWeatherSource
extends SqlDataSource<TimeBasedValue<WeatherValue>>
implements WeatherSource
SQL source for weather data
-
Field Summary
Fields inherited from class edu.ie3.datamodel.io.source.sql.SqlDataSource
log
-
Constructor Summary
ConstructorDescriptionSqlWeatherSource
(SqlConnector connector, IdCoordinateSource idCoordinateSource, String schemaName, String weatherTableName, TimeBasedWeatherValueFactory weatherFactory) Initializes a new SqlWeatherSource -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<TimeBasedValue<WeatherValue>>
createEntity
(Map<String, String> fieldMap) Converts a field to value map into a TimeBasedValue, removes the "tid"Map<org.locationtech.jts.geom.Point,
IndividualTimeSeries<WeatherValue>> getWeather
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval) Return the weather for the given time intervalMap<org.locationtech.jts.geom.Point,
IndividualTimeSeries<WeatherValue>> getWeather
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, Collection<org.locationtech.jts.geom.Point> coordinates) Return the weather for the given time interval AND coordinatesgetWeather
(ZonedDateTime date, org.locationtech.jts.geom.Point coordinate) Return the weather for the given time date AND coordinateMethods inherited from class edu.ie3.datamodel.io.source.sql.SqlDataSource
createBaseQueryString, executeQuery, getDbColumnName, getDbTables
-
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 connectionidCoordinateSource
- a coordinate source to map ids to pointsschemaName
- the database schema to useweatherTableName
- the name of the table containing weather dataweatherFactory
- 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 interfaceWeatherSource
- 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 interfaceWeatherSource
- Parameters:
timeInterval
- Queried time intervalcoordinates
- 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 interfaceWeatherSource
- Parameters:
date
- Queried date timecoordinate
- Queried coordinate- Returns:
- weather data for the specified time and coordinate
-
createEntity
Converts a field to value map into a TimeBasedValue, removes the "tid"- Specified by:
createEntity
in classSqlDataSource<TimeBasedValue<WeatherValue>>
- Parameters:
fieldMap
- the field to value map for one TimeBasedValue- Returns:
- an Optional of that TimeBasedValue
-