From 27e6bc3df3e39e0d0b147b155a89ad6837ea972b Mon Sep 17 00:00:00 2001
From: cjl <909710561@qq.com>
Date: Mon, 06 Jan 2025 09:19:24 +0800
Subject: [PATCH] Merge branch 'cjl' into dev

---
 screen-common/src/main/java/com/moral/util/AQIUtils.java |  556 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 391 insertions(+), 165 deletions(-)

diff --git a/screen-common/src/main/java/com/moral/util/AQIUtils.java b/screen-common/src/main/java/com/moral/util/AQIUtils.java
index 70cddb2..ea45313 100644
--- a/screen-common/src/main/java/com/moral/util/AQIUtils.java
+++ b/screen-common/src/main/java/com/moral/util/AQIUtils.java
@@ -1,193 +1,419 @@
 package com.moral.util;
 
-import org.springframework.util.ObjectUtils;
+import com.moral.pojo.AQI;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import com.moral.constant.Constants;
 
 public class AQIUtils {
-    public static int hourlyAqi(Map<String, Object> map) {
-        List<Integer> AQIList = new ArrayList<>();
-        for (Map.Entry<String, Object> entry : map.entrySet()) {
-            String key = entry.getKey();
-            if (entry.getValue().toString().equals("")) {
-                continue;
-            }
-            int PM2_5AQI;
-            int PM10AQI;
-            int SO2AQI;
-            int NO2AQI;
-            int COAQI;
-            int O3AQI;
-            switch (key) {
-                case Constants.SENSOR_CODE_PM25:
-                    PM2_5AQI = PM2_5AQI(Double.valueOf(entry.getValue().toString()));
-                    AQIList.add(PM2_5AQI);
-                    break;
-                case Constants.SENSOR_CODE_PM10:
-                    PM10AQI = PM10AQI(Double.valueOf(entry.getValue().toString()));
-                    AQIList.add(PM10AQI);
-                    break;
-                case Constants.SENSOR_CODE_SO2:
-                    SO2AQI = SO2AQI(Double.valueOf(entry.getValue().toString()));
-                    AQIList.add(SO2AQI);
-                    break;
-                case Constants.SENSOR_CODE_NO2:
-                    NO2AQI = NO2AQI(Double.valueOf(entry.getValue().toString()));
-                    AQIList.add(NO2AQI);
-                    break;
-                case Constants.SENSOR_CODE_CO:
-                    COAQI = COAQI(Double.valueOf(entry.getValue().toString()));
-                    AQIList.add(COAQI);
-                    break;
-                case Constants.SENSOR_CODE_O3:
-                    O3AQI = O3AQI(Double.valueOf(entry.getValue().toString()));
-                    AQIList.add(O3AQI);
-                    break;
-                default:
-                    break;
+    /*24������������������*/
+    private static Double[] SO2_Daily_Limit_Data = new Double[]{0d, 50d, 150d, 475d, 800d, 1600d, 2100d, 2620d};
+    private static Double[] NO2_Daily_Limit_Data = new Double[]{0d, 40d, 80d, 180d, 280d, 565d, 750d, 940d};
+    private static Double[] PM10_Daily_Limit_Data = new Double[]{0d, 50d, 150d, 250d, 350d, 420d, 500d, 600d};
+    private static Double[] CO_Daily_Limit_Data = new Double[]{0d, 2d, 4d, 14d, 24d, 36d, 48d, 60d};
+    private static Double[] PM2_5_Daily_Limit_Data = new Double[]{0d, 35d, 75d, 115d, 150d, 250d, 350d, 500d};
+    private static Double[] O3_Daily_Limit_Data = new Double[]{0d, 100d, 160d, 215d, 265d, 800d};
+    /*1������������������*/
+    private static Double[] SO2_Hourly_Limit_Data = new Double[]{0d, 150d, 500d, 650d, 800d};
+    private static Double[] NO2_Hourly_Limit_Data = new Double[]{0d, 100d, 200d, 700d, 1200d, 2340d, 3090d, 3840d};
+    private static Double[] PM10_Hourly_Limit_Data = new Double[]{0d, 50d, 150d, 250d, 350d, 420d, 500d, 600d};
+    private static Double[] CO_Hourly_Limit_Data = new Double[]{0d, 5d, 10d, 35d, 60d, 90d, 120d, 150d};
+    private static Double[] PM2_5_Hourly_Limit_Data = new Double[]{0d, 35d, 75d, 115d, 150d, 250d, 350d, 500d};
+    private static Double[] O3_Hourly_Limit_Data = new Double[]{0d, 160d, 200d, 300d, 400d, 800d, 1000d, 1200d};
+    /*���������������������*/
+    private static Double[] IAQI_Array = new Double[]{0d,50d,100d,150d,200d,300d,400d,500d};
+
+
+    //������6���������������������
+    public static int standardCount(Map<String,Object> data){
+        int count = 0;
+        if(data.get("PM2_5")!=null&&PM2_5IsStandard(Double.valueOf(data.get("PM2_5").toString())))
+            count++;
+        if(data.get("PM10")!=null&&PM10IsStandard(Double.valueOf(data.get("PM10").toString())))
+            count++;
+        if(data.get("SO2")!=null&&SO2IsStandard(Double.valueOf(data.get("SO2").toString())))
+            count++;
+        if(data.get("NO2")!=null&&NO2IsStandard(Double.valueOf(data.get("NO2").toString())))
+            count++;
+        if(data.get("CO")!=null&&COIsStandard(Double.valueOf(data.get("CO").toString())))
+            count++;
+        if(data.get("O3")!=null&&O3IsStandard(Double.valueOf(data.get("O3").toString())))
+            count++;
+        return count;
+    }
+
+    //������aqi������������
+    public static boolean aqiIsStandard(int aqi){
+        if(aqi<=100)
+            return true;
+        return false;
+    }
+    public static boolean PM2_5IsStandard(Double pm2_5){
+        if(pm2_5<=75)
+            return true;
+        return false;
+    }
+    public static boolean PM10IsStandard(Double pm10){
+        if(pm10<=150)
+            return true;
+        return false;
+    }
+    public static boolean SO2IsStandard(Double so2){
+        if(so2<=500)
+            return true;
+        return false;
+    }
+    public static boolean NO2IsStandard(Double no2){
+        if(no2<=80)
+            return true;
+        return false;
+    }
+    public static boolean COIsStandard(Double co){
+        if(co<=4)
+            return true;
+        return false;
+    }
+    public static boolean O3IsStandard(Double o3){
+        if(o3<=200)
+            return true;
+        return false;
+    }
+
+    /**
+    * @Description: ������AQI���������������������������������������
+            * @Param:
+            * @return:
+            * @Author: ���������
+            * @Date: 2021/10/29
+            */
+    public static String classOfPollutionByAqi(Integer aqi){
+        if(aqi>300)
+            return Constants.SERVER_WEATHER;
+        if(aqi>200)
+            return Constants.SERIOUS_WEATHER;
+        if(aqi>150)
+            return Constants.MIDDLE_WEATHER;
+        if(aqi>100)
+            return Constants.MILD_WEATHER;
+        if(aqi>50)
+            return Constants.GOOD_WEATHER;
+        return Constants.EXCELLENT_WEATHER;
+    }
+
+    /**
+    * @Description: ������AQI���������������������������������������Code
+            * @Param: [aqi]
+            * @return: java.lang.String
+            * @Author: ���������
+            * @Date: 2021/11/11
+            */
+    public static String classCodeOfPollutionByAqi(Integer aqi){
+        if(aqi>300)
+            return Constants.SERVER_WEATHER_CODE;
+        if(aqi>200)
+            return Constants.SERIOUS_WEATHER_CODE;
+        if(aqi>150)
+            return Constants.MIDDLE_WEATHER_CODE;
+        if(aqi>100)
+            return Constants.MILD_WEATHER_CODE;
+        if(aqi>50)
+            return Constants.GOOD_WEATHER_CODE;
+        return Constants.EXCELLENT_WEATHER_CODE;
+    }
+
+    /**
+     * @Description: 24������AQI
+     * @Param: [paramMap]
+     * @return: java.lang.Integer
+     * @Author: ���������
+     * @Date: 2021/11/3
+     */
+    public static AQI dailyAQI(Map<String,Object> paramMap){
+        if(paramMap==null)
+            return null;
+        List<Integer> IAQIList = new ArrayList<>();
+        List<String> primaryPollutantNames = new ArrayList<>();
+        List<String> primaryPollutantCodes = new ArrayList<>();
+        Integer PM2_5IAQI;
+        Integer SO2IAQI;
+        Integer NO2IAQI;
+        Integer COIAQI;
+        Integer PM10IAQI;
+        Integer O3IAQI;
+        if(paramMap.get(Constants.SENSOR_CODE_PM25)!=null){
+            Double PM2_5 = Double.valueOf(paramMap.get("a34004").toString());
+            PM2_5IAQI = calculateIAQIUniversal(PM2_5,PM2_5_Daily_Limit_Data);
+            IAQIList.add(PM2_5IAQI);
+            if(PM2_5IAQI>50){
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_PM25);
+                primaryPollutantNames.add("PM2.5");
             }
         }
-        int AQIMAX = 0;
-        if (!ObjectUtils.isEmpty(AQIList)) {
-            AQIMAX = Collections.max(AQIList);
+        if(paramMap.get(Constants.SENSOR_CODE_SO2)!=null){
+            Double SO2 = Double.valueOf(paramMap.get("a21026").toString());
+            SO2IAQI = calculateIAQIUniversal(SO2,SO2_Daily_Limit_Data);
+            IAQIList.add(SO2IAQI);
+            if(SO2IAQI>50){
+                primaryPollutantNames.add("SO2");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_SO2);
+            }
         }
-        return AQIMAX;
+        if(paramMap.get(Constants.SENSOR_CODE_NO2)!=null){
+            Double NO2 = Double.valueOf(paramMap.get("a21004").toString());
+            NO2IAQI = calculateIAQIUniversal(NO2,NO2_Daily_Limit_Data);
+            IAQIList.add(NO2IAQI);
+            if(NO2IAQI>50){
+                primaryPollutantNames.add("NO2");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_NO2);
+            }
+        }
+        if(paramMap.get(Constants.SENSOR_CODE_CO)!=null){
+            Double CO = Double.valueOf(paramMap.get("a21005").toString());
+            COIAQI = calculateIAQIUniversal(CO,CO_Daily_Limit_Data);
+            IAQIList.add(COIAQI);
+            if(COIAQI>50){
+                primaryPollutantNames.add("CO");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_CO);
+            }
+        }
+        if(paramMap.get(Constants.SENSOR_CODE_PM10)!=null){
+            Double PM10 = Double.valueOf(paramMap.get("a34002").toString());
+            PM10IAQI = calculateIAQIUniversal(PM10,PM10_Daily_Limit_Data);
+            IAQIList.add(PM10IAQI);
+            if(PM10IAQI>50){
+                primaryPollutantNames.add("PM10");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_PM10);
+            }
+        }
+        if(paramMap.get(Constants.SENSOR_CODE_O3)!=null){
+            Double O3 = Double.valueOf(paramMap.get("a05024").toString());
+            O3IAQI = calculateO3DailyIAQI(O3);
+            IAQIList.add(O3IAQI);
+            if(O3IAQI>50){
+                primaryPollutantNames.add("O3");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_O3);
+            }
+        }
+        AQI aqi= new AQI();
+        aqi.setAQIValue(getAQIByIAQIs(IAQIList));
+        aqi.setPrimaryPollutantCodes(primaryPollutantCodes);
+        aqi.setPrimaryPollutantNames(primaryPollutantNames);
+        return aqi;
     }
 
