public void CopySubsetWithAttributes()
        {
            IFeatureSet fs = BuildFeatureSet();

            IFeatureSet res = fs.CopySubset(string.Empty);

            Assert.AreEqual(res.Features.Count, 3);
            Assert.AreEqual(res.Features[0].DataRow["Test"], "hello");

            IFeatureSet res2 = fs.CopySubset("[Test] = 'hello'");

            Assert.AreEqual(res2.Features.Count, 2);
            Assert.AreEqual(res2.Features[0].DataRow["Test"], "hello");
        }
        public void CopySubsetWithoutAttributes()
        {
            IFeatureSet fs = BuildFeatureSet();

            IFeatureSet res3 = fs.CopySubset(string.Empty, false);

            Assert.AreEqual(res3.Features.Count, 3);
            Assert.AreEqual(res3.Features[0].DataRow.ItemArray.Length, 0);

            IFeatureSet res4 = fs.CopySubset("[Test] = 'hello'", false);

            Assert.AreEqual(res4.Features.Count, 2);
            Assert.AreEqual(res4.Features[0].DataRow.ItemArray.Length, 0);
        }
示例#3
0
        /// <summary>
        /// Spatial query using OGR
        /// </summary>
        /// <param name="featureSet">FeatureSet</param>
        /// <param name="region">Spatial region</param>
        /// <returns>Selected features</returns>
        public static IFeatureSet OgrSpatialQuery(IFeatureSet featureSet, IFeatureSet region)
        {
            List <int>  featureList = OgrSpatialFilter(featureSet, region);
            IFeatureSet result      = featureSet.CopySubset(featureList);

            return(result);
        }
示例#4
0
        /// <summary>
        /// Spatial query using DotSpatial
        /// </summary>
        /// <param name="featureSet">FeatureSet</param>
        /// <param name="region">Spatial region</param>
        /// <returns>Selected features</returns>
        public static IFeatureSet SpatialQuery(IFeatureSet featureSet, IFeatureSet region)
        {
            List <int>  indexList = SpatialFilter(featureSet, region);
            IFeatureSet resultSet = featureSet.CopySubset(indexList);

            return(resultSet);
        }
示例#5
0
        /// <summary>
        /// Executes the ReprojectFeatureSet Operation tool programmatically.
        /// </summary>
        /// <param name="featureSet">The input FeatureSet.</param>
        /// <param name="sourceProjection">The input Expression string to select features to Delete.</param>
        /// <param name="destProjection">The target projected coordinate system to reproject the featureset to</param>
        /// <param name="output">The output FeatureSet.</param>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True, if executed successfully.</returns>
        public bool Execute(IFeatureSet featureSet, ProjectionInfo sourceProjection, ProjectionInfo destProjection, IFeatureSet output, ICancelProgressHandler cancelProgressHandler)
        {
            string filename = output.Filename;

            output = featureSet.CopySubset(string.Empty);

            if (sourceProjection != null)
            {
                output.Projection = sourceProjection;
            }

            output.Reproject(destProjection);
            output.SaveAs(filename, true);
            return(true);
        }
示例#6
0
        private IFeatureSet CorrectFeatures(IFeatureSet featureSet)
        {
            IFeatureSet corFeatureSet = featureSet;
            List <int>  corList       = new List <int>();

            for (int i = 0; i < featureSet.ShapeIndices.Count; i++)
            {
                try
                {
                    IFeature    feature      = featureSet.GetFeature(i);
                    IFeatureSet reFeatureSet = new FeatureSet();
                    reFeatureSet.Features.Add(feature);
                    //有待检验能否检测出其他异常
                    reFeatureSet.SelectByAttribute("");
                    corList.Add(i);
                }
                catch
                {
                    //featureSet.Features.RemoveAt(i);
                }
            }
            corFeatureSet = corFeatureSet.CopySubset(corList);
            return(corFeatureSet);
        }
示例#7
0
        /// <summary>
        /// Spatial filter using DotSpatial
        /// </summary>
        /// <param name="featureSet">FeatureSet</param>
        /// <param name="region">Spatial region</param>
        /// <param name="filterExpression">SQL expression</param>
        /// <returns>Indexs of selected features</returns>
        public static List <int> Filter(IFeatureSet featureSet, IFeatureSet region, string filterExpression)
        {
            IGeometry geometry = GetGeometry(region);

            return(SpatialFilter(featureSet.CopySubset(filterExpression), geometry));
        }
示例#8
0
 /// <summary>
 /// Spatial query using DotSpatial
 /// </summary>
 /// <param name="featureSet">FeatureSet</param>
 /// <param name="geometry">Spatial geometry</param>
 /// <param name="filterExpression">SQL expression</param>
 /// <returns>Selected features</returns>
 public static IFeatureSet Query(IFeatureSet featureSet, IGeometry geometry, string filterExpression)
 {
     return(SpatialQuery(featureSet.CopySubset(filterExpression), geometry));
 }
示例#9
0
 /// <summary>
 /// Spatial query using DotSpatial
 /// </summary>
 /// <param name="featureSet">FeatureSet</param>
 /// <param name="region">Spatial region</param>
 /// <param name="filterExpression">SQL expression</param>
 /// <returns>Selected features</returns>
 public static IFeatureSet Query(IFeatureSet featureSet, IFeatureSet region, string filterExpression)
 {
     return(SpatialQuery(featureSet.CopySubset(filterExpression), region));
 }