void RainRadarUpdate_Tick(object sender, EventArgs e)
{
WebMercator w = new WebMercator();
//WebClient wc = new WebClient();
var topleft = new KmlPoint(-14.9515, 59.9934);
var bottomright = new KmlPoint(20.4106, 41.4389);
var fname = "http://www2.buienradar.nl/euradar/latlon_0.gif";//"rainradar.gif";
// File.Delete(fname);
// wc.DownloadFile("http://www2.buienradar.nl/euradar/latlon_0.gif", fname);
// var gwrap = new GdalWrapper();
// var f = gwrap.WarpImage(fname, topleft.Latitude, topleft.Longitude, bottomright.Latitude, bottomright.Longitude, 4326, 3857, 5000);
// fname = Directory.GetCurrentDirectory() + "\\" + f;
//var f = WarpImage(fname, topleft, bottomright, 4326, 3857, 5000);
var i = new Image
{
//Source = new BitmapImage(new Uri("file://" + fname)),
Source = new BitmapImage(new Uri(fname)),
IsHitTestVisible = false,
Stretch = Stretch.Fill
};
//<LatLonBox><north>59.9934</north><south>41.4389</south><east>20.4106</east><west>-14.9515</west></LatLonBox>
var mpa = new MapPoint(topleft.Longitude, topleft.Latitude);
var mpb = new MapPoint(bottomright.Longitude, bottomright.Latitude);
mpa = w.FromGeographic(mpa) as MapPoint;
mpb = w.FromGeographic(mpb) as MapPoint;
var envelope = new Envelope(mpa, mpb);
ElementLayer.SetEnvelope(i, envelope);
this.Children.Clear();
this.Children.Add(i);
if (Notifications)
{
AppStateSettings.Instance.TriggerNotification(new NotificationEventArgs()
{
Duration = new TimeSpan(0, 0, 0, 3),
Text = "Updated Rain Radar Image at"+ ":" + DateTime.Now
});
}
}