2011-02-07 5 views

答えて

3

UK Government list of schools and collegesストレート場所を含む英国政府のウェブから...あなたはおそらく、場所を取るし、郵便番号データから、おそらく(緯度/長い自分自身にそれを変換する必要があります)。

(居住の場所で)瞳の達成や欠勤を含め、追加のデータセットへのリンクについてthis linkを参照してください

1

Googleはあなたがアドレスを知っている場合に使用できるジオコーディングサービスを提供しています。あなたは、あなたのグーグルマップ上の学校の位置をプロットすることができ緯度と経度を持っていたら、コードのこの作品は、住所の緯度と経度をGoogleに問い合わせます:

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(); 
} 

を返された場所は、する必要があります解析される:

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

のGoogle APIを照会するために使用するURLは次のとおりです。

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

keyに適用し、Googleによって生成された、とPAですあなたの要求しているドメインにこの鍵を入手して無料サービスを利用することもできますが、料金は限られています。最後に、1日に50,000件に制限されていることを確認しました。私はあなたがキーを申請するために行くURLを忘れていますが、もしそれをGoogleにしても大した問題はありません.... heh :)

関連する問題