ArcGIS网络分析最短路径分析源代码(VB6.0)精品资料.doc
《ArcGIS网络分析最短路径分析源代码(VB6.0)精品资料.doc》由会员分享,可在线阅读,更多相关《ArcGIS网络分析最短路径分析源代码(VB6.0)精品资料.doc(30页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、ArcGIS网络分析最短路径分析源代码(VB6.0)12Copyright1995-2005ESRI34AllrightsreservedunderthecopyrightlawsoftheUnitedStates.56Youmayfreelyredistributeandusethissamplecode,withorwithoutmodification.78Disclaimer:THESAMPLECODEISPROVIDEDASISANDANYEXPRESSORIMPLIED9WARRANTIES,INCLUDINGTHEIMPLIEDWARRANTIESOFMERCHANTABILIT
2、YANDFITNESS10FORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALLESRIOR11CONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,12ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOF13SUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESS14INTERRUPTION)SUSTAINEDBYYOUORA
3、THIRDPARTY,HOWEVERCAUSEDANDONANY15THEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,ORTORTARISINGINANY16WAYOUTOFTHEUSEOFTHISSAMPLECODE,EVENIFADVISEDOFTHEPOSSIBILITYOF17SUCHDAMAGE.1819Foradditionalinformationcontact:EnvironmentalSystemsResearchInstitute,Inc.2021Attn:ContractsDept.2223380NewYorkStre
4、et2425Redlands,California,U.S.A.923732627Email:contracts2829OptionExplicit3031vbversionofthePathFinderobject3233本地变量34Privatem_ipGeometricNetworkAsesriGeoDatabase.IGeometricNetwork35Privatem_ipMapAsesriCarto.IMap36Privatem_ipPointsAsesriGeometry.IPointCollection37Privatem_ipPointToEIDAsesriNetworkAn
5、alysis.IPointToEID38返回结果变量39Privatem_dblPathCostAsDouble40Privatem_ipEnumNetEID_JunctionsAsesriGeoDatabase.IEnumNetEID41Privatem_ipEnumNetEID_EdgesAsesriGeoDatabase.IEnumNetEID42Privatem_ipPolylineAsesriGeometry.IPolyline434445OptionallysettheMap(e.g.thecurrentmapinArcMap),46otherwiseadefaultmapwill
6、bemade(forIPointToEID).4748PublicPropertySetMap(MapAsesriCarto.IMap)49Setm_ipMap=Map50EndProperty5152PublicPropertyGetMap()AsesriCarto.IMap53SetMap=m_ipMap54EndProperty5556EitherOpenAccessNetworkorOpenFeatureDatasetNetwork57needstobecalled.5859PublicSubOpenAccessNetwork(AccessFileNameAsString,Featur
7、eDatasetNameAsString)6061DimipWorkspaceFactoryAsesriGeoDatabase.IWorkspaceFactory62DimipWorkspaceAsesriGeoDatabase.IWorkspace63DimipFeatureWorkspaceAsesriGeoDatabase.IFeatureWorkspace64DimipFeatureDatasetAsesriGeoDatabase.IFeatureDataset6566AfterthisSubexits,wellhaveanINetworkinterface67andanIMapint
8、erfaceinitializedforthenetworkwellbeusing.6869closedownthelastoneifopened70CloseWorkspace7172openthemdb73SetipWorkspaceFactory=NewesriDataSourcesGDB.AccessWorkspaceFactory74SetipWorkspace=ipWorkspaceFactory.OpenFromFile(AccessFileName,0)7576gettheFeatureWorkspace77SetipFeatureWorkspace=ipWorkspace78
9、79opentheFeatureDataset80SetipFeatureDataset=ipFeatureWorkspace.OpenFeatureDataset(FeatureDatasetName)8182initializeNetworkandMap(m_ipNetwork,m_ipMap)83IfNotInitializeNetworkAndMap(ipFeatureDataset)ThenErr.Raise0,OpenAccessNetwork,ErrorinitializingNetworkandMap8485EndSub8687PublicSubOpenFeatureDatas
10、etNetwork(FeatureDatasetAsesriGeoDatabase.IFeatureDataset)88closedownthelastoneifopened89CloseWorkspace9091weassumethatthecallerhaspassedavalidFeatureDataset9293initializeNetworkandMap(m_ipNetwork,m_ipMap)94IfNotInitializeNetworkAndMap(FeatureDataset)ThenErr.Raise0,OpenFeatureDatasetNetwork,Errorini
11、tializingNetworkandMap9596EndSub9798Thecollectionofpointstotravelthroughmustbeset.99100PublicPropertySetStopPoints(PointsAsesriGeometry.IPointCollection)101Setm_ipPoints=Points102EndProperty103104PublicPropertyGetStopPoints()AsesriGeometry.IPointCollection105SetStopPoints=m_ipPoints106EndProperty107
12、108Calculatethepath109110PublicSubSolvePath(WeightNameAsString)111112DimipNetworkAsesriGeoDatabase.INetwork113DimipTraceFlowSolverAsesriNetworkAnalysis.ITraceFlowSolver114DimipNetSolverAsesriNetworkAnalysis.INetSolver115DimipNetFlagAsesriNetworkAnalysis.INetFlag116DimipaNetFlag()AsesriNetworkAnalysi
13、s.IEdgeFlag117DimipEdgePointAsesriGeometry.IPoint118DimipNetElementsAsesriGeoDatabase.INetElements119DimintEdgeUserClassIDAsLong120DimintEdgeUserIDAsLong121DimintEdgeUserSubIDAsLong122DimintEdgeIDAsLong123DimipFoundEdgePointAsesriGeometry.IPoint124DimdblEdgePercentAsDouble125DimipNetWeightAsesriGeoD
14、atabase.INetWeight126DimipNetSolverWeightsAsesriNetworkAnalysis.INetSolverWeights127DimipNetSchemaAsesriGeoDatabase.INetSchema128DimintCountAsLong129DimiAsLong130DimvaRes()AsVariant131132makesureweareready133Debug.AssertNotm_ipPointsIsNothing134Debug.AssertNotm_ipGeometricNetworkIsNothing135136insta
15、ntiateatraceflowsolver137SetipTraceFlowSolver=NewesriNetworkAnalysis.TraceFlowSolver138139gettheINetSolverinterface140SetipNetSolver=ipTraceFlowSolver141142setthesourcenetworktosolveon143SetipNetwork=m_ipGeometricNetwork.Network144SetipNetSolver.SourceNetwork=ipNetwork145146makeedgeflagsfromthepoint
16、s147148theINetElementsinterfaceisneededtogetUserID,UserClassID,149andUserSubIDfromanelementid150SetipNetElements=ipNetwork151152getthecount153intCount=m_ipPoints.PointCount154Debug.AssertintCount1155156dimensionourIEdgeFlagarray157ReDimipaNetFlag(intCount)158159Fori=0TointCount-1160makeanewEdgeFlag1
17、61SetipNetFlag=NewesriNetworkAnalysis.EdgeFlag162SetipEdgePoint=m_ipPoints.Point(i)163lookuptheEIDforthecurrentpoint(thiswillpopulateintEdgeIDanddblEdgePercent)164m_ipPointToEID.GetNearestEdgeipEdgePoint,intEdgeID,ipFoundEdgePoint,dblEdgePercent165Debug.AssertintEdgeID0elsePoint(eid)notfound166ipNet
18、Elements.QueryIDsintEdgeID,esriETEdge,intEdgeUserClassID,intEdgeUserID,intEdgeUserSubID167Debug.Assert(intEdgeUserClassID0)And(intEdgeUserID0)elsePointnotfound168ipNetFlag.UserClassID=intEdgeUserClassID169ipNetFlag.UserID=intEdgeUserID170ipNetFlag.UserSubID=intEdgeUserSubID171SetipaNetFlag(i)=ipNetF
19、lag172Next173174addtheseedgeflags175ipTraceFlowSolver.PutEdgeOriginsintCount,ipaNetFlag(0)176177settheweight(costfield)tosolveon178179gettheINetSchemainterface180SetipNetSchema=ipNetwork181SetipNetWeight=ipNetSchema.WeightByName(WeightName)182Debug.AssertNotipNetWeightIsNothing183184settheweight(use
20、thesameforbothdirections)185SetipNetSolverWeights=ipTraceFlowSolver186SetipNetSolverWeights.FromToEdgeWeight=ipNetWeight187SetipNetSolverWeights.ToFromEdgeWeight=ipNetWeight188189initializearrayforresultstonumberofsegmentsinresult190ReDimvaRes(intCount-1)191192solveit193ipTraceFlowSolver.FindPathesr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ArcGIS网络分析最短路径分析源代码VB6.0 精品资料 ArcGIS 网络分析 路径 分析 源代码 VB6 精品 资料
限制150内