本文整理汇总了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));
}
示例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));
}
示例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;
}
}
示例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);
}
}