private string[] NeighbourNodesInRange(LocationRange departureLocRange) { List<string> targetNeighbours = new List<string>(); foreach (ServiceNode neighbour in Neighbours) { /** The neighbour is within the range. */ if (departureLocRange.contains(neighbour.Location)) { targetNeighbours.Add(baseForwardAddress + neighbour.NodeName); } } return targetNeighbours.ToArray(); }
public List<Trip> GetTripWithRange(QueryBuilder filterTrip, LocationRange departureLocRange) { tripDatabaseLock.EnterReadLock(); try { tripDatabase = XDocument.Load(tripDatabasePath); var baseQuery = (from t in tripDatabase.Descendants("Trip") where departureLocRange.contains(new Location(Convert.ToDouble(t.Element("DepartureLatitude").Value),Convert.ToDouble(t.Element("DepartureLongitude").Value))) select new Trip() { ID = Convert.ToInt32(t.Element("ID").Value), Owner = t.Element("Owner").Value, DepartureName = t.Element("DepartureName").Value, DepartureDateTime = Convert.ToDateTime(t.Element("DepartureDateTime").Value), ArrivalName = t.Element("ArrivalName").Value, ArrivalDateTime = Convert.ToDateTime(t.Element("ArrivalDateTime").Value), Smoke = Convert.ToBoolean(t.Element("Smoke").Value), Music = Convert.ToBoolean(t.Element("Music").Value), Cost = Convert.ToDouble(t.Element("Cost").Value), FreeSits = Convert.ToInt32(t.Element("FreeSits").Value), Notes = t.Element("Notes").Value, Modifiable = Convert.ToBoolean(t.Element("Modifiable").Value) }); IEnumerable<Trip> filteredQuery = FilterQuery(filterTrip, baseQuery); return filteredQuery.ToList(); } finally { tripDatabaseLock.ExitReadLock(); } }