I realize that I had forgotten to cover geocoding, so I’ll discuss it here now.  Geocoding is simply the process of assigning latitude+longitude(+altitude) to geographic features.

Many times when building apps of this type, you’ll be provided with vast quantities of geocoded data points in an easy-to-consume format.  Other times, you’ll be lucky to have an address.

If that’s your situation, the MapPoint Web Service SDK provides geocoding that, given an address, will:

  • return a lat+long
  • return a confidence value between 0.0 and 1.0
  • scrub the address strings to correct funky abbreviations, etc.

The following code illustrates this:

LatLong GeocodeAddress(string address, string city, string stateOrProvince, string country, string postalCode)

{

  LatLong latlong = new LatLong();

  try {

   FindAddressSpecification spec = new FindAddressSpecification();

   FindResults results;

   spec.InputAddress = new YourProgram.MapPoint.Address();

   spec.DataSourceName = "MapPoint.NA"; // or “MapPoint.EU” or...

   spec.InputAddress.AddressLine = address;

   spec.InputAddress.PrimaryCity = city;

   spec.InputAddress.Subdivision = stateOrProvince;

   spec.InputAddress.CountryRegion = country;

   spec.InputAddress.PostalCode = postalCode;

   results = mapFindService.FindAddress(spec);

   latlong.Latitude = results.Results[0].FoundLocation.LatLong.Latitude;

   latlong.Longitude = results.Results[0].FoundLocation.LatLong.Longitude;

   } catch (Exception) {

     latlong.Latitude = latlong.Longitude = double.NaN;

  }

return latlong;

}

In my next post, I’ll discuss what I can about Virtual Earth + Silverlight.  It’s not as if I have some secret inside info, but, well, you’ll see…