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


C# SharpMap.TransformToImage方法代码示例

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


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

示例1: DrawLineString

        public static Region DrawLineString(System.Drawing.Graphics g, SharpMap.Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map)
        {
            if (line.Vertices.Count > 1)
            {
                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                PointF[] points = line.TransformToImage(map);
                gp.AddLines(points);
                g.DrawPath(pen, gp);

                GisSharpBlog.NetTopologySuite.Geometries.Coordinate[] coords = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate[points.Length];
                for (int i = 0; i < points.Length; i++)
                    coords[i] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(points[i].X, points[i].Y);

                GisSharpBlog.NetTopologySuite.Geometries.LineString ls = new
                    GisSharpBlog.NetTopologySuite.Geometries.LineString(coords);
                GisSharpBlog.NetTopologySuite.Geometries.Coordinate[] linearRingPoints = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate[5];
                linearRingPoints[0] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(0, 0);
                linearRingPoints[1] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(map.Size.Width, 0);
                linearRingPoints[2] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(map.Size.Width, map.Size.Height);
                linearRingPoints[3] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(0, map.Size.Height);
                linearRingPoints[4] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(0, 0);
                GisSharpBlog.NetTopologySuite.Geometries.LinearRing ring = new GisSharpBlog.NetTopologySuite.Geometries.LinearRing(linearRingPoints);
                GeoAPI.Geometries.IGeometry geom = ls.Intersection(new GisSharpBlog.NetTopologySuite.Geometries.Polygon(ring));

                System.Drawing.Drawing2D.GraphicsPath gp2 = new System.Drawing.Drawing2D.GraphicsPath();
                Pen p2 = new Pen(Color.Black, pen.Width < 4 ? 4 : pen.Width);

                if (geom is GisSharpBlog.NetTopologySuite.Geometries.LineString)
                {
                    GisSharpBlog.NetTopologySuite.Geometries.LineString lineString = geom as GisSharpBlog.NetTopologySuite.Geometries.LineString;
                    System.Drawing.PointF[] v = new System.Drawing.PointF[lineString.Coordinates.Length];
                    for (int i = 0; i < lineString.Coordinates.Length; i++)
                        v[i] = new PointF((float)lineString.Coordinates[i].X, (float)lineString.Coordinates[i].Y);

                    gp2.AddLines(v);
                }
                if (geom is GisSharpBlog.NetTopologySuite.Geometries.GeometryCollection)
                {
                    GisSharpBlog.NetTopologySuite.Geometries.GeometryCollection geomCollection = geom as GisSharpBlog.NetTopologySuite.Geometries.GeometryCollection;
                    foreach (GisSharpBlog.NetTopologySuite.Geometries.Geometry cGeom in geomCollection)
                    {
                        if (cGeom is GisSharpBlog.NetTopologySuite.Geometries.LineString)
                        {
                            GisSharpBlog.NetTopologySuite.Geometries.LineString lineString = cGeom as GisSharpBlog.NetTopologySuite.Geometries.LineString;
                            System.Drawing.PointF[] v = new System.Drawing.PointF[lineString.Coordinates.Length];
                            for (int i = 0; i < lineString.Coordinates.Length; i++)
                                v[i] = new PointF((float)lineString.Coordinates[i].X, (float)lineString.Coordinates[i].Y);

                            gp2.AddLines(v);
                        }
                    }
                }

                try
                {
                    gp2.Widen(p2);

                    System.Drawing.Region r = new System.Drawing.Region(gp2);
                    return r;
                }
                catch (OutOfMemoryException)
                {
                    return null;
                }
            }

            return null;
        }
开发者ID:oliverheilig,项目名称:SharpMap.Ptv,代码行数:68,代码来源:InteractiveRenderer.cs


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