Android Open Source - Sunset M A P






From Project

Back to project page Sunset.

License

The source code is released under:

GNU General Public License

If you think the Android project Sunset listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.rosehulman.mobilesunset;
/*  ww  w.  j  a  v a 2  s .  c  o  m*/
import android.util.Log;

public class MAP {

  private static final double [] PVS = {0.00006645, 0.00013290, 0.00019935, 0.00026580, 0.00033225, 0.00039870, 0.00046514, 0.00053159, 0.00059804, 0.00066449, 0.00073094, 0.00079739, 0.00086384, 0.00093029, 0.00099674, 0.00106319, 0.00150181, 0.00204933, 0.00263903, 0.00319257, 0.00373347, 0.00435934, 0.00507542, 0.00580486, 0.00664304, 0.00786244, 0.00962947, 0.01170381, 0.01356499, 0.01477863, 0.01532376, 0.01577071, 0.01689114, 0.01894273, 0.02145717, 0.02383163, 0.02594357, 0.02795410, 0.02975086, 0.03112222, 0.03208139, 0.03281137, 0.03344980, 0.03412034, 0.03504015, 0.03635071, 0.03784781, 0.03904410, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963, 0.03938963};

  private static final double [] PVNS = {0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.06043226, 0.05980158, 0.05716117, 0.05256470, 0.04671747, 0.04045857, 0.03433548, 0.02850713, 0.02310116, 0.01832646, 0.01432692, 0.01110797, 0.00866754, 0.00692981, 0.00577514, 0.00500595, 0.00442187, 0.00387381, 0.00331774, 0.00278829, 0.00230881, 0.00184453, 0.00136426, 0.00132025, 0.00127624, 0.00123223, 0.00118822, 0.00114421, 0.00110021, 0.00105620, 0.00101219, 0.00096818, 0.00092417, 0.00088016, 0.00083616, 0.00079215, 0.00074814, 0.00070413, 0.00066012, 0.00061612, 0.00057211, 0.00052810, 0.00048409, 0.00044008, 0.00039607, 0.00035207, 0.00030806, 0.00026405, 0.00022004, 0.00017603, 0.00013202, 0.00008802, 0.00004401, 0.00000000};

  private static final double [] PTS = {0.00018711, 0.00019788, 0.00020917, 0.00022099, 0.00023337, 0.00024632, 0.00025986, 0.00027400, 0.00028877, 0.00030419, 0.00032027, 0.00033704, 0.00035451, 0.00037269, 0.00039162, 0.00041130, 0.00043176, 0.00045301, 0.00047507, 0.00049796, 0.00052169, 0.00054628, 0.00057175, 0.00059811, 0.00062537, 0.00065355, 0.00068266, 0.00071272, 0.00074373, 0.00077570, 0.00080865, 0.00084258, 0.00087749, 0.00091340, 0.00095031, 0.00098822, 0.00102714, 0.00106705, 0.00110797, 0.00114988, 0.00119279, 0.00123669, 0.00128156, 0.00132741, 0.00137422, 0.00142197, 0.00147064, 0.00152024, 0.00157072, 0.00162208, 0.00167428, 0.00172731, 0.00178113, 0.00183572, 0.00189105, 0.00194708, 0.00200378, 0.00206111, 0.00211904, 0.00217752, 0.00223652, 0.00229599, 0.00235590, 0.00241620, 0.00247686, 0.00253785, 0.00259913, 0.00266069, 0.00272250, 0.00278458, 0.00284694, 0.00290962, 0.00297269, 0.00303626, 0.00310047, 0.00316553, 0.00323170, 0.00329933, 0.00336886, 0.00344084, 0.00351595, 0.00359498, 0.00367893, 0.00376893, 0.00386632, 0.00397265, 0.00408967, 0.00421935, 0.00436385, 0.00452557, 0.00470705, 0.00491099, 0.00514019, 0.00539748, 0.00568568, 0.00600748, 0.00636535, 0.00676146, 0.00719753, 0.00767472, 0.00819352, 0.00875363, 0.00935381, 0.00999185, 0.01066447, 0.01136725, 0.01209465, 0.01284002, 0.01359566, 0.01435292, 0.01510234, 0.01583381, 0.01653686, 0.01720079, 0.01781503, 0.01836938, 0.01885428, 0.01926111, 0.01958241, 0.01981213, 0.01994581, 0.01998069, 0.01991586, 0.01975221, 0.01949248, 0.01914110, 0.01870413, 0.01818900, 0.01760435, 0.01695976, 0.01626545, 0.01553204, 0.01477025, 0.01399063, 0.01320333, 0.01241790, 0.01164304, 0.01088656, 0.01015517, 0.00945450, 0.00878903, 0.00816213, 0.00757609, 0.00703219, 0.00653080, 0.00607150, 0.00565315, 0.00527408, 0.00493216, 0.00462493, 0.00434973, 0.00410375, 0.00388417, 0.00368819, 0.00351311, 0.00335638, 0.00321562, 0.00308862, 0.00297342, 0.00286825, 0.00277155, 0.00268196, 0.00259832, 0.00251964, 0.00244507, 0.00237393, 0.00230564, 0.00223975, 0.00217587, 0.00211373, 0.00205308, 0.00199376, 0.00193564, 0.00187861, 0.00182260, 0.00176758, 0.00171351, 0.00166038, 0.00160817, 0.00155689, 0.00150653, 0.00145711, 0.00140863, 0.00136110, 0.00131454, 0.00126894, 0.00122432, 0.00118069, 0.00113806, 0.00109642, 0.00105578, 0.00101614, 0.00097751, 0.00093988, 0.00090325, 0.00086762, 0.00083298, 0.00079932, 0.00076665, 0.00073495, 0.00070421, 0.00067442, 0.00064557, 0.00061764, 0.00059063, 0.00056453, 0.00053931, 0.00051496, 0.00049146, 0.00046881, 0.00044698, 0.00042595, 0.00040571, 0.00038624, 0.00036753, 0.00034954, 0.00033228, 0.00031570, 0.00029981, 0.00028457, 0.00026998, 0.00025601, 0.00024264, 0.00022985, 0.00021763, 0.00020596, 0.00019481, 0.00018418, 0.00017404, 0.00016438, 0.00015518, 0.00014642, 0.00013809, 0.00013016, 0.00012263, 0.00011548, 0.00010869, 0.00010225, 0.00009614, 0.00009036, 0.00008488};

  private static final double [] PTNS = {0.00195748, 0.00213332, 0.00230614, 0.00247233, 0.00263297, 0.00278313, 0.00292868, 0.00306224, 0.00319103, 0.00331318, 0.00343119, 0.00354121, 0.00365185, 0.00375741, 0.00386148, 0.00396719, 0.00406925, 0.00417170, 0.00427642, 0.00438753, 0.00449599, 0.00460440, 0.00471107, 0.00481241, 0.00491228, 0.00500528, 0.00508366, 0.00515075, 0.00520158, 0.00523686, 0.00525427, 0.00524993, 0.00523195, 0.00519179, 0.00513602, 0.00507337, 0.00500137, 0.00492072, 0.00484249, 0.00476853, 0.00469621, 0.00463191, 0.00457901, 0.00453805, 0.00450318, 0.00447892, 0.00446905, 0.00447050, 0.00448162, 0.00450502, 0.00453951, 0.00458717, 0.00464390, 0.00471798, 0.00479919, 0.00489874, 0.00500551, 0.00511991, 0.00524650, 0.00537109, 0.00548783, 0.00559503, 0.00570739, 0.00579749, 0.00587933, 0.00595134, 0.00600150, 0.00604087, 0.00607055, 0.00609187, 0.00610409, 0.00611362, 0.00612484, 0.00613601, 0.00615264, 0.00617128, 0.00619146, 0.00620996, 0.00622309, 0.00623251, 0.00622910, 0.00621362, 0.00618345, 0.00613140, 0.00605898, 0.00596229, 0.00584488, 0.00570522, 0.00554022, 0.00536665, 0.00517630, 0.00498313, 0.00477984, 0.00458017, 0.00438863, 0.00419984, 0.00402611, 0.00386792, 0.00372993, 0.00361443, 0.00352379, 0.00346224, 0.00342827, 0.00341944, 0.00342726, 0.00346900, 0.00352457, 0.00358485, 0.00366524, 0.00373958, 0.00381068, 0.00387594, 0.00393184, 0.00397450, 0.00400382, 0.00402264, 0.00403380, 0.00404418, 0.00405618, 0.00406965, 0.00409296, 0.00411983, 0.00415093, 0.00418630, 0.00422952, 0.00426525, 0.00429468, 0.00431216, 0.00431336, 0.00429657, 0.00425857, 0.00420087, 0.00412957, 0.00404405, 0.00395530, 0.00386506, 0.00378162, 0.00371752, 0.00366368, 0.00362933, 0.00361914, 0.00362505, 0.00365215, 0.00369485, 0.00375127, 0.00381631, 0.00388653, 0.00395741, 0.00402698, 0.00409365, 0.00414907, 0.00420416, 0.00424225, 0.00426515, 0.00428023, 0.00428392, 0.00428036, 0.00426243, 0.00423771, 0.00420851, 0.00417742, 0.00415442, 0.00413560, 0.00413149, 0.00414490, 0.00417062, 0.00421098, 0.00426929, 0.00433768, 0.00441729, 0.00449491, 0.00457093, 0.00464119, 0.00469344, 0.00473135, 0.00474736, 0.00474644, 0.00471845, 0.00467097, 0.00460374, 0.00452481, 0.00443076, 0.00432684, 0.00421714, 0.00409873, 0.00398367, 0.00386870, 0.00375673, 0.00365189, 0.00355849, 0.00347692, 0.00340749, 0.00334615, 0.00329517, 0.00326051, 0.00323032, 0.00320415, 0.00317944, 0.00314704, 0.00311311, 0.00307707, 0.00302983, 0.00298103, 0.00292203, 0.00286493, 0.00280731, 0.00275340, 0.00271477, 0.00268735, 0.00267897, 0.00268691, 0.00271157, 0.00275443, 0.00280742, 0.00286944, 0.00293491, 0.00299308, 0.00304913, 0.00308086, 0.00309691, 0.00308747, 0.00305151, 0.00299077, 0.00290696, 0.00280337, 0.00268569, 0.00255869, 0.00242505, 0.00229277, 0.00216430, 0.00204257, 0.00192671, 0.00182119, 0.00172285, 0.00163068, 0.00154042, 0.00144840, 0.00135411, 0.00125478, 0.00115138, 0.00104648};

