Creates a new NALayer from a network analysis layer in the map with the specified name.
[Visual Basic .NET]
Public Function CreateNALayer ( _
ByVal MapServer As IMapServer, _
ByVal MapName As String, _
ByVal NALayerName As String _
) As INALayer
[C#]
public INALayer CreateNALayer (
IMapServer MapServer,
string MapName,
string NALayerName
);
[C++]
HRESULT CreateNALayer(
IMapServer* MapServer,
BSTR MapName,
BSTR NALayerName
);
[C++]
Parameters
MapServer [in]
MapServer is a parameter of type IMapServer*
MapName [in]
MapName is a parameter of type BSTR
NALayerName [in]
NALayerName is a parameter of type BSTR
Product Availability
Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.
Remarks
Call
CreateNALayer to create a new
NALayer based on a network analysis layer that was published in your map document. You can store a reference to this layer within your server object extension and use it to get the
NAContext and from there things like the
NAClasses,
NetworkDataset,
Solver, etc. You can also use the
NALayer to call
INALayer2::CopyContext and optionally
INALayer::AttachContext to manage the state of an
NAContext between requests.
[C#]
private IServerObjectHelper serverObjectHelper;
private INALayer2 naLayer;
public void Init(IServerObjectHelper pSOH)
{
serverObjectHelper = pSOH;
}
public void Construct(IPropertySet props)
{
// In Construct of the SOE, get a reference to the NALayer in the Map named "MyRouteLayer"
IMapServer ms = (IMapServer)this.serverObjectHelper.ServerObject;
INASOEHelper naSOEHelper = new NASOEHelperClass();
naLayer = (INALayer2)naSOEHelper.CreateNALayer(this.ms, ms.DefaultMapName, "MyRouteLayer");
}
private byte[] MySOEOperationHandler(
NameValueCollection boundVariables,
JsonObject operationInput,
string outputFormat,
string requestProperties,
out string responseProperties)
{
// In the operation, make use of the NALayer to either just get the NAContext
// or create a new NAContext that you can populate, solve, and then throw away
// to keep the state of the original NAContext pristine.
// Do this to use the existing NAContext (Make sure to reset it's state after use)
INAContext naContext = naLayer.Context;
// Do this to create a new NAContext so the state of the original NAContext doesn't get modified
INAContext naContext = naLayer.CopyContext();
PopulateStuffOnTheNAContext(naContext);
return SolveAndReturnResults(naContext);
}
See Also
INASOEHelper Interface