0


I have to update my database from geocode to get longitude and latitude of address stored in database.
For that I created one console application. Daily I can update 25000 records from google per user, And I am executing my console from different 3 machines everyday since last 4 to 5 days.
But I am getting OVER_QUERY_LIMIT status from today and I am not able to update database.
What should i do for this?
Here is my code to get Longitude-latitude of console:

protected static void FindLocation(string strLocation, out string lat, out string lng, out string Output)
{
    StreamWriter myWriter;
    System.Net.HttpWebRequest geoRequest;
    string googResponse;
    googResponse = "";
    lat = "";
    lng = "";
    Output = "";
    string abc = "";
    string strRequestURL;
    strRequestURL = "https://maps.googleapis.com/maps/api/geocode/xml?address=" + strLocation + "&sensor=false";
    try
    {
        geoRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strRequestURL);
        geoRequest.Method = "POST";
        geoRequest.KeepAlive = true;

        UTF8Encoding encoding = new UTF8Encoding();
        byte[] bytes = encoding.GetBytes(strRequestURL);
        geoRequest.ContentLength = bytes.Length;
        using (Stream writeStream = geoRequest.GetRequestStream())
        {
            writeStream.Write(bytes, 0, bytes.Length);
            writeStream.Close();
        }

        System.Net.HttpWebResponse geoResponse;

        geoResponse = (System.Net.HttpWebResponse)geoRequest.GetResponse();

        if (geoResponse != null)
        {

            XPathDocument document = new XPathDocument(geoResponse.GetResponseStream());
            XPathNavigator navigator = document.CreateNavigator();

            // get response status
            XPathNodeIterator statusIterator = navigator.Select("/GeocodeResponse/status");
            while (statusIterator.MoveNext())
            {
                if (statusIterator.Current.Value != "OK")
                {
                    if (statusIterator.Current.Value == "OVER_QUERY_LIMIT")
                    {

                    }
                    Output = "Failed";

                }
                else
                {
                    Output = statusIterator.Current.Value;
                }
            }

            // get results
            XPathNodeIterator resultIterator = navigator.Select("/GeocodeResponse/result");
            while (resultIterator.MoveNext())
            {

                XPathNodeIterator geometryIterator = resultIterator.Current.Select("geometry");
                while (geometryIterator.MoveNext())
                {

                    XPathNodeIterator locationIterator = geometryIterator.Current.Select("location");
                    while (locationIterator.MoveNext())
                    {

                        XPathNodeIterator latIterator = locationIterator.Current.Select("lat");
                        while (latIterator.MoveNext())
                        {
                            lat = latIterator.Current.Value;
                        }

                        XPathNodeIterator lngIterator = locationIterator.Current.Select("lng");
                        while (lngIterator.MoveNext())
                        {
                            lng = lngIterator.Current.Value;
                        }
                    }
                }
            }
        }
        else
        {
            Output = "Failed";
        }
    }
    catch (Exception ex)
    {
        Output = "Failed";
    }

}
Trusha Savsani
  • 489
  • 1
  • 11
  • 31
  • Are you using a different api key per user? Also this may seem silly but has your program perhaps ALREADY done the 25000 requests today? – Eminem Mar 29 '16 at 05:07
  • Thanks for your quick response. I am sure, It is the first time for today. – Trusha Savsani Mar 29 '16 at 05:15
  • Check this [SO question](http://stackoverflow.com/questions/9805529/geocoding-api-over-query-limit) if it can help you :) – KENdi Mar 29 '16 at 12:44

0 Answers0