private static double searchNearestLinkDoppler(DataTable dt, DataRow gps, ref DataTable result)
        {
            //近傍リンクの絞込
            string query = "START_LAT > " + (gps.Field <double>(AndroidGpsRawDao.ColumnLatitude) - 0.05);

            query += " AND START_LAT < " + (gps.Field <double>(AndroidGpsRawDao.ColumnLatitude) + 0.05);
            query += " AND START_LONG > " + (gps.Field <double>(AndroidGpsRawDao.ColumnLongitude) - 0.05);
            query += " AND START_LONG < " + (gps.Field <double>(AndroidGpsRawDao.ColumnLongitude) + 0.05);
            DataRow[] dataRows = dt.Select(query);


            double minDist = 255;

            double tempLat  = 0;
            double tempLong = 0;

            //各Homewardリンクセグメントに対して
            for (int j = 0; j < dataRows.Length; j++)
            {
                TwoDimensionalVector linkStartEdge = new TwoDimensionalVector((double)dataRows[j]["START_LAT"], (double)dataRows[j]["START_LONG"]);
                TwoDimensionalVector linkEndEdge   = new TwoDimensionalVector((double)dataRows[j]["END_LAT"], (double)dataRows[j]["END_LONG"]);
                TwoDimensionalVector GPSPoint      = new TwoDimensionalVector(gps.Field <double>(AndroidGpsRawDao.ColumnLatitude), gps.Field <double>(AndroidGpsRawDao.ColumnLongitude));

                //線分内の最近傍点を探す
                TwoDimensionalVector matchedPoint = TwoDimensionalVector.nearest(linkStartEdge, linkEndEdge, GPSPoint);

                //最近傍点との距離
                double tempDist = TwoDimensionalVector.distance(GPSPoint, matchedPoint);
                //リンク集合の中での距離最小を探す
                if (tempDist < minDist)
                {
                    minDist  = tempDist;
                    tempLat  = matchedPoint.x;
                    tempLong = matchedPoint.y;
                }
            }

            DataRow row = result.NewRow();

            CopyRawDataToCorrectedRowDoppler(row, gps);

            row.SetField(AndroidGpsRawDopplerDao.ColumnLatitude, tempLat);
            row.SetField(AndroidGpsRawDopplerDao.ColumnLongitude, tempLong);

            result.Rows.Add(row);

            return(minDist);
        }
Exemple #2
0
        public Tuple <string, int> detect(double lat, double lng)
        {
            string linkId         = "RB000000000x";
            int    semanticLinkId = -1;
            double distance       = 255;

            // インスタンス変数のリンク集合から近傍リンクの絞り込み
            string query = "START_LAT > " + (lat - 0.05);

            query += " AND START_LAT < " + (lat + 0.05);
            query += " AND START_LONG > " + (lng - 0.05);
            query += " AND START_LOMG < " + (lng + 0.05);
            DataRow[] dataRows = _linkTable.Select(query);

            // 現在値をベクトル表現
            TwoDimensionalVector currentPoint = new TwoDimensionalVector(lat, lng);

            // 全探索
            foreach (DataRow row in dataRows)
            {
                // リンクの始端終端をそれぞれベクトル表現
                TwoDimensionalVector linkStartEdge = new TwoDimensionalVector((double)row["START_LAT"], (double)row["START_LONG"]);
                TwoDimensionalVector linkEndEdge   = new TwoDimensionalVector((double)row["END_LAT"], (double)row["END_LONG"]);

                // ベクトル演算により現在値と着目しているリンクの最近傍点を得る
                TwoDimensionalVector matchedPoint = TwoDimensionalVector.nearest(linkStartEdge, linkEndEdge, currentPoint);

                // マッチ点と現在地の距離
                double tempDist = TwoDimensionalVector.distance(currentPoint, matchedPoint);

                if (tempDist < distance)
                {
                    distance       = tempDist;
                    linkId         = (string)row["LINK_ID"];
                    semanticLinkId = (int)row["SEMANTIC_LINK_ID"];
                }
            }

            return(new Tuple <string, int>(linkId, semanticLinkId));
        }
Exemple #3
0
        private Tuple <int, double> searchLinkComponent(List <LinkData> linkList, double latitude, double longitude)
        {
            double minDist = 255;


            int    tempNum    = 0;
            string tempLinkId = null;
            double offset     = 0;

            //各リンクセグメントに対して
            for (int i = 0; i < linkList.Count; i++)
            {
                TwoDimensionalVector linkStartEdge = new TwoDimensionalVector(linkList[i].START_LAT, linkList[i].START_LONG);
                TwoDimensionalVector linkEndEdge   = new TwoDimensionalVector(linkList[i].END_LAT, linkList[i].END_LONG);
                TwoDimensionalVector GPSPoint      = new TwoDimensionalVector(latitude, longitude);

                //線分内の最近傍点を探す
                TwoDimensionalVector matchedPoint = TwoDimensionalVector.nearest(linkStartEdge, linkEndEdge, GPSPoint);

                //最近傍点との距離
                double tempDist = TwoDimensionalVector.distance(GPSPoint, matchedPoint);


                //リンク集合の中での距離最小を探す
                if (tempDist < minDist)
                {
                    minDist = tempDist;

                    tempNum    = linkList[i].NUM;
                    tempLinkId = linkList[i].LINK_ID;

                    offset = HubenyDistanceCalculator.CalcHubenyFormula(linkList[i].START_LAT, linkList[i].START_LONG, latitude, longitude);
                }
            }

            return(new Tuple <int, double>(tempNum, offset));
        }