public double this[IGeoItem node1, IGeoItem node2] { get { return(node1.Position.GetDistance(node2.Position)); } }
public void Merge(IGeoItem item, double distance) { Items.Add(item, distance); Position = Items.Count == 1 ? item.Position : calculateCenter(item); Radius = Items.Count == 1 ? 0 : calculateRadius(); Count = item is Cluster ? Count + (item as Cluster).Count : Count + 1; }
public IEnumerable <IGeoItem> GetNeiboursInRadius(IGeoItem node, double radius) { return(from n in nodes let t = new Tuple <IGeoItem, double>(n, node.Position.GetDistance(n.Position)) where (t.Item1 != node) && t.Item2 < radius orderby t.Item2 select t.Item1); }
public IEnumerable <Tuple <IGeoItem, double> > GetEdgesFor(IGeoItem node) { return(from n in nodes where (n != node) let t = new Tuple <IGeoItem, double>(n, n.Position.GetDistance(node.Position)) orderby t.Item2 select t); }
private Windows.Devices.Geolocation.Geopoint calculateCenter(IGeoItem newItem) { var countB = newItem is Cluster ? (newItem as Cluster).count : 1; var total = this.Count + countB; return(new Geopoint(new BasicGeoposition() { Longitude = (this.Position.Position.Longitude * this.Count + newItem.Position.Position.Longitude * countB) / total, Latitude = (this.Position.Position.Latitude * this.Count + newItem.Position.Position.Latitude * countB) / total, })); }
private void regrateCenter(IGeoItem item) { var removedCount = item is Cluster ? (item as Cluster).count : 1; if (removedCount != count) { this.Position = new Geopoint(new BasicGeoposition() { Longitude = (this.Position.Position.Longitude * this.Count - item.Position.Position.Longitude * removedCount) / (this.Count - removedCount), Latitude = (this.Position.Position.Latitude * this.Count - item.Position.Position.Latitude * removedCount) / (this.Count - removedCount), }); } }
public bool Contains(IGeoItem itemToFind) { bool result = false; foreach (var item in Items.Keys) { if (item is Cluster) { result = (item as Cluster).Contains(itemToFind); } else { result = item == itemToFind; } if (result) { break; } } return(result); }
public IEnumerable <IGeoItem> GetNeiboursInRadius(IGeoItem node, double radius) { return(viewArea.GetNeiboursInRadius(node, radius)); }