示例#1
0
        private IFeatureSet SelectTransFeatures(IFeatureSet dataSet, string filterExpression, string spatialRegion)
        {
            try
            {
                IFeatureSet filterSet = null;
                List <DotSpatial.Data.IFeature> filterList = null;

                bool getSpatialRegion = false;
                if (_spatialRigon != null && spatialRegion != "")
                {
                    IDataManager dataManager = new DataManager();
                    filterSet = dataManager.OpenFile(_spatialRigon) as IFeatureSet;
                    if (filterSet.FeatureType == FeatureType.Polygon)
                    {
                        filterList       = (filterSet as FeatureSet).SelectByAttribute("");
                        getSpatialRegion = true;
                    }
                }

                #region 空间和属性过滤

                IFeatureSet corFeatureSet = CorrectFeatures(dataSet as FeatureSet);
                List <DotSpatial.Data.IFeature> dataList = corFeatureSet.SelectByAttribute(filterExpression);
                if (getSpatialRegion)
                {
                    for (int i = 0; i < dataList.Count; i++)
                    {
                        bool isIntersection = false;
                        foreach (DotSpatial.Data.IFeature feature in filterList)
                        {
                            if (dataList[i].Geometry.Intersects(feature.Geometry))
                            {
                                isIntersection = true;
                                break;
                            }
                        }
                        if (!isIntersection)
                        {
                            dataList.RemoveAt(i);
                            i--;
                        }
                    }
                }

                #endregion

                IFeatureSet resultSet = new FeatureSet(dataList);
                resultSet.Projection = dataSet.Projection;
                return(resultSet);
            }
            catch (Exception ex)
            {
                MessageBox.Show("分析失败!");
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// Executes the Erase Opaeration tool programaticaly.
        /// Ping deleted static for external testing 01/2010
        /// </summary>
        /// <param name="input1">The input FeatureSet.</param>
        /// <param name="input2">The input Expression string to select features to Delete.</param>
        /// <param name="output">The output FeatureSet.</param>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns></returns>
        public bool Execute(
            IFeatureSet input1, string input2, IFeatureSet output, ICancelProgressHandler cancelProgressHandler)
        {
            // Validates the input and output data
            if (input1 == null || input2 == null || output == null)
            {
                return(false);
            }

            if (cancelProgressHandler.Cancel)
            {
                return(false);
            }

            int             previous             = 0;
            List <IFeature> fetList              = input1.SelectByAttribute(input2);
            int             noOfFeaturesToDelete = fetList.Count;
            int             noOfFeatures         = input1.Features.Count;

            output.FeatureType = input1.FeatureType;
            foreach (IFeature f in input1.Features)
            {
                output.Features.Add(f);
            }

            // Go through every item in the list
            for (int i = 0; i < noOfFeaturesToDelete; i++)
            {
                int current = Convert.ToInt32(Math.Round(i * 100D / noOfFeaturesToDelete));

                // only update when increment in percentage
                if (current > previous)
                {
                    cancelProgressHandler.Progress(string.Empty, current, current + TextStrings.progresscompleted);
                }

                previous = current;

                // loop through every item in the list
                for (int j = 0; j < noOfFeatures; j++)
                {
                    // Select the Feature from Feature set to detlete
                    if (fetList[i] == input1.Features[j])
                    {
                        output.Features.Remove(input1.Features[j]);
                    }
                }
            }

            output.SaveAs(output.Filename, true);
            return(true);
        }
 private bool checkSql()
 {
     if (m_CurrentFeaSet == null)
     {
         return(false);
     }
     try
     {
         m_ResultFeatures = m_CurrentFeaSet.SelectByAttribute(this.txtWhereClause.Text);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#4
0
        /// <summary>
        /// Executes the Erase Opaeration tool programaticaly.
        /// Ping deleted static for external testing 01/2010
        /// </summary>
        /// <param name="input1">The input FeatureSet.</param>
        /// <param name="input2">The input Expression string to select features to Delete.</param>
        /// <param name="output">The output FeatureSet.</param>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns></returns>
        public bool Execute(
            IFeatureSet input1, string input2, IFeatureSet output, ICancelProgressHandler cancelProgressHandler)
        {
            // Validates the input and output data
            if (input1 == null || input2 == null || output == null)
            {
                return false;
            }

            if (cancelProgressHandler.Cancel)
            {
                return false;
            }

            int previous = 0;
            List<IFeature> fetList = input1.SelectByAttribute(input2);
            int noOfFeaturesToDelete = fetList.Count;
            int noOfFeatures = input1.Features.Count;
            output.FeatureType = input1.FeatureType;
            foreach (IFeature f in input1.Features)
            {
                output.Features.Add(f);
            }

            // Go through every item in the list
            for (int i = 0; i < noOfFeaturesToDelete; i++)
            {
                int current = Convert.ToInt32(Math.Round(i * 100D / noOfFeaturesToDelete));

                // only update when increment in percentage
                if (current > previous)
                {
                    cancelProgressHandler.Progress(string.Empty, current, current + TextStrings.progresscompleted);
                }

                previous = current;

                // loop through every item in the list
                for (int j = 0; j < noOfFeatures; j++)
                {
                    // Select the Feature from Feature set to detlete
                    if (fetList[i] == input1.Features[j])
                    {
                        output.Features.Remove(input1.Features[j]);
                    }
                }
            }

            output.SaveAs(output.Filename, true);
            return true;
        }