Hello, I'm having trouble with the new standardizer. The following code produces an exception on the second call to ParseAddressSample(). Any ideas ?
using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Location;
namespace PopulateRC
{
class Program
{
private static IWorkspace pwps = null;
private static AoInitialize _arcObjects = null;
[STAThread]
static void Main(string[] args)
{
IWorkspaceFactory workspaceFactory = null;
//ArcGIS10
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Engine);
workspaceFactory = new FileGDBWorkspaceFactoryClass();
//Path of file GDB. Change it if necessary
string connstr = @"C:\GisData\PowerMap.gdb";
ArcObjectsStart();
pwps = workspaceFactory.OpenFromFile(connstr, 0);
if (pwps != null)
{
//First, a classic case. This one works!
ParseAddressSample("10 main st");
//Exception thrown with this string
ParseAddressSample("main st");
}
Console.WriteLine("Press any key to finish");
Console.ReadLine();
}
private static void ParseAddressSample(string freeFormat)
{
LocatorManagerClass locatorManager = new LocatorManagerClass();
ILocatorWorkspace locatorWorkspace = (ILocatorWorkspace)locatorManager.GetLocatorWorkspace(pwps);
ILocator locator = locatorWorkspace.GetLocator("StreetSegment");
if (locator != null)
{
// Get the Locator and QI to ISimpleStandardization
ISimpleStandardization standardizer = (ISimpleStandardization)locator;
try
{
// Get the Standardization fields from the locator
// exception on the 2nd call "Specified cast is not valid."
IPropertySet standardizedAddressSet = standardizer.SimpleStandardizeAddress(freeFormat);
}
catch (Exception ex)
{
Console.WriteLine("Problem parsing (" + freeFormat + ") " + ex.Message);
}
}
}
#region "ESRi licencing"
#endregion
}
}
... View more