-    //PM2.5 IAQI
-    public static int PM2_5AQI(Double value) {
-        double result;
-        if (value <= 0) {
-            result = 0;
-        } else if (value <= 35) {
-            result = 50d / 35d * (value - 0) + 0;
-        } else if (value <= 75) {
-            result = 50d / 40d * (value - 35) + 50;
-        } else if (value <= 115) {
-            result = 50d / 40d * (value - 75) + 100;
-        } else if (value <= 150) {
-            result = 50d / 35d * (value - 115) + 150;
-        } else if (value <= 250) {
-            result = 100d / 100d * (value - 150) + 200;
-        } else if (value <= 350) {
-            result = 100d / 100d * (value - 250) + 300;
-        } else {
-            result = 100d / 150d * (value - 350) + 400;
+    /**
+     * @Description: 1������AQI
+     * @Param: [paramMap]
+     * @return: java.lang.Integer
+     * @Author: ���������
+     * @Date: 2021/11/3
+     */
+    public static AQI hourlyAQI(Map<String,Object> paramMap){
+        if(paramMap==null)
+            return null;
+        List<Integer> IAQIList = new ArrayList<>();
+        List<String> primaryPollutantNames = new ArrayList<>();
+        List<String> primaryPollutantCodes = new ArrayList<>();
+        Integer PM2_5IAQI;
+        Integer SO2IAQI;
+        Integer NO2IAQI;
+        Integer COIAQI;
+        Integer PM10IAQI;
+        Integer O3IAQI;
+        if(paramMap.get("a34004")!=null){
+            Double PM2_5 = Double.valueOf(paramMap.get("a34004").toString());
+            PM2_5IAQI = calculateIAQIUniversal(PM2_5,PM2_5_Hourly_Limit_Data);
+            IAQIList.add(PM2_5IAQI);
+            if(PM2_5IAQI>50){
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_PM25);
+                primaryPollutantNames.add("PM2.5");
+            }
         }
-        return (int) Math.ceil(result);
+        if(paramMap.get("a21026")!=null){
+            Double SO2 = Double.valueOf(paramMap.get("a21026").toString());
+            SO2IAQI = calculateSO2HourlyIAQI(SO2);
+            IAQIList.add(SO2IAQI);
+            if(SO2IAQI>50){
+                primaryPollutantNames.add("SO2");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_SO2);
+            }
+        }
+        if(paramMap.get("a21004")!=null){
+            Double NO2 = Double.valueOf(paramMap.get("a21004").toString());
+            NO2IAQI = calculateIAQIUniversal(NO2,NO2_Hourly_Limit_Data);
+            IAQIList.add(NO2IAQI);
+            if(NO2IAQI>50){
+                primaryPollutantNames.add("NO2");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_NO2);
+            }
+        }
+        if(paramMap.get("a21005")!=null){
+            Double CO = Double.valueOf(paramMap.get("a21005").toString());
+            COIAQI = calculateIAQIUniversal(CO,CO_Hourly_Limit_Data);
+            IAQIList.add(COIAQI);
+            if(COIAQI>50){
+                primaryPollutantNames.add("CO");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_CO);
+            }
+        }
+        if(paramMap.get("a34002")!=null){
+            Double PM10 = Double.valueOf(paramMap.get("a34002").toString());
+            PM10IAQI = calculateIAQIUniversal(PM10,PM10_Hourly_Limit_Data);
+            IAQIList.add(PM10IAQI);
+            if(PM10IAQI>50){
+                primaryPollutantNames.add("PM10");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_PM10);
+            }
+        }
+        if(paramMap.get("a05024")!=null){
+            Double O3 = Double.valueOf(paramMap.get("a05024").toString());
+            O3IAQI = calculateIAQIUniversal(O3,O3_Hourly_Limit_Data);
+            IAQIList.add(O3IAQI);
+            if(O3IAQI>50) {
+                primaryPollutantNames.add("O3");
+                primaryPollutantCodes.add(Constants.SENSOR_CODE_O3);
+            }
+        }
+        AQI aqi= new AQI();
+        aqi.setAQIValue(getAQIByIAQIs(IAQIList));
+        aqi.setPrimaryPollutantCodes(primaryPollutantCodes);
+        aqi.setPrimaryPollutantNames(primaryPollutantNames);
+        return aqi;
     }
 
