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


C# GeometryFactory.Intersects方法代碼示例

本文整理匯總了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));
 }
開發者ID:Walt-D-Cat,項目名稱:NetTopologySuite,代碼行數:10,代碼來源:RobustLineIntersectorTest.cs

示例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);
					});
			}
		}
開發者ID:Walt-D-Cat,項目名稱:NetTopologySuite,代碼行數:61,代碼來源:ShapeDataReader.cs

示例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));
        }
開發者ID:Walt-D-Cat,項目名稱:NetTopologySuite,代碼行數:22,代碼來源:MiscellaneousTest.cs


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