// GPSデータ点と、driver_idから最近傍リンクとセマンティックリンクを求める // driver_idで読み込むセマンティックリンクを限定する public static Tuple <string, int> detectLink(int driverId, string direction, double lat, double lng) { string linkId = "RB000000000x"; int semanticLinkId = -1; #region Driver毎に、特定のセマンティックリンクidのリストの作成 List <int> semanticLinkIdList = new List <int>(); switch (driverId) { // 運転者やルート追加ごとにこれらの更新が必要になる。 case 1: if (direction == "outward") { for (int id = 187; id <= 201; id++) { semanticLinkIdList.Add(id); } } else if (direction == "homeward") { for (int id = 202; id <= 218; id++) { semanticLinkIdList.Add(id); } } break; } int[] semanticLinkIdArray = semanticLinkIdList.ToArray(); #endregion // 運転者ごとのリンクが得られる // TODO 何度も同じテーブルを得ることになるので、上手くキャッシュする仕組みが必要。 DataTable linkTable = LinkDao.GetLinkTableforMM(semanticLinkIdArray); return(new Tuple <string, int>(linkId, semanticLinkId)); }
private static LinkDetector CreateInstance(int driverID, string direction) { // リンクテーブルを作成 #region Driver毎に、特定のセマンティックリンクidのリストの作成 List <int> semanticLinkIdList = new List <int>(); switch (driverID) { // 運転者やルート追加ごとにこれらの更新が必要になる。 // TODO: ここをハードコードにしない case 1: if (direction == "outward") { for (int id = 187; id <= 201; id++) { semanticLinkIdList.Add(id); } } else if (direction == "homeward") { for (int id = 202; id <= 218; id++) { semanticLinkIdList.Add(id); } } break; } int[] semanticLinkIdArray = semanticLinkIdList.ToArray(); #endregion return(new LinkDetector { DriverID = driverID, Direction = direction, _linkTable = LinkDao.GetLinkTableforMM(semanticLinkIdArray) }); }
public static DataTable getResultMapMatchingDoppler(DataTable gpsRawTable, InsertDatum datum) { if (gpsRawTable.Rows.Count == 0) { return(new DataTable()); } List <DataTable> dt = new List <DataTable>(); if (datum.DriverId == 1)//被験者1用のマップマッチング道路リンクを取得 { int[] id = new int[] { 220 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "復路,代官山下ルート"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 224 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "復路,代官山上ルート"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 221 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "往路,小学校上ルート"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 225 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "往路,小学校下ルート"; dt.Add(tempTable); dt[3].DefaultView.Sort = "START_LAT, " + "" + "" + "" + "" + "" + "" + "" + "" + "START_LONG"; } else if (datum.DriverId == 17)//マップマッチング道路リンクを取得 { int[] id = new int[] { 328 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17復路ルート1"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 329 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート1"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 330 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート2"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 331 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート2"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 340 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート3"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 341 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17復路ルート3"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; } else if (datum.DriverId == 28) { int[] id = new int[] { 365 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id); tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 往路ルート1"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 366 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 復路ルート1"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 369 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 往路ルート2"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 370 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 復路ルート2"; dt.Add(tempTable); dt[3].DefaultView.Sort = "START_LAT, START_LONG"; } //TODO マップマッチング処理 double[] sumDist = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の総和 double[] maxDist = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の最大値 DataTable[] mapMatchedGpsTable = DataTableUtil.GetAndroidGpsRawDopplerTableArray(dt.Count); for (int i = 0; i < gpsRawTable.Rows.Count; i++) { for (int n = 0; n < dt.Count; n++) { double tempDist = searchNearestLinkDoppler(dt[n], gpsRawTable.Rows[i], ref mapMatchedGpsTable[n]); sumDist[n] += tempDist; if (tempDist > maxDist[n]) { maxDist[n] = tempDist; } } } int element = getMinElement(sumDist); if (sumDist.Length == 0) { SlackUtil.noMapMatching(datum, gpsRawTable.Rows[0]); return(new DataTable()); } if (sumDist[element] > 0.5 || maxDist[element] > 0.003) { SlackUtil.noMapMatching(datum, gpsRawTable.Rows[0]); return(new DataTable()); } return(mapMatchedGpsTable[element]); }
public static DataTable getResultMapMatching(DataTable gpsRawTable, InsertDatum datum) { if (gpsRawTable.Rows.Count == 0) { return(new DataTable()); } List <DataTable> dt = new List <DataTable>(); if (datum.DriverId == 1)//富井先生用のマップマッチング道路リンクを取得 { int[] id = new int[] { 220 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id);//復路マップマッチング(富井先生:代官山下ルート) tempTable.TableName = "富井先生,復路,代官山下ルート"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 224 }; tempTable = LinkDao.GetLinkTableforMM(id);//復路マップマッチング(富井先生:代官山上ルート) tempTable.TableName = "富井先生,復路,代官山上ルート"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 221 }; tempTable = LinkDao.GetLinkTableforMM(id);//往路マップマッチング(富井先生:小学校上ルート) tempTable.TableName = "富井先生,往路,小学校上ルート"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 225 }; tempTable = LinkDao.GetLinkTableforMM(id);//往路マップマッチング(富井先生:小学校下ルート) tempTable.TableName = "富井先生,往路,小学校下ルート"; dt.Add(tempTable); dt[3].DefaultView.Sort = "START_LAT, " + "" + "" + "" + "" + "" + "" + "" + "" + "START_LONG"; } //TODO マップマッチング処理 double[] sumDist = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の総和 double[] maxDist = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の最大値 DataTable[] mapMatchedGpsTable = DataTableUtil.GetAndroidGpsRawTableArray(dt.Count); for (int i = 0; i < gpsRawTable.Rows.Count; i++) { for (int n = 0; n < dt.Count; n++) { double tempDist = searchNearestLink(dt[n], gpsRawTable.Rows[i], ref mapMatchedGpsTable[n]); sumDist[n] += tempDist; if (tempDist > maxDist[n]) { maxDist[n] = tempDist; } } } int element = getMinElement(sumDist); if (sumDist.Length == 0) { return(new DataTable()); } if (sumDist[element] > 0.5 || maxDist[element] > 0.003) { return(new DataTable()); } return(mapMatchedGpsTable[element]); }