public FetchClimateGridResponce FetchClimateGrid(ClimateParameter parameter, double latmin, double latmax, double lonmin, double lonmax, int hourmin, int hourmax, int daymin, int daymax, int yearmin, int yearmax, double dlat, double dlon, FetchingOptions options) { int nlat = (int)Math.Round((latmax - latmin) / dlat); int nlon = (int)Math.Round((lonmax - lonmin) / dlon); double[] latsGrid = new double[nlat + 1]; double[] lonsGrid = new double[nlon + 1]; for (int i = 0; i < latsGrid.Length; i++) latsGrid[i] = latmin + i * dlat; for (int i = 0; i < lonsGrid.Length; i++) lonsGrid[i] = lonmin + i * dlon; int[] hourmins = new int[nlat * nlon]; int[] hourmaxs = new int[nlat * nlon]; int[] daymins = new int[nlat * nlon]; int[] daymaxs = new int[nlat * nlon]; int[] yearmins = new int[nlat * nlon]; int[] yearmaxs = new int[nlat * nlon]; double[] latmins = new double[nlat * nlon]; double[] latmaxs = new double[nlat * nlon]; double[] lonmins = new double[nlat * nlon]; double[] lonmaxs = new double[nlat * nlon]; int rowIndex, colIndex; for (int i = 0; i < nlat * nlon; i++) { rowIndex = i / nlon; colIndex = i % nlon; lonmins[i] = lonsGrid[colIndex]; lonmaxs[i] = lonsGrid[colIndex + 1]; latmins[i] = latsGrid[rowIndex]; latmaxs[i] = latsGrid[rowIndex + 1]; hourmins[i] = hourmin; hourmaxs[i] = hourmax; daymins[i] = daymin; daymaxs[i] = daymax; yearmins[i] = yearmin; yearmaxs[i] = yearmax; } var resB = FetchClimate(parameter, latmins, latmaxs, lonmins, lonmaxs, hourmins, hourmaxs, daymins, daymaxs, yearmins, yearmaxs, options, ResearchVariationType.Spatial); ClimateParameterValue[] result = resB.Values; ClimateParameterValue[,] result2D = new ClimateParameterValue[nlat, nlon]; for (int i = 0; i < nlat * nlon; i++) { rowIndex = i / nlon; colIndex = i % nlon; result2D[rowIndex, colIndex] = result[i]; } FetchClimateGridResponce res = new FetchClimateGridResponce(); res.Values = result2D; res.ServiceVersion = resB.ServiceVersion; return res; }
public FetchClimateGridResponce FetchClimateGrid(ClimateParameter parameter, double latmin, double latmax, double lonmin, double lonmax, int hourmin, int hourmax, int daymin, int daymax, int yearmin, int yearmax, double dlat, double dlon, FetchingOptions options) { int nlat = (int)Math.Round((latmax - latmin) / dlat); int nlon = (int)Math.Round((lonmax - lonmin) / dlon); double[] latsGrid = new double[nlat + 1]; double[] lonsGrid = new double[nlon + 1]; for (int i = 0; i < latsGrid.Length; i++) { latsGrid[i] = latmin + i * dlat; } for (int i = 0; i < lonsGrid.Length; i++) { lonsGrid[i] = lonmin + i * dlon; } int[] hourmins = new int[nlat * nlon]; int[] hourmaxs = new int[nlat * nlon]; int[] daymins = new int[nlat * nlon]; int[] daymaxs = new int[nlat * nlon]; int[] yearmins = new int[nlat * nlon]; int[] yearmaxs = new int[nlat * nlon]; double[] latmins = new double[nlat * nlon]; double[] latmaxs = new double[nlat * nlon]; double[] lonmins = new double[nlat * nlon]; double[] lonmaxs = new double[nlat * nlon]; int rowIndex, colIndex; for (int i = 0; i < nlat * nlon; i++) { rowIndex = i / nlon; colIndex = i % nlon; lonmins[i] = lonsGrid[colIndex]; lonmaxs[i] = lonsGrid[colIndex + 1]; latmins[i] = latsGrid[rowIndex]; latmaxs[i] = latsGrid[rowIndex + 1]; hourmins[i] = hourmin; hourmaxs[i] = hourmax; daymins[i] = daymin; daymaxs[i] = daymax; yearmins[i] = yearmin; yearmaxs[i] = yearmax; } var resB = FetchClimate(parameter, latmins, latmaxs, lonmins, lonmaxs, hourmins, hourmaxs, daymins, daymaxs, yearmins, yearmaxs, options, ResearchVariationType.Spatial); ClimateParameterValue[] result = resB.Values; ClimateParameterValue[,] result2D = new ClimateParameterValue[nlat, nlon]; for (int i = 0; i < nlat * nlon; i++) { rowIndex = i / nlon; colIndex = i % nlon; result2D[rowIndex, colIndex] = result[i]; } FetchClimateGridResponce res = new FetchClimateGridResponce(); res.Values = result2D; res.ServiceVersion = resB.ServiceVersion; return(res); }