コード例 #1
0
        protected override void Execute()
        {
            var featureClass = FeatureWorkspace.OpenFeatureClass(Args.FeatureClass.Trim());

            var errors = ValidateFields(featureClass, Args.ReturnValues);

            if (errors.Any())
            {
                ErrorMessage = "{0} does not contain an attribute {1}. Check your spelling."
                               .With(Args.FeatureClass, string.Join(" or ", errors));

                return;
            }

            var filter = new QueryFilterClass
            {
                WhereClause = Args.WhereClause
            };

            var fCursor = featureClass.Search(filter, true);

            var fields = featureClass.Fields;

            var container = AddResultsToContainer(fCursor, fields, Args.ReturnValues, Args.SpatialRefefence);

            Result = container;
        }
コード例 #2
0
        protected override void Execute()
        {
            IFeatureClass featureClass;

            try
            {
                featureClass = FeatureWorkspace.OpenFeatureClass(Args.FeatureClass.Trim());
            }
            catch (COMException ex)
            {
                ErrorMessage =
                    "{0} is not a spatial feature class and cannot be queried with a geometry. Result: {1}".With(Args.FeatureClass, ex.HResult);

                return;
            }

            var errors = ValidateFields(featureClass, Args.ReturnValues);

            if (errors.Any())
            {
                ErrorMessage = "{0} does not contain an attribute {1}. Check your spelling."
                               .With(Args.FeatureClass, string.Join(" or ", errors));

                return;
            }

            if (Args.Shape == null)
            {
                ErrorMessage = "The point used to do the query appears to be invalid. Check the syntax point:[x,y]";

                return;
            }

            var spatFilter = new SpatialFilterClass
            {
                SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects,
                WhereClause = Args.WhereClause,
                Geometry    = Args.Shape
            };

            var fCursor = featureClass.Search(spatFilter, true);

            var fields = featureClass.Fields;

            var container = AddResultsToContainer(fCursor, fields, Args.ReturnValues, Args.SpatialRefefence);

            Marshal.ReleaseComObject(fields);
            Marshal.ReleaseComObject(spatFilter);
            Marshal.ReleaseComObject(featureClass);
            Marshal.ReleaseComObject(FeatureWorkspace);

            Result = container;
        }