Exemple #1
0
		private static Cluster<T> BuildCluster<T>(ISpatialIndex<PointInfo<T>> index, PointInfo<T> point, IReadOnlyList<PointInfo<T>> neighborhood, double epsilon, int minimumPointsPerCluster)
			where T : IPointData
		{
			var points = new List<T>() { point.Item };
			var cluster = new Cluster<T>() { Objects = points };
			point.Cluster = cluster;

			var queue = new Queue<PointInfo<T>>(neighborhood);
			while (queue.Any())
			{
				var newPoint = queue.Dequeue();
				if (!newPoint.Visited)
				{
					newPoint.Visited = true;
					var newNeighbors = index.Search(newPoint.Point, epsilon);
					if (newNeighbors.Count >= minimumPointsPerCluster)
						foreach (var p in newNeighbors)
							queue.Enqueue(p);
				}

				if (newPoint.Cluster == null)
				{
					newPoint.Cluster = cluster;
					points.Add(newPoint.Item);
				}
			}

			return cluster;
		}
Exemple #2
0
        public IEnumerable <IVectorFeature> GetFeatureByRange(Envelope env)
        {
            var featureIds = _SpatialIndex.Search(env);

            foreach (var fid in featureIds)
            {
                yield return(GetFeatureByID(fid));
            }
        }
Exemple #3
0
		public static ClusterSet<T> CalculateClusters<T>(
			ISpatialIndex<PointInfo<T>> index,
			double epsilon,
			int minimumPointsPerCluster)
			where T : IPointData
		{
			var points = index.Search().ToList();

			var clusters = new List<Cluster<T>>();

			foreach (var p in points)
			{
				if (p.Visited) continue;

				p.Visited = true;
				var candidates = index.Search(p.Point, epsilon);

				if (candidates.Count >= minimumPointsPerCluster)
				{
					clusters.Add(
						BuildCluster(
							index,
							p,
							candidates,
							epsilon,
							minimumPointsPerCluster));
				}
			}

			return new ClusterSet<T>
			{
				Clusters = clusters,
				UnclusteredObjects = points
					.Where(p => p.Cluster == null)
					.Select(p => p.Item)
					.ToList(),
			};
		}
Exemple #4
0
 /// <inheritdoc />
 public IObservable <Element> Get(BoundingBox bbox, int zoomLevel)
 {
     return(SpatialIndexTree.Search(bbox)
            .ObserveOn(Scheduler.CurrentThread)
            .Select((offset) => ElementStore.Get(offset)));
 }