コード例 #1
0
 public static double CalcAcc(double latitudeBefore, double longitudeBefore, 
     double latitudeThis, double longitudeThis, 
     double latitudeAfter, double longitudeAfter, double samplingTime)
 {
     //中間差分法による導出
     return (DistanceCalculator.CalcDistance(latitudeThis, longitudeThis, latitudeAfter, longitudeAfter) 
         - DistanceCalculator.CalcDistance(latitudeBefore, longitudeBefore, latitudeThis, longitudeBefore)) / Math.Pow(samplingTime, 2);
 }
コード例 #2
0
        /** km/h の速度を返す **/
        public static double CalcSpeed(double latitudeBefore, double longitudeBefore, DateTime timeBefore, double latitudeAfter, double longitudeAfter, DateTime timeAfter,
                                       double latitudeFocused, double longitudeFocused)
        {
            //中間差分法を用いた導出
            //return DistanceCalculator.CalcDistance(latitudeBefore, longitudeBefore, latitudeAfter, longitudeAfter) / 2 / samplingSeconds * 3.6;

            return((DistanceCalculator.CalcDistance(latitudeBefore, longitudeBefore, latitudeFocused, longitudeFocused) +
                    DistanceCalculator.CalcDistance(latitudeFocused, longitudeFocused, latitudeAfter, longitudeAfter)) /
                   (timeAfter - timeBefore).TotalSeconds * 3.6);
        }
コード例 #3
0
        private string SelectLink(double latitude, double longitude, double heading, DataRow[] selectedRows)
        {
            string matchedLink  = "";
            double minDistance  = double.PositiveInfinity;
            double linkDistance = double.PositiveInfinity;

            //車のHEADINGを計算
            double carHeading;

            if (heading > 180)
            {
                carHeading = heading - 180;
            }
            else
            {
                carHeading = heading;
            }

            //自動車の向きとリンクの向きのなす角
            double  minAngle = double.PositiveInfinity;
            Boolean flag     = true;

            foreach (DataRow row in selectedRows)
            {
                double pointY; //リンク上のGPSの点との最近点の緯度
                double pointX; //リンク上のGPSの点との最近点の経度

                //リンクとGPS上の点との距離とリンク上の最近点を計算
                CalculateMinimumDistancePointOfLink(latitude, longitude, row, out pointY, out pointX);

                //リンクとの最短距離
                double distance = DistanceCalculator.CalcDistance(latitude, longitude, pointY, pointX);

                if (row.Field <double?>("heading") != null)
                {
                    double linkHeading = row.Field <double>("heading");
                    //リンクとHEADINGの角度を算出
                    double angle = Math.Abs(carHeading - linkHeading);

                    if (angle > 90)
                    {
                        angle = 180 - angle;
                    }
                    if (linkDistance >= distance)
                    {
                        //リンクとの距離が10m以内でかつなす角が小さいものをマッチング
                        if (distance < 10 && (minAngle - angle > 3 ||
                                              (Math.Abs(minAngle - angle) <= 3 && linkDistance > distance)))
                        {
                            linkDistance = distance;
                            minAngle     = angle;
                            matchedLink  = row.Field <string>("link_id").Trim();
                            flag         = false;
                        }
                        //10m以内のリンクがないときは距離が短いものをマッチング
                        else if (minDistance >= distance && flag)
                        {
                            minDistance = distance;
                            matchedLink = row.Field <string>("link_id").Trim();
                        }
                    }
                }
                else
                {
                    //Headingが計算できないときは距離が短いものをマッチング
                    if (minDistance >= distance && flag)
                    {
                        minDistance = distance;

                        matchedLink = row.Field <string>("link_id").Trim();
                    }
                }
            }

            return(matchedLink);
        }