를 사용하는 방법 네임 스페이스 System.Spatial
내가 필요 정확히 것 같다,하지만 난 그것을 사용하는 방법을 알아낼 수 없습니다나는 점 A와 점 B 사이의 거리를 계산하는 함수를 필요 System.Spatial.GeographyPoint
.
IPoint
은 모두 인 Latitude
및 Longitude
을 제공하는 인터페이스입니다.
첫 번째 시도 :
public static double CalculateDistance(IPoint pointA, IPoint pointB)
{
var gp1 = GeographyPoint.Create(pointA.Latitude, pointA.Longitude);
var gp2 = GeographyPoint.Create(pointB.Latitude, pointB.Longitude);
return gp1.Distance(gp2) ?? 0;
}
point1.Distance(point2)
에 NotImplementedException
로 끝납니다. 메시지는 프랑스어이지만 기본적으로 "등록 된 작업 없음. SpatialImplementation.CurrentImplementation.Operations 속성을 사용하여 작업을 제공하십시오."
좋아, 다음이 시도됩니다
public static double CalculateDistance(IPoint pointA, IPoint pointB)
{
var gp1 = GeographyPoint.Create(pointA.Latitude, pointA.Longitude);
var gp2 = GeographyPoint.Create(pointB.Latitude, pointB.Longitude);
return SpatialImplementation.CurrentImplementation.Operations.Distance(gp1, gp2);
}
가 지금은
SpatialImplementation.CurrentImplementation.Operations
에
NullReferenceException
을 얻었다.
Msdn에 대한 자세한 내용은 많지 않습니다.
누구든지 이러한 구현 방법을 설명 할 수 있습니까?
어떻게 그 메소드를 호출하고 클래스와 함께'IPoint' 인터페이스를 구현 했습니까? – Habib
물론 구현했습니다. 위도와 경도를 제공합니다. 오류는 제가 말한 것과 정확히 같습니다. 나는 지금 이것을 단위 테스트에서 호출하고있다. – Johnny5