Example #1
0
 public IList <CalculatedDataOutput> CalculateAvgDistancesForAllToAll_v2C(IList <CalculatedDataOutput> data) //the data in the finally element of array should be empty string - see ReduceToHourData_v2 ... note this is bug prone due to it being called from anthine
 {
     foreach (CalculatedDataOutput dataRow in data)
     {
         LatLongPoint pointB = new LatLongPoint
         {
             Latitude  = Convert.ToDouble(dataRow.Latitude),
             Longitude = Convert.ToDouble(dataRow.Longitude)
         };
         double avgDist = CalculateAvgDistancesForAToAll_v2C(data, pointB);
         // dataRow[dataRow.Length - 1] = avgDist.ToString(); // this end element should be "", but could do with a sanity check/validation. Even better, use a proper class!
         dataRow.NeigbourhoodSize = avgDist.ToString();
         double analyse = avgDist - AcceptableNeighbourhoodSize;
         if (analyse > 0)
         {
             dataRow.IsAcceptable = true.ToString();
             dataRow.IsHappyFace  = " :-) ";
         }
         else
         {
             dataRow.IsAcceptable = true.ToString();
             dataRow.IsHappyFace  = " :-( ";
         }
     }
     return(data);
 }
Example #2
0
        public double CalculateAvgDistancesForAToAll_v2C(IList <CalculatedDataOutput> data, LatLongPoint pointA) //ideally the reduced data
        {
            double cumDistanceAToB = 0;

            foreach (CalculatedDataOutput row in data)
            {
                var latitude = row.Latitude;
                var logitude = row.Longitude;

                LatLongPoint pointB = new LatLongPoint
                {
                    Latitude  = Convert.ToDouble(latitude),
                    Longitude = Convert.ToDouble(logitude)
                };

                double distanceAToB = CalculateDist(pointA, pointB);
                cumDistanceAToB += distanceAToB;
            }

            if (data.Count() == 0) // zero error
            {
                return(0);         // not technically true but ok for here
            }

            double avgDistanceForAToAll = cumDistanceAToB / data.Count(); // this forms the index measure for the last hour

            return(avgDistanceForAToAll);
        }
Example #3
0
        public double CalculateDist(LatLongPoint point1, LatLongPoint point2)
        {
            double LatDist  = Math.Abs(point1.Latitude - point2.Latitude);
            double LongDist = Math.Abs(point1.Longitude - point2.Longitude);

            double aSq = Math.Pow(LatDist, 2);
            double bSq = Math.Pow(LongDist, 2);
            double cSq = aSq + bSq;

            double c = Math.Sqrt(cSq);

            return(c);
        }
Example #4
0
 public IList <string[]> CalculateAvgDistancesForAllToAll(IList <string[]> data) //the data in the finally element of array should be empty string - see ReduceToHourData_v2 ... note this is bug prone due to it being called from anthine
 {
     foreach (string[] dataRow in data)
     {
         LatLongPoint pointB = new LatLongPoint
         {
             Latitude  = Convert.ToDouble(dataRow[8]),
             Longitude = Convert.ToDouble(dataRow[9])
         };
         double avgDist = CalculateAvgDistancesForAToAll(data, pointB);
         dataRow[dataRow.Length - 1] = avgDist.ToString(); // this end element should be "", but could do with a sanity check/validation. Even better, use a proper class!
     }
     return(data);
 }