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


C# GeoAPI类代码示例

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


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

示例1: OnRenderInternal

    /// <summary>
    /// Method to place the street direction symbols
    /// </summary>
    /// <param name="map"></param>
    /// <param name="lineString"></param>
    /// <param name="graphics"></param>
    private void OnRenderInternal(SharpMap.Map map, GeoAPI.Geometries.ILineString lineString,
        System.Drawing.Graphics graphics)
    {

        var length = lineString.Length;
        var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString);
        if (length < RepeatInterval + ArrowLength)
        {
            var start = System.Math.Max(0, (length - ArrowLength)/2);
            var end = System.Math.Min(length, (length + ArrowLength)/2);
            var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(start, end);

            RenderArrow(map, graphics, arrow);

            return;
        }

        var numArrows = (int) ((lineString.Length - ArrowLength)/RepeatInterval);
        var offset = (lineString.Length - numArrows*RepeatInterval - ArrowLength)*0.5;

        while (offset + ArrowLength < lineString.Length)
        {
            var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(offset, offset + ArrowLength);
            RenderArrow(map, graphics, arrow);
            offset += RepeatInterval;
        }

    }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:LineSymbolizerTest.cs

示例2: RenderArrow

 /// <summary>
 /// Method to render the arrow
 /// </summary>
 /// <param name="map">The map</param>
 /// <param name="graphics">The graphics object</param>
 /// <param name="arrow">The arrow</param>
 private void RenderArrow(SharpMap.Map map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow)
 {
     var pts = new System.Drawing.PointF[arrow.Coordinates.Length];
     for (var i = 0; i < pts.Length; i++)
         pts[i] = map.WorldToImage(arrow.GetCoordinateN(i));
     graphics.DrawLines(ArrowPen, pts);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:13,代码来源:LineSymbolizerTest.cs

示例3: OnRenderInternal

 protected override void OnRenderInternal(SharpMap.Map map, GeoAPI.Geometries.IPolygon polygon, System.Drawing.Graphics g)
 {
     var pt = polygon.Centroid;
     g.RenderingOrigin =
         System.Drawing.Point.Truncate(SharpMap.Utilities.Transform.WorldtoMap(pt.Coordinate, map));
     base.OnRenderInternal(map, polygon, g);
 }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:7,代码来源:PolygonSymbolizerTest.cs

示例4: GetPieChart

    /// <summary>
    /// Method for creating pie chart symbols
    /// </summary>
    /// <remarks>
    /// <para>In this example we just create some random pie charts, 
    /// but it probably should be based on attributes read from the row.</para>
    ///	<para>Credits goes to gonzalo_ar for posting this in the forum</para></remarks>
    /// <param name="row"></param>
    /// <returns></returns>
    private static Bitmap GetPieChart(GeoAPI.Features.IFeature row)
    {
        // Replace polygon with a center point (this is where we place the symbol
        row.Geometry = row.Geometry.Centroid;

        // Just for the example I use random values 
        int size = rand.Next(20, 35);
        int angle1 = rand.Next(60, 180);
        int angle2 = rand.Next(angle1 + 60, 300);
        RectangleF rect = new RectangleF(0, 0, size, size);
        Bitmap b = new Bitmap(size, size);
        using (IGraphics g = Graphics.FromImage(b).G())
        {
            // Draw Pie 
            g.FillPie(Brushes.LightGreen, rect, 0, angle1);
            g.FillPie(Brushes.Pink, rect, angle1, angle2 - angle1);
            g.FillPie(Brushes.PeachPuff, rect, angle2, 360 - angle2);

            // Draw Borders 
            g.DrawPie(Pens.Green, rect, 0, angle1);
            g.DrawPie(Pens.Red, rect, angle1, angle2 - angle1);
            g.DrawPie(Pens.Orange, rect, angle2, 360 - angle2);
        }
        return b;
    }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:PieCharts.aspx.cs

示例5: PointsFromXml

 /// <summary>
 /// Creates an enumeration of <see cref="GeoAPI.Geometries.Coordinate"/>s from an xml string
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="xml">the xml string</param>
 /// <returns>Coordinates</returns>
 public static System.Collections.Generic.IEnumerable<GeoAPI.Geometries.IGeometry> PointsFromXml(
     GeoAPI.Geometries.IGeometryFactory factory,
     System.IO.Stream xml)
 {
     foreach (var coordinate in CoordinatesFromXml(xml))
         yield return factory.CreatePoint(coordinate);
 }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:13,代码来源:ReadXmlExample.cs

示例6: OnMouseUp

 public void OnMouseUp(GeoAPI.Geometries.ICoordinate worldPosition, System.Windows.Forms.MouseEventArgs e)
 {
     if (enabled)
     {
         MessageBox.Show("Hallo Rob", "Demo MapTool");
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:7,代码来源:MapToolExample.cs

示例7: FindGeoNearPoint

        public static FeatureDataRow FindGeoNearPoint(GeoAPI.Geometries.IPoint point, VectorLayer layer, double amountGrow)
        {
            var box = new Envelope(point.Coordinate);
            box.ExpandBy(amountGrow);

            var fds = new FeatureDataSet();
            layer.DataSource.ExecuteIntersectionQuery(box, fds);

            FeatureDataRow result = null;
            var minDistance = double.MaxValue;

            foreach (FeatureDataTable fdt in fds.Tables)
            {
                foreach (FeatureDataRow fdr in fdt.Rows)
                {
                    if (fdr.Geometry != null)
                    {
                        var distance = point.Distance(fdr.Geometry);
                        if (distance < minDistance)
                        {
                            result = fdr;
                            minDistance = distance;
                        }
                    }
                }
            }

            return result;
        }
开发者ID:haoye1985,项目名称:Oasis-V1.2,代码行数:29,代码来源:GeospatialHelper.cs

示例8: GetCountryStyle

 /// <summary>
 /// This method is used for determining the style
 /// It is used as a delegate for the CustomTheme class.
 /// </summary>
 /// <param name="row"></param>
 /// <returns></returns>
 private VectorStyle GetCountryStyle(GeoAPI.Features.IFeature row)
 {
     VectorStyle s = new VectorStyle();
     s.Fill = new SolidBrush(Color.Green);
     s.Symbol = GetPieChart(row);
     return s;
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:13,代码来源:PieCharts.aspx.cs

示例9: JustTracks

 public static bool JustTracks(GeoAPI.Features.IFeature fdr)
 {
     //System.Console.WriteLine(fdr [0] + ";"+ fdr[4]);
     var s = fdr.Attributes[4] as string;
     if (s != null)
         return s == "track";
     return true;
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:8,代码来源:ShapeFileProviderTests.cs

示例10: ToPolygon

 internal static GeoAPI.Geometries.IGeometry ToPolygon(GeoAPI.Geometries.Envelope queryWindow)
 {
     return new NetTopologySuite.Geometries.Polygon(new NetTopologySuite.Geometries.LinearRing(new[] { 
         new GeoAPI.Geometries.Coordinate(queryWindow.MinX, queryWindow.MinY),
         new GeoAPI.Geometries.Coordinate(queryWindow.MinX, queryWindow.MaxY),
         new GeoAPI.Geometries.Coordinate(queryWindow.MaxX, queryWindow.MaxY),
         new GeoAPI.Geometries.Coordinate(queryWindow.MaxX, queryWindow.MinY),
         new GeoAPI.Geometries.Coordinate(queryWindow.MinX, queryWindow.MinY)}));
 }
开发者ID:netgrim,项目名称:MapKit,代码行数:9,代码来源:Util.cs

示例11: Geometry

 public Geometry(GeoAPI.Geometries.IGeometry shape)
 {
     this.coordinates = new decimal[shape.Coordinates.Length][];
     for(var i = 0; i < shape.Coordinates.Length; i++)
     {
         var coordinate = shape.Coordinates[i];
         this.coordinates[i] = new decimal[2] { System.Convert.ToDecimal(coordinate.X), System.Convert.ToDecimal(coordinate.Y) };
     }
 }
开发者ID:stoolrossa,项目名称:Tile5MVCExample,代码行数:9,代码来源:Geometry.cs

示例12: mapBox1_GeometryDefined

        void mapBox1_GeometryDefined(GeoAPI.Geometries.IGeometry geometry)
        {
            MessageBox.Show("Geometry defined!\r\n"+geometry);

            geoProvider.Geometries.Add(geometry);

            this.mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
            this.mapBox1.Refresh();

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:FormDemoDrawGeometries.cs

示例13: GetRotatedSymol

        public SharpMap.Styles.VectorStyle GetRotatedSymol(GeoAPI.Features.IFeature row)
        {
            if (!System.String.IsNullOrEmpty(StyleRotationColumn))
                try
                {
                    SharpMap.Styles.VectorStyle dataStyle = CloneStyle(DefaultStyle);
                    dataStyle.SymbolRotation = System.Convert.ToSingle(row.Attributes[StyleRotationColumn]);
                    return dataStyle;
                }
                catch { }

            return null;
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:13,代码来源:Theming.cs

示例14: CreateRectangle

 public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IGeometryFactory factory, 
     GeoAPI.Geometries.Coordinate leftTop, GeoAPI.Geometries.Coordinate rightBottom)
 {
     var pts = new[]
                     {
                         leftTop, 
                         new GeoAPI.Geometries.Coordinate(rightBottom.X, leftTop.Y), 
                         rightBottom,
                         new GeoAPI.Geometries.Coordinate(leftTop.X, rightBottom.Y), 
                         leftTop
                     };
     return factory.CreateLinearRing(pts);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:13,代码来源:CreatingData.cs

示例15: TransformBox

		/// <summary>
		/// Transforms a <see cref="Envelope"/>.
		/// </summary>
		/// <param name="box">BoundingBox to transform</param>
		/// <param name="transform">Math Transform</param>
		/// <returns>Transformed object</returns>
		public static GeoAPI.Geometries.IEnvelope TransformBox(GeoAPI.Geometries.IEnvelope box, IMathTransform transform)
		{
			if (box == null)
				return null;
            double[][] corners = new double[4][];
            corners[0] = transform.Transform(ToLightStruct(box.MinX, box.MinY)); //LL
            corners[1] = transform.Transform(ToLightStruct(box.MaxX, box.MaxY)); //UR
            corners[2] = transform.Transform(ToLightStruct(box.MinX, box.MaxY)); //UL
            corners[3] = transform.Transform(ToLightStruct(box.MaxX, box.MinY)); //LR

			IEnvelope result = GeometryFactory.CreateEnvelope();
            foreach (double[] p in corners)
				result.ExpandToInclude(p[0], p[1]);
			return result;
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:GeometryTransform.cs


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