-    //PM10 IAQI
-    public static int PM10AQI(Double value) {
-        double result;
-        if (value <= 0) {
-            result = 0;
-        } else if (value <= 50) {
-            result = 50d / 50d * (value - 0) + 0;
-        } else if (value <= 150) {
-            result = 50d / 100d * (value - 50) + 50;
-        } else if (value <= 250) {
-            result = 50d / 100d * (value - 150) + 100;
-        } else if (value <= 350) {
-            result = 50d / 100d * (value - 250) + 150;
-        } else if (value <= 420) {
-            result = 100d / 70d * (value - 350) + 200;
-        } else if (value <= 500) {
-            result = 100d / 80d * (value - 420) + 300;
-        } else {
-            result = 100d / 100d * (value - 500) + 400;
-        }
-        return (int) Math.ceil(result);
+
+    /**
+     * @Description: ������IAQI������AQI
+     * @Param: [IAQIs]
+     * @return: int
+     * @Author: ���������
+     * @Date: 2021/11/3
+     */
+    private static Integer getAQIByIAQIs(List<Integer> IAQIs){
+        if(IAQIs.size()==0)
+            return null;
+        Optional<Integer> max = IAQIs.stream().max(Comparator.comparing(Integer::intValue));
+        return max.get();
     }
 
-    //SO2 IAQI
-    public static int SO2AQI(Double value) {
-        double result;
-        if (value <= 0) {
-            result = 0;
-        } else if (value <= 150) {
-            result = 50d / 150d * (value - 0) + 0;
-        } else if (value <= 500) {
-            result = 50d / 350d * (value - 150) + 50;
-        } else if (value <= 650) {
-            result = 50d / 150d * (value - 500) + 100;
-        } else {
-            result = 50d / 150d * (value - 650) + 150;
+
+    /**
+     * @Description: ������so2���������IAQI���O3������IAQI������IAQI������������
+     * @Param: [Cp, limitData]
+     * @return: java.lang.Integer
+     * @Author: ���������
+     * @Date: 2021/11/2
+     */
+    private static Integer calculateIAQIUniversal(Double Cp,Double[] limitData){
+        int index = getStartIndexFromArray(Cp, limitData);
+        Double BPHi;
+        Double BPLo;
+        Double IAQIHi;
+        Double IAQILo;
+        if(index==limitData.length-1){
+            return 500;
+        }else{
+            BPHi = limitData[index+1];
+            BPLo = limitData[index];
+            IAQIHi = IAQI_Array[index+1];
+            IAQILo = IAQI_Array[index];
         }
-        return (int) Math.ceil(result);
+        return calculateIAQIFormula(Cp,BPHi,BPLo,IAQIHi,IAQILo);
     }
 
-    //NO2 IAQI
-    public static int NO2AQI(Double value) {
-        double result;
-        if (value <= 0) {
-            result = 0;
-        } else if (value <= 100) {
-            result = 50d / 100d * (value - 0) + 0;
-        } else if (value <= 200) {
-            result = 50d / 100d * (value - 100) + 50;
-        } else if (value <= 700) {
-            result = 50d / 500d * (value - 200) + 100;
-        } else if (value <= 1200) {
-            result = 50d / 500d * (value - 700) + 150;
-        } else if (value <= 2340) {
-            result = 100d / 1140d * (value - 1200) + 200;
-        } else if (value <= 3090) {
-            result = 100d / 750d * (value - 2340) + 300;
-        } else {
-            result = 100d / 750d * (value - 3090) + 400;
+    /**
+     * @Description: ������so2���������IAQI
+     * @Param: [Cp, limitData]
+     * @return: java.lang.Integer
+     * @Author: ���������
+     * @Date: 2021/11/2
+     */
+    private static Integer calculateSO2HourlyIAQI(Double Cp){
+        Double BPHi;
+        Double BPLo;
+        Double IAQIHi;
+        Double IAQILo;
+        Double[] limitData = SO2_Hourly_Limit_Data;
+        int index = getStartIndexFromArray(Cp, limitData);
+        //������so2���������������������������������������24������������������������������������������
+        if(index ==SO2_Hourly_Limit_Data.length-1){
+            limitData = SO2_Daily_Limit_Data;
+            index = getStartIndexFromArray(Cp,limitData);
         }
-        return (int) Math.ceil(result);
+        if(index==limitData.length-1){
+            return 500;
+        }else{
+            BPHi = limitData[index+1];
+            BPLo = limitData[index];
+            IAQIHi = IAQI_Array[index+1];
+            IAQILo = IAQI_Array[index];
+        }
+        return calculateIAQIFormula(Cp,BPHi,BPLo,IAQIHi,IAQILo);
     }
 
-    //CO IAQI
-    public static int COAQI(Double value) {
-        double result;
-        if (value <= 0) {
-            result = 0;
-        } else if (value <= 5) {
-            result = 50d / 5d * (value - 0) + 0;
-        } else if (value <= 10) {
-            result = 50d / 5d * (value - 5) + 50;
-        } else if (value <= 35) {
-            result = 50d / 25d * (value - 10) + 100;
-        } else if (value <= 60) {
-            result = 50d / 25d * (value - 35) + 150;
-        } else if (value <= 90) {
-            result = 100d / 30d * (value - 60) + 200;
-        } else if (value <= 120) {
-            result = 100d / 30d * (value - 90) + 300;
-        } else {
-            result = 100d / 30d * (value - 120) + 400;
+    /**
+     * @Description: ������O3������IAQI
+     * @Param: [Cp]
+     * @return: java.lang.Integer
+     * @Author: ���������
+     * @Date: 2021/11/3
+     */
+    private static Integer calculateO3DailyIAQI(Double Cp){
+        Double BPHi;
+        Double BPLo;
+        Double IAQIHi;
+        Double IAQILo;
+        Double[] limitData = O3_Daily_Limit_Data;
+        int index = getStartIndexFromArray(Cp, limitData);
+        //������so2���������������������������������������24������������������������������������������
+        if(index ==O3_Daily_Limit_Data.length-1){
+            limitData = O3_Hourly_Limit_Data;
+            index = getStartIndexFromArray(Cp,limitData);
         }
-        return (int) Math.ceil(result);
+        if(index==limitData.length-1){
+            return 500;
+        }else{
+            BPHi = limitData[index+1];
+            BPLo = limitData[index];
+            IAQIHi = IAQI_Array[index+1];
+            IAQILo = IAQI_Array[index];
+        }
+        return calculateIAQIFormula(Cp,BPHi,BPLo,IAQIHi,IAQILo);
     }
 
-    //O3 IAQI
-    public static int O3AQI(Double value) {
-        double result;
-        if (value <= 0) {
-            result = 0;
-        } else if (value <= 100) {
-            result = 50d / 100d * (value - 0) + 0;
-        } else if (value <= 160) {
-            result = 50d / 60d * (value - 100) + 50;
-        } else if (value <= 215) {
-            result = 50d / 55d * (value - 160) + 100;
-        } else if (value <= 265) {
-            result = 50d / 150d * (value - 215) + 150;
-        } else if (value <= 800) {
-            result = 100d / 535d * (value - 265) + 200;
-        } else if (value <= 2100) {
-            result = 100d / 12d * (value - 800) + 300;
-        } else {
-            result = 100d / 12d * (value - 48) + 400;
-        }
-        return (int) Math.ceil(result);
+    /**
+     * @Description: ������IAQI���������
+     * @Param: [Cp, BPHi, BPLo, IAQIHi, IAQILo]
+     * @return: java.lang.Integer
+     * @Author: ���������
+     * @Date: 2021/11/3
+     */
+    private static Integer calculateIAQIFormula(Double Cp, Double BPHi, Double BPLo, Double IAQIHi, Double IAQILo) {
+        Double tmp1 = MathUtils.sub(IAQIHi, IAQILo);
+        Double tmp2 = MathUtils.sub(BPHi, BPLo);
+        Double tmp3 = MathUtils.sub(Cp, BPLo);
+
+        Double tmp4 = MathUtils.division(tmp1, tmp2, 2);
+        Double tmp5 = MathUtils.mul(tmp4, tmp3);
+        Double IAQI = MathUtils.add(tmp5, IAQILo);
+        return new Double(AmendUtils.sciCal(IAQI, 0)).intValue();
     }
+
+    /*������������������������������������������������������
+     * ������������������5               10
+     *       ���������[0,5,15,20]     [0,5,8,12]
+     *       ���������1(������������)     2
+     *       */
+    private static int getStartIndexFromArray(Double num, Double[] array) {
+        for (int i = 0; i < array.length - 1; i++) {
+            if (num >= array[i] && num < array[i + 1])
+                return i;
+            if (i == array.length - 2)
+                return i + 1;
+        }
+        return 0;
+    }
+
 }
+

--
Gitblit v1.8.0