예제 #1
0
        public void InfiniteShouldReturnTheSameResultInBothVerison()
        {
            var minPoint = new Coordinate {
                Latitude = 6544, Longitude = 5577
            };
            var maxPoint = new Coordinate {
                Latitude = 9687, Longitude = 1254
            };

            var minPointA = new[] { minPoint.Latitude, minPoint.Longitude };
            var maxPointA = new[] { maxPoint.Latitude, maxPoint.Longitude };

            var hyperRect = new HyperRect <double>();

            hyperRect.MinPoint = minPointA;
            hyperRect.MaxPoint = maxPointA;

            var hyperRectCoordinate = new HyperRectCoordinate <Coordinate>();

            hyperRectCoordinate.MinPoint = minPoint;
            hyperRectCoordinate.MaxPoint = maxPoint;

            var rect           = hyperRect.Clone();
            var rectCoordinate = hyperRectCoordinate.Clone();

            var res1 = HyperRect <double> .Infinite(2, double.MaxValue, double.MinValue);

            var res2 = HyperRectCoordinate <Coordinate> .Infinite(2, double.MaxValue, double.MinValue);

            res1.MaxPoint[0].Should().Be(res2.MaxPoint.Latitude);
            res1.MaxPoint[1].Should().Be(res2.MaxPoint.Longitude);
            res1.MinPoint[0].Should().Be(res2.MinPoint.Latitude);
            res1.MinPoint[1].Should().Be(res2.MinPoint.Longitude);
        }
예제 #2
0
        /// <inheritdoc />
        public IEnumerable <int> NearestNeighborIndexes(TNode target, int k)
        {
            var point = this.PointSelector(target);
            var nearestNeighborList = new BoundablePriorityList <int, double>(k, true);
            var rect = HyperRect <double> .Infinite(this.Dimensions, double.MaxValue, double.MinValue);

            this.SearchForNearestNeighbors(this.rootNode, point, rect, 0, nearestNeighborList, double.MaxValue);
            return(nearestNeighborList);
        }
예제 #3
0
        /// <inheritdoc />
        public IEnumerable <int> RadialSearchIndexes(TNode center, double radius)
        {
            var nearestNeighbors = new BoundablePriorityList <int, double>();
            var centerPoint      = this.PointSelector(center);

            this.SearchForNearestNeighbors(
                this.rootNode,
                centerPoint,
                HyperRect <double> .Infinite(this.Dimensions, double.MaxValue, double.MinValue),
                0,
                nearestNeighbors,
                radius);

            return(nearestNeighbors);
        }