123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- using System.Net;
- using Newtonsoft.Json.Linq;
- namespace SimulationCommon;
- public class Text_readNC
- {
- public NCread windNCread = new NCread();
- public int times;
- public int latitudes;
- public int longitudes;
- public int times1;
- public int latitudes1;
- public int longitudes1;
- public int times2;
- public int latitudes2;
- public int longitudes2;
- public int times3;
- public int latitudes3;
- public int longitudes3;
- public int times4;
- public int latitudes4;
- public int longitudes4;
- public double initlatitudes;
- public double initlongitudes;
- public bool GetNCData()
- {
-
-
- string url1 = $"{Util.baseURl}rescue-platform-service/api/v1/dem/getNcInfos?ncPath=D:/data/haiyang/2023_u10_v10_temp.nc&varName=v10¢erLon=" + initlongitudes.ToString() + "¢erLat=" + initlatitudes.ToString();
-
- HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url1);
- request1.Method = "GET";
-
- using (HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse())
- {
- using (StreamReader reader1 = new StreamReader(response1.GetResponseStream()))
- {
- string result1 = reader1.ReadToEnd();
-
-
- JObject resultObject1 = JObject.Parse(result1);
-
- JArray dataArray1 = (JArray)resultObject1["data"];
- if (dataArray1 == null)
- return false;
-
- times = dataArray1.Count;
- latitudes = ((JArray)dataArray1[0]).Count;
- longitudes = ((JArray)dataArray1[0][0]).Count;
-
- float[][][] v10Array = new float[times][][];
-
- for (int t = 0; t < times; t++)
- {
- v10Array[t] = new float[latitudes][];
- for (int lat = 0; lat < latitudes; lat++)
- {
- v10Array[t][lat] = new float[longitudes];
- for (int lon = 0; lon < longitudes; lon++)
- {
- v10Array[t][lat][lon] = (float)dataArray1[t][lat][lon];
- }
- }
- }
- JArray lonArray = (JArray)resultObject1["data_lon"];
- JArray lanArray = (JArray)resultObject1["data_lat"];
-
- int lons = lonArray.Count;
- int lans = lanArray.Count;
-
- float[] longitudeArray = new float[lons];
- float[] latitudeArray = new float[lans];
-
- for (int i = 0; i < lons; i++)
- {
- longitudeArray[i] = (float)lonArray[i];
- }
- for (int j = 0; j < lans; j++)
- {
- latitudeArray[j] = (float)lanArray[j];
- }
-
- windNCread.latitudeArray = latitudeArray;
- windNCread.longitudeArray = longitudeArray;
- windNCread.v10Array = v10Array;
-
-
- }
- }
- string url2 = $"{Util.baseURl}rescue-platform-service/api/v1/dem/getNcInfos?ncPath=D:/data/haiyang/2023_u10_v10_temp.nc&varName=u10¢erLon=" + initlongitudes + "¢erLat=" + initlatitudes;
-
- HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(url2);
- request1.Method = "GET";
-
- using (HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse())
- {
- using (StreamReader reader2 = new StreamReader(response2.GetResponseStream()))
- {
- string result2 = reader2.ReadToEnd();
-
-
- JObject resultObject2 = JObject.Parse(result2);
-
- JArray dataArray2 = (JArray)resultObject2["data"];
- if (dataArray2 == null)
- return false;
-
- times1 = dataArray2.Count;
- latitudes1 = ((JArray)dataArray2[0]).Count;
- longitudes1 = ((JArray)dataArray2[0][0]).Count;
-
- float[][][] u10Array = new float[times1][][];
-
- for (int t = 0; t < times1; t++)
- {
- u10Array[t] = new float[latitudes1][];
- for (int lat = 0; lat < latitudes1; lat++)
- {
- u10Array[t][lat] = new float[longitudes1];
- for (int lon = 0; lon < longitudes1; lon++)
- {
- u10Array[t][lat][lon] = (float)dataArray2[t][lat][lon];
- }
- }
- }
- windNCread.u10Array = u10Array;
- }
- }
- string url3 = $"{Util.baseURl}rescue-platform-service/api/v1/dem/getNcInfos?ncPath=D:/data/haiyang/2023_mwd_currentV_waveHeight.nc&varName=p140208¢erLon=" + initlongitudes + "¢erLat=" + initlatitudes;
-
- HttpWebRequest request3 = (HttpWebRequest)WebRequest.Create(url3);
- request1.Method = "GET";
-
- using (HttpWebResponse response3 = (HttpWebResponse)request3.GetResponse())
- {
- using (StreamReader reader3 = new StreamReader(response3.GetResponseStream()))
- {
- string result3 = reader3.ReadToEnd();
-
-
- JObject resultObject3 = JObject.Parse(result3);
-
- JArray dataArray3 = (JArray)resultObject3["data"];
- if (dataArray3 == null)
- return false;
-
- times2 = dataArray3.Count;
- latitudes2 = ((JArray)dataArray3[0]).Count;
- longitudes2 = ((JArray)dataArray3[0][0]).Count;
-
- float[][][] p140208Array = new float[times2][][];
-
- for (int t = 0; t < times2; t++)
- {
- p140208Array[t] = new float[latitudes2][];
- for (int lat = 0; lat < latitudes2; lat++)
- {
- p140208Array[t][lat] = new float[longitudes2];
- for (int lon = 0; lon < longitudes2; lon++)
- {
- p140208Array[t][lat][lon] = (float)dataArray3[t][lat][lon];
- }
- }
- }
- windNCread.p140208Array = p140208Array;
- }
- }
- string url4 = $"{Util.baseURl}rescue-platform-service/api/v1/dem/getNcInfos?ncPath=D:/data/haiyang/2023_mwd_currentV_waveHeight.nc&varName=mwd¢erLon=" + initlongitudes + "¢erLat=" + initlatitudes;
-
- HttpWebRequest request4 = (HttpWebRequest)WebRequest.Create(url4);
- request1.Method = "GET";
-
- using (HttpWebResponse response4 = (HttpWebResponse)request4.GetResponse())
- {
- using (StreamReader reader4 = new StreamReader(response4.GetResponseStream()))
- {
- string result4 = reader4.ReadToEnd();
-
-
- JObject resultObject4 = JObject.Parse(result4);
-
- JArray dataArray4 = (JArray)resultObject4["data"];
- if (dataArray4 == null)
- return false;
-
- times3 = dataArray4.Count;
- latitudes3 = ((JArray)dataArray4[0]).Count;
- longitudes3 = ((JArray)dataArray4[0][0]).Count;
-
- float[][][] mwdArray = new float[times3][][];
-
- for (int t = 0; t < times3; t++)
- {
- mwdArray[t] = new float[latitudes3][];
- for (int lat = 0; lat < latitudes3; lat++)
- {
- mwdArray[t][lat] = new float[longitudes3];
- for (int lon = 0; lon < longitudes3; lon++)
- {
- mwdArray[t][lat][lon] = (float)dataArray4[t][lat][lon];
- }
- }
- }
- windNCread.mwdArray = mwdArray;
- }
- }
- return true;
- }
- public bool GetWaveHighData()
- {
-
- string url1 = $"{Util.baseURl}rescue-platform-service/api/v1/dem/getNcInfos?ncPath=D:/data/haiyang/2023_mwd_currentV_waveHeight.nc&varName=hmax¢erLon=" + initlongitudes + "¢erLat=" + initlatitudes;
-
- HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url1);
- request1.Method = "GET";
-
- using (HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse())
- {
- using (StreamReader reader1 = new StreamReader(response1.GetResponseStream()))
- {
- string result1 = reader1.ReadToEnd();
-
-
- JObject resultObject1 = JObject.Parse(result1);
-
- JArray dataArray1 = (JArray)resultObject1["data"];
- if (dataArray1 == null)
- return false;
-
- times4 = dataArray1.Count;
- latitudes4 = ((JArray)dataArray1[0]).Count;
- longitudes4 = ((JArray)dataArray1[0][0]).Count;
-
- float[][][] hmaxArray = new float[times4][][];
- for (int t = 0; t < times4; t++)
- {
- hmaxArray[t] = new float[latitudes4][];
- for (int lat = 0; lat < latitudes4; lat++)
- {
- hmaxArray[t][lat] = new float[longitudes4];
- for (int lon = 0; lon < longitudes4; lon++)
- {
- hmaxArray[t][lat][lon] = (float)dataArray1[t][lat][lon];
- }
- }
- }
- JArray lonArray = (JArray)resultObject1["data_lon"];
- JArray lanArray = (JArray)resultObject1["data_lat"];
-
- int lons = lonArray.Count;
- int lans = lanArray.Count;
-
- float[] longitudeArray = new float[lons];
- float[] latitudeArray = new float[lans];
-
- for (int i = 0; i < lons; i++)
- {
- longitudeArray[i] = (float)lonArray[i];
- }
- for (int j = 0; j < lans; j++)
- {
- latitudeArray[j] = (float)lanArray[j];
- }
- windNCread.hmaxArray = hmaxArray;
-
- }
- }
- return true;
- }
- }
|