|
|
|
@ -6,10 +6,11 @@ import com.aliyun.tablestore.grid.model.GridDataSetMeta;
|
|
|
|
|
import com.aliyun.tablestore.grid.model.grid.Grid4D;
|
|
|
|
|
import com.htfp.weather.griddata.common.GfsVariableHeightEnum;
|
|
|
|
|
import com.htfp.weather.griddata.common.GfsVariableIsobaricEnum;
|
|
|
|
|
import com.htfp.weather.griddata.common.TableConfigBean;
|
|
|
|
|
import com.htfp.weather.griddata.common.TableConfig;
|
|
|
|
|
import com.htfp.weather.griddata.operation.GfsDataFetcher;
|
|
|
|
|
import com.htfp.weather.griddata.operation.QueryMeta;
|
|
|
|
|
import com.htfp.weather.info.Constant;
|
|
|
|
|
import com.htfp.weather.info.GfsLevelsEnum;
|
|
|
|
|
import com.htfp.weather.utils.DateTimeUtils;
|
|
|
|
|
import com.htfp.weather.utils.NdArrayUtils;
|
|
|
|
|
import com.htfp.weather.web.exception.AppExcpetion;
|
|
|
|
@ -22,8 +23,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import ucar.ma2.Array;
|
|
|
|
|
import ucar.ma2.Index4D;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.time.OffsetDateTime;
|
|
|
|
@ -37,7 +40,8 @@ import java.util.stream.Collectors;
|
|
|
|
|
* @Date : 2024/2/2 15:47
|
|
|
|
|
* @Description : 获取tablestore格点数据
|
|
|
|
|
*/
|
|
|
|
|
@Service("tablestore-gfs") @Slf4j
|
|
|
|
|
@Service("tablestore-gfs")
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
private static final int SURFACE_LEVEL = 9999;
|
|
|
|
|
@Resource
|
|
|
|
@ -45,9 +49,18 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
@Resource
|
|
|
|
|
QueryMeta queryMeta;
|
|
|
|
|
@Resource
|
|
|
|
|
TableConfigBean tableConfigBean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TableConfig tableConfig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取变量随高度的变化廓线
|
|
|
|
|
*
|
|
|
|
|
* @param targetTime 目标时间 UTC
|
|
|
|
|
* @param variableName 数据库中的变量名
|
|
|
|
|
* @param latitude 纬度
|
|
|
|
|
* @param longitude 经度
|
|
|
|
|
* @return {@link ProfileResponse}
|
|
|
|
|
*/
|
|
|
|
|
public ProfileResponse getProfile(OffsetDateTime targetTime, String variableName, double latitude, double longitude) {
|
|
|
|
|
String targetVariable = GfsVariableIsobaricEnum.getGfsVariableName(variableName);
|
|
|
|
|
|
|
|
|
@ -66,7 +79,7 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
int iLon = getLongitudeIndex(longitude);
|
|
|
|
|
try {
|
|
|
|
|
String gridDataSetId = lastGridDataSetMeta.getGridDataSetId();
|
|
|
|
|
int[] pressureLevels = tableConfigBean.getPressureList();
|
|
|
|
|
int[] pressureLevels = tableConfig.getPressureList();
|
|
|
|
|
Array array = gfsDataFetcher.getProfile(gridDataSetId, targetVariable, iTime, iLat, iLon);
|
|
|
|
|
float[] values = (float[]) array.getStorage();
|
|
|
|
|
return new ProfileResponse(pressureLevels, values);
|
|
|
|
@ -76,6 +89,14 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取未来24小时的气象时间序列数据
|
|
|
|
|
*
|
|
|
|
|
* @param latitude 纬度
|
|
|
|
|
* @param longitude 经度
|
|
|
|
|
* @param level 高度:9999代表地面,其他代表指定气压高度
|
|
|
|
|
* @return @{@link TimeSeriesDataset}
|
|
|
|
|
*/
|
|
|
|
|
public TimeSeriesDataset getForecastSeries(double latitude, double longitude, int level) {
|
|
|
|
|
GridDataSetMeta lastGridDataSetMeta = null;
|
|
|
|
|
try {
|
|
|
|
@ -95,6 +116,7 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
try {
|
|
|
|
|
String gridDataSetId = lastGridDataSetMeta.getGridDataSetId();
|
|
|
|
|
GridDataSet gridDataSet = gfsDataFetcher.getSeries(gridDataSetId, variableNames, iTimes, iLev, iLat, iLon);
|
|
|
|
|
|
|
|
|
|
if (level == SURFACE_LEVEL) {
|
|
|
|
|
return buildTimeSeriesDatasetSurface(timeList, gridDataSet);
|
|
|
|
|
} else {
|
|
|
|
@ -106,12 +128,20 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前时刻的天气状况
|
|
|
|
|
*
|
|
|
|
|
* @param latitude 纬度
|
|
|
|
|
* @param longitude 经度
|
|
|
|
|
* @param level 高度:9999代表地面,其他代表指定气压高度
|
|
|
|
|
* @return @{@link NowWeatherStatus}
|
|
|
|
|
*/
|
|
|
|
|
public NowWeatherStatus getNowWeather(double latitude, double longitude, int level) {
|
|
|
|
|
GridDataSetMeta lastGridDataSetMeta = null;
|
|
|
|
|
try {
|
|
|
|
|
lastGridDataSetMeta = queryMeta.getLastGridDataSetMeta();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.DATA_SET_EMPTY, ": e.getMessage()");
|
|
|
|
|
throw new AppExcpetion(ErrorCode.DATA_SET_EMPTY, ": " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
int iTime = getTargetTimeIndex(OffsetDateTime.now(), lastGridDataSetMeta);
|
|
|
|
|
int iLat = getLatitudeIndex(latitude);
|
|
|
|
@ -122,38 +152,106 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
try {
|
|
|
|
|
String gridDataSetId = lastGridDataSetMeta.getGridDataSetId();
|
|
|
|
|
GridDataSet gridDataSet = gfsDataFetcher.getSinglePoint(gridDataSetId, variableNames, iTime, iLev, iLat, iLon);
|
|
|
|
|
if (level == SURFACE_LEVEL) {
|
|
|
|
|
return buildNowWeatherSurface(gridDataSet);
|
|
|
|
|
} else {
|
|
|
|
|
return buildNowWeatherPressure(gridDataSet);
|
|
|
|
|
}
|
|
|
|
|
// 每个变量都是0维数组
|
|
|
|
|
final GfsLevelsEnum levelFlag = GfsLevelsEnum.getByCode(level);
|
|
|
|
|
|
|
|
|
|
NowWeatherStatus nowWeatherStatus = buildNowWeatherInTargetPoint(gridDataSet, 0, 0, 0, levelFlag);
|
|
|
|
|
nowWeatherStatus.setLatitude(latitude);
|
|
|
|
|
nowWeatherStatus.setLongitude(longitude);
|
|
|
|
|
return nowWeatherStatus;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获得指定点序列上的当前气象信息
|
|
|
|
|
* @param latitude
|
|
|
|
|
* @param longitude
|
|
|
|
|
* @param level
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<NowWeatherStatus> getNowWeatherByMultiPoint(List<Double> latitude, List<Double> longitude, int level) {
|
|
|
|
|
GridDataSetMeta lastGridDataSetMeta = null;
|
|
|
|
|
try {
|
|
|
|
|
lastGridDataSetMeta = queryMeta.getLastGridDataSetMeta();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.DATA_SET_EMPTY, ": " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
if (latitude.size() != longitude.size()) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.INDEX_SIZE_ERROR, ": 经纬度数组大小不一致");
|
|
|
|
|
}
|
|
|
|
|
int pointSize = latitude.size();
|
|
|
|
|
List<String> variableNames = getVariableNamesInDatabase(level);
|
|
|
|
|
int iTime = getTargetTimeIndex(OffsetDateTime.now(), lastGridDataSetMeta);
|
|
|
|
|
List<Integer> latIndex = latitude.stream().map(this::getLatitudeIndex).collect(Collectors.toList());
|
|
|
|
|
List<Integer> lonIndex = longitude.stream().map(this::getLongitudeIndex).collect(Collectors.toList());
|
|
|
|
|
int iMinLat = Collections.min(latIndex).intValue();
|
|
|
|
|
int iMaxLat = Collections.max(latIndex).intValue();
|
|
|
|
|
int iMinLon = Collections.min(lonIndex).intValue();
|
|
|
|
|
int iMaxLon = Collections.max(lonIndex).intValue();
|
|
|
|
|
int iLev = getLevelIndex(level);
|
|
|
|
|
int latLength = iMaxLat - iMinLat + 1;
|
|
|
|
|
int lonLength = iMaxLon - iMinLon + 1;
|
|
|
|
|
// int levLength = iMaxLev - iMinLev + 1;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
private List<String> getVariableNamesInDatabase(int level) {
|
|
|
|
|
List<String> variableNames = new ArrayList<>();
|
|
|
|
|
if (level == SURFACE_LEVEL) {
|
|
|
|
|
for (String e: tableConfigBean.getVariableList()){
|
|
|
|
|
String gfsVariableName = GfsVariableHeightEnum.getGfsVariableName(e);
|
|
|
|
|
if (gfsVariableName != null){
|
|
|
|
|
variableNames.add(gfsVariableName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (String e: tableConfigBean.getVariableList()){
|
|
|
|
|
String gfsVariableName = GfsVariableIsobaricEnum.getGfsVariableName(e);
|
|
|
|
|
if (gfsVariableName != null){
|
|
|
|
|
variableNames.add(gfsVariableName);
|
|
|
|
|
}
|
|
|
|
|
String gridDataSetId = lastGridDataSetMeta.getGridDataSetId();
|
|
|
|
|
int[] origin = new int[]{iTime, iLev, 0, 0};
|
|
|
|
|
int[] shape = new int[]{1, 1, tableConfig.getLatSize(), tableConfig.getLatSize()};
|
|
|
|
|
GridDataSet gridDataSet = gfsDataFetcher.queryByTableStore(gridDataSetId, variableNames,
|
|
|
|
|
origin, shape);
|
|
|
|
|
|
|
|
|
|
List<NowWeatherStatus> nowWeatherStatusList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < pointSize; i++) {
|
|
|
|
|
NowWeatherStatus nowWeatherStatus = new NowWeatherStatus();
|
|
|
|
|
// NOTE 2024/6/11: build中传入的索引和数据库的查询索引意义不同
|
|
|
|
|
|
|
|
|
|
final GfsLevelsEnum levelFlag = GfsLevelsEnum.getByCode(level);
|
|
|
|
|
nowWeatherStatus = buildNowWeatherInTargetPoint(gridDataSet, 0, latIndex.get(i), lonIndex.get(i), levelFlag);
|
|
|
|
|
nowWeatherStatus.setLatitude(latitude.get(i));
|
|
|
|
|
nowWeatherStatus.setLongitude(longitude.get(i));
|
|
|
|
|
nowWeatherStatusList.add(nowWeatherStatus);
|
|
|
|
|
}
|
|
|
|
|
return nowWeatherStatusList;
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
return variableNames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int[] getMarginIndexByMultiPoint(List<Double> latitude, List<Double> longitude, List<Double> level) {
|
|
|
|
|
int minLat = Integer.MIN_VALUE;
|
|
|
|
|
int maxLat = Integer.MAX_VALUE;
|
|
|
|
|
int minLon = Integer.MIN_VALUE;
|
|
|
|
|
int maxLon = Integer.MAX_VALUE;
|
|
|
|
|
int minLev = Integer.MIN_VALUE;
|
|
|
|
|
int maxLev = Integer.MAX_VALUE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int iMinLat = getLatitudeIndex(minLat);
|
|
|
|
|
int iMaxLat = getLatitudeIndex(maxLat);
|
|
|
|
|
int iMinLon = getLongitudeIndex(minLon);
|
|
|
|
|
int iMaxLon = getLongitudeIndex(maxLon);
|
|
|
|
|
|
|
|
|
|
return new int[]{iMinLat, iMaxLat, iMinLon, iMaxLon};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定变量、时间、高度的二维数组数据
|
|
|
|
|
*
|
|
|
|
|
* @param targetTime 目标时间 UTC
|
|
|
|
|
* @param variableName 数据库中的变量名
|
|
|
|
|
* @param level 高度
|
|
|
|
|
* @param minLat 最小纬度
|
|
|
|
|
* @param maxLat 最大纬度
|
|
|
|
|
* @param minLon 最小经度
|
|
|
|
|
* @param maxLon 最大经度
|
|
|
|
|
* @return @{@link PlaneResponse}
|
|
|
|
|
*/
|
|
|
|
|
public PlaneResponse getPlane(OffsetDateTime targetTime, String variableName, int level, double minLat, double maxLat, double minLon, double maxLon) {
|
|
|
|
|
int iLev;
|
|
|
|
|
String targetVariable;
|
|
|
|
@ -194,11 +292,32 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> getVariableNamesInDatabase(int level) {
|
|
|
|
|
List<String> variableNames = new ArrayList<>();
|
|
|
|
|
if (level == SURFACE_LEVEL) {
|
|
|
|
|
for (String e : tableConfig.getVariableList()) {
|
|
|
|
|
String gfsVariableName = GfsVariableHeightEnum.getGfsVariableName(e);
|
|
|
|
|
if (gfsVariableName != null) {
|
|
|
|
|
variableNames.add(gfsVariableName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (String e : tableConfig.getVariableList()) {
|
|
|
|
|
String gfsVariableName = GfsVariableIsobaricEnum.getGfsVariableName(e);
|
|
|
|
|
if (gfsVariableName != null) {
|
|
|
|
|
variableNames.add(gfsVariableName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return variableNames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PlaneResponse buildPlane(Array array, int iMinLat, int iMinLon, int latLength, int lonLength) {
|
|
|
|
|
PlaneResponse planeResponse = new PlaneResponse();
|
|
|
|
|
float[][] values = (float[][]) array.reduce().copyToNDJavaArray();
|
|
|
|
|
planeResponse.setLatList(Arrays.copyOfRange(tableConfigBean.getLatList(), iMinLat, iMinLat + latLength));
|
|
|
|
|
planeResponse.setLonList(Arrays.copyOfRange(tableConfigBean.getLonList(), iMinLon, iMinLon + lonLength));
|
|
|
|
|
planeResponse.setLatList(Arrays.copyOfRange(tableConfig.getLatList(), iMinLat, iMinLat + latLength));
|
|
|
|
|
planeResponse.setLonList(Arrays.copyOfRange(tableConfig.getLonList(), iMinLon, iMinLon + lonLength));
|
|
|
|
|
planeResponse.setValues(values);
|
|
|
|
|
return planeResponse;
|
|
|
|
|
}
|
|
|
|
@ -245,49 +364,47 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
return timeSeriesDataset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private NowWeatherStatus buildNowWeatherPressure(GridDataSet gridDataSet) {
|
|
|
|
|
String timeStr = OffsetDateTime.now().withMinute(0).withNano(0).format(DateTimeFormatter.ofPattern(Constant.API_TIME_STRING));
|
|
|
|
|
NowWeatherStatus nowWeatherStatus = new NowWeatherStatus();
|
|
|
|
|
nowWeatherStatus.setTime(timeStr);
|
|
|
|
|
Grid4D grid4D;
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableIsobaricEnum.getGfsVariableName(GfsVariableIsobaricEnum.TEMP));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setTemp(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
}
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableIsobaricEnum.getGfsVariableName(GfsVariableIsobaricEnum.WIND_SPEED));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setWindSpeed(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
}
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableIsobaricEnum.getGfsVariableName(GfsVariableIsobaricEnum.WIND360));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setWind360(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
}
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableIsobaricEnum.getGfsVariableName(GfsVariableIsobaricEnum.CLOUD));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setCloud(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
}
|
|
|
|
|
return nowWeatherStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private NowWeatherStatus buildNowWeatherSurface(GridDataSet gridDataSet) {
|
|
|
|
|
/**
|
|
|
|
|
* 构建指定位置的当前天气
|
|
|
|
|
* @param gridDataSet
|
|
|
|
|
* @param iLevInGrid-目标点在返回的网格中的高度索引
|
|
|
|
|
* @param iLatInGrid-目标点在返回的网格中的高度索引
|
|
|
|
|
* @param iLonInGrid-目标点在返回的网格中的高度索引
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private NowWeatherStatus buildNowWeatherInTargetPoint(GridDataSet gridDataSet, int iLevInGrid, int iLatInGrid, int iLonInGrid, GfsLevelsEnum levelFlag) {
|
|
|
|
|
String timeStr = OffsetDateTime.now().withMinute(0).withNano(0).format(DateTimeFormatter.ofPattern(Constant.API_TIME_STRING));
|
|
|
|
|
NowWeatherStatus nowWeatherStatus = new NowWeatherStatus();
|
|
|
|
|
nowWeatherStatus.setTime(timeStr);
|
|
|
|
|
Grid4D grid4D;
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableHeightEnum.getGfsVariableName(GfsVariableHeightEnum.TEMP));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setTemp(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
}
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableHeightEnum.getGfsVariableName(GfsVariableHeightEnum.WIND_SPEED));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setWindSpeed(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
}
|
|
|
|
|
grid4D = gridDataSet.getVariable(GfsVariableHeightEnum.getGfsVariableName(GfsVariableHeightEnum.WIND360));
|
|
|
|
|
if (grid4D != null) {
|
|
|
|
|
nowWeatherStatus.setWind360(((float[]) grid4D.toArray().getStorage())[0]);
|
|
|
|
|
NowWeatherStatus result = new NowWeatherStatus();
|
|
|
|
|
result.setTime(timeStr);
|
|
|
|
|
// 利用反射构建数据集
|
|
|
|
|
Class<? extends NowWeatherStatus> aClass = result.getClass();
|
|
|
|
|
for (Map.Entry<String, Grid4D> entry : gridDataSet.getVariables().entrySet()) {
|
|
|
|
|
String variableNameInFile = entry.getKey();
|
|
|
|
|
String variableNameInApi;
|
|
|
|
|
if (GfsLevelsEnum.SURFACE.equals(levelFlag)) {
|
|
|
|
|
variableNameInApi = GfsVariableHeightEnum.getVariableNameInApi(variableNameInFile);
|
|
|
|
|
} else {
|
|
|
|
|
variableNameInApi = GfsVariableIsobaricEnum.getVariableNameInApi(variableNameInFile);
|
|
|
|
|
}
|
|
|
|
|
if (variableNameInApi == null) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.NO_SUCH_VARIABLE);
|
|
|
|
|
}
|
|
|
|
|
Grid4D grid4D = entry.getValue(); Index4D index = new Index4D(grid4D.getShape());
|
|
|
|
|
try {
|
|
|
|
|
String setMethodName = "set" + variableNameInApi.substring(0, 1).toUpperCase() + variableNameInApi.substring(1);
|
|
|
|
|
Method method = aClass.getDeclaredMethod(setMethodName, aClass.getDeclaredField(variableNameInApi).getType());
|
|
|
|
|
method.invoke(result, grid4D.toArray().getFloat(index.set(0, iLevInGrid, iLatInGrid, iLonInGrid)));
|
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.NO_SUCH_VARIABLE, e);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new AppExcpetion(ErrorCode.RESPONSE_DATA_BUILD_ERROR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nowWeatherStatus;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getTargetTimeIndex(OffsetDateTime targetTime, GridDataSetMeta lastGridDataSetMeta) {
|
|
|
|
|
long milli = (long) lastGridDataSetMeta.getAttributes().get(AttributionEnum.REFERENCE_TIME.getName());
|
|
|
|
|
OffsetDateTime refTime = OffsetDateTime.ofInstant(Instant.ofEpochMilli(milli), ZoneOffset.ofHours(0));
|
|
|
|
@ -336,8 +453,9 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
map.put("timeList", timeList);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getLongitudeIndex(double lon) {
|
|
|
|
|
double[] lonList = tableConfigBean.getLonList();
|
|
|
|
|
double[] lonList = tableConfig.getLonList();
|
|
|
|
|
if (lonList.length == 0) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.LONGITUDE_INDEX_ERROR, "经度列表为空, 无法查找索引");
|
|
|
|
|
}
|
|
|
|
@ -354,7 +472,7 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getLatitudeIndex(double lat) {
|
|
|
|
|
double[] latList = tableConfigBean.getLatList();
|
|
|
|
|
double[] latList = tableConfig.getLatList();
|
|
|
|
|
if (latList.length == 0) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.LATITUDE_INDEX_ERROR, "纬度列表为空, 无法查找索引");
|
|
|
|
|
}
|
|
|
|
@ -372,7 +490,7 @@ public class GfsDataServiceImpl implements IDataService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getPressureIndex(int pressureLevel) {
|
|
|
|
|
List<Integer> levList = Arrays.stream(tableConfigBean.getPressureList()).boxed().collect(Collectors.toList());
|
|
|
|
|
List<Integer> levList = Arrays.stream(tableConfig.getPressureList()).boxed().collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isEmpty(levList)) {
|
|
|
|
|
throw new AppExcpetion(ErrorCode.LEVEL_INDEX_ERROR, "气压列表为空, 无法查找索引");
|
|
|
|
|
}
|
|
|
|
|