本文整理汇总了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;
}