public IActionResult GetFloor(int department, int floor) { int n = 0; List <double[]> lst = new List <double[]>(); var final = new Hashtable(); double[] temp = new double[2]; double[,] floorLocations = LocationData.GetFloorLocations(department, floor); Dictionary <string, double[]> places = LocationData.GetFloorPlaces(department, floor); Place[] arr = new Place[places.Count]; for (int i = 0; i < floorLocations.GetLength(0); i++) { lst.Add(new double[] { floorLocations[i, 0], floorLocations[i, 1] }); } //this should change according to the department if (floor == 0) { final.Add("floor_0_locations", lst); } else if (floor == 1) { final.Add("floor_1_locations", lst); } else { final.Add("floor_2_locations", lst); } foreach (KeyValuePair <string, double[]> pair in places) { temp = pair.Value; arr[n++] = new Place() { name = pair.Key, lat = temp[0], lon = temp[1] }; } final.Add("places", arr); return(Json(final)); }
public IActionResult GetFloorWithPlace(int placeID) { int n = 0; int[] ids = LocationData.GetDepartmentAndFloor(placeID); List <double[]> lst = new List <double[]>(); var final = new Hashtable(); double[] temp = new double[2]; double[,] floorLocations = LocationData.GetFloorLocations(ids[0], ids[1]); Dictionary <string, double[]> places = LocationData.GetFloorPlaces(ids[0], ids[1]); Dictionary <string, double[]> place = LocationData.GetPlaceWithName(placeID); Place[] arr = new Place[places.Count]; Place pl = new Place(); for (int i = 0; i < floorLocations.GetLength(0); i++) { lst.Add(new double[] { floorLocations[i, 0], floorLocations[i, 1] }); } //this should change according to the department if (ids[1] == 0) { final.Add("floor_0_locations", lst); } else if (ids[1] == 1) { final.Add("floor_1_locations", lst); } else { final.Add("floor_2_locations", lst); } foreach (KeyValuePair <string, double[]> pair_0 in place)//only once { foreach (KeyValuePair <string, double[]> pair in places) { if (pair_0.Key == pair.Key) { temp = pair.Value; pl = new Place() { name = pair.Key, lat = temp[0], lon = temp[1] }; } else { temp = pair.Value; arr[n++] = new Place() { name = pair.Key, lat = temp[0], lon = temp[1] }; } } } final.Add("places", arr); final.Add("place", pl); return(Json(final)); }