Hi, i have problem setting the curbapproach for some points while loading them with loadlocations in C#.
The code runs unter ArcGIS Desktop und Engine 10.2.1.
We want to calculate routes with curbapproach right for main roads and right/left for side roads.
In my sample i just wanted to test all my points mit curbaprroach right, i couldn't find sample code except for old c++ code i couldnt get through. i tried the set_DefaultValue("CurbApproach", "?") with 1 and "Right side of vehicle".
The result is always that the my assigned curbapproach ist not inherited.
public int LoadNALocations(ICursor inputPointFeatureCursor, INAContext naContext, string naClassName, string KeyfeldLayer)
{
if(inputPointFeatureCursor == null)
{
return 0;
}
INAClassLoader2 naClassLoader = new NAClassLoaderClass() as INAClassLoader2;
var listOfAgents = new List<ESRI.ArcGIS.NetworkAnalyst.INALocatorAgent>();
naClassLoader.Initialize(naContext, naClassName, inputPointFeatureCursor);
int rowsIn = 0;
int rowsOut = 0;
naClassLoader.FieldMap.set_MappedField("Name", "Stuetzpunkte.ID");
naClassLoader.FieldMap.set_DefaultValue("CurbApproach", "Right side of vehicle");
int agentCount = naContext.Locator.LocatorAgentCount;
for (int locIndex = 0; locIndex < agentCount; locIndex++)
{
listOfAgents.Add(naContext.Locator.get_LocatorAgent(locIndex));
}
// Remove the existing locator agents from the locator. This for loop is done in reverse order, because agents are being removed as the loop executes
for (int locIndex = agentCount - 1; locIndex >= 0; locIndex--)
{
naContext.Locator.RemoveLocatorAgent(locIndex);
}
INALocatorLocationFieldsAgent naLocFAgent = new NALocatorLocationFieldsAgentClass();
naLocFAgent.OIDFieldName = "Stuetzpunkte.SOURCEOID";
naLocFAgent.SourceIDFieldName = "Stuetzpunkte.SOURCEID";
naLocFAgent.PositionFieldName = "Stuetzpunkte.POSALONG";
naLocFAgent.SideFieldName = "Stuetzpunkte.SIDEOFEDGE";
((INALocatorAgent)naLocFAgent).Bind(naContext.NetworkDataset, null);
naContext.Locator.AddLocatorAgent(naLocFAgent as INALocatorAgent);
try
{
naClassLoader.Load(inputPointFeatureCursor, null, ref rowsIn, ref rowsOut);
}
catch(Exception ex)
{
Prot.Meldung("Beim Laden der Stützpunkte ist ein Fehler aufgetreten:\n" + ex.ToString(), true);
return 0;
}
((INAContextEdit)naContext).ContextChanged();
if (naContext.Locator.LocatorAgentCount == 1)
{
// Now remove the custom fields agent and add back the stored agents
naContext.Locator.RemoveLocatorAgent(0);
foreach (var agent in listOfAgents)
{
naContext.Locator.AddLocatorAgent(agent);
}
}
return rowsOut;
}