示例#1
0
        public async Task <IActionResult> GetPath(string user, string req_user)
        {
            int             user1_id, user2_id, start, end, graphNo = 0, V_No = Data.footGrapheVertices;
            Location        loc_1, loc_2;
            List <double[]> lst   = new List <double[]>();
            var             final = new Hashtable();
            Calculations    cal   = new Calculations();

            user1_id = LocationData.GetUserId(user);
            user2_id = LocationData.GetUserId(req_user);

            loc_1 = await FetchUserLocation(user1_id);

            loc_2 = await FetchUserLocation(user2_id);

            start = cal.GetNearestVertexNo(V_No, graphNo, loc_1.Lat, loc_1.Lon);
            end   = cal.GetNearestVertexNo(V_No, graphNo, loc_2.Lat, loc_2.Lon);

            if (start != end)
            {
                int[] routes = cal.GetRouteNumbers(graphNo, start, end);
                double[,] routeLocations;
                foreach (int r in routes)
                {
                    routeLocations = LocationData.GetFootRoute(r);
                    lst.AddRange(new List <double[]>(cal.ValidateRoute(start, end, graphNo, r, routeLocations)));
                }
                final.Add("routelocations", lst);
                final.Add("distance_time", cal.FindDistanceAndTime(graphNo, start, end));
                return(Json(final));
            }
            return(Json(final));
        }
示例#2
0
        public async Task <IActionResult> UserLocation(string userName, double LAT, double LON)
        {
            int userId = LocationData.GetUserId(userName);

            if (userId != 0)
            {
                Location loc = new Location()
                {
                    Username = userName,
                    Lat      = LAT,
                    Lon      = LON
                };
                try
                {
                    FirebaseClient client = new FirebaseClient("https://university-roadmap-default-rtdb.firebaseio.com/");
                    await client.Child("UserLocation/" + userId).PutAsync(loc);

                    return(Ok("Successfully Updated..!"));
                }
                catch
                {
                    return(BadRequest("There is an issue with realtime database connection..!"));
                }
            }
            else
            {
                return(BadRequest("This username is not exist in the database ..!"));
            }
        }