Ejemplo n.º 1
0
        private static void SaveMapMatchingToDB(string json)
        {
            dynamic response = JObject.Parse(json) as JObject;
            Dictionary<int, List<SpatialInformation>> linksWithWaypoints = new Dictionary<int, List<SpatialInformation>>();
            foreach (dynamic entries in response.diary.entries) {
                foreach (dynamic link in entries.route.links) {
                    List<SpatialInformation> waypoints = new List<SpatialInformation>();
                    if (link.wpts != null) {
                        int linkId = (int)link.id;

                        if (!linksWithWaypoints.ContainsKey(linkId)) {
                            linksWithWaypoints.Add(linkId, waypoints);
                        }

                        foreach (dynamic waypoint in link.wpts) {
                            int waypointId = (int)waypoint.id;
                            double x = (double)waypoint.x;
                            double y = (double)waypoint.y;
                            waypoints.Add(new SpatialInformation(waypointId, new GeoCoordinate(x, y)));
                        }
                    }
                }
            }

            DBController dbc = new DBController();
            dbc.UpdateGPSFactsWithMapMatching(linksWithWaypoints);
            dbc.Close();
        }