2011-02-07 4 views

답변

3

UK Government list of schools and colleges 바로 위치를 포함하여 영국 정부 웹에서 ... 당신은 아마 위치를 타고 우편 번호 데이터에서 아마 (A 위도/경도 자신으로 변환해야합니다).

은 (거주의 위치에 따라) 학생 달성과 결석

1

구글은 당신이 주소를 알고있는 경우에 사용할 수있는 지오 코딩 서비스를 제공 등의 추가 데이터 세트에 대한 링크 this link를 참조하십시오. 이 코드 조각은, 주소의 위도와 경도를 위해 구글을 쿼리합니다 당신은 위도가와 경도 일단 당신은 다음 구글지도에서 학교의 위치를 ​​플롯 할 수 있습니다 :

public string GeocodeAddress(string address) 
{ 
    DateTime startTime = DateTime.Now; 

    address = address.Replace(' ', '+'); 

    string url = string.Format(_GEOCODE_API_TEMPLATE, address, "csv", _GOOGLE_API_KEY); 

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 

    IWebProxy proxy = WebRequest.DefaultWebProxy; 
    proxy.Credentials = CredentialCache.DefaultNetworkCredentials; 
    request.Proxy = proxy; 

    StringBuilder location = new StringBuilder(); 
    HttpWebResponse response = null; 
    try 
    { 
     response = (HttpWebResponse)request.GetResponse(); 

     if (response.StatusCode != HttpStatusCode.OK) 
      throw new System.Net.WebException(string.Format("Bad response code: {0}", response.StatusCode)); 

     StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8")); 
     char[] chars = new char[256]; 
     int pos = 0; 
     int numCharsRead = 0; 
     while ((numCharsRead = sr.Read(chars, 0, chars.Length)) > 0) 
     { 
      pos += numCharsRead; 
      location.Append(chars, 0, numCharsRead); 
     } 
    } 
    finally 
    { 
     if (response != null) 
      response.Close(); 
    } 

    return location.ToString(); 
} 

반환되는 위치는 다음에 필요 구문 분석 :

private const string _GEOCODE_API_TEMPLATE = "http://maps.google.com/maps/geo?q={0}&output={1}&key={2}"; 

key가 적용 구글에 의해 생성되며, PA입니다 :

float latitude, longitude; 
float.TryParse(ar.RawGeocode.Split(',')[2], out latitude); 
float.TryParse(ar.RawGeocode.Split(',')[3], out longitude); 

구글 API를 조회하는 데 사용되는 URL입니다 귀하의 요청한 도메인에 맞게 이 키를 가져 와서 무료로 사용할 수는 있지만 요금이 한정되어 있습니다. 마지막으로 내가 당신을 하루에 50K 요청으로 제한했다는 것을 확인했습니다. 나는 당신이 열쇠를 신청하기 위해가는 URL을 잊어 버린다. 그러나 당신이 구글이라면 많은 문제가 없어야한다 .... heh :)

관련 문제