• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GeoAPI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: EnsureVisible

public static void EnsureVisible(SharpMap.Map map, GeoAPI.Geometries.Coordinate pt)
{
    const double ensureVisibleRatio = 0.1d;
            
    //Get current map envelope
    var bb = map.Envelope;
    System.Console.WriteLine(string.Format("Map envelope: {0}", bb));
            
    //Set valid envelope
    var evbb = bb.Grow(- ensureVisibleRatio * bb.Width, -ensureVisibleRatio * bb.Height );
    System.Console.WriteLine(string.Format("Valid envelope: {0}", evbb));
            
    //Test if Point is in valid envelope
    if (evbb.Contains(pt)) return;

    //It is not
    System.Console.WriteLine(string.Format("Valid envelope does not contain {0}", pt));

    //LineString from Map.Center -> to Point
    var ls = map.Factory.CreateLineString(new[] {evbb.Centre, pt});
    System.Console.WriteLine(string.Format("LineString Map.Center -> Point: {0}", ls));

    //Setup Linestring from BoundingBox
    var evbbpts = new [] {evbb.TopLeft(), evbb.TopRight(), evbb.BottomRight(), evbb.BottomLeft(), evbb.TopLeft() };
    var evbblinearring = map.Factory.CreateLineString(evbbpts);
    System.Console.WriteLine(string.Format("Linestring of valid envelope: {0}", evbblinearring));

    //// convert geometries to NTS
    //var ntsevbb = (NetTopologySuite.Geometries.LineString)
    //    SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(evbblinearring, gf);
    //var ntsls = (NetTopologySuite.Geometries.LineString)
    //    SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(ls, gf);

    // Get intersection point
    var intGeo = evbblinearring.Intersection(ls);
    var intPt = (NetTopologySuite.Geometries.Point)intGeo;
    System.Console.WriteLine(string.Format("Intersection point is: {0}", intPt));

    //Compute offset
    var dx = pt.X - intPt.X;
    var dy = pt.Y - intPt.Y;
    System.Console.WriteLine(string.Format("Map.Center needs to be shifted by: [{0}, {1}]", dx, dy));

    //Set new center Center
    map.Center = new GeoAPI.Geometries.Coordinate(map.Center.X + dx, map.Center.Y + dy);

}
开发者ID:geobabbler,项目名称:SharpMap,代码行数:47,代码来源:EnsureVisibleSample.cs


示例17: OnMouseDown

        public override void OnMouseDown(GeoAPI.Geometries.ICoordinate worldPosition, System.Windows.Forms.MouseEventArgs e)
        {
            // Starting a new measurement?
            if (pointGometries.Count >= 2)
            {
                Clear();
            }

            // Add the newly selected point
            pointGometries.Add(new GeoPoint(worldPosition));

            CalculateDistance();

            // Refresh the screen
            pointLayer.RenderRequired = true;
            MapControl.Refresh(); // HACK: Why is this needed? (Only RenderRequired = true isn't enough...)
            
            base.OnMouseDown(worldPosition, e);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:MeasureTool.cs


示例18: SplitLineString

public GeoAPI.Geometries.IMultiLineString SplitLineString(
    GeoAPI.Geometries.ILineString lineString, 
    System.Double length)
{
    if (lineString == null || lineString.IsEmpty)
        throw new System.ArgumentException("Linestring is null or Empty", "lineString");

    //var gf = new NetTopologySuite.Geometries.GeometryFactory();
    //var ntsLine = (NetTopologySuite.Geometries.LineString)
    //                SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf);

    var ret = new System.Collections.Generic.List<GeoAPI.Geometries.ILineString>();
    var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString);

    double currentLength = 0d;
    while (currentLength  < lineString.Length)
    {
        var tmpLine = (GeoAPI.Geometries.ILineString)
            lil.ExtractLine(currentLength, currentLength + length);
        ret.Add(tmpLine);
        currentLength += length;
    }
    return lineString.Factory.CreateMultiLineString(ret.ToArray());
}
开发者ID:geobabbler,项目名称:SharpMap,代码行数:24,代码来源:LengthIndexedLineSample.cs


示例19: ToDotSpatialLineString

        internal static DotSpatial.Topology.LineString ToDotSpatialLineString(GeoAPI.Geometries.ILineString l)
        {
            DotSpatial.Topology.Coordinate[] c = new DotSpatial.Topology.Coordinate[l.Coordinates.Count()];

            for (int i = 0; i < l.Coordinates.Count(); i++)
            {
                c[i] = new DotSpatial.Topology.Coordinate(l.Coordinates[i].X, l.Coordinates[i].Y);
            }
            return new DotSpatial.Topology.LineString(c);
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:10,代码来源:Contour.cs


示例20: ToDotSpatialCoordinate

 internal static DotSpatial.Topology.Coordinate ToDotSpatialCoordinate(GeoAPI.Geometries.Coordinate coordinate)
 {
     return new DotSpatial.Topology.Coordinate(coordinate.X, coordinate.Y);
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:4,代码来源:Contour.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GeoCoordinate类代码示例发布时间:2022-05-24
下一篇:
C# Genre类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap