2009-10-22 2 views
1

Google API를 사용하는 iphone 응용 프로그램을 개발 중입니다. 위도와 경도가 있습니다. 이러한 점에서 남서 및 북동점을 찾아야합니다. 어떻게해야합니까? 사전SouthWest 및 NorthEast Points

답변

2

에서

감사 감안할 때 :

 
    A point (LAT, LNG) 
    A distance or radius DIST 
    1° of latitude ~= 69 miles ~= 111 kms 
    1° of longitude ~= cos(latitude)*69 ~= cos(latitude)*111 

남서 지점입니다 :

 
lng_sw = LNG - (DIST/abs(cos(radians(LAT))) * 111) 
lat_sw = LAT - (DIST/111) 

북동 포인트는 다음과 같습니다

 
lng_ne = LNG + (DIST/abs(cos(radians(LAT))) * 111) 
lat_ne = LAT + (DIST/111) 

당신이 마일을 사용하는 경우 111 대신 111 단위 사용 .

0

이 사람이

private double DegreeToRadian(double angle) { 
    return Math.PI * angle/180.0; 
} 

private bool CalculateNeSw(double distance, double lat, double lng, out MapPoint[] points) { 
     /* 
     * 1° of latitude ~= 69 miles ~= 111 kms, 1° of longitude ~= cos(latitude)*69 ~= cos(latitude)*111 
     * SW.LNG = LNG - (DIST/abs(cos(radians(LAT))) * 111), SW.LAT = LAT - (DIST/111) 
     * NE.LNG = LNG + (DIST/abs(cos(radians(LAT))) * 111), NE.LAT = LAT + (DIST/111) 
     */ 
     points = new MapPoint[2]; 
     try { 
      double deltaLat = distance/69; 
      double deltaLng = distance/Math.Abs(Math.Cos(DegreeToRadian(lat)) * 69); 

      /* South-West */ 
      points[1] = new MapPoint { 
       Lng = (lng - deltaLng).ToString(), 
       Lat = (lat - deltaLat).ToString(), 
       IsSet = true, 
       FormattedAddress = "South-West" 
      }; 

      /* North-East */ 
      points[0] = new MapPoint { 
       Lng = (lng + deltaLng).ToString(), 
       Lat = (lat + deltaLat).ToString(), 
       IsSet = true, 
       FormattedAddress = "North-East" 
      }; 

      return true; 
     } 
     catch (Exception ex) { 
      return false; 
     }} 

주의해야하는 경우 C# 코드는 다음과 같습니다

  • 를 MapPoint 내가 마일을 사용

  • 위도/경도 특성을 가진 간단한 데이터 클래스를 ==> 69

관련 문제