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


C# GeometryFactory.CreatePolygon方法代码示例

本文整理汇总了C#中NetTopologySuite.Geometries.GeometryFactory.CreatePolygon方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryFactory.CreatePolygon方法的具体用法?C# GeometryFactory.CreatePolygon怎么用?C# GeometryFactory.CreatePolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetTopologySuite.Geometries.GeometryFactory的用法示例。


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

示例1: main

		public static void main(string[] args)
		{
			ExtendedCoordinateSequenceFactory seqFact = ExtendedCoordinateSequenceFactory.Instance();
			
			ExtendedCoordinate[] array1 = new ExtendedCoordinate[] { new ExtendedCoordinate(0, 0, 0, 91), 
                new ExtendedCoordinate(10, 0, 0, 92), new ExtendedCoordinate(10, 10, 0, 93), 
                new ExtendedCoordinate(0, 10, 0, 94), new ExtendedCoordinate(0, 0, 0, 91)};
			ICoordinateSequence seq1 = seqFact.Create(array1);
			
			ICoordinateSequence seq2 = seqFact.Create(new ExtendedCoordinate[] { new ExtendedCoordinate(5, 5, 0, 91), 
                new ExtendedCoordinate(15, 5, 0, 92), new ExtendedCoordinate(15, 15, 0, 93), 
                new ExtendedCoordinate(5, 15, 0, 94), new ExtendedCoordinate(5, 5, 0, 91)});
			
			GeometryFactory fact = new GeometryFactory(ExtendedCoordinateSequenceFactory.Instance());

            IGeometry g1 = fact.CreatePolygon(fact.CreateLinearRing(seq1), null);
            IGeometry g2 = fact.CreatePolygon(fact.CreateLinearRing(seq2), null);
			
			Console.WriteLine("WKT for g1: " + g1);
			Console.WriteLine("Internal rep for g1: " + ((IPolygon) g1).ExteriorRing.CoordinateSequence);
			
			Console.WriteLine("WKT for g2: " + g2);
            Console.WriteLine("Internal rep for g2: " + ((IPolygon)g2).ExteriorRing.CoordinateSequence);

            IGeometry gInt = g1.Intersection(g2);
			
			Console.WriteLine("WKT for gInt: " + gInt);
            Console.WriteLine("Internal rep for gInt: " + ((IPolygon)gInt).ExteriorRing.CoordinateSequence);
		}
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:29,代码来源:extendedcoordinateexample.cs

示例2: LoadParcels

        private void LoadParcels(List<PointD> pt, Color color, string labelname)
        {
            SharpMap.Map map = new SharpMap.Map();
            List<GeoAPI.Geometries.Coordinate> vertices = new List<GeoAPI.Geometries.Coordinate>();

            foreach (PointD i in pt)
            {
                GeoAPI.Geometries.Coordinate p = new GeoAPI.Geometries.Coordinate();
                p.X = i.X;
                p.Y = i.Y;
                vertices.Add(p);
            }
            GeoAPI.Geometries.Coordinate l = new GeoAPI.Geometries.Coordinate();
            l.X = pt[0].X;
            l.Y = pt[0].Y;
            vertices.Add(l);

            //Collection<GeoAPI.Geometries.IGeometry> geom = new Collection<GeoAPI.Geometries.IGeometry>();

            GeometryFactory gf = new NetTopologySuite.Geometries.GeometryFactory();
            GeoAPI.Geometries.ILinearRing shell = gf.CreateLinearRing(vertices.ToArray());

            GeoAPI.Geometries.IPolygon polygon = gf.CreatePolygon(shell, null);

            SharpMap.Data.Providers.GeometryProvider geomProvider= new SharpMap.Data.Providers.GeometryProvider(polygon);

            SharpMap.Layers.VectorLayer layerParcels = new SharpMap.Layers.VectorLayer("Parcels");

            SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();

            style.Fill = new SolidBrush(Color.FromArgb(200,color));
            style.Outline = new Pen(new SolidBrush(color));

            layerParcels.Style = style;
            layerParcels.Style.EnableOutline = true;

            layerParcels.DataSource = geomProvider;
            layerParcels.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;

            var fdt = new SharpMap.Data.FeatureDataTable();
            fdt.Columns.Add(new System.Data.DataColumn("id", typeof(uint)));
            fdt.Columns.Add(new System.Data.DataColumn("label", typeof(string)));
            var fdr = (SharpMap.Data.FeatureDataRow)fdt.NewRow();
            fdr.ItemArray = new object[] { 1, labelname };
            fdr.Geometry =  polygon;
            fdt.AddRow(fdr);

            var dataprovider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);

            var ll = new SharpMap.Layers.LabelLayer("llayer");
            ll.DataSource = dataprovider;
            ll.LabelColumn = "label";
            ll.Style.Font = new Font("Eurostile Extended", 16,FontStyle.Bold);

            mapBox1.Map.Layers.Add(layerParcels);
            mapBox1.Map.Layers.Add(ll);

            mapBox1.Map.ZoomToExtents();
            mapBox1.Refresh();
        }
开发者ID:gerie-tanabe,项目名称:rubix,代码行数:62,代码来源:FormViewer.cs

示例3: ToPolygon

 public static IGeometry ToPolygon(QuadEdge[] e)
 {
     var ringPts = new[]
                       {
                           e[0].Orig.Coordinate,
                           e[1].Orig.Coordinate,
                           e[2].Orig.Coordinate,
                           e[0].Orig.Coordinate
                       };
     var fact = new GeometryFactory();
     ILinearRing ring = fact.CreateLinearRing(ringPts);
     IPolygon tri = fact.CreatePolygon(ring, null);
     return tri;
 }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:14,代码来源:QuadEdgeTriangle.cs

示例4: GetGeometry

 public IGeometry GetGeometry(GeometryFactory fact)
 {
     ILinearRing ring = fact.CreateLinearRing(GetCoordinates());
     IPolygon tri = fact.CreatePolygon(ring, null);
     return tri;
 }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:6,代码来源:QuadEdgeTriangle.cs

示例5: AddVectorLayers

        /// <summary>        
        /// /// Add a list of vector layers to the map.
        /// </summary>
        /// <param name="vectorLayers"></param>
        public void AddVectorLayers(List<FeatureInfo> vectorLayers)
        {
            int counter = 0;
            if (vectorLayers == null) return;
            vectorLayers.ForEach(layer => {

                VectorLayer vectorLayer = new VectorLayer("VectorLayer-" + counter);
                GeometryFactory factory = new GeometryFactory();
                List<IGeometry> geometries = new List<IGeometry>();

                FeatureDataTable featureData = new FeatureDataTable();
                featureData.Columns.Add("text", typeof(String));
                featureData.Columns.Add("style", typeof(MapExport.Style));

                layer.features.ForEach(feature =>
                {
                    FeatureDataRow dataRow = featureData.NewRow();
                    dataRow["text"] = feature.attributes.text;
                    dataRow["style"] = feature.attributes.style;

                    List<GeoAPI.Geometries.Coordinate> vertices = new List<GeoAPI.Geometries.Coordinate>();

                    feature.coordinates.ForEach(coordinate =>
                    {
                        double x = coordinate[0];
                        double y = coordinate[1];
                        vertices.Add((new GeoAPI.Geometries.Coordinate(x, y)));
                    });

                    switch (feature.type)
                    {
                        case "Text":
                        case "Point":
                            if (vertices.Count > 0)
                            {
                                var point = factory.CreatePoint(new GeoAPI.Geometries.Coordinate(vertices[0]));
                                dataRow.Geometry = point;
                            }
                            break;
                        case "LineString":
                            var lineString = factory.CreateLineString(vertices.ToArray());
                            dataRow.Geometry = lineString;
                            break;
                        case "Polygon":
                            var polygon = factory.CreatePolygon(vertices.ToArray());
                            dataRow.Geometry = polygon;
                            break;
                    }

                    featureData.AddRow(dataRow);
                });

                vectorLayer.DataSource = new SharpMap.Data.Providers.GeometryFeatureProvider(featureData);
                //vectorLayer.DataSource = new SharpMap.Data.Providers.FeatureProvider(featureData);

                //vectorLayer.Theme = new CustomTheme(GetFeatureStyle);
                vectorLayer.Theme = new CustomTheme(GetFeatureStyle);
                map.Layers.Add(vectorLayer);

                LabelLayer labels = new LabelLayer("Labels");

                labels.DataSource = vectorLayer.DataSource;
                labels.Enabled = true;
                labels.LabelColumn = "text";
                labels.Theme = new CustomTheme(GetLabelStyle);
                labels.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                labels.SmoothingMode = SmoothingMode.HighQuality;
                labels.SRID = vectorLayer.SRID;

                map.Layers.Add(labels);
                counter++;
            });
        }
开发者ID:Johkar,项目名称:Hajk2,代码行数:77,代码来源:MapExporter.cs


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