private void GetLocationData() { string url = @"http://developer.kensnz.com/getlocdata"; using (WebClient client = new WebClient()) { var json = client.DownloadString(url); JavaScriptSerializer ser = new JavaScriptSerializer(); var JSONArray = ser.Deserialize <Dictionary <string, string>[]>(json); //rTBnotes.AppendText(json + "\n\n"); foreach (Dictionary <string, string> map in JSONArray) { int userid = int.Parse(map["userid"]); double latitude = double.Parse(map["latitude"]); double longitude = double.Parse(map["longitude"]); string description = map["description"]; PlaceOfInterest poi = new PlaceOfInterest(userid, latitude, longitude, description); //listViewPOI.Items.Add(poi.UserID + " : " + poi.Latitude + " : " + poi.Longitude + " : " + poi.Description); placeOfInterests.Add(poi); if (!UserIds.Contains(poi.UserID)) { UserIds.Add(poi.UserID); CBofIds.Items.Add(poi.UserID); } } } }//GetLocationData
private void GetLocationData() { string url = @"http://developer.kensnz.com/getlocdata"; using (WebClient client = new WebClient()) { var json = client.DownloadString(url); JavaScriptSerializer ser = new JavaScriptSerializer(); var JSONArray = ser.Deserialize <Dictionary <string, string>[]>(json); foreach (Dictionary <string, string> map in JSONArray) { int userid = int.Parse(map["userid"]); double latitude = double.Parse(map["latitude"]); double longitude = double.Parse(map["longitude"]); string description = map["description"]; PlaceOfInterest poi = new PlaceOfInterest(userid, latitude, longitude, description); ListViewItem listViewItem = new ListViewItem(); listViewItem.Text = (poi.UserID.ToString()); listViewItem.SubItems.Add(poi.Latitude.ToString()); listViewItem.SubItems.Add(poi.Longitude.ToString()); listViewItem.SubItems.Add(poi.Description.ToString()); listViewPOI.Items.Add(listViewItem); placeOfInterests.Add(poi); } } }//GetLocationData
private static List <PlaceOfInterest> HullSorted(List <PlaceOfInterest> newPoints) { List <PlaceOfInterest> upperHull = new List <PlaceOfInterest>(); foreach (PlaceOfInterest p in SelectHull) { while (upperHull.Count >= 2) { PlaceOfInterest q = upperHull[upperHull.Count - 1]; PlaceOfInterest r = upperHull[upperHull.Count - 2]; if ((q.Latitude - r.Latitude) * (p.Longitude - r.Longitude) >= (q.Longitude - r.Longitude) * (p.Latitude - r.Latitude)) { upperHull.RemoveAt(upperHull.Count - 1); } else { break; } }//While upperHull.Add(p); } upperHull.RemoveAt(upperHull.Count - 1); List <PlaceOfInterest> lowerHull = new List <PlaceOfInterest>(); for (int i = SelectHull.Count - 1; i >= 0; i--) { PlaceOfInterest p = SelectHull[i]; while (lowerHull.Count >= 2) { PlaceOfInterest q = lowerHull[lowerHull.Count - 1]; PlaceOfInterest r = lowerHull[lowerHull.Count - 2]; if ((q.Latitude - r.Latitude) * (p.Longitude - r.Longitude) >= (q.Longitude - r.Longitude) * (p.Latitude - r.Latitude)) { lowerHull.RemoveAt(lowerHull.Count - 1); } else { break; } } lowerHull.Add(p); } lowerHull.RemoveAt(lowerHull.Count - 1); if (!(upperHull.Count == 1 && Enumerable.SequenceEqual(upperHull, lowerHull))) { upperHull.AddRange(lowerHull); upperHull.Add(SelectHull[0]); } return(upperHull); }