2012-04-20 2 views
1

현재 위치를 찾는 안드로이드 앱이 있지만 현재 위치에서 20 마일 이내에있는 우편 번호를 알아 내야합니다. 이 정보를 찾는 가장 좋은 방법은 무엇입니까? 공개 API 또는 웹 서비스가 있습니까? 위도/경도 또는 우편 번호를 입력 할 수 있습니다.위도/경도 부근의 우편 번호 목록 받기

+0

작업을 자신의 데이터베이스를 만들 된 우편 번호 데이터베이스 http://zips.sourceforge.net/을 사용할 수있는 위도/경도를 읽을 수있는 주소로 바꾸는 과정입니다. https://developers.google.com/maps/documentation/geocoding/ Google API가 있습니다. 시작하면 도움이 될 것입니다. – twain249

답변

0

. 이 결과를 사용하여 해당 반경을 기준으로 우편 번호를 찾습니다. 내가 아는 한

import com.google.android.maps.GeoPoint; 

public class DistanceCalculator { 

    private double Radius; 

    // R = earth's radius (mean radius = 6,371km) 
    // Constructor 
    DistanceCalculator(double R) { 
     Radius = R; 
    } 

    public double CalculationByDistance(GeoPoint StartP, GeoPoint EndP) { 
     double lat1 = StartP.getLatitudeE6()/1E6; 
     double lat2 = EndP.getLatitudeE6()/1E6; 
     double lon1 = StartP.getLongitudeE6()/1E6; 
     double lon2 = EndP.getLongitudeE6()/1E6; 
     double dLat = Math.toRadians(lat2-lat1); 
     double dLon = Math.toRadians(lon2-lon1); 
     double a = Math.sin(dLat/2) * Math.sin(dLat/2) + 
     Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * 
     Math.sin(dLon/2) * Math.sin(dLon/2); 
     double c = 2 * Math.asin(Math.sqrt(a)); 
     return Radius * c; 
    } 
} 
0

긴 I로이에 대한 API가 없다, 그러나 당신이 효과적으로 리버스 지오 코딩의 문제이다

관련 문제