private void pull_data_online(string country1, string state1, string city1, string street1)
{
//this function pulls the data from online devices...
/*
1.country,state,city,street,latitude,longitude,elev,zip
*/
string country = country1;
string state = state1;
string city = city1;
string street = street1;
// string zip = zip1;
int value;
// if (int.TryParse(zip, out value))
// {
if (country != "" && city != "")
{
string join_string = "";
//--THIS IS DONE BECAUSE state,and street if present some api do not give response
//if (state != "" && street != "")
//{
// join_string = country + "," + state + "," + city + "," + street;
//}
//else
//{
join_string = country + "," + city;
// }
//geo location code goes here..
try
{
var address = join_string;
string BingMapsKey = "AgMVAaLqK8vvJe6OTRRu57wu0x2zBX1bUaqSizo0QhE32fqEK5fN8Ek4wWmO4QR4";
//Create REST Services geocode request using Locations API
string geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + address + "?o=xml&key=" + BingMapsKey;
using (var wc = new WebClient())
{
string api_url = geocodeRequest;
var data = wc.DownloadString(api_url);
// MessageBox.Show("string apic return =" + data);
string xml_string = data.ToString();
//MessageBox.Show(xml_string);
//--Parsing the xml document int the c# application...
//xml parsing...
XmlDocument xml = new XmlDocument();
xml.LoadXml(xml_string);
ProcessResponse(xml);
latPulledValue = latVal.ToString();//--Storing it in this variable to make it a string...
longPulledValue = longVal.ToString();
//MessageBox.Show("lat = " + latPulledValue + "long = " + longPulledValue);
//--This is for the elevation part...
string elevationAPI_URL = "http://dev.virtualearth.net/REST/v1/Elevation/List?pts=" + latVal + "," + longVal + "&key=AgMVAaLqK8vvJe6OTRRu57wu0x2zBX1bUaqSizo0QhE32fqEK5fN8Ek4wWmO4QR4&output=xml";
var elevationData = wc.DownloadString(elevationAPI_URL);
// MessageBox.Show("elev data = " + elevationData);
//--Now lets do the parsing...
//xml parsing...
XmlDocument xmlElevation = new XmlDocument();
xmlElevation.LoadXml(elevationData);
elevationPulledValue = elevationProcess(xmlElevation).ToString();//--This gives the elevation...
// MessageBox.Show("Pulled elevation");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}//close of if...
// }//close of if int try parse.
else
{
MessageBox.Show(WFA_psychometric_chart.Properties.Resources.Please_enter_a_valid_zip_numbe);
}
}