ArcGIS网络分析最短路径分析源代码(VB6.0)

  1ArcGIS网络分析最短路径分析源代码(VB6.0)
  2ArcGIS网络分析最短路径分析源代码(VB6.0)' Copyright 1995-2005 ESRI
  3ArcGIS网络分析最短路径分析源代码(VB6.0)
  4ArcGIS网络分析最短路径分析源代码(VB6.0)' All rights reserved under the copyright laws of the United States.
  5ArcGIS网络分析最短路径分析源代码(VB6.0)
  6ArcGIS网络分析最短路径分析源代码(VB6.0)' You may freely redistribute and use this sample code, with or without modification.
  7ArcGIS网络分析最短路径分析源代码(VB6.0)
  8ArcGIS网络分析最短路径分析源代码(VB6.0)' Disclaimer: THE SAMPLE CODE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  9ArcGIS网络分析最短路径分析源代码(VB6.0)' WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 10ArcGIS网络分析最短路径分析源代码(VB6.0)' FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESRI OR
 11ArcGIS网络分析最短路径分析源代码(VB6.0)' CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 12ArcGIS网络分析最短路径分析源代码(VB6.0)' OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 13ArcGIS网络分析最短路径分析源代码(VB6.0)' SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 14ArcGIS网络分析最短路径分析源代码(VB6.0)' INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY
 15ArcGIS网络分析最短路径分析源代码(VB6.0)' THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ARISING IN ANY
 16ArcGIS网络分析最短路径分析源代码(VB6.0)' WAY OUT OF THE USE OF THIS SAMPLE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF
 17ArcGIS网络分析最短路径分析源代码(VB6.0)' SUCH DAMAGE.
 18ArcGIS网络分析最短路径分析源代码(VB6.0)
 19ArcGIS网络分析最短路径分析源代码(VB6.0)' For additional information contact: Environmental Systems Research Institute, Inc.
 20ArcGIS网络分析最短路径分析源代码(VB6.0)
 21ArcGIS网络分析最短路径分析源代码(VB6.0)' Attn: Contracts Dept.
 22ArcGIS网络分析最短路径分析源代码(VB6.0)
 23ArcGIS网络分析最短路径分析源代码(VB6.0)' 380 New York Street
 24ArcGIS网络分析最短路径分析源代码(VB6.0)
 25ArcGIS网络分析最短路径分析源代码(VB6.0)' Redlands, California, U.S.A. 92373
 26ArcGIS网络分析最短路径分析源代码(VB6.0)
 27ArcGIS网络分析最短路径分析源代码(VB6.0)' Email: contracts@esri.com
 28ArcGIS网络分析最短路径分析源代码(VB6.0)
 29ArcGIS网络分析最短路径分析源代码(VB6.0)Option Explicit
 30ArcGIS网络分析最短路径分析源代码(VB6.0)
 31ArcGIS网络分析最短路径分析源代码(VB6.0)' vb version of the PathFinder object
 32ArcGIS网络分析最短路径分析源代码(VB6.0)
 33ArcGIS网络分析最短路径分析源代码(VB6.0)' 本地变量
 34ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipGeometricNetwork As esriGeoDatabase.IGeometricNetwork
 35ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipMap As esriCarto.IMap
 36ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipPoints As esriGeometry.IPointCollection
 37ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipPointToEID As esriNetworkAnalysis.IPointToEID
 38ArcGIS网络分析最短路径分析源代码(VB6.0)' 返回结果变量 
 39ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_dblPathCost As Double
 40ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipEnumNetEID_Junctions As esriGeoDatabase.IEnumNetEID
 41ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipEnumNetEID_Edges As esriGeoDatabase.IEnumNetEID
 42ArcGIS网络分析最短路径分析源代码(VB6.0)Private m_ipPolyline As esriGeometry.IPolyline
 43ArcGIS网络分析最短路径分析源代码(VB6.0)
 44ArcGIS网络分析最短路径分析源代码(VB6.0)
 45ArcGIS网络分析最短路径分析源代码(VB6.0)' Optionally set the Map (e.g. the current map in ArcMap),
 46ArcGIS网络分析最短路径分析源代码(VB6.0)' otherwise a default map will be made (for IPointToEID).
 47ArcGIS网络分析最短路径分析源代码(VB6.0)
 48ArcGIS网络分析最短路径分析源代码(VB6.0)Public Property Set Map(Map As esriCarto.IMap)
 49ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipMap = Map
 50ArcGIS网络分析最短路径分析源代码(VB6.0)End Property
 51ArcGIS网络分析最短路径分析源代码(VB6.0)
 52ArcGIS网络分析最短路径分析源代码(VB6.0)Public Property Get Map() As esriCarto.IMap
 53ArcGIS网络分析最短路径分析源代码(VB6.0)  Set Map = m_ipMap
 54ArcGIS网络分析最短路径分析源代码(VB6.0)End Property
 55ArcGIS网络分析最短路径分析源代码(VB6.0)
 56ArcGIS网络分析最短路径分析源代码(VB6.0)' Either OpenAccessNetwork or OpenFeatureDatasetNetwork
 57ArcGIS网络分析最短路径分析源代码(VB6.0)' needs to be called.
 58ArcGIS网络分析最短路径分析源代码(VB6.0)
 59ArcGIS网络分析最短路径分析源代码(VB6.0)Public Sub OpenAccessNetwork(AccessFileName As String, FeatureDatasetName As String)
 60ArcGIS网络分析最短路径分析源代码(VB6.0)  
 61ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipWorkspaceFactory As esriGeoDatabase.IWorkspaceFactory
 62ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipWorkspace As esriGeoDatabase.IWorkspace
 63ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipFeatureWorkspace As esriGeoDatabase.IFeatureWorkspace
 64ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipFeatureDataset As esriGeoDatabase.IFeatureDataset
 65ArcGIS网络分析最短路径分析源代码(VB6.0)
 66ArcGIS网络分析最短路径分析源代码(VB6.0)  ' After this Sub exits, we'll have an INetwork interface
 67ArcGIS网络分析最短路径分析源代码(VB6.0)  ' and an IMap interface initialized for the network we'll be using.
 68ArcGIS网络分析最短路径分析源代码(VB6.0)
 69ArcGIS网络分析最短路径分析源代码(VB6.0)  ' close down the last one if opened
 70ArcGIS网络分析最短路径分析源代码(VB6.0)  CloseWorkspace
 71ArcGIS网络分析最短路径分析源代码(VB6.0)
 72ArcGIS网络分析最短路径分析源代码(VB6.0)  ' open the mdb
 73ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipWorkspaceFactory = New esriDataSourcesGDB.AccessWorkspaceFactory
 74ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipWorkspace = ipWorkspaceFactory.OpenFromFile(AccessFileName, 0)
 75ArcGIS网络分析最短路径分析源代码(VB6.0)
 76ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the FeatureWorkspace
 77ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipFeatureWorkspace = ipWorkspace
 78ArcGIS网络分析最短路径分析源代码(VB6.0)  
 79ArcGIS网络分析最短路径分析源代码(VB6.0)  ' open the FeatureDataset
 80ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipFeatureDataset = ipFeatureWorkspace.OpenFeatureDataset(FeatureDatasetName)
 81ArcGIS网络分析最短路径分析源代码(VB6.0)
 82ArcGIS网络分析最短路径分析源代码(VB6.0)  ' initialize Network and Map (m_ipNetwork, m_ipMap)
 83ArcGIS网络分析最短路径分析源代码(VB6.0)  If Not InitializeNetworkAndMap(ipFeatureDataset) Then Err.Raise 0"OpenAccessNetwork""Error initializing Network and Map"
 84ArcGIS网络分析最短路径分析源代码(VB6.0)
 85ArcGIS网络分析最短路径分析源代码(VB6.0)End Sub
 86ArcGIS网络分析最短路径分析源代码(VB6.0)
 87ArcGIS网络分析最短路径分析源代码(VB6.0)Public Sub OpenFeatureDatasetNetwork(FeatureDataset As esriGeoDatabase.IFeatureDataset)
 88ArcGIS网络分析最短路径分析源代码(VB6.0)  ' close down the last one if opened
 89ArcGIS网络分析最短路径分析源代码(VB6.0)  CloseWorkspace
 90ArcGIS网络分析最短路径分析源代码(VB6.0)   
 91ArcGIS网络分析最短路径分析源代码(VB6.0)  ' we assume that the caller has passed a valid FeatureDataset
 92ArcGIS网络分析最短路径分析源代码(VB6.0)
 93ArcGIS网络分析最短路径分析源代码(VB6.0)  ' initialize Network and Map (m_ipNetwork, m_ipMap)
 94ArcGIS网络分析最短路径分析源代码(VB6.0)  If Not InitializeNetworkAndMap(FeatureDataset) Then Err.Raise 0"OpenFeatureDatasetNetwork""Error initializing Network and Map"
 95ArcGIS网络分析最短路径分析源代码(VB6.0)
 96ArcGIS网络分析最短路径分析源代码(VB6.0)End Sub
 97ArcGIS网络分析最短路径分析源代码(VB6.0)
 98ArcGIS网络分析最短路径分析源代码(VB6.0)' The collection of points to travel through must be set.
 99ArcGIS网络分析最短路径分析源代码(VB6.0)
