public static void ResetFilterSubsetParameters(INetworkAttribute2 netAttribute, List <string> netSourceNames)
        {
            IArray netParams = new ESRI.ArcGIS.esriSystem.ArrayClass();
            INetworkAttributeParameter netParam = null;
            object paramValue = null;

            netParam   = new NetworkAttributeParameterClass();
            paramValue = true;

            string paramName = "";

            paramName  = BaseParameterName;
            paramName += "_Restrict";

            netParam.Name         = paramName;
            netParam.VarType      = (int)VarType.Bool;
            netParam.Value        = paramValue;
            netParam.DefaultValue = paramValue;
            netParams.Add(netParam);

            netParam   = new NetworkAttributeParameterClass();
            paramValue = 1;

            foreach (string netSourceName in netSourceNames)
            {
                netParam   = new NetworkAttributeParameterClass();
                paramValue = null;

                paramName             = BaseParameterName;
                paramName            += "_EIDs_";
                paramName            += netSourceName;
                netParam.Name         = paramName;
                netParam.VarType      = (int)(VarType.Array | VarType.Integer);
                netParam.Value        = paramValue;
                netParam.DefaultValue = paramValue;
                netParams.Add(netParam);
            }

            //does not preserve existing parameters if any
            netAttribute.Parameters = netParams;
        }
Пример #2
0
        public static IArray OrganizeMapWorkspaceAndLayer(IMap pMap)
        {
            IArray        arrayClass       = new ESRI.ArcGIS.esriSystem.ArrayClass();
            IPropertySet  propertySetClass = new PropertySetClass();
            IFeatureLayer featureLayer     = null;


            UID uid = new UIDClass();

            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            IEnumLayer layers = pMap.Layers[uid, true];

            layers.Reset();
            ILayer pLayer = layers.Next();

            while (pLayer != null)
            {
                if (pLayer is IFeatureLayer)
                {
                    featureLayer = pLayer as IFeatureLayer;
                    IDataset featureClass = featureLayer.FeatureClass as IDataset;
                    if (featureClass != null && !(featureClass is ICoverageFeatureClass))
                    {
                        IWorkspace workspace = featureClass.Workspace;
                        if (workspace is IFeatureWorkspace)
                        {
                            IPropertySet connectionProperties = workspace.ConnectionProperties;
                            bool         hasFindWorkspace     = false;
                            for (int i = 0; i < arrayClass.Count; i++)
                            {
                                PipeWorkspaceInfo workspaceInfo = arrayClass.Element[i] as PipeWorkspaceInfo;
                                if (workspaceInfo.Workspace.ConnectionProperties.Equals(connectionProperties))
                                {
                                    workspaceInfo.AddClass(featureLayer.FeatureClass);
                                    hasFindWorkspace = true;
                                    break;
                                }
                            }
                            if (hasFindWorkspace == false)
                            {
                                PipeWorkspaceInfo workspaceInfo = new PipeWorkspaceInfo(workspace);
                                workspaceInfo.AddClass(featureLayer.FeatureClass);
                                arrayClass.Add(workspaceInfo);
                            }
                        }
                    }
                }
                pLayer = layers.Next();
            }
            return(arrayClass);
        }
Пример #3
0
        /// <summary>
        /// 获取覆盖区域
        /// </summary>
        /// <param name="geometry"></param>
        /// <param name="featureClass"></param>
        public static void seek_IntersectFeature(IGeometry geometry, IFeatureClass featureClass, ref IArray array)
        {
            try
            {
                IFeature feature = null;
                if (array != null)
                {
                    //让我们显示控制COM对象的生存==你调用这个方法,就是通过.NET环境,告诉COM对象,不用你了,马上消失。)
                    Marshal.ReleaseComObject(array);
                }
                array = new ESRI.ArcGIS.esriSystem.ArrayClass();
                //SpatialFilter空间查询
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                IQueryFilter   pQueryFilter  = spatialFilter as IQueryFilter;

                // 设置空间过滤器的范围(多边形)
                spatialFilter.Geometry = geometry;
                // 设置空间过滤器空间关系类型
                spatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                spatialFilter.WhereClause = null;
                //获取FeatureCursor游标
                IFeatureCursor featureCursor = featureClass.Search(pQueryFilter, false);
                //遍历FeatureCursor
                feature = featureCursor.NextFeature();
                while (feature != null)
                {
                    //获取要素对象
                    array.Add(feature);
                    feature = featureCursor.NextFeature();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
		public static void ResetScaleSubsetParameters(INetworkAttribute2 netAttribute, List<string> netSourceNames)
		{
			IArray netParams = new ESRI.ArcGIS.esriSystem.ArrayClass();
			INetworkAttributeParameter netParam = null;
			object paramValue = null;
			string paramName = "";

			netParam = new NetworkAttributeParameterClass();
			paramValue = 1;

			paramName = BaseParameterName;
			paramName += "_Factor";

			netParam.Name = paramName;
			netParam.VarType = (int)VarType.Double;
			netParam.Value = paramValue;
			netParam.DefaultValue = paramValue;
			netParams.Add(netParam);

			foreach (string netSourceName in netSourceNames)
			{
				netParam = new NetworkAttributeParameterClass();
				paramValue = null;

				paramName = BaseParameterName;
				paramName += "_eids_";
				paramName += netSourceName;
				netParam.Name = paramName;
				netParam.VarType = (int)(VarType.Array | VarType.Integer);
				netParam.Value = paramValue;
				netParam.DefaultValue = paramValue;
				netParams.Add(netParam);
			}

			//does not preserve existing parameters if any
			netAttribute.Parameters = netParams;
		}