Example #1
0
 public float[] TransformationOfDistance(float distance, IMBR mbr)
 {
     var transformation = new float[mbr.Lower.Length];
     for (var i = 0; i < mbr.Lower.Length; i++)
         transformation[i] = distance;
     return transformation;
 }
Example #2
0
 public RTreeNode(IMBR mbr, IEnumerable<ARTreeContainer> children = null, ARTreeContainer parent = null)
 {
     if (parent != null)
         Parent = parent;
     Lower = mbr.Lower;
     Upper = mbr.Upper;
     Children = children != null ? new List<ARTreeContainer>(children) : new List<ARTreeContainer>();
 }
 public SpatialDataContainer(IMBR mbr,
     ARTreeContainer parent = null)
 {
     if (parent != null)
         Parent = parent;
     Lower = mbr.Lower;
     Upper = mbr.Upper;
 }
Example #4
0
 public RTreeLeaf(IMBR mbr, ARTreeContainer parent = null)
 {
     Lower = mbr.Lower;
     Upper = mbr.Upper;
     if (parent != null)
         Parent = parent;
     Data = new List<IRTreeDataContainer>();
 }
Example #5
0
        public float[] TransformationOfDistance(float distance, IMBR mbr)
        {
            var transformation = new float[mbr.Lower.Length];

            for (var i = 0; i < mbr.Lower.Length; i++)
            {
                transformation[i] = distance;
            }
            return(transformation);
        }
Example #6
0
 public RTreeLeaf(IMBR mbr, ARTreeContainer parent = null)
 {
     Lower = mbr.Lower;
     Upper = mbr.Upper;
     if (parent != null)
     {
         Parent = parent;
     }
     Data = new List <IRTreeDataContainer>();
 }
Example #7
0
 public RTreeNode(IMBR mbr, IEnumerable <ARTreeContainer> children = null, ARTreeContainer parent = null)
 {
     if (parent != null)
     {
         Parent = parent;
     }
     Lower    = mbr.Lower;
     Upper    = mbr.Upper;
     Children = children != null ? new List <ARTreeContainer>(children) : new List <ARTreeContainer>();
 }
Example #8
0
 public SpatialDataContainer(IMBR mbr,
                             ARTreeContainer parent = null)
 {
     if (parent != null)
     {
         Parent = parent;
     }
     Lower = mbr.Lower;
     Upper = mbr.Upper;
 }
Example #9
0
        public void GeometryToMBRUnitTest()
        {
            Assert.Inconclusive("TODO");


            IGeometry target   = CreateIGeometry(); // TODO: Initialize to an appropriate value
            IMBR      expected = null;              // TODO: Initialize to an appropriate value
            IMBR      actual;

            actual = target.GeometryToMBR();
            Assert.AreEqual(expected, actual);
        }
Example #10
0
        public void TransformationOfDistanceUnitTest()
        {
            Assert.Inconclusive("TODO");

            IMetric target   = CreateIMetric(); // TODO: Initialize to an appropriate value
            float   distance = 0F;              // TODO: Initialize to an appropriate value
            IMBR    mbr      = null;            // TODO: Initialize to an appropriate value

            float[] expected = null;            // TODO: Initialize to an appropriate value
            float[] actual;
            actual = target.TransformationOfDistance(distance, mbr);
            Assert.AreEqual(expected, actual);
        }
