| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 
 |  
public static bool DecodeLatLong(ref GeoLocation location)
        {
            bool ret = false;
            HttpRequestCachePolicy cPolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default);
            string url = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false",
                location.latitude.ToString(numberFormat),location.longitude.ToString(numberFormat));
            try
            {
                HttpWebRequest httpWRequest = (HttpWebRequest)WebRequest.Create(url);
                httpWRequest.CachePolicy = cPolicy;
                httpWRequest.AllowAutoRedirect = false;
                httpWRequest.Method = "GET";
 
                httpWResponse = (HttpWebResponse)httpWRequest.GetResponse();
 
                Log.Info("Resultat provenant du cache : " + httpWResponse.IsFromCache);
 
                ret = ParsingXml(httpWResponse.GetResponseStream(),ref location);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                ret = false;
            }
            finally
            {
                if (httpWResponse != null) httpWResponse.Close();
            }
            return true;
        } | 
Partager