|
@@ -26,12 +26,12 @@ public class Current
|
|
|
|
|
|
public class NCread
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//各数组来源文件'Text_readNC.cs';时间范围:2024-06-04T00:00:00 ... 2024-06-04T23:00:00;
|
|
|
//地点范围:落水点为中心100公里
|
|
|
public float[] longitudeArray = new float[10];//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
public float[] latitudeArray = new float[7];//纬度一维数组来源自文件'Text_readNC.cs'
|
|
|
- public float[][][] u10Array ;//风的10米U(向东)分量三维数组来源自文件'Text_readNC.cs'
|
|
|
+ public float[][][] u10Array;//风的10米U(向东)分量三维数组来源自文件'Text_readNC.cs'
|
|
|
public float[][][] v10Array;//风的10米V(向北)分量三维数组来源自文件'Text_readNC.cs'
|
|
|
public float[][][] p140208Array;//海洋上空的自由对流速度三维数组来源自文件'Text_readNC.cs'
|
|
|
public float[][][] mwdArray;//平均波向(单位:度;0度表示北方,90度表示东方)三维数组来源自文件'Text_readNC.cs'
|
|
@@ -52,15 +52,15 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
// 交付类方法
|
|
|
- public static List<double[]> GetDrift(NCread nCread,double[] initialPosition, double dt, double totalTime)
|
|
|
+ public static List<double[]> GetDrift(NCread nCread, double[] initialPosition, double dt, double totalTime, int times, int latitudes, int longitudes, int days, int hour, double initlatitudes, double initlongitudes)
|
|
|
{
|
|
|
// run 获取轨迹的函数
|
|
|
// initialPosition --> 初始位置; dt --> 时间步长; totalTime --> 总时长
|
|
|
- List<double[]> trajectory = CalculateDriftTrajectory(nCread,initialPosition, dt, totalTime);
|
|
|
+ List<double[]> trajectory = CalculateDriftTrajectory(nCread, initialPosition, dt, totalTime, times, latitudes, longitudes, days, hour, initlatitudes, initlongitudes);
|
|
|
return trajectory;
|
|
|
}
|
|
|
|
|
|
- public static List<double[]> CalculateDriftTrajectory(NCread nCread,double[] initialPosition, double dt, double totalTime)
|
|
|
+ public static List<double[]> CalculateDriftTrajectory(NCread nCread, double[] initialPosition, double dt, double totalTime, int times, int latitudes, int longitudes, int days, int hour, double initlatitudes, double initlongitudes)
|
|
|
{
|
|
|
int timeSteps = (int)(totalTime / dt);
|
|
|
List<double[]> trajectory = new List<double[]>();
|
|
@@ -72,8 +72,8 @@ public class SeaSJ
|
|
|
|
|
|
int outputTime = 3600 * t;
|
|
|
// 动态获取当前位置的风力和洋流数据
|
|
|
- double[] windVelocity = GetWindVelocityFromAPI(nCread,currentPos[0], currentPos[1], outputTime);
|
|
|
- double[] currentVelocity = GetCurrentVelocityFromAPI(nCread,currentPos[0], currentPos[1], outputTime);
|
|
|
+ double[] windVelocity = GetWindVelocityFromAPI(nCread, currentPos[0], currentPos[1], outputTime, times, latitudes, longitudes, days, hour);
|
|
|
+ double[] currentVelocity = GetCurrentVelocityFromAPI(nCread, currentPos[0], currentPos[1], outputTime, times, latitudes, longitudes, days, hour);
|
|
|
|
|
|
// 计算漂移速度(m/s)
|
|
|
double[] driftVelocity = {
|
|
@@ -93,7 +93,7 @@ public class SeaSJ
|
|
|
return trajectory;//(纬度,经度)
|
|
|
}
|
|
|
|
|
|
- public static double[] GetWindVelocityFromAPI(NCread windNCread,double latitude, double longitude, double temptime)
|
|
|
+ public static double[] GetWindVelocityFromAPI(NCread windNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int days, int hour)
|
|
|
{
|
|
|
float[] longitudeArray = windNCread.longitudeArray;//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[] latitudeArray = windNCread.latitudeArray;//纬度一维数组来源自文件'Text_readNC.cs'
|
|
@@ -105,7 +105,7 @@ public class SeaSJ
|
|
|
int temptimeNum = 0;
|
|
|
//定义NC文件中读取不到的坐标点海洋数据信息(后续可采用插值法等)
|
|
|
//经度连续化
|
|
|
- for (int i = 0; i < 9; i++)
|
|
|
+ for (int i = 0; i < longitudes - 1; i++)
|
|
|
{
|
|
|
if (longitude >= longitudeArray[i] && longitude < longitudeArray[i + 1])
|
|
|
{
|
|
@@ -115,7 +115,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//纬度连续化
|
|
|
- for (int i = 0; i < 6; i++)
|
|
|
+ for (int i = 0; i < latitudes - 1; i++)
|
|
|
{
|
|
|
if (latitude >= latitudeArray[i] && latitude < latitudeArray[i + 1])
|
|
|
{
|
|
@@ -123,9 +123,9 @@ public class SeaSJ
|
|
|
latitudeNum = i;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//时间连续化
|
|
|
- for (int i = 0; i < 23 ; i ++)
|
|
|
+ for (int i = 0; i < times - 1; i++)
|
|
|
{
|
|
|
if (temptime >= 3600 * i && temptime < (3600 * (i + 1)))
|
|
|
{
|
|
@@ -133,13 +133,15 @@ public class SeaSJ
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ temptimeNum += (days - 1) * 24 + hour;
|
|
|
+
|
|
|
double windX = (double)u10Array[temptimeNum][latitudeNum][longitudeNum];
|
|
|
- double windY = (double)v10Array[temptimeNum][latitudeNum][ longitudeNum];
|
|
|
+ double windY = (double)v10Array[temptimeNum][latitudeNum][longitudeNum];
|
|
|
|
|
|
return new double[] { windX, windY };
|
|
|
}
|
|
|
|
|
|
- public static double[] GetCurrentVelocityFromAPI(NCread CurrentNCread,double latitude, double longitude, double temptime)
|
|
|
+ public static double[] GetCurrentVelocityFromAPI(NCread CurrentNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int days, int hour)
|
|
|
{
|
|
|
float[] longitudeArray = CurrentNCread.longitudeArray;//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[] latitudeArray = CurrentNCread.latitudeArray;//纬度一维数组来源自文件'Text_readNC.cs'
|
|
@@ -153,7 +155,7 @@ public class SeaSJ
|
|
|
int temptimeNum = 0;
|
|
|
//定义NC文件中读取不到的坐标点海洋数据信息(后续可采用插值法等)
|
|
|
//经度连续化
|
|
|
- for (int i = 0; i < 9; i++)
|
|
|
+ for (int i = 0; i < longitudes - 1; i++)
|
|
|
{
|
|
|
if (longitude >= longitudeArray[i] && longitude < longitudeArray[i + 1])
|
|
|
{
|
|
@@ -163,7 +165,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//纬度连续化
|
|
|
- for (int i = 0; i < 6; i++)
|
|
|
+ for (int i = 0; i < latitudes - 1; i++)
|
|
|
{
|
|
|
if (latitude >= latitudeArray[i] && latitude < latitudeArray[i + 1])
|
|
|
{
|
|
@@ -171,27 +173,28 @@ public class SeaSJ
|
|
|
latitudeNum = i;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//时间连续化
|
|
|
- for (int i = 0; i < 23; i++)
|
|
|
+ for (int i = 0; i < times - 1; i++)
|
|
|
{
|
|
|
if (temptime >= 3600 * 1 && temptime < 3600 * (i + 1))
|
|
|
{
|
|
|
temptimeNum = i;
|
|
|
}
|
|
|
}
|
|
|
- double currentSpeed = (double)p140208Array[temptimeNum][latitudeNum][ longitudeNum];
|
|
|
- double currentDirection = (double)mwdArray[temptimeNum][latitudeNum][ longitudeNum];
|
|
|
+ temptimeNum += (days - 1) * 24 + hour;
|
|
|
+ double currentSpeed = (double)p140208Array[temptimeNum][latitudeNum][longitudeNum];
|
|
|
+ double currentDirection = (double)mwdArray[temptimeNum][latitudeNum][longitudeNum];
|
|
|
|
|
|
double currentDirectionInRadians = currentDirection * (Math.PI / 180);
|
|
|
double currentX = currentSpeed * Math.Cos(currentDirectionInRadians);
|
|
|
double currentY = currentSpeed * Math.Sin(currentDirectionInRadians);
|
|
|
|
|
|
return new double[] { currentX, currentY };
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
//海浪高度获取
|
|
|
- public static double GetWaveHeightFromAPI(NCread WaveNCread,double latitude, double longitude, double temptime)//temptime:仿真时间(秒)
|
|
|
+ public static double GetWaveHeightFromAPI(NCread WaveNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int days, int hour)//temptime:仿真时间(秒)
|
|
|
{
|
|
|
float[] longitudeArray = WaveNCread.longitudeArray;//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[] latitudeArray = WaveNCread.latitudeArray;//纬度一维数组来源自文件'Text_readNC.cs'
|
|
@@ -203,7 +206,7 @@ public class SeaSJ
|
|
|
|
|
|
//定义NC文件中读取不到的坐标点海洋数据信息(后续可采用插值法等)
|
|
|
//经度连续化
|
|
|
- for (int i = 0; i < 9; i++)
|
|
|
+ for (int i = 0; i < longitudes - 1; i++)
|
|
|
{
|
|
|
if (longitude >= longitudeArray[i] && longitude < longitudeArray[i + 1])
|
|
|
{
|
|
@@ -213,7 +216,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//纬度连续化
|
|
|
- for (int i = 0; i < 6; i++)
|
|
|
+ for (int i = 0; i < latitudes - 1; i++)
|
|
|
{
|
|
|
if (latitude >= latitudeArray[i] && latitude < latitudeArray[i + 1])
|
|
|
{
|
|
@@ -223,19 +226,19 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//时间连续化
|
|
|
- for (int i = 0; i < 23 ; i ++)
|
|
|
+ for (int i = 0; i < times - 1; i++)
|
|
|
{
|
|
|
if (temptime >= 3600 * i && temptime < (3600 * (i + 1)))
|
|
|
{
|
|
|
temptimeNum = i;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- double WaveHeight = (double)hmaxArray[temptimeNum][ latitudeNum][ longitudeNum];
|
|
|
+ temptimeNum += (days - 1) * 24 + hour;
|
|
|
+ double WaveHeight = (double)hmaxArray[temptimeNum][latitudeNum][longitudeNum];
|
|
|
|
|
|
return WaveHeight;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 交付部分方法代码
|
|
|
public static List<double[]> getminEnclosingRect(List<double[]> latLonList)
|
|
|
{
|
|
@@ -250,7 +253,7 @@ public class SeaSJ
|
|
|
|
|
|
// 获取凸包
|
|
|
Point2f[] convexHull = Rectangular_Area_Search_Function.GetConvexHull(pointList);
|
|
|
-
|
|
|
+
|
|
|
//获取凸包各点经纬度坐标
|
|
|
List<double[]> hullPoint = new List<double[]>();
|
|
|
for (int num = 0; num < convexHull.Length - 1; num++)
|
|
@@ -265,7 +268,7 @@ public class SeaSJ
|
|
|
double pointLon = Rectangular_Area_Search_Function.RMokatuoLon(point[0]);
|
|
|
hullPointLatLon.Add(new double[] { pointLat, pointLon });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 计算最小包围矩形
|
|
|
List<double[]> minEnclosingRect = Rectangular_Area_Search_Function.MinEnclosingRectangle(convexHull);
|
|
|
|