本文整理汇总了C#中IGeometry.GeometryToMBR方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.GeometryToMBR方法的具体用法?C# IGeometry.GeometryToMBR怎么用?C# IGeometry.GeometryToMBR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.GeometryToMBR方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchDistance
/// <summary>
/// find all object which distance less or equal d from this geometry have
/// </summary>
/// <param name="result">
/// result
/// </param>
/// <param name="distance">
/// value of distance for serching
/// </param>
/// <param name="geometry">
/// geometry
/// </param>
/// <returns>
/// <c>true</c> if something was found; otherwise, <c>false</c>.
/// </returns>
public bool SearchDistance(out ReadOnlyCollection<AGraphElement> result, float distance, IGeometry geometry)
{
if (ReadResource())
{
result = new List<AGraphElement>().AsReadOnly();
SpatialDataContainer searchContainer;
if (DimensionTest(geometry.Dimensions) && TestOfGeometry(geometry))
{
searchContainer = CreateSearchContainer(geometry.GeometryToMBR(), distance);
result = OverlapSearch(searchContainer);
}
FinishReadResource();
return result.Count > 0;
}
throw new CollisionException(this);
}
示例2: Overlap
public bool Overlap(out ReadOnlyCollection<AGraphElement> result, IGeometry geometry)
{
if (ReadResource())
{
result = new List<AGraphElement>().AsReadOnly();
if (TestOfGeometry(geometry) && DimensionTest(geometry.Dimensions))
{
IRTreeDataContainer searchContainer;
if (geometry is IPoint)
searchContainer = new PointDataContainer(((IPoint)geometry).PointToSpaceR());
else
searchContainer = new SpatialDataContainer(geometry.GeometryToMBR());
result = OverlapSearch(searchContainer);
}
FinishReadResource();
return result.Count > 0;
}
throw new CollisionException(this);
}
示例3: Distance
public float Distance(IGeometry geometry1, IGeometry geometry2)
{
if (ReadResource())
{
if (geometry1 is IPoint && geometry2 is IPoint)
{
FinishReadResource();
return Metric.Distance(new RTreePoint(((IPoint)geometry1).PointToSpaceR()),
new RTreePoint(((IPoint)geometry2).PointToSpaceR()));
}
var mbr1 = geometry1.GeometryToMBR();
var mbr2 = geometry2.GeometryToMBR();
var points = FindNeighborPoints(mbr1.Lower, mbr1.Upper, mbr2.Lower, mbr2.Upper);
FinishReadResource();
return Metric.Distance(points.Item1, points.Item2);
}
throw new CollisionException(this);
}
示例4: GetNextNeighbors
public bool GetNextNeighbors(out ReadOnlyCollection<AGraphElement> result, IGeometry geometry, int countOfNextNeighbors)
{
if (ReadResource())
{
result = new List<AGraphElement>().AsReadOnly();
if (TestOfGeometry(geometry) && DimensionTest(geometry.Dimensions))
{
IRTreeDataContainer output;
if (geometry is IPoint)
output = new PointDataContainer(((IPoint)geometry).PointToSpaceR());
else
output = new SpatialDataContainer(geometry.GeometryToMBR());
var containers = new LinkedList<Tuple<float, IRTreeDataContainer>>();
var maxElement = float.PositiveInfinity;
var stack = new Stack<ARTreeContainer>();
if (Distance(_root, output) < maxElement || containers.Count < countOfNextNeighbors)
stack.Push(_root);
while (stack.Count > 0)
{
var currentContainer = stack.Pop();
if (!currentContainer.IsLeaf)
{
foreach (var value2 in ((RTreeNode)currentContainer).Children)
{
if (Distance(value2, output) < maxElement || containers.Count < countOfNextNeighbors)
stack.Push(value2);
}
}
else
{
foreach (var value2 in ((RTreeLeaf)currentContainer).Data)
{
var dist = Distance(value2, output);
if ((containers.Count < countOfNextNeighbors || dist < maxElement) && value2 != output)
{
if (containers.Count == 0)
{
containers.AddFirst(new LinkedListNode<Tuple<float, IRTreeDataContainer>>(Tuple.Create(dist, value2)));
maxElement = dist;
}
else
{
var end = true;
var start = containers.First;
while (end)
{
if (dist < start.Value.Item1)
{
containers.AddBefore(start, Tuple.Create(dist, value2));
if (containers.Count > countOfNextNeighbors)
{
containers.RemoveLast();
maxElement = containers.Last.Value.Item1;
}
break;
}
if (start == containers.Last)
{
end = false;
}
else
{
start = start.Next;
}
}
if (!end && containers.Count < countOfNextNeighbors)
{
maxElement = dist;
containers.AddLast(Tuple.Create(dist, value2));
}
}
}
}
}
}
result = containers.Select(_ => _.Item2.GraphElement).ToList().AsReadOnly();
}
FinishReadResource();
return result.Count > 0;
}
throw new CollisionException(this);
}
示例5: TestOfGeometry
private bool TestOfGeometry(IGeometry key)
{
var iPoint = key as IPoint;
return iPoint != null ? TestOfPoint(iPoint) : TestOfMBR(key.GeometryToMBR());
}