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


C# Polygon类代码示例

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


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

示例1: mergePartialBuffers

        private static Polygon mergePartialBuffers(List<Polygon> buffers)
        {
            Polygon temp = new Polygon();
            ICollection<IGeometry> gc;
            while (buffers.Count > 1)
            {
                List<Polygon> tempBuffers = new List<Polygon>();
                for (int i = 0; i < buffers.Count; i += 2)
                {
                    if (i + 1 == buffers.Count)
                        tempBuffers.Add(buffers[i]);
                    else
                    {
                        gc = buffers[i].Union(buffers[i + 1]);
                        if (gc.Count > 0)
                            temp = (Polygon)((GeometryCollection)gc)[0];
                        tempBuffers.Add(temp);
                    }
                }
                buffers = tempBuffers;
            }

            if (buffers.Count == 0)
                return null;

            return buffers[0];

        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:28,代码来源:GeoBuffer.cs

示例2: MillionSquare

        public void MillionSquare()
        {
            Polygon P = new Polygon(MillionSquarePoints);
            Detector D = new Detector(P);

            Assert.AreEqual(D.Result, 3999996000001);
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:7,代码来源:DetectorTests.cs

示例3: DrawPolygon

		// Draw the unsimplified polygon
		private void DrawPolygon()
		{
			// Get current viewpoints extent from the MapView
			var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
			var viewpointExtent = currentViewpoint.TargetGeometry.Extent; 

			MapPoint center = viewpointExtent.GetCenter();
			double lat = center.Y;
			double lon = center.X + 300;
			double latOffset = 300;
			double lonOffset = 300;

			var points = new PointCollection()
			{
				new MapPoint(lon - lonOffset, lat),
				new MapPoint(lon, lat + latOffset),
				new MapPoint(lon + lonOffset, lat),
				new MapPoint(lon, lat - latOffset),
				new MapPoint(lon - lonOffset, lat),
				new MapPoint(lon - 2 * lonOffset, lat + latOffset),
				new MapPoint(lon - 3 * lonOffset, lat),
				new MapPoint(lon - 2 * lonOffset, lat - latOffset),
				new MapPoint(lon - 1.5 * lonOffset, lat + latOffset),
				new MapPoint(lon - lonOffset, lat)
			};
			_unsimplifiedPolygon = new Polygon(points, MyMapView.SpatialReference);

			_polygonOverlay.Graphics.Clear();
			_polygonOverlay.Graphics.Add(new Graphic(_unsimplifiedPolygon));
		}
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:31,代码来源:Simplify.xaml.cs

示例4: Plane

 private Plane(IPlaneEntity entity, double size, bool display = false)
     : base(entity, false)
 {
     InitializeGuaranteedProperties();
     if (display && size>1)
         mDisplayPolygon = CreatePlaneVisuals(size,true);
 }
开发者ID:samuto,项目名称:designscript,代码行数:7,代码来源:Plane.cs

示例5: AreaOfInterestButton_Click

        // Gets the users digitized area of interest polygon
        private async void AreaOfInterestButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _graphicsOverlay.Graphics.Clear();

                Polygon aoi = null;
                if (chkFreehand.IsChecked == true)
                {
                    var boundary = await MyMapView.Editor.RequestShapeAsync(DrawShape.Freehand) as Polyline;
                    if (boundary.Parts.First().Count <= 1)
                        return;

                    aoi = new Polygon(boundary.Parts, MyMapView.SpatialReference);
                    aoi = GeometryEngine.Simplify(aoi) as Polygon;
                }
                else
                {
                    aoi = await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon) as Polygon;
                }

                _graphicsOverlay.Graphics.Add(new Graphic(aoi));
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
开发者ID:jmiller121,项目名称:arcgis-runtime-samples-dotnet,代码行数:29,代码来源:ExtractData.xaml.cs

示例6: CreateSegmentListFromString

		public static List<SlicePerimeterSegment> CreateSegmentListFromString(string segmentListData)
		{
			List<SlicePerimeterSegment> output = new List<SlicePerimeterSegment>();
			string[] segmentData = segmentListData.Split('|');
			foreach (string segment in segmentData)
			{
				if (segment != "")
				{
					List<IntPoint> outPoints = new Polygon();
					string[] points = segment.Split('&');
					foreach (string point in points)
					{
						string[] coordinates = point.Split(',');
						string elementX = coordinates[0];
						string elementY = coordinates[1];
                        int xIndex = elementX.IndexOf("x:");
                        int yIndex = elementY.IndexOf("y:");
						outPoints.Add(new IntPoint(int.Parse(elementX.Substring(xIndex+2)), int.Parse(elementY.Substring(yIndex+2))));
					}
					output.Add(new SlicePerimeterSegment(outPoints[0], outPoints[1]));
				}
			}

			return output;
		}
开发者ID:broettge,项目名称:MatterSlice,代码行数:25,代码来源:SlicerLayer.cs

示例7: HotSpot

 public HotSpot(Vector2[] vertices, Texture2D texture)
 {
     shape = new Polygon(vertices);
     this.texture = texture;
     this.MouseEnabled = true;
     this.Name = "HotSpot" + counter++;
 }
开发者ID:vkrajacic89,项目名称:MagiciansEscape-TVZ,代码行数:7,代码来源:HotSpot.cs

示例8: StartButton_Click

        private async void StartButton_Click(object sender, RoutedEventArgs e)
        {

            outputGraphicsLayer.Graphics.Clear();

            InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;

            InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
            StartButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            ResetButton.Visibility = Windows.UI.Xaml.Visibility.Visible;

            //Get the user's input geometry and add it to the map
            inputDifferencePolygonGeometry = (await mapView1.Editor.RequestShapeAsync(DrawShape.Polygon)) as Polygon;
            drawGraphicsLayer.Graphics.Clear();
            drawGraphicsLayer.Graphics.Add(new Graphic { Geometry = inputDifferencePolygonGeometry });

            //Simplify the input geometry
            var simplifyGeometry = GeometryEngine.Simplify(inputDifferencePolygonGeometry);

            //Generate the difference geometries
            var inputGeometries1 = inputGraphicsLayer.Graphics.Select(x => x.Geometry).ToList();
            var inputGeometries2 = new List<Geometry> { simplifyGeometry };
            var differenceOutputGeometries = GeometryEngine.Difference(inputGeometries1, inputGeometries2);

            //Add the difference geometries to the amp
            foreach (var geom in differenceOutputGeometries)
            {
                outputGraphicsLayer.Graphics.Add(new Graphic { Geometry = geom });
            }

            ResetButton.IsEnabled = true;
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:32,代码来源:Difference.xaml.cs

示例9: SideWalkExtruder

 public SideWalkExtruder(Polygon polygon, Mesh mesh, float quantity, float outlineOffset)
 {
     _polygon = polygon;
     _mesh = mesh;
     _quantity = quantity;
     _outlineOffset = outlineOffset;
 }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:7,代码来源:SideWalkExtruder.cs

示例10: ExtensionsPolygonAddWaysAcceptsCollectionOfOSMWays

        public void ExtensionsPolygonAddWaysAcceptsCollectionOfOSMWays()
        {
            OSMDB db = new OSMDB();

            OSMNode p1 = new OSMNode(1, 10, 15);
            OSMNode p2 = new OSMNode(2, 0, 15);
            OSMNode p3 = new OSMNode(3, 0, 0);

            OSMWay way1 = new OSMWay(10);
            OSMWay way2 = new OSMWay(11);

            db.Nodes.Add(p1);
            db.Nodes.Add(p2);
            db.Nodes.Add(p3);

            way1.Nodes.Add(p1.ID);
            way1.Nodes.Add(p2.ID);
            way1.Nodes.Add(p3.ID);

            way2.Nodes.Add(p3.ID);
            way2.Nodes.Add(p1.ID);

            Polygon<OSMNode> target = new Polygon<OSMNode>();
            target.AddWays(new OSMWay[] {way1, way2}, db);

            Assert.Equal(3, target.VerticesCount);
            CompareVerticesLists(new IPointGeo[] { p3, p2, p1 }, target.Vertices);
        }
开发者ID:guifa,项目名称:traveltimeanalysis,代码行数:28,代码来源:ExtensionsTest.cs

示例11: MultiPolygonWktToPolygon

        private static Polygon MultiPolygonWktToPolygon(string wkt)
        {
            var polygon = new Polygon();

            var pointCollection = new PointCollection();
            var removed = wkt.Replace("MULTIPOLYGON (", "");
            var preSplit = removed.Replace(")), ((", "|");
            var rings = preSplit.Split('|');

            foreach (var r in rings)
            {
                PointCollection pc = new PointCollection();

                var r1 = r.Replace("(", "");
                var r2 = r1.Replace(")", "");
                var r3 = r2.Trim();

                var coords = r3.Split(',');
                foreach(var coord in coords)
                {
                    coord.Trim();
                    var xy = coord.Trim().Split(' ');
                    if (xy.Length != 2)
                    continue;

                    pc.Add(new MapPoint(double.Parse(xy[0], CultureInfo.InvariantCulture), double.Parse(xy[1], CultureInfo.InvariantCulture)));
                }

                polygon.Rings.Add(pc);
            }

            return polygon;
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:33,代码来源:WktConverter.cs

示例12: Multipg

        public void Multipg()
        {
            var rnd = new Random();
            var pg = new Polygon[50];
            var pgcheck = new GeoAPI.Geometries.IPolygon[50];
            var gf = new NetTopologySuite.Geometries.GeometryFactory();
            for (var i = 0; i < 50; i++)
            {
                var center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                var coord = new Coordinate[36];
                var coordscheck = new GeoAPI.Geometries.Coordinate[36];
                for (var ii = 0; ii < 36; ii++)
                {
                    coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                    var x = coord[ii].X;
                    var y = coord[ii].Y;
                    var c = new GeoAPI.Geometries.Coordinate(x, y);
                    coordscheck[ii] = c;
                }
                coord[35] = new Coordinate(coord[0].X, coord[0].Y);
                coordscheck[35] = new GeoAPI.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y);
                var ring = gf.CreateLinearRing(coordscheck);
                pgcheck[i] = gf.CreatePolygon(ring, null);
                pg[i] = new Polygon(coord);

            }
            var mpg = new MultiPolygon(pg);
            var mpgcheck = gf.CreateMultiPolygon(pgcheck);
            for (var ii = 0; ii < mpg.Coordinates.Count; ii++)
            {
                Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X);
                Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y);
            }
        }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:34,代码来源:MultiShape.cs

