This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > NetworkAnalysis > ESRI.ArcGIS.NetworkAnalysis > Interfaces > IP > IPointToEID Interface (ArcObjects .NET 10.5 SDK) |
Provides access to members that find the nearest network element to a given point.
Use the methods on IPointToEID to find the nearest network element to a given point in the map.
Description | ||
---|---|---|
GeometricNetwork | Source geometric network from which the result EID will come. | |
GetNearestEdge | Returns the edge EID nearest to the input point, the physical point location that corresponds to the EID, and the percentage along that EID. | |
GetNearestJunction | Returns the junction EID nearest to the input point, and the physical point location that corresponds to the EID. | |
SnapTolerance | Maximum distance from the input point to an acceptable EID. | |
SourceMap | Source map in which to search for the nearest EID. |
CoClasses and Classes | Description |
---|---|
PointToEID | A container for finding the nearest network element ID to a given point. |
The following code can be used to place a junction flag on the nearest junction feature to the given (x,y) map coordinate. It assumes you have a reference to the source map in the map variable, a reference to the Network Analysis Extension in the networkAnalysisExt variable, and the flag symbol in the symbol variable.
// convert the (x,y) map coordinate to a new Point object
IPoint point=new PointClass() as IPoint;
point.X=x;
point.Y=y;
// find the nearest junction element to this Point
int EID;
IPoint outPoint;
IPointToEID pointToEID=new PointToEIDClass() as IPointToEID;
pointToEID.GeometricNetwork=networkAnalysisExt.CurrentNetwork;
pointToEID.SourceMap=map;
pointToEID.SnapTolerance=10; // set a snap tolerance of 10 map units
pointToEID.GetNearestJunction(point, out EID, out outPoint);
// convert the EID to a feature class ID, feature ID, and sub ID
INetElements netElements=networkAnalysisExt.CurrentNetwork.Network as INetElements;
int FCID, FID, subID;
netElements.QueryIDs(EID, esriETJunction, out FCID, out FID, out subID);
// create a new JunctionFlagDisplay object and populate it
IJunctionFlagDisplay junctionFlagDisplay=new JunctionFlagDisplayClass() as IJunctionFlagDisplay;
IFlagDisplay flagDisplay=junctionFlagDisplay as IFlagDisplay;
flagDisplay.FeatureClassID=FCID;
flagDisplay.FID=FID;
flagDisplay.SubID=subID;
flagDisplay.Geometry=outPoint as IGeometry;
flagDisplay.Symbol=symbol as ISymbol;
// add the JunctionFlagDisplay object to the Network Analysis extension
INetworkAnalysisExtFlags networkAnalysisExtFlags=networkAnalysisExt as INetworkAnalysisExtFlags;
networkAnalysisExtFlags.AddJunctionFlag(junctionFlagDisplay);
The following code can be used to place a junction flag on the nearest junction feature to the given (x,y) map coordinate. It assumes you have a reference to the source map in the map variable, a reference to the Network Analysis Extension in the networkAnalysisExt variable, and the flag symbol in the symbol variable.
' convert the (x,y) map coordinate to a new Point object
Dim point As IPoint=New Point
point.X=x
point.Y=y
' find the nearest junction element to this Point
Dim EID As Integer
Dim outPoint As IPoint
Dim pointToEID As IPointToEID=New PointToEID
With pointToEID
.GeometricNetwork=networkAnalysisExt.CurrentNetwork
.SourceMap=map
.SnapTolerance=10 ' set a snap tolerance of 10 map units
.GetNearestJunction(point, EID, outPoint)
End With
' convert the EID to a feature class ID, feature ID, and sub ID
Dim netElements As INetElements=CType(networkAnalysisExt.CurrentNetwork.Network, INetElements)
Dim FCID As Integer, FID As Integer, subID As Integer
netElements.QueryIDs(EID, esriETJunction, FCID, FID, subID)
' create a new JunctionFlagDisplay object and populate it
Dim junctionFlagDisplay As IJunctionFlagDisplay=New JunctionFlagDisplay
Dim flagDisplay As IFlagDisplay=CType(junctionFlagDisplay, IFlagDisplay)
With flagDisplay
.FeatureClassID=FCID
.FID=FID
.SubID=subID
.Geometry=CType(outPoint, IGeometry)
.Symbol=CType(symbol, ISymbol)
End With
' add the JunctionFlagDisplay object to the Network Analysis extension
Dim networkAnalysisExtFlags As INetworkAnalysisExtFlags=CType(networkAnalysisExt, INetworkAnalysisExtFlags)
networkAnalysisExtFlags.AddJunctionFlag(junctionFlagDisplay)