100ArcGIS网络分析最短路径分析源代码(VB6.0)Public Property Set StopPoints(Points As esriGeometry.IPointCollection)
101ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPoints = Points
102ArcGIS网络分析最短路径分析源代码(VB6.0)End Property
103ArcGIS网络分析最短路径分析源代码(VB6.0)
104ArcGIS网络分析最短路径分析源代码(VB6.0)Public Property Get StopPoints() As esriGeometry.IPointCollection
105ArcGIS网络分析最短路径分析源代码(VB6.0)  Set StopPoints = m_ipPoints
106ArcGIS网络分析最短路径分析源代码(VB6.0)End Property
107ArcGIS网络分析最短路径分析源代码(VB6.0)
108ArcGIS网络分析最短路径分析源代码(VB6.0)' Calculate the path
109ArcGIS网络分析最短路径分析源代码(VB6.0)
110ArcGIS网络分析最短路径分析源代码(VB6.0)Public Sub SolvePath(WeightName As String)
111ArcGIS网络分析最短路径分析源代码(VB6.0)  
112ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetwork As esriGeoDatabase.INetwork
113ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipTraceFlowSolver As esriNetworkAnalysis.ITraceFlowSolver
114ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetSolver As esriNetworkAnalysis.INetSolver
115ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetFlag As esriNetworkAnalysis.INetFlag
116ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipaNetFlag() As esriNetworkAnalysis.IEdgeFlag
117ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipEdgePoint As esriGeometry.IPoint
118ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetElements As esriGeoDatabase.INetElements
119ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim intEdgeUserClassID As Long
120ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim intEdgeUserID As Long
121ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim intEdgeUserSubID As Long
122ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim intEdgeID As Long
123ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipFoundEdgePoint As esriGeometry.IPoint
124ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim dblEdgePercent As Double
125ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetWeight As esriGeoDatabase.INetWeight
126ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetSolverWeights As esriNetworkAnalysis.INetSolverWeights
127ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetSchema As esriGeoDatabase.INetSchema
128ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim intCount As Long
129ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim i As Long
130ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim vaRes() As Variant
131ArcGIS网络分析最短路径分析源代码(VB6.0)
132ArcGIS网络分析最短路径分析源代码(VB6.0)  ' make sure we are ready
133ArcGIS网络分析最短路径分析源代码(VB6.0)  Debug.Assert Not m_ipPoints Is Nothing
134ArcGIS网络分析最短路径分析源代码(VB6.0)  Debug.Assert Not m_ipGeometricNetwork Is Nothing
135ArcGIS网络分析最短路径分析源代码(VB6.0)
136ArcGIS网络分析最短路径分析源代码(VB6.0)  ' instantiate a trace flow solver
137ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipTraceFlowSolver = New esriNetworkAnalysis.TraceFlowSolver
138ArcGIS网络分析最短路径分析源代码(VB6.0)
139ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the INetSolver interface
140ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetSolver = ipTraceFlowSolver
141ArcGIS网络分析最短路径分析源代码(VB6.0)
142ArcGIS网络分析最短路径分析源代码(VB6.0)  ' set the source network to solve on
143ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetwork = m_ipGeometricNetwork.Network
144ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetSolver.SourceNetwork = ipNetwork
145ArcGIS网络分析最短路径分析源代码(VB6.0)
146ArcGIS网络分析最短路径分析源代码(VB6.0)  ' make edge flags from the points
147ArcGIS网络分析最短路径分析源代码(VB6.0)
148ArcGIS网络分析最短路径分析源代码(VB6.0)  ' the INetElements interface is needed to get UserID, UserClassID,
149ArcGIS网络分析最短路径分析源代码(VB6.0)  ' and UserSubID from an element id
150ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetElements = ipNetwork
151ArcGIS网络分析最短路径分析源代码(VB6.0)
152ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the count
153ArcGIS网络分析最短路径分析源代码(VB6.0)  intCount = m_ipPoints.PointCount
154ArcGIS网络分析最短路径分析源代码(VB6.0)  Debug.Assert intCount > 1
155ArcGIS网络分析最短路径分析源代码(VB6.0)
156ArcGIS网络分析最短路径分析源代码(VB6.0)  ' dimension our IEdgeFlag array
157ArcGIS网络分析最短路径分析源代码(VB6.0)  ReDim ipaNetFlag(intCount)
158ArcGIS网络分析最短路径分析源代码(VB6.0)  
159ArcGIS网络分析最短路径分析源代码(VB6.0)  For i = 0 To intCount - 1
160ArcGIS网络分析最短路径分析源代码(VB6.0)    ' make a new Edge Flag
161ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipNetFlag = New esriNetworkAnalysis.EdgeFlag
162ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipEdgePoint = m_ipPoints.Point(i)
163ArcGIS网络分析最短路径分析源代码(VB6.0)    ' look up the EID for the current point  (this will populate intEdgeID and dblEdgePercent)
164ArcGIS网络分析最短路径分析源代码(VB6.0)    m_ipPointToEID.GetNearestEdge ipEdgePoint, intEdgeID, ipFoundEdgePoint, dblEdgePercent
165ArcGIS网络分析最短路径分析源代码(VB6.0)    Debug.Assert intEdgeID > 0   ' else Point (eid) not found
166ArcGIS网络分析最短路径分析源代码(VB6.0)    ipNetElements.QueryIDs intEdgeID, esriETEdge, intEdgeUserClassID, intEdgeUserID, intEdgeUserSubID
167ArcGIS网络分析最短路径分析源代码(VB6.0)    Debug.Assert (intEdgeUserClassID > 0And (intEdgeUserID > 0)  ' else Point not found
168ArcGIS网络分析最短路径分析源代码(VB6.0)    ipNetFlag.UserClassID = intEdgeUserClassID
169ArcGIS网络分析最短路径分析源代码(VB6.0)    ipNetFlag.UserID = intEdgeUserID
170ArcGIS网络分析最短路径分析源代码(VB6.0)    ipNetFlag.UserSubID = intEdgeUserSubID
171ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipaNetFlag(i) = ipNetFlag
172ArcGIS网络分析最短路径分析源代码(VB6.0)  Next
173ArcGIS网络分析最短路径分析源代码(VB6.0)
174ArcGIS网络分析最短路径分析源代码(VB6.0)  ' add these edge flags
175ArcGIS网络分析最短路径分析源代码(VB6.0)  ipTraceFlowSolver.PutEdgeOrigins intCount, ipaNetFlag(0)
176ArcGIS网络分析最短路径分析源代码(VB6.0)
177ArcGIS网络分析最短路径分析源代码(VB6.0)  ' set the weight (cost field) to solve on
178ArcGIS网络分析最短路径分析源代码(VB6.0)
179ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the INetSchema interface
180ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetSchema = ipNetwork
181ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetWeight = ipNetSchema.WeightByName(WeightName)
182ArcGIS网络分析最短路径分析源代码(VB6.0)  Debug.Assert Not ipNetWeight Is Nothing
183ArcGIS网络分析最短路径分析源代码(VB6.0)
184ArcGIS网络分析最短路径分析源代码(VB6.0)  ' set the weight (use the same for both directions)
185ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetSolverWeights = ipTraceFlowSolver
186ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetSolverWeights.FromToEdgeWeight = ipNetWeight
187ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetSolverWeights.ToFromEdgeWeight = ipNetWeight
188ArcGIS网络分析最短路径分析源代码(VB6.0)
189ArcGIS网络分析最短路径分析源代码(VB6.0)  ' initialize array for results to number of segments in result
190ArcGIS网络分析最短路径分析源代码(VB6.0)  ReDim vaRes(intCount - 1)
191ArcGIS网络分析最短路径分析源代码(VB6.0)
192ArcGIS网络分析最短路径分析源代码(VB6.0)  ' solve it
193ArcGIS网络分析最短路径分析源代码(VB6.0)  ipTraceFlowSolver.FindPath esriFMConnected, esriSPObjFnMinSum, m_ipEnumNetEID_Junctions, m_ipEnumNetEID_Edges, intCount - 1, vaRes(0)
194ArcGIS网络分析最短路径分析源代码(VB6.0)
195ArcGIS网络分析最短路径分析源代码(VB6.0)  ' compute total cost
196ArcGIS网络分析最短路径分析源代码(VB6.0)  m_dblPathCost = 0
197ArcGIS网络分析最短路径分析源代码(VB6.0)  For i = LBound(vaRes) To UBound(vaRes)
198ArcGIS网络分析最短路径分析源代码(VB6.0)    m_dblPathCost = m_dblPathCost + vaRes(i)
199ArcGIS网络分析最短路径分析源代码(VB6.0)  Next
200ArcGIS网络分析最短路径分析源代码(VB6.0)
201ArcGIS网络分析最短路径分析源代码(VB6.0)  ' clear the last polyline result
202ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPolyline = Nothing
203ArcGIS网络分析最短路径分析源代码(VB6.0)  
204ArcGIS网络分析最短路径分析源代码(VB6.0)End Sub
205ArcGIS网络分析最短路径分析源代码(VB6.0)
206ArcGIS网络分析最短路径分析源代码(VB6.0)' Property to get the cost
207ArcGIS网络分析最短路径分析源代码(VB6.0)
208ArcGIS网络分析最短路径分析源代码(VB6.0)Public Property Get PathCost() As Double
209ArcGIS网络分析最短路径分析源代码(VB6.0)  PathCost = m_dblPathCost
210ArcGIS网络分析最短路径分析源代码(VB6.0)End Property
211ArcGIS网络分析最短路径分析源代码(VB6.0)
212ArcGIS网络分析最短路径分析源代码(VB6.0)' Property to get the shape
213ArcGIS网络分析最短路径分析源代码(VB6.0)
214ArcGIS网络分析最短路径分析源代码(VB6.0)Public Property Get PathPolyLine() As esriGeometry.IPolyline
215ArcGIS网络分析最短路径分析源代码(VB6.0)
216ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipEIDHelper As esriNetworkAnalysis.IEIDHelper
217ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim count As Long, i As Long
218ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipEIDInfo As esriNetworkAnalysis.IEIDInfo
219ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipEnumEIDInfo As esriNetworkAnalysis.IEnumEIDInfo
220ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipGeometry As esriGeometry.IGeometry
221ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNewGeometryColl As esriGeometry.IGeometryCollection
222ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipSpatialReference As esriGeometry.ISpatialReference
223ArcGIS网络分析最短路径分析源代码(VB6.0)
224ArcGIS网络分析最短路径分析源代码(VB6.0)  ' if the line is already computed since the last path, just return it
225ArcGIS网络分析最短路径分析源代码(VB6.0)  If Not m_ipPolyline Is Nothing Then
226ArcGIS网络分析最短路径分析源代码(VB6.0)    Set PathPolyLine = m_ipPolyline
227ArcGIS网络分析最短路径分析源代码(VB6.0)    Exit Property
228ArcGIS网络分析最短路径分析源代码(VB6.0)  End If
229ArcGIS网络分析最短路径分析源代码(VB6.0)
230ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPolyline = New esriGeometry.Polyline
231ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNewGeometryColl = m_ipPolyline
232ArcGIS网络分析最短路径分析源代码(VB6.0)
233ArcGIS网络分析最短路径分析源代码(VB6.0)  ' a path should be solved first
234ArcGIS网络分析最短路径分析源代码(VB6.0)  Debug.Assert Not m_ipEnumNetEID_Edges Is Nothing
235ArcGIS网络分析最短路径分析源代码(VB6.0)
236ArcGIS网络分析最短路径分析源代码(VB6.0)  ' make an EIDHelper object to translate edges to geometric features
237ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipEIDHelper = New esriNetworkAnalysis.EIDHelper
238ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork
239ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipSpatialReference = m_ipMap.SpatialReference
240ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipEIDHelper.OutputSpatialReference = ipSpatialReference
241ArcGIS网络分析最短路径分析源代码(VB6.0)  ipEIDHelper.ReturnGeometries = True
242ArcGIS网络分析最短路径分析源代码(VB6.0)
243ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the details using the  IEIDHelper classes
244ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_ipEnumNetEID_Edges)
245ArcGIS网络分析最短路径分析源代码(VB6.0)  count = ipEnumEIDInfo.count
246ArcGIS网络分析最短路径分析源代码(VB6.0)
247ArcGIS网络分析最短路径分析源代码(VB6.0)  ' set the iterator to beginning
248ArcGIS网络分析最短路径分析源代码(VB6.0)  ipEnumEIDInfo.Reset
249ArcGIS网络分析最短路径分析源代码(VB6.0)
250ArcGIS网络分析最短路径分析源代码(VB6.0)  For i = 1 To count
251ArcGIS网络分析最短路径分析源代码(VB6.0)      
252ArcGIS网络分析最短路径分析源代码(VB6.0)    ' get the next EID and a copy of its geometry (it makes a Clone)
253ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipEIDInfo = ipEnumEIDInfo.Next
254ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipGeometry = ipEIDInfo.Geometry
255ArcGIS网络分析最短路径分析源代码(VB6.0)
256ArcGIS网络分析最短路径分析源代码(VB6.0)    ipNewGeometryColl.AddGeometryCollection ipGeometry
257ArcGIS网络分析最短路径分析源代码(VB6.0)
258ArcGIS网络分析最短路径分析源代码(VB6.0)  Next  ' EID
259ArcGIS网络分析最短路径分析源代码(VB6.0)
260ArcGIS网络分析最短路径分析源代码(VB6.0)  ' return the merged geometry as a Polyline
261ArcGIS网络分析最短路径分析源代码(VB6.0)  Set PathPolyLine = m_ipPolyline
262ArcGIS网络分析最短路径分析源代码(VB6.0)  
263ArcGIS网络分析最短路径分析源代码(VB6.0)End Property
264ArcGIS网络分析最短路径分析源代码(VB6.0)
265ArcGIS网络分析最短路径分析源代码(VB6.0)' Private
266ArcGIS网络分析最短路径分析源代码(VB6.0)
267ArcGIS网络分析最短路径分析源代码(VB6.0)Private Sub CloseWorkspace()
268ArcGIS网络分析最短路径分析源代码(VB6.0)  ' make sure we let go of everything and start with new results
269ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipGeometricNetwork = Nothing
270ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPoints = Nothing
271ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPointToEID = Nothing
272ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipEnumNetEID_Junctions = Nothing
273ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipEnumNetEID_Edges = Nothing
274ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPolyline = Nothing
275ArcGIS网络分析最短路径分析源代码(VB6.0)End Sub
276ArcGIS网络分析最短路径分析源代码(VB6.0)
277ArcGIS网络分析最短路径分析源代码(VB6.0)Private Function InitializeNetworkAndMap(FeatureDataset As esriGeoDatabase.IFeatureDataset) As Boolean
278ArcGIS网络分析最短路径分析源代码(VB6.0)
279ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetworkCollection As esriGeoDatabase.INetworkCollection
280ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipNetwork As esriGeoDatabase.INetwork
281ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim count As Long, i As Long
282ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipFeatureClassContainer As esriGeoDatabase.IFeatureClassContainer
283ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipFeatureClass As esriGeoDatabase.IFeatureClass
284ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipGeoDataset As esriGeoDatabase.IGeoDataset
285ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipLayer As esriCarto.ILayer
286ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipFeatureLayer As esriCarto.IFeatureLayer
287ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim ipEnvelope  As esriGeometry.IEnvelope, ipMaxEnvelope As esriGeometry.IEnvelope
288ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim dblSearchTol As Double
289ArcGIS网络分析最短路径分析源代码(VB6.0)  Dim dblWidth As Double, dblHeight As Double
290ArcGIS网络分析最短路径分析源代码(VB6.0)
291ArcGIS网络分析最短路径分析源代码(VB6.0)  On Error GoTo Trouble
292ArcGIS网络分析最短路径分析源代码(VB6.0)
293ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the networks
294ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetworkCollection = FeatureDataset
295ArcGIS网络分析最短路径分析源代码(VB6.0)
296ArcGIS网络分析最短路径分析源代码(VB6.0)  ' even though a FeatureDataset can have many networks, we'll just
297ArcGIS网络分析最短路径分析源代码(VB6.0)  ' assume the first one (otherwise you would pass the network name in, etc.)
298ArcGIS网络分析最短路径分析源代码(VB6.0)
299ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the count of networks
300ArcGIS网络分析最短路径分析源代码(VB6.0)  count = ipNetworkCollection.GeometricNetworkCount
301ArcGIS网络分析最短路径分析源代码(VB6.0)
302ArcGIS网络分析最短路径分析源代码(VB6.0)  Debug.Assert count > 0  ' then Exception.Create('No networks found');
303ArcGIS网络分析最短路径分析源代码(VB6.0)
304ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the first Geometric Newtork (0 - based)
305ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipGeometricNetwork = ipNetworkCollection.GeometricNetwork(0)
306ArcGIS网络分析最短路径分析源代码(VB6.0)
307ArcGIS网络分析最短路径分析源代码(VB6.0)  ' get the Network
308ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipNetwork = m_ipGeometricNetwork.Network
309ArcGIS网络分析最短路径分析源代码(VB6.0)
310ArcGIS网络分析最短路径分析源代码(VB6.0)  ' The EID Helper class that converts points to EIDs needs a
311ArcGIS网络分析最短路径分析源代码(VB6.0)  ' IMap, so we'll need one around with all our layers added.
312ArcGIS网络分析最短路径分析源代码(VB6.0)  ' This Pathfinder object has an optional Map property than may be set
313ArcGIS网络分析最短路径分析源代码(VB6.0)  ' before opening the Network.
314ArcGIS网络分析最短路径分析源代码(VB6.0)  If m_ipMap Is Nothing Then
315ArcGIS网络分析最短路径分析源代码(VB6.0)    Set m_ipMap = New esriCarto.Map
316ArcGIS网络分析最短路径分析源代码(VB6.0)
317ArcGIS网络分析最短路径分析源代码(VB6.0)    ' Add each of the Feature Classes in this Geometric Network as a map Layer
318ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipFeatureClassContainer = m_ipGeometricNetwork
319ArcGIS网络分析最短路径分析源代码(VB6.0)    count = ipFeatureClassContainer.ClassCount
320ArcGIS网络分析最短路径分析源代码(VB6.0)    Debug.Assert count > 0   ' then Exception.Create('No (network) feature classes found');
321ArcGIS网络分析最短路径分析源代码(VB6.0)
322ArcGIS网络分析最短路径分析源代码(VB6.0)    For i = 0 To count - 1
323ArcGIS网络分析最短路径分析源代码(VB6.0)      ' get the feature class
324ArcGIS网络分析最短路径分析源代码(VB6.0)      Set ipFeatureClass = ipFeatureClassContainer.Class(i)
325ArcGIS网络分析最短路径分析源代码(VB6.0)      ' make a layer
326ArcGIS网络分析最短路径分析源代码(VB6.0)      Set ipFeatureLayer = New esriCarto.FeatureLayer
327ArcGIS网络分析最短路径分析源代码(VB6.0)      Set ipFeatureLayer.FeatureClass = ipFeatureClass
328ArcGIS网络分析最短路径分析源代码(VB6.0)      ' add layer to the map
329ArcGIS网络分析最短路径分析源代码(VB6.0)      m_ipMap.AddLayer ipFeatureLayer
330ArcGIS网络分析最短路径分析源代码(VB6.0)    Next
331ArcGIS网络分析最短路径分析源代码(VB6.0)  End If     '  we needed to make a Map
332ArcGIS网络分析最短路径分析源代码(VB6.0)
333ArcGIS网络分析最短路径分析源代码(VB6.0)
334ArcGIS网络分析最短路径分析源代码(VB6.0)  ' Calculate point snap tolerance as 1/100 of map width.
335ArcGIS网络分析最短路径分析源代码(VB6.0)  count = m_ipMap.LayerCount
336ArcGIS网络分析最短路径分析源代码(VB6.0)  Set ipMaxEnvelope = New esriGeometry.Envelope
337ArcGIS网络分析最短路径分析源代码(VB6.0)  For i = 0 To count - 1
338ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipLayer = m_ipMap.Layer(i)
339ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipFeatureLayer = ipLayer
340ArcGIS网络分析最短路径分析源代码(VB6.0)    ' get its dimensions (for setting search tolerance)
341ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipGeoDataset = ipFeatureLayer
342ArcGIS网络分析最短路径分析源代码(VB6.0)    Set ipEnvelope = ipGeoDataset.Extent
343ArcGIS网络分析最短路径分析源代码(VB6.0)    ' merge with max dimensions
344ArcGIS网络分析最短路径分析源代码(VB6.0)    ipMaxEnvelope.Union ipEnvelope
345ArcGIS网络分析最短路径分析源代码(VB6.0)  Next
346ArcGIS网络分析最短路径分析源代码(VB6.0)
347ArcGIS网络分析最短路径分析源代码(VB6.0)  ' finally, we can set up the IPointToEID ArcGIS网络分析最短路径分析源代码(VB6.0)
348ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPointToEID = New esriNetworkAnalysis.PointToEID
349ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPointToEID.SourceMap = m_ipMap
350ArcGIS网络分析最短路径分析源代码(VB6.0)  Set m_ipPointToEID.GeometricNetwork = m_ipGeometricNetwork
351ArcGIS网络分析最短路径分析源代码(VB6.0)
352ArcGIS网络分析最短路径分析源代码(VB6.0)  ' set snap tolerance
353ArcGIS网络分析最短路径分析源代码(VB6.0)  dblWidth = ipMaxEnvelope.Width
354ArcGIS网络分析最短路径分析源代码(VB6.0)  dblHeight = ipMaxEnvelope.Height
355ArcGIS网络分析最短路径分析源代码(VB6.0)
356ArcGIS网络分析最短路径分析源代码(VB6.0)  If dblWidth > dblHeight Then
357ArcGIS网络分析最短路径分析源代码(VB6.0)    dblSearchTol = dblWidth / 100#
358ArcGIS网络分析最短路径分析源代码(VB6.0)  Else
359ArcGIS网络分析最短路径分析源代码(VB6.0)    dblSearchTol = dblHeight / 100#
360ArcGIS网络分析最短路径分析源代码(VB6.0)  End If
361ArcGIS网络分析最短路径分析源代码(VB6.0)
362ArcGIS网络分析最短路径分析源代码(VB6.0)  m_ipPointToEID.SnapTolerance = dblSearchTol
363ArcGIS网络分析最短路径分析源代码(VB6.0)
364ArcGIS网络分析最短路径分析源代码(VB6.0)  InitializeNetworkAndMap = True      ' good to go
365ArcGIS网络分析最短路径分析源代码(VB6.0)  Exit Function
366ArcGIS网络分析最短路径分析源代码(VB6.0)
367ArcGIS网络分析最短路径分析源代码(VB6.0)Trouble:
368ArcGIS网络分析最短路径分析源代码(VB6.0)  InitializeNetworkAndMap = False     ' we had an error
369ArcGIS网络分析最短路径分析源代码(VB6.0)End Function
370ArcGIS网络分析最短路径分析源代码(VB6.0)

相关文章: