简体   繁体   English

DbGeography.Distance 返回不正确的结果

[英]DbGeography.Distance returned incorrect result

Here is my simplified code:这是我的简化代码:

var P1 = Common.Geography.CreatePoint((decimal)-73.980000, (decimal)40.7155773);
var P2 = Common.Geography.CreatePoint((decimal)-73.984434, (decimal)40.7155773);
var Distance = P1.Distance(P2);

Here is "CreatePoint" function:这是“CreatePoint”function:

public static DbGeography CreatePoint(decimal Longitude, decimal Latitude)
{
    return DbGeography.FromText(String.Format(CultureInfo.InvariantCulture, "POINT({0} {1})", Longitude, Latitude));
}

I saw in a several sources that results should be in meters so I expected to see 493 :我在几个来源中看到结果应该以米为单位,所以我预计会看到493

http://boulter.com/gps/distance/?from=-73.98%2C40.7155773&to=-73.984434%2C40.7155773&units=k http://boulter.com/gps/distance/?from=-73.98%2C40.7155773&to=-73.984434%2C40.7155773&units=k

Google Maps measure tool shows same result (but it doesn't allow to share link).谷歌地图测量工具显示相同的结果(但它不允许共享链接)。

However result I got from "Distance" function is 374.65 .但是我从“距离” function 得到的结果是374.65 I checked CoordinateSystemId for both objecs and it has default value 4326.我检查了两个对象的 CoordinateSystemId,它的默认值是 4326。

So what I'm doing wrong?那么我做错了什么? Or in which units is that result?或者那个结果是哪个单位的?

Check if the latitude / longitude order is swapped somewhere.检查纬度/经度顺序是否在某处交换。

I get 0.37k if I swap the order in your boulter link: http://boulter.com/gps/distance/?from=40.7155773%2C-73.98&to=40.7155773%2C-73.984434&units=k which is probably what you get in C# code.如果我在您的 boulter 链接中交换订单,我会得到 0.37k: http://boulter.com/gps/distance/?from=40.7155773%2C-73.98&to=40.7155773%2C-73.984434&units=k这可能就是您得到的在 C# 代码中。

Note that for boulter and google maps order should be latitude, longitude ;请注意,博尔特和谷歌地图的顺序应该是latitude, longitude WKT uses the opposite order longitude, latitude . WKT 使用相反顺序的longitude, latitude

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

相关问题 System.Data.Spatial DbGeography.Distance单位? - System.Data.Spatial DbGeography.Distance units? System.Data.Spatial DbGeography.Distance不能始终如一地工作 - System.Data.Spatial DbGeography.Distance is not working consistantly 如何在 Code First Entity Framework 中返回 DbGeography.Distance 计算值而不丢失强类型? - How to return DbGeography.Distance calculated value In Code First Entity Framework without losing strong typing? System.Data.Spatial DBGeography.Distance()将与SQL Server 2008一起使用吗? - Will System.Data.Spatial DBGeography.Distance() will work with SQL Server 2008? 如何将dbgeography中的距离返回到km? - how return a distance in dbgeography to km? 什么是DbGeography返回距离单位? - What is DbGeography return Distance unit? 如何返回以米为单位的地理距离? - how return distance dbgeography in meter? 向DbGeography添加距离和方位以获取新点 - Add a distance and bearing to a DbGeography to get a new point 在EF 6 / LINQ中计算和返回距离到实体/ DbGeography? - Compute and return distance in EF 6 / LINQ to Entities / DbGeography? System.Data.Entity.Spatial.DbGeography带有标高的距离 - System.Data.Entity.Spatial.DbGeography Distance with elevation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM