Thursday, February 26, 2009

Creating and using GeoMedia WebMap Geocoding with the sample dataset

GeoMedia WebMap 6.1 can be used to create and provide geocoding web services. Here are the steps to create the geocoding web service.
  1. On the Windows desktop, select Start > All Programs > GeoMedia WebMap > Publisher > Server Configuration Utility.

    The Publisher Server Configuratin Utility dialog box appears.

  2. Click Add.

    The GeoMedia WebMap Publisher Application And Service Wizard appears.

  3. In the drop down list, select Location Utility Web Service.

    The GeoMedia WebMap Publisher Application And Service Wizard should like the screen below.

  4. Click Next.

    The New Location Utility Web Service Wizard appears.

  5.  If you want to use the sample data in the new web service, then toggle on Include demo data in the web service.

    The New Location Utility Web Service Wizard may look like the screen below.


  6. Click Next five times to complete the wizard. If you want to change the default Location, website and virtual directory alias name, then please do so when prompted.

    The new web service is created.

    If you choose to use the sample dataset, then the following address geocoding index files would be copied over to the default WebMap Publisher Project folder as shown below.

Once the Location Utility Web Service has been created, you can write a web page or a Windows application to connect to and perform geocoding requests to the web service. An example Windows Console program is shown below. All the program does is to submit the address string: "1818 Lake Avenue, Knoxville, 37916" to the web service and prints out the results of the geocoding matches from the web service. 


The c# code snippet for this simple example is shown below.

//Get a pointer to the geocoding web service
localhost.WSILocationUtility theWebSvc = new localhost.WSILocationUtility();
theWebSvc.Url = "http://localhost/locationutilityservice/locate.asmx";

//Get information about the address geocoding datasets. 
//There are 2 sets in the sample dataset.
localhost.LocationUtilityDatasetInfo[] dsInfo = theWebSvc.GetAllDatasetInfo();

//Form the street address to submit to the geocoding web service
localhost.StreetAddress streetAddr = new localhost.StreetAddress();
streetAddr.Street = "1818 Lake Avenue";
streetAddr.Municipality = "Knoxville";
streetAddr.PostalCode = "37916";

//Just print out some informative messages
Console.WriteLine ("Street to geocode is '" + streetAddr.Street + "'");
Console.WriteLine("Municipality to geocode is '" + streetAddr.Municipality + "'");
Console.WriteLine("Postal code to geocode is '" + streetAddr.PostalCode + "'");

//Add the street address to an array of addresses. 
//We can submit more than one address to the web service. 
localhost.Address[] addresses;
addresses = new localhost.Address[1];
addresses[0] = streetAddr;

//Set the parameters to control the geocoding matching
localhost.GeocodeSpec spec = new localhost.GeocodeSpec();
// We want to query the 2nd dataset which is TN or Tennessee";
spec.DatasetName = dsInfo[1].Name; 
spec.MaxResultCount = 5;
spec.MinimumCandidateScore = 80;
spec.ReturnMatchedAddress = true;
spec.ReturnPointGeometry = true;            

localhost.GeocodeResult[] geocodeResults;

try
{
//Submit the addresses to the geocoding web service
   geocodeResults = theWebSvc.Geocode(spec, addresses);
   Console.WriteLine("Found " + geocodeResults.Length.ToString() + " match(es).");
//If there are any matches...
   if (geocodeResults.Length > 0)
   {
      for (int i = 0; i < geocodeResults.Length; i++)
      {
         localhost.GeocodeResult result = geocodeResults[i];
         localhost.GeocodedAddress[] resultAddrs = result.GeocodedAddresses;

//For each geocoded result...
         for (int j = 0; j < resultAddrs.Length; j++)
         {
            localhost.GeocodedAddress resultAddr = resultAddrs[j];
            localhost.Address matchAddr = resultAddr.MatchedAddress;
            localhost.StreetAddress matchStAddr = (localhost.StreetAddress) matchAddr;                    
            localhost.Address standardAddr = resultAddr.StandardizedAddress;

//Get the geocoded point location
            localhost.PointPropertyType pntPropTyp = resultAddr.PointGeometry;
            string matchStats = resultAddr.MatchStatus;
            Console.WriteLine("Matching status message is '" + matchStats + "'");
            Console.WriteLine("Matched street address is '" + matchStAddr.Street + "'");
            Console.WriteLine("Geocoded point location is " + pntPropTyp.Point.coordinates.Value);
         }
      }
   }
}
catch (Exception ex)
   {
       Console.WriteLine(ex.Message);
       Console.WriteLine(ex.StackTrace);
   }

2 comments:

Unknown said...

Hi!
I am new to the GIS space. My company has a Geomedia professional license. We are trying to learn the tool.

Would you kindly guide me in the following:
When I enter my GPS data in the format 21° 40' 37.49740" N 81° 34' 03.29602" E in my warehouse and try to geocode my data, it says
"Coordinate parsing error: Invalid character string. Characters must be numeric and express a value in the indicated unit. Please correct your input."

I am just not able to fix it.
Any guidance is welcome.

Thank you,
Vaibhav Jain

jain.vai@gmail.com
vaibhav.jain@ustl.co.in

dominoc925 said...

Hi Jain
I presume you are trying to key in coordinates in the Precision Coordinates entry field? If you are, then choose the entry format on the left combo box e.g. Lon,Lat(d:m:s). Then on the right side, type in 21:40:37.49740,81:34:03.29602.
HTH