当前位置: 首页>>代码示例>>C#>>正文


C# IGeometry类代码示例

本文整理汇总了C#中IGeometry的典型用法代码示例。如果您正苦于以下问题:C# IGeometry类的具体用法?C# IGeometry怎么用?C# IGeometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IGeometry类属于命名空间,在下文中一共展示了IGeometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergeLines

 public static IGeometry MergeLines(IGeometry g)
 {
     LineMerger merger = new LineMerger();
     merger.Add(g);
     IList<IGeometry> lines = merger.GetMergedLineStrings();
     return g.Factory.BuildGeometry(lines);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:LineHandlingFunctions.cs

示例2: Union

 /// <summary>
 /// Computes the set-theoretic union of two <c>Geometry</c>s, using enhanced precision.
 /// </summary>
 /// <param name="geom0">The first Geometry.</param>
 /// <param name="geom1">The second Geometry.</param>
 /// <returns>The Geometry representing the set-theoretic union of the input Geometries.</returns>
 public static IGeometry Union(IGeometry geom0, IGeometry geom1)
 {
     ApplicationException originalEx;
     try
     {
         IGeometry result = geom0.Union(geom1);
         return result;
     }
     catch (ApplicationException ex)
     {
         originalEx = ex;
     }
     /*
      * If we are here, the original op encountered a precision problem
      * (or some other problem).  Retry the operation with
      * enhanced precision to see if it succeeds
      */
     try
     {
         CommonBitsOp cbo = new CommonBitsOp(true);
         IGeometry resultEp = cbo.Union(geom0, geom1);
         // check that result is a valid point after the reshift to orginal precision
         if (!resultEp.IsValid)
             throw originalEx;
         return resultEp;
     }
     catch (ApplicationException)
     {
         throw originalEx;
     }
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:37,代码来源:EnhancedPrecisionOp.cs

示例3: CheckEqual

 protected void CheckEqual(IGeometry expected, IGeometry actual)
 {
     var actualNorm = actual.Normalized();       
     var expectedNorm = expected.Normalized();                 
     var equal = actualNorm.EqualsExact(expectedNorm);
     Assert.That(equal, Is.True, String.Format("Expected = {0}\nactual   = {1}", expected, actual));
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:GeometryTestCase.cs

示例4: Intersects

        /// <summary>
        /// Tests whether the given Geometry intersects the query rectangle.
        /// </summary>
        /// <param name="geom">The Geometry to test (may be of any type)</param>
        /// <returns><value>true</value> if an intersection must occur 
        /// or <value>false</value> if no conclusion about intersection can be made</returns>
        public bool Intersects(IGeometry geom)
        {
            if (!_rectEnv.Intersects(geom.EnvelopeInternal))
                return false;

            /**
             * Test if rectangle envelope intersects any component envelope.
             * This handles Point components as well
             */
            var visitor = new EnvelopeIntersectsVisitor(_rectEnv);
            visitor.ApplyTo(geom);
            if (visitor.Intersects)
                return true;

            /**
             * Test if any rectangle vertex is contained in the target geometry
             */
            var ecpVisitor = new GeometryContainsPointVisitor(_rectangle);
            ecpVisitor.ApplyTo(geom);
            if (ecpVisitor.ContainsPoint)
                return true;

            /**
             * Test if any target geometry line segment intersects the rectangle
             */
            var riVisitor = new RectangleIntersectsSegmentVisitor(_rectangle);
            riVisitor.ApplyTo(geom);
            return riVisitor.Intersects;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:35,代码来源:RectangleIntersects.cs

示例5: Write

//		#region Methods

		/// <summary>
		/// Converts a Geometry to its Well-known Text representation.
		/// </summary>
		/// <param name="geometry">A Geometry to write.</param>
		/// <returns>A &lt;Geometry Tagged Text&gt; string (see the OpenGIS Simple
		///  Features Specification)</returns>
		public static string Write(IGeometry geometry)
		{
			return new WKTWriter().Write(geometry);
//			StringWriter sw = new StringWriter();
//			Write(geometry, sw);
//			return sw.ToString();
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:GeometryToWKT.cs

示例6: ToAndroidBitmap

 private static AndroidBitmap ToAndroidBitmap(IGeometry geometry)
 {
     var raster = (IRaster)geometry;
     var rasterData = raster.Data.ToArray();
     var bitmap = BitmapFactory.DecodeByteArray(rasterData, 0, rasterData.Length);
     return bitmap;
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:7,代码来源:RasterRenderer.cs

示例7: GetHashCodeShouldBeComputedLazyAndShouldBeVeryFast

        public void GetHashCodeShouldBeComputedLazyAndShouldBeVeryFast()
        {
            var geometryCount = 1000000;
            var geometries = new IGeometry[geometryCount];

            for (int i = 0; i < geometryCount; i++)
            {
                geometries[i] = new Polygon(new LinearRing(new[] { new Coordinate(1.0, 2.0), new Coordinate(2.0, 3.0), new Coordinate(3.0, 4.0), new Coordinate(1.0, 2.0) }));
            }

            var polygon = new Polygon(new LinearRing(new[] { new Coordinate(1.0, 2.0), new Coordinate(2.0, 3.0), new Coordinate(3.0, 4.0), new Coordinate(1.0, 2.0) }));

            // computes hash code every call
            var t0 = DateTime.Now;
            for (int i = 0; i < geometryCount; i++)
            {
                geometries[i].GetHashCode();
            }
            var t1 = DateTime.Now;

            var dt1 = t1 - t0;

            // computes hash code only first time (lazy)
            t0 = DateTime.Now;
            for (int i = 0; i < geometryCount; i++)
            {
                polygon.GetHashCode();
            }
            t1 = DateTime.Now;

            var dt2 = t1 - t0;

            Assert.IsTrue(dt2.TotalMilliseconds < 15 * dt1.TotalMilliseconds);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:GeometryTest.cs

示例8: Write

        protected override byte[] Write(IGeometry gIn)
        {
            var geoWriter = new MsSql2008GeometryWriter();
            var b = geoWriter.WriteGeometry(gIn);
            var b2 = geoWriter.Write(gIn);
            using( var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO [nts_io_geometry] VALUES(@P1, @P2, @P3);";
                    var p1 = new SqlParameter("P1", SqlDbType.Int) { SqlValue = Counter };
                    var p2 = new SqlParameter("P2", SqlDbType.Text) { SqlValue = gIn.AsText() };
                    var p3 = new SqlParameter("P3", SqlDbType.Udt) { UdtTypeName = "geometry", SqlValue = b };
                    cmd.Parameters.AddRange(new[] { p1, p2, p3 });
                    cmd.ExecuteNonQuery();

                    /*
                    p1.SqlValue = 100000 + Counter;
                    cmd.Parameters.Remove(p3);
                    p3 = new SqlParameter("P3", SqlDbType.Image) { SqlValue = b };
                    cmd.Parameters.Add(p3);
                    p3.SqlValue = b2;
                    cmd.ExecuteNonQuery();
                     */
                }

            }
            return b2;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:30,代码来源:SqlGeometryFixture.cs

示例9: BufferUnion

 private IGeometry BufferUnion(IGeometry g0, IGeometry g1)
 {
     IGeometryFactory factory = g0.Factory;
     IGeometry gColl = factory.CreateGeometryCollection(new IGeometry[] { g0, g1 });
     IGeometry unionAll = gColl.Buffer(0.0);
     return unionAll;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:7,代码来源:UnionInteracting.cs

示例10: Circumcentre

 public static IGeometry Circumcentre(IGeometry g)
 {
     Coordinate[] pts = TrianglePts(g);
     Coordinate cc = Triangle.Circumcentre(pts[0], pts[1], pts[2]);
     IGeometryFactory geomFact = FunctionsUtil.GetFactoryOrDefault(g);
     return geomFact.CreatePoint(cc);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:TestCaseGeometryFunctions.cs

示例11: TrianglePts

 private static Coordinate[] TrianglePts(IGeometry g)
 {
     Coordinate[] pts = g.Coordinates;
     if (pts.Length < 3)
         throw new ArgumentException("Input geometry must have at least 3 points");
     return pts;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:TestCaseGeometryFunctions.cs

示例12: BufferMitredJoin

        public static IGeometry BufferMitredJoin(IGeometry g, double distance)
        {
            BufferParameters bufParams = new BufferParameters();
            bufParams.JoinStyle = JoinStyle.Mitre;

            return BufferOp.Buffer(g, distance, bufParams);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:TestCaseGeometryFunctions.cs

示例13: ComputeLocation

 /// <summary>
 ///
 /// </summary>
 /// <param name="p"></param>
 /// <param name="geom"></param>
 private void ComputeLocation(Coordinate p, IGeometry geom)
 {
     if (geom is ILineString)
         UpdateLocationInfo(Locate(p, geom));
     else if (geom is IPolygon)
         UpdateLocationInfo(Locate(p, geom));
     else if (geom is IMultiLineString)
     {
         IMultiLineString ml = (IMultiLineString)geom;
         foreach (ILineString l in ml.Geometries)
             UpdateLocationInfo(Locate(p, l));
     }
     else if (geom is IMultiPolygon)
     {
         IMultiPolygon mpoly = (IMultiPolygon)geom;
         foreach (IPolygon poly in mpoly.Geometries)
             UpdateLocationInfo(Locate(p, poly));
     }
     else if (geom is IGeometryCollection)
     {
         IEnumerator geomi = new GeometryCollection.Enumerator((IGeometryCollection)geom);
         while (geomi.MoveNext())
         {
             IGeometry g2 = (IGeometry)geomi.Current;
             if (g2 != geom)
                 ComputeLocation(p, g2);
         }
     }
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:34,代码来源:PointLocator.cs

示例14: SimplePointCursor

		public SimplePointCursor(string filePath, IFields fields, int OID, 
			System.Array fieldMap, IEnvelope queryEnv, esriGeometryType geomType)	
		{
			//HIGHLIGHT: 0 - Set up cursor
			m_bIsFinished = false;
			m_pStreamReader = new System.IO.StreamReader(filePath);
			m_fields = fields;
			m_iOID = OID;
			m_fieldMap = fieldMap;
			m_searchEnv = queryEnv;
			switch (geomType)
			{
				case esriGeometryType.esriGeometryPolygon:
					m_wkGeom = new Polygon() as IGeometry;
					m_workPts = new PointClass[5];
					for (int i = 0; i < m_workPts.Length; i++)
						m_workPts[i] = new PointClass();
					break;
				case esriGeometryType.esriGeometryPolyline:
					m_wkGeom = new PolylineClass() as IGeometry;
					m_workPts = new PointClass[5];
					for (int i = 0; i < m_workPts.Length; i++)
						m_workPts[i] = new PointClass();
					break;
				
				case esriGeometryType.esriGeometryPoint:
					m_wkGeom = new PointClass() as IGeometry;
					break;
				default:	//doesn't need to set worker geometry if it is table 
					break;
			}

			//advance cursor so data is readily available
			this.NextRecord();
		}
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:35,代码来源:SimplePointCursor.cs

示例15: MDBFile

 /// <summary>
 /// ���캯��
 /// </summary>
 /// <param name="bRead">�Ƿ��Ƕ�ȡ</param>
 /// <param name="strFilePathName">�����ļ�����</param>
 /// <param name="pCutGeometry">���з�Χ</param>
 /// <param name="pCutGeometry">���з�Χ</param>
 public MDBFile(bool bRead, string strFilePathName,bool bCut,IGeometry pCutGeometry)
 {
     this.m_bRead = bRead;
     this.m_strFilePathName = strFilePathName;
     base.m_dataType = ArcDataType.MDB;
     base.m_CutGeometry = pCutGeometry;
     base.m_bCut = bCut;
     if (this.m_bRead == true)
     {
         //�ж�MDB�ļ��Ƿ����
         if (File.Exists(this.m_strFilePathName) == true)
         {
             //����MDB����Դ
             this.Workspace = ConnectWorkspace();
         }
     }
     else
     {
         //�ж�MDB�ļ��Ƿ����
         if (File.Exists(this.m_strFilePathName) == true)
         {
             //����MDB����Դ
             this.Workspace = ConnectWorkspace();
         }
         else
         {
             //����MDB����Դ
             this.Workspace = CreateWorkspace();
         }
     }
 }
开发者ID:hy1314200,项目名称:HyDM,代码行数:38,代码来源:MDBFile.cs


注:本文中的IGeometry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。