예제 #1
0
        public bool QueryTheRoue(IPoint breakPoint, AxMapControl mapControl, IFeatureLayer featureLayer, string dbPath, string featureSetName, string ndsName, ref IPoint rightPoint)
        {
            IFeature feature  = null;
            double   distance = 0;
            int      distNum  = 0;

            rightPoint = DistanceUtil.GetNearestLineInFeatureLayer(featureLayer, breakPoint, ref feature, ref distance, ref distNum);
            if (rightPoint == null)
            {
                return(false);
            }
            //获取线要素的点集合
            IPointCollection lineCollection = feature.Shape as IPointCollection;
            //实例化站点和障碍点要素
            IFeatureClass stopFeatureClass =
                FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "stops");
            IFeatureClass barriesFeatureClass =
                FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "barries");

            //添加站点
            FeatureClassUtil.InsertSimpleFeature(lineCollection.get_Point(0), stopFeatureClass);
            FeatureClassUtil.InsertSimpleFeature(lineCollection.get_Point(lineCollection.PointCount - 1), stopFeatureClass);
            //添加障碍
            FeatureClassUtil.InsertSimpleFeature(rightPoint, barriesFeatureClass);
            //组装站点和障碍点要素
            IDictionary <string, DecorateRouteFeatureClass> featureClasses = new Dictionary <string, DecorateRouteFeatureClass>();

            featureClasses.Add("Stops", new DecorateRouteFeatureClass(0.2, stopFeatureClass));
            featureClasses.Add("Barriers", new DecorateRouteFeatureClass(0.2, barriesFeatureClass));
            ILayer routeLayer = null;

            //最短路径分析
            return(NormalNetworkUtil.Short_Path(mapControl, dbPath, featureSetName, ndsName, featureClasses, false, false, ref routeLayer));
        }
 /// <summary>
 /// 根据障碍点和经过点求解最短路径
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="featureLayer"></param>
 /// <param name="dbPath"></param>
 /// <param name="featureSetName"></param>
 /// <param name="ndsName"></param>
 /// <param name="stopPoints"></param>
 /// <param name="barryPoints"></param>
 /// <param name="routeLayer"></param>
 /// <returns></returns>
 public bool QueryTheRoue(ESRI.ArcGIS.Controls.AxMapControl mapControl, ESRI.ArcGIS.Carto.IFeatureLayer featureLayer, string dbPath, string featureSetName, string ndsName, List<ESRI.ArcGIS.Geometry.IPoint> stopPoints, List<ESRI.ArcGIS.Geometry.IPoint> barryPoints, ref ILayer routeLayer)
 {
    // List<IPoint>   newStopPoints;
   //  List<IPoint>  newBarryPoints;
 //    UpdatePointsToRouteCore(featureLayer, stopPoints, barryPoints, out newStopPoints, out newBarryPoints);
     //实例化站点和障碍点要素
     IFeatureClass stopFeatureClass =
         FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "stops");
     IFeatureClass barriesFeatureClass =
         FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "barries");
     //添加站点
     foreach (var value in stopPoints)
     {
         FeatureClassUtil.InsertSimpleFeature(value, stopFeatureClass);
     }
     //添加障碍
     foreach (var value in barryPoints)
     {
         FeatureClassUtil.InsertSimpleFeature(value, barriesFeatureClass);
     }
     //组装站点和障碍点要素
     IDictionary<string, DecorateRouteFeatureClass> featureClasses = new Dictionary<string, DecorateRouteFeatureClass>();
     featureClasses.Add("Stops", new DecorateRouteFeatureClass(0.2,stopFeatureClass));
     featureClasses.Add("Barriers", new DecorateRouteFeatureClass(0.2,barriesFeatureClass));
     //最短路径分析
     bool result=NormalNetworkUtil.Short_Path(mapControl, dbPath, featureSetName, ndsName, featureClasses, false, false, ref routeLayer);
     //if (result)
    //    {
   //        showRouteShape(routeLayer as IFeatureLayer, mapControl);
   //  }
     return result;
 }