简体   繁体   English

如何使用Geolocator确定纬度是北纬还是南纬,还是西经还是东经?

[英]How to determine if Latitude is North or South, or Longitude West or East with Geolocator?

I'm building an Universal App in WinRT and am able to get the Latitude Longitude of my device using the Geolocator. 我正在WinRT中构建通用应用程序,并且能够使用Geolocator获取设备的纬度经度。 But for my input I also need the direction (North, South for Latitude and East West for Longitude). 但是对于我的输入,我还需要方向(北,南代表纬度,东西向代表经度)。

But how do I know if a Latitude or Longitude is within a specific direction? 但是,我怎么知道纬度或经度是否在特定方向上? Is there a build-in way, or what would be the calculation to do this? 是否有内置方法,或者执行此操作的计算方法是什么?

51.3705 to 51.3705N 51.370551.3705N

6.1724 to 6.1724E 6.17246.1724E

Geoposition GeoPosition = await GeoLocator.GetGeopositionAsync();
double Latitude = GeoPosition.Coordinate.Point.Position.Latitude;
double Longitude = GeoPosition.Coordinate.Point.Position.Longitude;

Kind regards, Niels 亲切的问候,尼尔斯

Have a look here . 在这里看看。

Instead of adding S/N or W/E to indicate the direction, you will get values from -90° (S) to 90° (N) and -180° (W) to 180° (E). 不用添加S / N或W / E来指示方向,您将获得-90°(S)至90°(N)和-180°(W)至180°(E)的值。 The docs doesn't explicitly specify which direction is positive, but what I've written here should be the most common convention. 文档未明确指定哪个方向是积极的,但是我在这里写的应该是最常见的约定。

Common sense :): 常识:):

private string ConvertLatitudeToGPS(double Latitude)
    {
        string Direction = "";
        double UnformattedLatitude = Latitude;
        if (Latitude > 0)
        {
            Direction = "N";
        }
        else
        {
            UnformattedLatitude = UnformattedLatitude * -1;
            Direction = "S";
        }
        string GPSString = UnformattedLatitude.ToString("0.0000") + Direction;
        return GPSString;
    }

    private string ConvertLongitudeToGPS(double Longitude)
    {
        string Direction = "";
        double UnformattedLongitude = Longitude;
        if (Longitude > 0)
        {
            Direction = "E";
        }
        else
        {
            UnformattedLongitude = UnformattedLongitude * -1;
            Direction = "W";
        }
        string GPSString = UnformattedLongitude.ToString("0.0000") + Direction;
        return GPSString;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找到二维阵列中的北,东,南,西和对角线邻居? - How can I find the North, East, South, West and diagonal neighbours in a 2D array? 在一系列经纬度中找到西北和东南 - Find the North West and South East among bunch of Latitudes and Longitudes 从Google Map中的地理编码获取北,南,东,西的街道名称 - Get North,South,East,West street names from Geocode in Google Map 是否可以将“北,南,东”与“北,东,南”进行比较并找到对等关系? - Is it possible to compare “North, South, East” and “North, East, South” and find equivalence? 使用 GeoLocator for Longitude 和 Latitude 在 Xamarin 表单中给出以下错误 - Using GeoLocator for Longitude and Latitude giving the following error in Xamarin forms 如何确定两组纬度/经度坐标之间的距离? - How can I determine the distance between two sets of latitude/longitude coordinates? 如何对经纬度坐标进行插值 - How to interpolate latitude and longitude coordinates 在 C# 中计算矩阵东西对角线 - calculate matrix east west diagonal in C# 如何在gmap中使用经度和纬度获取地址? - How to get the address using Latitude and Longitude with gmap? 如何将WellKnownBinary和CoordinateSystemId转换为经度和纬度 - How to convert WellKnownBinary and CoordinateSystemId to latitude and longitude
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM