本文整理汇总了C#中NetTopologySuite.Geometries.GeometryFactory.Intersects方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryFactory.Intersects方法的具体用法?C# GeometryFactory.Intersects怎么用?C# GeometryFactory.Intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetTopologySuite.Geometries.GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory.Intersects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestA
public void TestA() {
Coordinate p1 = new Coordinate(-123456789, -40);
Coordinate p2 = new Coordinate(381039468754763d, 123456789);
Coordinate q = new Coordinate(0, 0);
ILineString l = new GeometryFactory().CreateLineString(new Coordinate[] {p1, p2});
IPoint p = new GeometryFactory().CreatePoint(q);
Assert.AreEqual(false, l.Intersects(p));
Assert.AreEqual(false, CGAlgorithms.IsOnLine(q, new Coordinate[] { p1, p2 }));
Assert.AreEqual(-1, CGAlgorithms.ComputeOrientation(p1, p2, q));
}
示例2: ReadByMBRFilter
/// <summary>
/// Query shapefile by MBR.
/// MBR coordinates MUST be in the Shapefile's coordinate system.
///
/// NOTE: If you are using the default ISpatialIndex (which is an instance of the STRtree NTS class), it has some limitations.
/// Since it works with MBRs rather than the shapes themselves, you can get some shapes that are not actually in the MBR
/// you provided just because their MBRs are bounded by the given envelope.
/// If you wish to avoid this behaviour, send true in the second paramter, but be weary of the consequences listed below.
/// </summary>
/// <param name="envelope"> The envlope to query. </param>
/// <param name="testGeometriesActuallyInMBR">
/// False by default, true to double-check the returned geometries against given Envelope, to avoid index error margin.
///
/// It is advisable that you implement your own ISpatialIndex with your required precision rather than set this to True.
///
/// **********
/// CAUTION: If you choose to set this parameter as True, it will greatly affect performance as it
/// will cancel any lazy mechanism implemented with reading the geometries from the file.
/// Do not set this to True unless you either:
/// A. Do not have any performance restrictions.
/// Or:
/// B. Absolutely need that precision in the geographic query.
/// **********
/// </param>
/// <returns></returns>
public IEnumerable<IShapefileFeature> ReadByMBRFilter(Envelope envelope, bool testGeometriesActuallyInMBR = false)
{
if (envelope == null)
{
throw new ArgumentNullException("envelope");
}
// If index creation task wasnt completed, wait for it to complete.
if (!m_IsIndexingComplete)
{
m_IndexCreationTask.Wait();
}
IList<ShapeLocationInFileInfo> shapesInRegion = m_SpatialIndex.Query(envelope);
if (shapesInRegion.Count == 0)
{
return Enumerable.Empty<IShapefileFeature>();
}
IEnumerable<IShapefileFeature> results = shapesInRegion.Select(ReadFeature);
if (!testGeometriesActuallyInMBR)
{
return results;
}
else
{
IGeometry envelopeGeo = new GeometryFactory().ToGeometry(envelope);
return results.Where(feature =>
{
return envelopeGeo.Intersects(feature.Geometry);
});
}
}
示例3: testPredicatesReturnFalseForEmptyGeometries
public void testPredicatesReturnFalseForEmptyGeometries()
{
var p1 = new GeometryFactory().CreatePoint((Coordinate) null);
var p2 = new GeometryFactory().CreatePoint(new Coordinate(5, 5));
Assert.AreEqual(false, p1.Equals(p2));
Assert.AreEqual(true, p1.Disjoint(p2));
Assert.AreEqual(false, p1.Intersects(p2));
Assert.AreEqual(false, p1.Touches(p2));
Assert.AreEqual(false, p1.Crosses(p2));
Assert.AreEqual(false, p1.Within(p2));
Assert.AreEqual(false, p1.Contains(p2));
Assert.AreEqual(false, p1.Overlaps(p2));
Assert.AreEqual(false, p2.Equals(p1));
Assert.AreEqual(true, p2.Disjoint(p1));
Assert.AreEqual(false, p2.Intersects(p1));
Assert.AreEqual(false, p2.Touches(p1));
Assert.AreEqual(false, p2.Crosses(p1));
Assert.AreEqual(false, p2.Within(p1));
Assert.AreEqual(false, p2.Contains(p1));
Assert.AreEqual(false, p2.Overlaps(p1));
}