LoklakDotNet.Loklak.geocode C# (CSharp) Method

geocode() public method

This servlet provides geocoding of place names to location coordinates and also reverse geocoding of location coordinates to place names.
public geocode ( IList places ) : Task
places IList List of place names
return Task
        public async Task<string> geocode(IList<string> places)
        {
            Dictionary<string,string> qs = new Dictionary<string,string>();
            qs.Add("places", string.Join(",", places));
            return (await ProcessUrlAsync("geocode.json", qs));
        }

Usage Example

Example #1
0
 public async Task geocode()
 {
     Loklak loklak = new Loklak();
     var p = new List<string>();
     p.Add("Delhi");
     p.Add("Berlin");
     var result = await loklak.geocode(p);
     var d = JObject.Parse(result);
     Assert.IsNotNull(d.Property("locations"));
     Assert.AreEqual(((JObject)(((JObject)d.GetValue("locations")).GetValue("Delhi"))).GetValue("country_code").ToString(),"IN");
     Assert.AreEqual(((JObject)(((JObject)d.GetValue("locations")).GetValue("Berlin"))).GetValue("country_code").ToString(), "DE");
 }