示例13: AddBooleanPolygon

 public void AddBooleanPolygon(Polygon polygon)
 {
     if(!booleanPolygons.Contains(polygon)) {
         booleanPolygons.Add(polygon);
         UpdateMesh();
     }
 }
开发者ID:JakeCataford,项目名称:unity-tinkerbox,代码行数:7,代码来源:DestructibleLevel.cs

示例14: ToPolygon

 public Polygon ToPolygon(int offset = 0)
 {
     offset += HitBox;
     var result = new Polygon();
     var innerRadius = -0.1562f * Distance + 687.31f;
     var outerRadius = 0.35256f * Distance + 133f;
     outerRadius = outerRadius / (float) Math.Cos(2 * Math.PI / CircleLineSegmentN);
     var innerCenters = LeagueSharp.Common.Geometry.CircleCircleIntersection(
         Start, End, innerRadius, innerRadius);
     var outerCenters = LeagueSharp.Common.Geometry.CircleCircleIntersection(
         Start, End, outerRadius, outerRadius);
     var innerCenter = innerCenters[0];
     var outerCenter = outerCenters[0];
     var direction = (End - outerCenter).Normalized();
     var end = (Start - outerCenter).Normalized();
     var maxAngle = (float) (direction.AngleBetween(end) * Math.PI / 180);
     var step = -maxAngle / CircleLineSegmentN;
     for (var i = 0; i < CircleLineSegmentN; i++)
     {
         var angle = step * i;
         var point = outerCenter + (outerRadius + 15 + offset) * direction.Rotated(angle);
         result.Add(point);
     }
     direction = (Start - innerCenter).Normalized();
     end = (End - innerCenter).Normalized();
     maxAngle = (float) (direction.AngleBetween(end) * Math.PI / 180);
     step = maxAngle / CircleLineSegmentN;
     for (var i = 0; i < CircleLineSegmentN; i++)
     {
         var angle = step * i;
         var point = innerCenter + Math.Max(0, innerRadius - offset - 100) * direction.Rotated(angle);
         result.Add(point);
     }
     return result;
 }
开发者ID:StopMotionCuber,项目名称:LeagueSharp-1,代码行数:35,代码来源:Geometry.cs

示例15: Tile

        public Tile( Polygon boundary, Polygon drawn, Geometry geometry )
            : this()
        {
            Boundary = boundary;
            Drawn = drawn;
            Geometry = geometry;

            // Make the vertex circle.
            VertexCircle = boundary.CircumCircle;

            // ZZZ - we shouldn't do this here (I did it for the slicing study page).
            //VertexCircle.Radius = 1.0;

            //
            // Below are experimentations with different vertex circle sizes.
            //

            //VertexCircle.Radius *= (1+1.0/9);

            // cuts adjacent cells at midpoint
            // Math.Sqrt(63)/6 for {3,6}
            // (1 + 1.0/5) for {3,7}
            // (1 + 1.0/9) for {3,8}
            // (1 + 1.0/20) for {3,9}

            // cuts at 1/3rd
            // 2/Math.Sqrt(3) for {3,6}
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:28,代码来源:Tile.cs


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