<i id='6oCZ0'><tr id='6oCZ0'><dt id='6oCZ0'><q id='6oCZ0'><span id='6oCZ0'><b id='6oCZ0'><form id='6oCZ0'><ins id='6oCZ0'></ins><ul id='6oCZ0'></ul><sub id='6oCZ0'></sub></form><legend id='6oCZ0'></legend><bdo id='6oCZ0'><pre id='6oCZ0'><center id='6oCZ0'></center></pre></bdo></b><th id='6oCZ0'></th></span></q></dt></tr></i><div id='6oCZ0'><tfoot id='6oCZ0'></tfoot><dl id='6oCZ0'><fieldset id='6oCZ0'></fieldset></dl></div>

      <bdo id='6oCZ0'></bdo><ul id='6oCZ0'></ul>

      1. <small id='6oCZ0'></small><noframes id='6oCZ0'>

        <legend id='6oCZ0'><style id='6oCZ0'><dir id='6oCZ0'><q id='6oCZ0'></q></dir></style></legend><tfoot id='6oCZ0'></tfoot>

        C#的纬度和经度边界框?

        latitude and longitude bounding box for C#?(C#的纬度和经度边界框?)
          1. <i id='S3oD5'><tr id='S3oD5'><dt id='S3oD5'><q id='S3oD5'><span id='S3oD5'><b id='S3oD5'><form id='S3oD5'><ins id='S3oD5'></ins><ul id='S3oD5'></ul><sub id='S3oD5'></sub></form><legend id='S3oD5'></legend><bdo id='S3oD5'><pre id='S3oD5'><center id='S3oD5'></center></pre></bdo></b><th id='S3oD5'></th></span></q></dt></tr></i><div id='S3oD5'><tfoot id='S3oD5'></tfoot><dl id='S3oD5'><fieldset id='S3oD5'></fieldset></dl></div>
                  <bdo id='S3oD5'></bdo><ul id='S3oD5'></ul>

                    <tbody id='S3oD5'></tbody>
                • <tfoot id='S3oD5'></tfoot>

                • <small id='S3oD5'></small><noframes id='S3oD5'>

                  <legend id='S3oD5'><style id='S3oD5'><dir id='S3oD5'><q id='S3oD5'></q></dir></style></legend>
                  本文介绍了C#的纬度和经度边界框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我只想找到一个简单的 C# 类,它接受起始纬度和经度以及距离并找到边界框(最大纬度、最小纬度、最大经度、最小经度).在 SO 上还有其他类似的问题,但没有一个能真正回答这个问题,而且 C# 中也没有.

                  I just want to find a straightforward, C# class that takes in a starting latitude and longitude and a distance and finds the bounding box (max lat, min lat, max lon, min lon). There are other, similar, questions here on SO but none of them really answer this and the ones that do are not in C#.

                  帮助.

                  推荐答案

                  这就是您要的.感谢 Federico A. Ramponi 用 Python 这里.

                  Here's what you are asking for. Kudos to Federico A. Ramponi who wrote the original in Python here.

                  public class MapPoint
                  {
                      public double Longitude { get; set; } // In Degrees
                      public double Latitude { get; set; } // In Degrees
                  }
                  
                  public class BoundingBox
                  {
                      public MapPoint MinPoint { get; set; }
                      public MapPoint MaxPoint { get; set; }
                  }        
                  
                  // Semi-axes of WGS-84 geoidal reference
                  private const double WGS84_a = 6378137.0; // Major semiaxis [m]
                  private const double WGS84_b = 6356752.3; // Minor semiaxis [m]
                  
                  // 'halfSideInKm' is the half length of the bounding box you want in kilometers.
                  public static BoundingBox GetBoundingBox(MapPoint point, double halfSideInKm)
                  {            
                      // Bounding box surrounding the point at given coordinates,
                      // assuming local approximation of Earth surface as a sphere
                      // of radius given by WGS84
                      var lat = Deg2rad(point.Latitude);
                      var lon = Deg2rad(point.Longitude);
                      var halfSide = 1000 * halfSideInKm;
                  
                      // Radius of Earth at given latitude
                      var radius = WGS84EarthRadius(lat);
                      // Radius of the parallel at given latitude
                      var pradius = radius * Math.Cos(lat);
                  
                      var latMin = lat - halfSide / radius;
                      var latMax = lat + halfSide / radius;
                      var lonMin = lon - halfSide / pradius;
                      var lonMax = lon + halfSide / pradius;
                  
                      return new BoundingBox { 
                          MinPoint = new MapPoint { Latitude = Rad2deg(latMin), Longitude = Rad2deg(lonMin) },
                          MaxPoint = new MapPoint { Latitude = Rad2deg(latMax), Longitude = Rad2deg(lonMax) }
                      };            
                  }
                  
                  // degrees to radians
                  private static double Deg2rad(double degrees)
                  {
                      return Math.PI * degrees / 180.0;
                  }
                  
                  // radians to degrees
                  private static double Rad2deg(double radians)
                  {
                      return 180.0 * radians / Math.PI;
                  }
                  
                  // Earth radius at a given latitude, according to the WGS-84 ellipsoid [m]
                  private static double WGS84EarthRadius(double lat)
                  {
                      // http://en.wikipedia.org/wiki/Earth_radius
                      var An = WGS84_a * WGS84_a * Math.Cos(lat);
                      var Bn = WGS84_b * WGS84_b * Math.Sin(lat);
                      var Ad = WGS84_a * Math.Cos(lat);
                      var Bd = WGS84_b * Math.Sin(lat);
                      return Math.Sqrt((An*An + Bn*Bn) / (Ad*Ad + Bd*Bd));
                  }
                  

                  这篇关于C#的纬度和经度边界框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                    <tbody id='QjiMd'></tbody>
                • <small id='QjiMd'></small><noframes id='QjiMd'>

                    <legend id='QjiMd'><style id='QjiMd'><dir id='QjiMd'><q id='QjiMd'></q></dir></style></legend>
                    <i id='QjiMd'><tr id='QjiMd'><dt id='QjiMd'><q id='QjiMd'><span id='QjiMd'><b id='QjiMd'><form id='QjiMd'><ins id='QjiMd'></ins><ul id='QjiMd'></ul><sub id='QjiMd'></sub></form><legend id='QjiMd'></legend><bdo id='QjiMd'><pre id='QjiMd'><center id='QjiMd'></center></pre></bdo></b><th id='QjiMd'></th></span></q></dt></tr></i><div id='QjiMd'><tfoot id='QjiMd'></tfoot><dl id='QjiMd'><fieldset id='QjiMd'></fieldset></dl></div>

                    • <bdo id='QjiMd'></bdo><ul id='QjiMd'></ul>

                      <tfoot id='QjiMd'></tfoot>