• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IGeometry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Write

		/// <summary>
		/// Writes a geometry to a byte array using the specified encoding.
		/// </summary>
		/// <param name="g">The geometry to write</param>
		/// <param name="wkbByteOrder">Byte order</param>
		/// <returns>WKB representation of the geometry</returns>
		public static byte[] Write(IGeometry geometry, WkbByteOrder wkbByteOrder)
		{
			byte[] result = null;
			switch (wkbByteOrder)
			{
				case WkbByteOrder.Ndr:
					result = new WKBWriter(ByteOrder.LittleEndian).Write(geometry);
					break;
				case WkbByteOrder.Xdr:
					result = new WKBWriter(ByteOrder.BigEndian).Write(geometry);
					break;
			}
			return result;
			
//			MemoryStream ms = new MemoryStream();
//			BinaryWriter bw = new BinaryWriter(ms);
//
//			//Write the byteorder format.
//			bw.Write((byte)wkbByteOrder);
//
//			//Write the type of this geometry
//			WriteType(g, bw, wkbByteOrder);
//
//			//Write the geometry
//			WriteGeometry(g, bw, wkbByteOrder);
//
//			return ms.ToArray();
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:GeometryToWKB.cs


示例17: GeometryGraphOperation

        /// <summary>
        /// 
        /// </summary>
        /// <param name="g0"></param>
        public GeometryGraphOperation(IGeometry g0) 
        {
            ComputationPrecision = g0.PrecisionModel;

            arg = new GeometryGraph[1];
            arg[0] = new GeometryGraph(0, g0);;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:11,代码来源:GeometryGraphOperation.cs


示例18: Move

        public virtual void Move(IGeometry targetGeometry, IGeometry sourceGeometry, IList<IGeometry> geometries, IList<int> handleIndices, 
                         int mouseIndex, double deltaX, double deltaY)
        {
            if ((targetGeometry != null) && (sourceGeometry != null))
            {
                if (targetGeometry.Coordinates.Length != sourceGeometry.Coordinates.Length)
                {
                    throw new ArgumentException("Source and target geometries should have same number of coordinates.");
                }

                //for performance reasons, get the coordinates once: for example for polygons this is a heavy call
                var targetCoordinates = targetGeometry.Coordinates; 
                var sourceCoordinates = sourceGeometry.Coordinates;

                for (int i = 0; i < handleIndices.Count; i++)
                {
                    GeometryHelper.MoveCoordinate(targetCoordinates, sourceCoordinates, handleIndices[i], deltaX, deltaY);
                    targetGeometry.GeometryChangedAction();

                    if (null != geometries)
                    {
                        IGeometry tracker = geometries[handleIndices[i]];
                        GeometryHelper.MoveCoordinate(tracker, 0, deltaX, deltaY);
                        tracker.GeometryChangedAction();
                    }
                }
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:28,代码来源:NoFallOffPolicy.cs


示例19: IsValid

 public static bool IsValid(IGeometry g, double distance, IGeometry result)
 {
     BufferResultValidator validator = new BufferResultValidator(g, distance, result);
     if (validator.IsValid())
         return true;
     return false;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:7,代码来源:BufferResultValidator.cs


示例20: Write

        /// <summary>
        /// Writes a geometry to a byte array using the specified encoding.
        /// </summary>
        /// <param name="g">The geometry to write</param>
        /// <param name="wkbByteOrder">Byte order</param>
        /// <returns>WKB representation of the geometry</returns>
        public static byte[] Write(IGeometry g, WkbByteOrder wkbByteOrder)
        {
            ByteOrder order;
            switch (wkbByteOrder)
            {
                case WkbByteOrder.Xdr:
                    order = ByteOrder.BigEndian;
                    break;
                case WkbByteOrder.Ndr:
                    order = ByteOrder.LittleEndian;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("wkbByteOrder");
            }

            WKBWriter wkb = new WKBWriter(order);
            return wkb.Write(g);

            /*
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            //Write the byteorder format.
            bw.Write((byte) wkbByteOrder);

            //Write the type of this geometry
            WriteType(g, bw, wkbByteOrder);

            //Write the geometry
            WriteGeometry(g, bw, wkbByteOrder);

            return ms.ToArray();
            */
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:40,代码来源:GeometryToWKB.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IGeometryCollection类代码示例发布时间:2022-05-24
下一篇:
C# IGenomeFactory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap