Abel Zimusi

Abel Zimusi

  • NA
  • 19
  • 595

How do I reverse Geocode a polygon to get addresses inside i

Sep 17 2019 4:04 AM
I want to develop a C# app that can reverse GeoCode polygon and give me all the addresses that can be found inside the area of the polygon.
 
I managed to find a solution to reverse GeoCode long and lat coordinates as shown below:
  1. static string ReverseGeoCoding(string latitude, string longitude)  
  2. {  
  3. var json = new WebClient().DownloadString(baseUrlRGC + latitude.Replace(" """) + "," + longitude.Replace(" """) + plusUrl);  
  4. //concatenate URL with the input lat/lng and downloads the requested resource  
  5. GoogleGeoCodeResponse jsonResult = JsonConvert.DeserializeObject<GoogleGeoCodeResponse>(json);  
  6. //deserializing the result to GoogleGeoCodeResponse  
  7. string status = jsonResult.status;  
  8. // get status s  
  9. tring geoLocation = String.Empty;  
  10. if (status == "OK")  
  11. //check if status is OK  
  12. {  
  13. for (int i = 0; i < jsonResult.results.Length; i++) //loop throught the result for addresses  
  14. {  
  15. geoLocation += "Address: " + jsonResult.results[i].formatted_address + Environment.NewLine;  
  16. //append the result addresses to every new line  
  17. }  
  18. return geoLocation; //return result  
  19. }  
  20. else  
  21. {  
  22. return status; //return status / error if not OK  
  23. }  
  24. }  
However what I want is a solution to provide multiple coordinates for the polygon and return all addresses inside the area.