Example #11
0
        public bool Inclusion(IMBR container)
        {
            var currentLower = container.Lower;
            var currentUpper = container.Upper;

            for (int i = 0; i < Lower.Length; i++)
            {
                if (Lower[i] > currentLower[i] || Upper[i] < currentUpper[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Example #12
0
        public void SearchRegionUnitTest()
        {
            Assert.Inconclusive("TODO");

            ISpatialIndex target = CreateISpatialIndex();             // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> result         = null; // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> resultExpected = null; // TODO: Initialize to an appropriate value
            IMBR minimalBoundedRechtangle = null;                     // TODO: Initialize to an appropriate value
            bool expected = false;                                    // TODO: Initialize to an appropriate value
            bool actual;

            actual = target.SearchRegion(out result, minimalBoundedRechtangle);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
Example #13
0
        public float[] TransformationOfDistance(float distance, IMBR mbr)
        {
            {
                if (mbr.Lower.Length != 2)
                {
                    throw new Exception("The points are not in geo space");
                }

                var result    = new float[2];
                var latidtude = mbr.Lower[0] * Math.PI / 180;
                result[0] = 180 * distance / ((float)Math.PI * RadiusOfEarth);
                var dist = (float)(180 * distance / (Math.PI * RadiusOfEarth * Math.Cos(latidtude)));
                if (dist > 360)
                {
                    result[1] = 360;
                }
                else
                {
                    result[1] = dist;
                }
                return(result);
            }
        }
Example #14
0
        /// <summary>
        /// create new search container
        /// </summary>
        /// <param name="mbr">
        /// minimal bounded rechtangle
        /// </param>
        /// <param name="distance">
        /// distance
        /// </param>
        /// <returns>
        /// container for searching
        /// </returns>
        private SpatialDataContainer CreateSearchContainer(IMBR mbr, float distance)
        {
            var lower = new float[_countOfR];
            var upper = new float[_countOfR];

            var transformationOfDistance = Metric.TransformationOfDistance(distance, mbr);

            for (int i = 0; i < _countOfR; i++)
            {
                lower[i] = mbr.Lower[i] - transformationOfDistance[i];
                upper[i] = mbr.Upper[i] + transformationOfDistance[i];
            }

            return new SpatialDataContainer(new MBR(lower, upper));
        }
Example #15
0
        public float[] TransformationOfDistance(float distance, IMBR mbr)
        {
            {
                if (mbr.Lower.Length != 2)
                    throw new Exception("The points are not in geo space");

                var result = new float[2];
                var latidtude = mbr.Lower[0] * Math.PI / 180;
                result[0] = 180 * distance / ((float)Math.PI * RadiusOfEarth);
                var dist = (float)(180 * distance / (Math.PI * RadiusOfEarth * Math.Cos(latidtude)));
                if (dist > 360)
                {

                    result[1] = 360;
                }
                else
                {
                    result[1] = dist;
                }
                return result;
            }
        }
Example #16
0
        private float GetArea(IMBR mbr)
        {
            var currentArea = 1.0f;
            for (int i = 0; i < mbr.Lower.Length; i++)
            {
                currentArea *= mbr.Upper[i] - mbr.Lower[i];

            }

            return currentArea;
        }
Example #17
0
 private bool TestOfMBR(IMBR mbr)
 {
     if (mbr.Lower.Length != mbr.Upper.Length && mbr.Lower.Length != _countOfR)
     {
         return false;
     }
     for (int i = 0; i < mbr.Lower.Length; i++)
         if (mbr.Lower[i] > mbr.Upper[i])
             return false;
     return true;
 }
Example #18
0
 public bool SearchRegion(out ReadOnlyCollection<AGraphElement> result, IMBR minimalBoundedRechtangle)
 {
     if (ReadResource())
     {
         result = new List<AGraphElement>().AsReadOnly();
         if (TestOfMBR(minimalBoundedRechtangle))
         {
             var searchRegion = new SpatialDataContainer(minimalBoundedRechtangle);
             result = OverlapSearch(searchRegion);
         }
         FinishReadResource();
         return result.Count > 0;
     }
     throw new CollisionException(this);
 }
Example #19
0
        public bool Inclusion(IMBR container)
        {
            var currentLower = container.Lower;
            var currentUpper = container.Upper;

            for (int i = 0; i < Lower.Length; i++)
            {

                if (Lower[i] > currentLower[i] || Upper[i] < currentUpper[i])
                    return false;
            }

            return true;
        }
Example #20
0
        private float FindOverlapValue(IMBR mbr1, IMBR mbr2)
        {
            var value = new float[_countOfR];
            var lowerPoint1 = mbr1.Lower;
            var upperPoint1 = mbr1.Upper;
            var lowerPoint2 = mbr2.Lower;
            var upperPoint2 = mbr2.Upper;
            var overlapValue = 1.0f;

            for (int i = 0; i < _countOfR; i++)
            {

                var lower1 = lowerPoint1[i];
                var upper1 = upperPoint1[i];
                var lower2 = lowerPoint2[i];
                var upper2 = upperPoint2[i];
                if (lower2 >= lower1)
                {
                    if (upper1 > lower2)
                    {
                        if (upper1 > upper2)
                            value[i] = upper2 - lower1;
                        else
                            value[i] = upper1 - lower2;
                    }
                    else
                        return 0;
                }
                else
                {
                    if (upper2 > lower1)
                    {
                        if (upper2 > upper1)
                            value[i] = upper1 - lower1;
                        else
                            value[i] = upper2 - lower1;
                    }
                    else
                        return 0;
                }

                overlapValue *= value[i];
            }

            return overlapValue;
        }