using System; using System.Drawing; using System.IO; using System.Net; using System.Windows.Forms; using BwnMatLabTest.Bwn; namespace BwnMatLabTest { public partial class Form1 : Form { private BwnFunctionsWrapperSoapClient soapClient; private void Form1Load(object sender, EventArgs e) { soapClient = new BwnFunctionsWrapperSoapClient(); } public Form1() { InitializeComponent(); } private void Button1Click(object sender, EventArgs e) { const string ncFile = "http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/waterbase/sea_surface_height/id54-J6.nc"; const string ncVariable = "sea_surface_height"; var centre = new[] {53.22917, 5.154906}; var vertex = new[] {53.15018 , 5.120844}; var imageName = soapClient.InterpolateToLine(ncFile, ncVariable, centre[0], centre[1], vertex[0], vertex[1]); pictureBox1.Image = LoadPicture("http://" + soapClient.Endpoint.Address.Uri.Authority + imageName); } private void Button2Click(object sender, EventArgs e) { const string ncFile = "http://dtvirt5.deltares.nl:8080/thredds/dodsC/opendap/knmi/etmgeg/etmgeg_344.nc"; const string ncVariable = "wind_speed_mean"; const string startDay = "01/01/2010"; const string startTime = "00:00:00"; const string stopDay = "08/01/2010"; const string stopTime = "00:00:00"; var imageName = soapClient.PlotTimeSeries(ncFile, ncVariable,startDay,startTime,stopDay,stopTime); pictureBox1.Image = LoadPicture("http://" + soapClient.Endpoint.Address.Uri.Authority + imageName); } private void Button3Click(object sender, EventArgs e) { const string startTime = "00:00:00"; const string stopTime = "00:00:00"; const string startDay = "11/01/2009"; const string stopDay = "12/12/2009"; const int lon = 52; const double lat = 3.5; var imageName = soapClient.WaveTransformationTable(lon, lat, startDay, startTime, stopDay, stopTime); pictureBox1.Image = LoadPicture("http://" + soapClient.Endpoint.Address.Uri.Authority + imageName[1]); } private static Bitmap LoadPicture(string url) { HttpWebRequest wreq; Stream mystream = null; HttpWebResponse wresp = null; try { wreq = (HttpWebRequest) WebRequest.Create(url); wreq.AllowWriteStreamBuffering = true; wresp = (HttpWebResponse) wreq.GetResponse(); if ((mystream = wresp.GetResponseStream()) != null) return new Bitmap(mystream); } finally { if (mystream != null) mystream.Close(); if (wresp != null) wresp.Close(); } return null; } } }