  private static final double MIN_SVM_OUTPUT = -4;

  private static final double MAX_SVM_OUTPUT = 4;

  private static final double MIN_TIMES_OUTPUT = -120;

  private static final double MAX_TIMES_OUTPUT = 120;

  private static final double MIN_MAP = 0.001;
  
  public static double map_time(double timeDistanceInMinutes){
    int timeIndex = -1;
    double result = -1;
    double PTSValue, PTNSValue;
    if (timeDistanceInMinutes <= MIN_TIMES_OUTPUT
        || timeDistanceInMinutes >= MAX_TIMES_OUTPUT) {
      PTSValue = MIN_MAP;
      PTNSValue = 1;
    } else {
      timeIndex = (int) Math
          .ceil((timeDistanceInMinutes - MIN_TIMES_OUTPUT)
              / ((MAX_TIMES_OUTPUT - MIN_TIMES_OUTPUT) / (PTS.length - 1)));
      PTSValue = PTS[timeIndex];
      PTNSValue = PTNS[timeIndex];
    }
    result = PTSValue / (PTSValue + PTNSValue);
    return result;
  }
  
  public static double map_svm(double svmDistance){
    double result = -1;
    int visualIndex = -1;
    double PVSValue, PVNSValue;
    if (svmDistance <= MIN_SVM_OUTPUT || svmDistance >= MAX_SVM_OUTPUT) {
      PVSValue = MIN_MAP;
      PVNSValue = 1;
    } else {
      visualIndex = (int) Math.ceil((svmDistance - MIN_SVM_OUTPUT)
          / ((MAX_SVM_OUTPUT - MIN_SVM_OUTPUT) / (PVS.length - 1)));
      PVSValue = PVS[visualIndex];
      PVNSValue = PVNS[visualIndex];
    }
    result = PVSValue / (PVSValue + PVNSValue);
    return result;
  }
  public static double map(double svmDistance, double timeDistanceInMinutes) {
    // get which bin it is in
    double result = -1;
    int visualIndex = -1, timeIndex = -1;
    double PVSValue, PVNSValue, PTSValue, PTNSValue;

    if (svmDistance <= MIN_SVM_OUTPUT || svmDistance >= MAX_SVM_OUTPUT) {
      PVSValue = MIN_MAP;
      PVNSValue = 1;
    } else {
      visualIndex = (int) Math.ceil((svmDistance - MIN_SVM_OUTPUT)
          / ((MAX_SVM_OUTPUT - MIN_SVM_OUTPUT) / (PVS.length - 1)));
      PVSValue = PVS[visualIndex];
      PVNSValue = PVNS[visualIndex];
    }

    if (timeDistanceInMinutes <= MIN_TIMES_OUTPUT
        || timeDistanceInMinutes >= MAX_TIMES_OUTPUT) {
      PTSValue = MIN_MAP;
      PTNSValue = 1;
    } else {
      timeIndex = (int) Math
          .ceil((timeDistanceInMinutes - MIN_TIMES_OUTPUT)
              / ((MAX_TIMES_OUTPUT - MIN_TIMES_OUTPUT) / (PTS.length - 1)));
      PTSValue = PTS[timeIndex];
      PTNSValue = PTNS[timeIndex];
    }
//    Log.d(MobileSunset.TAG, String.format("time index [%d], svmIndex [%d]", timeIndex,visualIndex));
//    Log.d(MobileSunset.TAG, String.format("PVS = [%.2f], PVNS = [%.2f], PTS = [%.2f], PTNS = [%.2f],",PVSValue, PVNSValue, PTSValue, PTNSValue  ));
    result = (PVSValue * PTSValue)
        / ((PVSValue * PTSValue) + (PVNSValue * PTNSValue));
    return result;
  }

}




Java Source Code List

edu.rosehulman.mobilesunset.CameraPreview.java
edu.rosehulman.mobilesunset.MAP.java
edu.rosehulman.mobilesunset.MobileSunset.java
edu.rosehulman.mobilesunset.OddsRatios.java
edu.rosehulman.mobilesunset.svm.SVMData.java
edu.rosehulman.mobilesunset.svm.SVM.java
edu.rosehulman.sunrisesunset.SunriseSunsetCalculator.java
edu.rosehulman.sunrisesunset.Zenith.java
edu.rosehulman.sunrisesunset.calculator.SolarEventCalculator.java
edu.rosehulman.sunrisesunset.dto.Location.java