當前位置: 首頁>>代碼示例>>C#>>正文


C# BoundingBox.Join方法代碼示例

本文整理匯總了C#中BoundingBox.Join方法的典型用法代碼示例。如果您正苦於以下問題:C# BoundingBox.Join方法的具體用法?C# BoundingBox.Join怎麽用?C# BoundingBox.Join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BoundingBox的用法示例。


在下文中一共展示了BoundingBox.Join方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestJoin

 public void TestJoin()
 {
     BoundingBox b1 = new BoundingBox(20, 30, 40, 50);
     BoundingBox b2 = new BoundingBox(-20, 56, 70, 75);
     BoundingBox bJoined = new BoundingBox(-20, 30, 70, 75);
     Assert.AreEqual(bJoined, b1.Join(b2));
     BoundingBox box = null;
     Assert.AreEqual(b1, b1.Join(box));
     Assert.AreEqual(bJoined, BoundingBox.Join(b1, b2));
     Assert.AreEqual(b2, BoundingBox.Join(null, b2));
     Assert.AreEqual(b1, BoundingBox.Join(b1, null));
     Assert.AreEqual(bJoined, BoundingBox.Join(b2, b1));
 }
開發者ID:geobabbler,項目名稱:SharpMap,代碼行數:13,代碼來源:BoundingBoxTests.cs

示例2: JoinTest

		public void JoinTest()
		{
			BoundingBox b1 = new BoundingBox(20, 30, 40, 50);
			BoundingBox b2 = new BoundingBox(-20, 56, 70, 75);
			BoundingBox joined = new BoundingBox(-20, 30, 70, 75);
			Assert.AreEqual(joined, b1.Join(b2));
			Assert.AreEqual(b1, b1.Join(BoundingBox.Empty));
			Assert.AreEqual(joined, BoundingBox.Join(b1, b2));
			Assert.AreEqual(b2, BoundingBox.Join(BoundingBox.Empty, b2));
			Assert.AreEqual(b1, BoundingBox.Join(b1, BoundingBox.Empty));
			Assert.AreEqual(joined, BoundingBox.Join(b2, b1));
			Assert.AreEqual(joined, new BoundingBox(b1, b2));
		}
開發者ID:sridhar19091986,項目名稱:sharpmapcf,代碼行數:13,代碼來源:BoundingBoxTests.cs

示例3: QuadTree

        /// <summary>
        /// Creates a node and either splits the objects recursively into sub-nodes, or stores them at the node depending on the heuristics.
        /// Tree is built top->down
        /// </summary>
        /// <param name="objList">Geometries to index</param>
        /// <param name="depth">Current depth of tree</param>
        /// <param name="heurdata">Heuristics data</param>
        public QuadTree(List<BoxObjects> objList, uint depth, Heuristic heurdata)
        {
            _Depth = depth;

            _box = objList[0].box;
            for (int i = 0; i < objList.Count; i++)
                _box = _box.Join(objList[i].box);

            // test our build heuristic - if passes, make children
            if (depth < heurdata.maxdepth && objList.Count > heurdata.mintricnt &&
                (objList.Count > heurdata.tartricnt || ErrorMetric(_box) > heurdata.minerror))
            {
                List<BoxObjects>[] objBuckets = new List<BoxObjects>[2]; // buckets of geometries
                objBuckets[0] = new List<BoxObjects>();
                objBuckets[1] = new List<BoxObjects>();

                uint longaxis = _box.LongestAxis; // longest axis
                double geoavg = 0; // geometric average - midpoint of ALL the objects

                // go through all bbox and calculate the average of the midpoints
                double frac = 1.0f/objList.Count;
                for (int i = 0; i < objList.Count; i++)
                    geoavg += objList[i].box.GetCentroid()[longaxis]*frac;

                // bucket bbox based on their midpoint's side of the geo average in the longest axis
                for (int i = 0; i < objList.Count; i++)
                    objBuckets[geoavg > objList[i].box.GetCentroid()[longaxis] ? 1 : 0].Add(objList[i]);

                //If objects couldn't be splitted, just store them at the leaf
                //TODO: Try splitting on another axis
                if (objBuckets[0].Count == 0 || objBuckets[1].Count == 0)
                {
                    _child0 = null;
                    _child1 = null;
                    // copy object list
                    _objList = objList;
                }
                else
                {
                    // create new children using the buckets
                    _child0 = new QuadTree(objBuckets[0], depth + 1, heurdata);
                    _child1 = new QuadTree(objBuckets[1], depth + 1, heurdata);
                }
            }
            else
            {
                // otherwise the build heuristic failed, this is 
                // set the first child to null (identifies a leaf)
                _child0 = null;
                _child1 = null;
                // copy object list
                _objList = objList;
            }
        }
開發者ID:lishxi,項目名稱:_SharpMap,代碼行數:61,代碼來源:SpatialIndexing.cs

示例4: ExtendBoxForCollection

        private static void ExtendBoxForCollection(LayerCollection layersCollection, ref BoundingBox bbox)
        {
            foreach (ILayer l in layersCollection)
            {
                
                //Tries to get bb. Fails on some specific shapes and Mercator projects (World.shp)
                BoundingBox bb;
                try
                {
                    bb = l.Envelope;
                }
                catch (Exception)
                {
                    bb = new BoundingBox(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789);
                }

                if (bb != null)
                    bbox = bbox == null ? bb : bbox.Join(bb);

            }
        }
開發者ID:lishxi,項目名稱:_SharpMap,代碼行數:21,代碼來源:Map.cs


注:本文中的BoundingBox.Join方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。