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


C# ILinearRing类代码示例

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


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

示例1: TestAreaPrecisionPerformance

        public void TestAreaPrecisionPerformance()
        {

            const double originX = 1000000;
            const double originY = 5000000;
            var sw = new Stopwatch();
            var sw1 = new Stopwatch();
            var sw2 = new Stopwatch();
            var sw3 = new Stopwatch();
                                   
            //-2,23057128323489E-11

            sw.Start();
            for (var nrVertices = 4; nrVertices <= 5000000; nrVertices *= 2)
            {
                var coordinates = new Coordinate[nrVertices + 1];

                for (var i = 0; i <= nrVertices; i++)
                {
                    var vertex = new Coordinate(originX + (1d + Math.Sin( i/(double) nrVertices*2*Math.PI)),
                                                originY + (1d + Math.Cos( i/(double) nrVertices*2*Math.PI)));
                    coordinates[i] = vertex;
                }
                // close ring
                coordinates[nrVertices] = coordinates[0];

                var g1 = new GeometryFactory().CreateLinearRing(coordinates);
                var holes = new ILinearRing[] {};
                var polygon = (Polygon) new GeometryFactory().CreatePolygon(g1, holes);
                //Console.WriteLine(polygon);

                sw1.Start();
                var area = polygon.Area;
                sw1.Stop();
                sw2.Start();
                var area2 = AccurateSignedArea(coordinates);
                sw2.Stop();
                sw3.Start();
                var areaOld = OriginalSignedArea(coordinates);
                sw3.Stop();

                var exactArea = 0.5 * nrVertices * Math.Sin(2 * Math.PI / nrVertices);
                var eps1 = exactArea - area;
                var eps2 = exactArea - area2;
                var eps3 = exactArea - areaOld;
                
                //Assert.IsTrue(Math.Abs(eps2) <= Math.Abs(eps3));

                Console.WriteLine(string.Format("{0,10},\tnow err: {1,23},\tacc err: {2,23},\told err: {3,23}", nrVertices ,eps1, eps2 ,eps3));
            }
            
            sw.Stop();

            Console.WriteLine("\n\nTime: " + sw.Elapsed);
            Console.WriteLine("Time Now: " + sw1.ElapsedTicks);
            Console.WriteLine("Time Acc: " + sw2.ElapsedTicks);
            Console.WriteLine("Time Old: " + sw3.ElapsedTicks);
            
            Assert.IsTrue(true);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:60,代码来源:AreaPrecisionPerformanceTest.cs

示例2: IsPointInRing

 ///<summary>
 /// Determines whether a point lies in a LinearRing, using the ring envelope to short-circuit if possible.
 ///</summary>
 /// <param name="p">The point to test</param>
 /// <param name="ring">A linear ring</param>
 /// <returns><c>true</c> if the point lies inside the ring</returns>
 private static Boolean IsPointInRing(Coordinate p, ILinearRing ring)
 {
     // short-circuit if point is not in ring envelope
     if (!ring.EnvelopeInternal.Intersects(p))
         return false;
     return CGAlgorithms.IsPointInRing(p, ring.Coordinates);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:13,代码来源:SimplePointInAreaLocator.cs

示例3: FindPointNotNode

 /// <summary>
 /// Find a point from the list of testCoords
 /// that is NOT a node in the edge for the list of searchCoords.
 /// </summary>
 /// <param name="testCoords"></param>
 /// <param name="searchRing"></param>
 /// <param name="graph"></param>
 /// <returns>The point found, or <c>null</c> if none found.</returns>
 public static ICoordinate FindPointNotNode(ICoordinate[] testCoords, ILinearRing searchRing, GeometryGraph graph)
 {
     // find edge corresponding to searchRing.
     Edge searchEdge = graph.FindEdge(searchRing);
     // find a point in the testCoords which is not a node of the searchRing
     EdgeIntersectionList eiList = searchEdge.EdgeIntersectionList;
     // somewhat inefficient - is there a better way? (Use a node map, for instance?)
     foreach(ICoordinate pt in testCoords)
         if(!eiList.IsIntersection(pt))
             return pt;            
     return null;
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:20,代码来源:IsValidOp.cs

示例4: Polygon

 /// <summary>
 /// Constructs a <c>Polygon</c> with the given exterior boundary and
 /// interior boundaries.
 /// </summary>       
 /// <param name="shell">
 /// The outer boundary of the new <c>Polygon</c>,
 /// or <c>null</c> or an empty <c>LinearRing</c> if the empty
 /// point is to be created.
 /// </param>
 /// <param name="holes">
 /// The inner boundaries of the new <c>Polygon</c>
 /// , or <c>null</c> or empty <c>LinearRing</c>s if the empty
 /// point is to be created.
 /// </param>
 /// <param name="factory"></param>
 public Polygon(ILinearRing shell, ILinearRing[] holes, IGeometryFactory factory) : base(factory)
 {        
     if (shell == null) 
         shell = Factory.CreateLinearRing((ICoordinateSequence) null);            
     if (holes == null) 
         holes = new ILinearRing[] { };
     if (HasNullElements(holes)) 
         throw new ArgumentException("holes must not contain null elements");
     if (shell.IsEmpty && HasNonEmptyElements(holes)) 
         throw new ArgumentException("shell is empty but holes are not");
     this.shell = shell;
     this.holes = holes;
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:28,代码来源:Polygon.cs

示例5: Reproject

        public static IPolygon Reproject(this IPolygon polygon, ProjectionInfo source, ProjectionInfo target)
        {
            var shell = Reproject(polygon.Shell, source, target);
            ILinearRing[] holes = null;
            if (polygon.NumHoles > 0)
            {
                holes = new ILinearRing[polygon.NumHoles];
                var i = 0;
                foreach (var hole in polygon.Holes)
                    holes[i++] = Reproject(hole, source, target);
            }

            return polygon.Factory.CreatePolygon(shell, holes);
        }
开发者ID:haoas,项目名称:DotSpatial.Plugins,代码行数:14,代码来源:ReprojectExtensions.cs

示例6: PolygonSamples

 /// <summary>
 /// 
 /// </summary>
 public PolygonSamples() : base(new GeometryFactory(new PrecisionModel(PrecisionModels.Fixed)))
 {
     shell = Factory.CreateLinearRing(new ICoordinate[] { new Coordinate(100,100),
                                                          new Coordinate(200,100),
                                                          new Coordinate(200,200),                
                                                          new Coordinate(100,200),
                                                          new Coordinate(100,100), });
     hole = Factory.CreateLinearRing(new ICoordinate[] {  new Coordinate(120,120),
                                                          new Coordinate(180,120),
                                                          new Coordinate(180,180),                                                                                
                                                          new Coordinate(120,180),                                                                
                                                          new Coordinate(120,120), });
     polygon = Factory.CreatePolygon(shell, new ILinearRing[] { hole, });
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:17,代码来源:PolygonSamples.cs

示例7: Init

 public void Init()
 {
     shell = Factory.CreateLinearRing(new ICoordinate[] {    new Coordinate(100,100),
                                                             new Coordinate(200,100),
                                                             new Coordinate(200,200),                
                                                             new Coordinate(100,200),
                                                             new Coordinate(100,100), });
     // NOTE: Hole is created with not correct order for holes
     hole = Factory.CreateLinearRing(new ICoordinate[] {      new Coordinate(120,120),
                                                             new Coordinate(180,120),
                                                             new Coordinate(180,180),                                                                                
                                                             new Coordinate(120,180),                                                                
                                                             new Coordinate(120,120), });
     polygon = Factory.CreatePolygon(shell, new ILinearRing[] { hole, });
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:15,代码来源:NormalizeTest.cs

示例8: IsInside

 /// <summary>
 /// 
 /// </summary>
 /// <param name="innerRing"></param>
 /// <param name="searchRing"></param>
 /// <returns></returns>
 private bool IsInside(ILinearRing innerRing, ILinearRing searchRing)
 {
     ICoordinate[] innerRingPts = innerRing.Coordinates;
     ICoordinate[] searchRingPts = searchRing.Coordinates;
     if (!innerRing.EnvelopeInternal.Intersects(searchRing.EnvelopeInternal))
         return false;
     ICoordinate innerRingPt = IsValidOp.FindPointNotNode(innerRingPts, searchRing, graph);
     Assert.IsTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring");
     bool isInside = CGAlgorithms.IsPointInRing(innerRingPt, searchRingPts);
     if (isInside) 
     {
         nestedPt = innerRingPt;
         return true;
     }
     return false;
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:22,代码来源:SweeplineNestedRingTester.cs

示例9: GMLTesting

        /// <summary>
        /// 
        /// </summary>
        public GMLTesting() 
        {
            point = Factory.CreatePoint(new Coordinate(100, 100));

            ICoordinate[] coordinates = new ICoordinate[]
            {
                 new Coordinate(10,10),
                 new Coordinate(20,20),
                 new Coordinate(20,10),                 
            };
            line = Factory.CreateLineString(coordinates);

            coordinates = new ICoordinate[]
            {
                new Coordinate(100,100),
                new Coordinate(200,100),
                new Coordinate(200,200),                
                new Coordinate(100,200),
                new Coordinate(100,100),
            };
            ICoordinate[] interior1 = new ICoordinate[] 
            { 
                new Coordinate(120,120),
                new Coordinate(180,120),
                new Coordinate(180,180),                
                new Coordinate(120,180),
                new Coordinate(120,120),
            };
            ILinearRing linearRing = Factory.CreateLinearRing(coordinates);
            ILinearRing[] holes = new ILinearRing[] { Factory.CreateLinearRing(interior1), };
            polygon = Factory.CreatePolygon(linearRing, holes);

            coordinates = new ICoordinate[]
            {
                new Coordinate(100,100),
                new Coordinate(200,200),
                new Coordinate(300,300),                
                new Coordinate(400,400),
                new Coordinate(500,500),
            };
            multiPoint = Factory.CreateMultiPoint(coordinates);

            writer = new GMLWriter();
            reader = new GMLReader();
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:48,代码来源:GMLTesting.cs

示例10: ToPolygon

 /// <summary>
 /// 
 /// </summary>
 /// <param name="geometryFactory"></param>
 /// <returns></returns>
 public IPolygon ToPolygon(IGeometryFactory geometryFactory)
 {
     ILinearRing[] holeLR = new ILinearRing[_holes.Count];
     for (int i = 0; i < _holes.Count; i++)
         holeLR[i] = _holes[i].LinearRing;
     IPolygon poly = geometryFactory.CreatePolygon(LinearRing, holeLR);
     return poly;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:13,代码来源:EdgeRing.cs

示例11: SetByteStream

		/// <summary>
		/// 
		/// </summary>
		/// <param name="geometry"></param>
		/// <returns></returns>
		protected int SetByteStream(ILinearRing geometry)
		{
			return SetByteStream(geometry.Coordinates, geometry);
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:9,代码来源:PostGisWriter.cs

示例12: ExtractShellPolygon

        private static PolygonType ExtractShellPolygon(ref ILinearRing shell, SurfacePropertyType member)
        {
            PolygonType sur = member.Surface as PolygonType;
            LinearRingType li = sur.Exterior.Ring as LinearRingType;
            foreach (DirectPositionListType rings in li.Items)
            {
                List<Coordinate> lstCoor = ExtractCoordinates(rings);

                shell = new LinearRing(lstCoor);

            }
            return sur;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:13,代码来源:WFSClient.cs

示例13: GetPolygon

        private IBasicGeometry GetPolygon(MultiSurfaceType multi)
        {
            Polygon[] p = new Polygon[multi.SurfaceMemberItems.Count];
                ;
           
            int npoly = 0;
            foreach (SurfacePropertyType member in multi.SurfaceMemberItems)
            {
                ILinearRing shell = null;
                ILinearRing[] holes = null;
                PolygonType sur = ExtractShellPolygon(ref shell, member);

                if (sur.Interior.Count == 0  && shell !=null)
                        p[npoly] = new Polygon(shell);
                else
                {
                    holes = new ILinearRing[sur.Interior.Count];
                    ExtractInteriorPolygon(holes, sur);
                    p[npoly] = new Polygon(shell, holes);
                }
                npoly++;
            }
            return new MultiPolygon(p);

        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:25,代码来源:WFSClient.cs

示例14: McPointInRing

 /// <summary>
 ///
 /// </summary>
 /// <param name="ring"></param>
 public McPointInRing(ILinearRing ring)
 {
     _ring = ring;
     BuildIndex();
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:9,代码来源:McPointInRing.cs

示例15: Write

 /// <summary>
 /// 
 /// </summary>
 /// <param name="linearRing"></param>
 /// <param name="writer"></param>
 protected void Write(ILinearRing linearRing, XmlTextWriter writer)
 {
     writer.WriteStartElement("LinearRing", GMLElements.gmlNS);
     WriteCoordinates(linearRing.Coordinates, writer);
     writer.WriteEndElement();
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:11,代码来源:GMLWriter.cs


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