|
@@ -55,15 +55,21 @@ public class WindDirectionALG {
|
|
|
* @return
|
|
|
*/
|
|
|
public static int[] fxRadarRoses(List<PowerPointData> list){
|
|
|
- int[] count = new int[16];
|
|
|
- list.stream().sorted(Comparator.comparing(PowerPointData::getSpeed)).forEach(item -> {
|
|
|
- int df = windDFAngle(item.getDfwc());
|
|
|
- if (count[df] < 1000) {
|
|
|
- count[df]++;
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- return count;
|
|
|
+ try {
|
|
|
+ int[] count = new int[16];
|
|
|
+ list.stream().sorted(Comparator.comparing(PowerPointData::getSpeed)).forEach(item -> {
|
|
|
+ int df = windDFAngle(item.getDfwc());
|
|
|
+ if (count.length > df && count[df] < 1000) {
|
|
|
+ count[df]++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return count;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -129,47 +135,52 @@ public class WindDirectionALG {
|
|
|
* @return
|
|
|
*/
|
|
|
public static Map<String, Object> windDeviationPoint(List<PowerPointData> points){
|
|
|
- List<PowerPointData> list = new ArrayList<>();
|
|
|
- List<Object> temp = new ArrayList<>();
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- Map<Integer, double[]> map = new LinkedHashMap<>();
|
|
|
-
|
|
|
- //过滤对风偏差
|
|
|
- for (int i = 0; i < points.size(); i++){
|
|
|
- PowerPointData item = points.get(i);
|
|
|
- if ((item.getSpeed() < 4.5 || item.getSpeed() >= 10.5) && item.getMxzt() != 2)
|
|
|
- continue;
|
|
|
-
|
|
|
- list.add(item);
|
|
|
- Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
|
|
|
- if (!map.containsKey(speed))
|
|
|
- map.put(speed, new double[2]); //[0]最小值 [1]最大值
|
|
|
-
|
|
|
- double[] value = map.get(speed);
|
|
|
- double power = item.getPower() < 0 ? 0 : item.getPower();
|
|
|
- value[0] = power < value[0] ? power : value[0]; //最小值
|
|
|
- value[1] = power > value[1] ? power : value[1]; //最大值
|
|
|
- }
|
|
|
+ try {
|
|
|
+ List<PowerPointData> list = new ArrayList<>();
|
|
|
+ List<Object> temp = new ArrayList<>();
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ Map<Integer, double[]> map = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ //过滤对风偏差
|
|
|
+ for (int i = 0; i < points.size(); i++){
|
|
|
+ PowerPointData item = points.get(i);
|
|
|
+ if ((item.getSpeed() < 4.5 || item.getSpeed() >= 10.5) && item.getMxzt() != 2)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ list.add(item);
|
|
|
+ Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
|
|
|
+ if (!map.containsKey(speed))
|
|
|
+ map.put(speed, new double[2]); //[0]最小值 [1]最大值
|
|
|
|
|
|
- int avg = 0;
|
|
|
- DecimalFormat sf = new DecimalFormat("0.00");
|
|
|
- for (int i = 0; i < list.size(); i++){
|
|
|
- PowerPointData item = list.get(i);
|
|
|
- Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
|
|
|
- int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
|
|
|
- int index = ele - 180;
|
|
|
- if (index >= -30 && index <= 30 && item.getPower() > 0) {
|
|
|
- avg += index;
|
|
|
double[] value = map.get(speed);
|
|
|
- double v = (item.getPower() - value[0]) / (value[1] - value[0]);
|
|
|
- double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
|
|
|
- temp.add(s);
|
|
|
+ double power = item.getPower() < 0 ? 0 : item.getPower();
|
|
|
+ value[0] = power < value[0] ? power : value[0]; //最小值
|
|
|
+ value[1] = power > value[1] ? power : value[1]; //最大值
|
|
|
}
|
|
|
- }
|
|
|
- result.put("data", temp);
|
|
|
- result.put("avg", temp.size() > 0 ? avg/temp.size() : 0);
|
|
|
|
|
|
- return result;
|
|
|
+ int avg = 0;
|
|
|
+ DecimalFormat sf = new DecimalFormat("0.00");
|
|
|
+ for (int i = 0; i < list.size(); i++){
|
|
|
+ PowerPointData item = list.get(i);
|
|
|
+ Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
|
|
|
+ int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
|
|
|
+ int index = ele - 180;
|
|
|
+ if (index >= -30 && index <= 30 && item.getPower() > 0) {
|
|
|
+ avg += index;
|
|
|
+ double[] value = map.get(speed);
|
|
|
+ double v = (item.getPower() - value[0]) / (value[1] - value[0]);
|
|
|
+ double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
|
|
|
+ temp.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("data", temp);
|
|
|
+ result.put("avg", temp.size() > 0 ? avg/temp.size() : 0);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
|