/**
 * Map Generator Groovy weather sample
 */
package weather.data;

import idea.geographic.coordsys.orthogonal2d.CartesianGeoPosition;
import idea.map.data.AbstractDataValues;
import idea.map.data.DataValue;
import idea.map.generator.MapGenerator;

/**
 * Data values to visualize on the map - use airport air pressure (QNH)
 * 
 * @author Lumir Vanek, vanek@idea-envi.cz
 *
 */
class WeatherDataValues extends AbstractDataValues 
{
	/**
	 * Stored airports list
	 */
	private final List< Airport > airports;
	
	/**
	 * Constructor
	 * 
	 * @param airports Airports list with weather data
	 */
	public WeatherDataValues(List< Airport > airports)
	{
		super(null, null);
		this.airports = airports;
	}
	
	/**
	 * Initialize
	 * 
	 * @param mapGenerator The map generator
	 */
	public void initialize(final MapGenerator mapGenerator)
	{
		/**
		 * For each airport: extract weather data and create data value for Map Generator
		 */
		airports.each { Airport airport ->
			
				this.add new DataValueWithMetar(airport.icaoCode,
				(float) airport.weather.airPressure,
				mapGenerator.getCoordTransformation().transformWGS84ToCartesianGeoPos(airport.geoPosition).convertToCartesianGeoPosition(),
				airport.name,
				true,
				airport.weather.metarOrigin);
			}
	}
}