本文整理汇总了C#中Envelope.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.Contains方法的具体用法?C# Envelope.Contains怎么用?C# Envelope.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Envelope
的用法示例。
在下文中一共展示了Envelope.Contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClipGeometryCollection
private static IGeometryCollection ClipGeometryCollection(IGeometryCollection geom, Envelope clipEnv)
{
var clipPoly = geom.Factory.ToGeometry(clipEnv);
var clipped = new List<IGeometry>();
for (var i = 0; i < geom.NumGeometries; i++)
{
var g = geom.GetGeometryN(i);
IGeometry result = null;
// don't clip unless necessary
if (clipEnv.Contains(g.EnvelopeInternal))
result = g;
else if (clipEnv.Intersects(g.EnvelopeInternal))
{
result = clipPoly.Intersection(g);
// keep vertex key info
result.UserData = g.UserData;
}
if (result != null && !result.IsEmpty)
{
clipped.Add(result);
}
}
return geom.Factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(clipped));
}
示例2: CheckPointInNode
public static bool CheckPointInNode(Coordinate coord, Envelope box)
{
bool _isChecked;
if (box.Contains(coord))
{
_isChecked = true;
}
else
{
_isChecked = false;
}
return _isChecked;
}
示例3: ExecuteIntersectionQueryReturnsExpectedFeatures
public void ExecuteIntersectionQueryReturnsExpectedFeatures()
{
DataTable source = CreateDataTableSource();
DataTablePoint provider = new DataTablePoint(source, "oid", "x", "y");
var query = new Envelope(400, 600, 400, 600);
FeatureDataTable expected = new FeatureDataTable();
expected.TableName = "PointSource";
foreach (DataColumn column in source.Columns)
{
expected.Columns.Add(column.ColumnName, column.DataType);
}
foreach (DataRowView rowView in source.DefaultView)
{
if (query.Contains(new Coordinate((double) rowView["x"], (double) rowView["y"])))
{
expected.ImportRow(rowView.Row);
}
}
FeatureDataSet dataSet = new FeatureDataSet();
provider.ExecuteIntersectionQuery(query, dataSet);
Assert.IsNotNull(dataSet);
Assert.IsNotNull(dataSet.Tables);
Assert.AreEqual(1, dataSet.Tables.Count);
FeatureDataTable actual = dataSet.Tables[0];
Assert.AreEqual(expected.Rows.Count, actual.Rows.Count);
foreach (DataRowView expectedRowView in expected.DefaultView)
{
DataRow[] actualRows = actual.Select("oid = " + expectedRowView["oid"]);
Assert.AreEqual(1, actualRows.Length);
Assert.AreEqual(expectedRowView["oid"], actualRows[0]["oid"]);
Assert.AreEqual(expectedRowView["x"], actualRows[0]["x"]);
Assert.AreEqual(expectedRowView["y"], actualRows[0]["y"]);
}
}
示例4: TestEverything
public void TestEverything()
{
Envelope e1 = new Envelope();
Assert.IsTrue(e1.IsNull);
Assert.AreEqual(0, e1.Width, 1E-3);
Assert.AreEqual(0, e1.Height, 1E-3);
e1.ExpandToInclude(100, 101);
e1.ExpandToInclude(200, 202);
e1.ExpandToInclude(150, 151);
Assert.AreEqual(200, e1.MaxX, 1E-3);
Assert.AreEqual(202, e1.MaxY, 1E-3);
Assert.AreEqual(100, e1.MinX, 1E-3);
Assert.AreEqual(101, e1.MinY, 1E-3);
Assert.IsTrue(e1.Contains(120, 120));
Assert.IsTrue(e1.Contains(120, 101));
Assert.IsTrue(!e1.Contains(120, 100));
Assert.AreEqual(101, e1.Height, 1E-3);
Assert.AreEqual(100, e1.Width, 1E-3);
Assert.IsTrue(!e1.IsNull);
Envelope e2 = new Envelope(499, 500, 500, 501);
Assert.IsTrue(!e1.Contains(e2));
Assert.IsTrue(!e1.Intersects(e2));
e1.ExpandToInclude(e2);
Assert.IsTrue(e1.Contains(e2));
Assert.IsTrue(e1.Intersects(e2));
Assert.AreEqual(500, e1.MaxX, 1E-3);
Assert.AreEqual(501, e1.MaxY, 1E-3);
Assert.AreEqual(100, e1.MinX, 1E-3);
Assert.AreEqual(101, e1.MinY, 1E-3);
Envelope e3 = new Envelope(300, 700, 300, 700);
Assert.IsTrue(!e1.Contains(e3));
Assert.IsTrue(e1.Intersects(e3));
Envelope e4 = new Envelope(300, 301, 300, 301);
Assert.IsTrue(e1.Contains(e4));
Assert.IsTrue(e1.Intersects(e4));
}
示例5: ComputeKey
/// <summary>
/// Return a square envelope containing the argument envelope,
/// whose extent is a power of two and which is based at a power of 2.
/// </summary>
/// <param name="itemEnv"></param>
public void ComputeKey(Envelope itemEnv)
{
_level = ComputeQuadLevel(itemEnv);
_env = new Envelope();
ComputeKey(_level, itemEnv);
// MD - would be nice to have a non-iterative form of this algorithm
while (!_env.Contains(itemEnv))
{
_level += 1;
ComputeKey(_level, itemEnv);
}
}
示例6: CheckEnvelope
private void CheckEnvelope()
{
if (_distance < 0.0) return;
double padding = _distance * MaxEnvDiffFrac;
if (padding == 0.0) padding = 0.001;
var expectedEnv = new Envelope(_input.EnvelopeInternal);
expectedEnv.ExpandBy(_distance);
var bufEnv = new Envelope(_result.EnvelopeInternal);
bufEnv.ExpandBy(padding);
if (!bufEnv.Contains(expectedEnv))
{
_isValid = false;
_errorMsg = "Buffer envelope is incorrect";
_errorIndicator = _result;
}
Report("Envelope");
}
示例7: IsInSegmentEnvelopes
///// <summary>
/////
///// </summary>
///// <param name="x1"></param>
///// <param name="x2"></param>
///// <param name="x3"></param>
///// <param name="x4"></param>
///// <returns></returns>
//private double SmallestInAbsValue(double x1, double x2, double x3, double x4)
//{
// double x = x1;
// double xabs = Math.Abs(x);
// if (Math.Abs(x2) < xabs)
// {
// x = x2;
// xabs = Math.Abs(x2);
// }
// if (Math.Abs(x3) < xabs)
// {
// x = x3;
// xabs = Math.Abs(x3);
// }
// if (Math.Abs(x4) < xabs)
// x = x4;
// return x;
//}
/// <summary>
/// Test whether a point lies in the envelopes of both input segments.
/// A correctly computed intersection point should return <c>true</c>
/// for this test.
/// Since this test is for debugging purposes only, no attempt is
/// made to optimize the envelope test.
/// </summary>
/// <param name="intPt"></param>
/// <returns><c>true</c> if the input point lies within both input segment envelopes.</returns>
private bool IsInSegmentEnvelopes(Coordinate intPt)
{
Envelope env0 = new Envelope(InputLines[0, 0], InputLines[0, 1]);
Envelope env1 = new Envelope(InputLines[1, 0], InputLines[1, 1]);
return env0.Contains(intPt) && env1.Contains(intPt);
}