Esempio n. 1
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet self  = _inputParam[0].Value as IFeatureSet;
            IFeatureSet other = _inputParam[1].Value as IFeatureSet;

            if (self != null && other != null)
            {
                self.FillAttributes();
                other.FillAttributes();
            }

            IFeatureSet result = Overlay.EraseFeatures(self, other, cancelProgressHandler);

            if (cancelProgressHandler.Cancel)
            {
                _outputParam = null;
                return(false);
            }
            else
            {
                result.Filename = ((IFeatureSet)_outputParam[0].Value).Filename;
                result.Save();
                _outputParam[0].Value = result;
                return(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet self = _inputParam[0].Value as IFeatureSet;

            if (self != null)
            {
                self.FillAttributes();
            }

            IFeatureSet other = _inputParam[1].Value as IFeatureSet;

            if (other != null)
            {
                other.FillAttributes();
            }

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            if (self == null)
            {
                return(false);
            }

            if (other == null)
            {
                return(false);
            }

            return(self.Features.Count < other.Features.Count
                       ? Execute(self, other, output, cancelProgressHandler)
                       : Execute(other, self, output, cancelProgressHandler));
        }
Esempio n. 3
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input = _inputParam[0].Value as IFeatureSet;

            if (input == null)
            {
                return(false);
            }

            input.FillAttributes();
            ListParam lp = _inputParam[1] as ListParam;

            if (lp == null)
            {
                return(false);
            }

            string           zField       = lp.ValueList[lp.Value];
            double           cellSize     = (double)_inputParam[2].Value;
            double           power        = (double)_inputParam[3].Value;
            NeighborhoodType neighborType = _inputParam[4].Value as string == TextStrings.FixedDistance
                                                ? NeighborhoodType.FixedDistance
                                                : NeighborhoodType.FixedCount;
            int     pointCount = (int)_inputParam[5].Value;
            double  distance   = (double)_inputParam[6].Value;
            IRaster output     = _outputParam[0].Value as IRaster;

            return(Execute(
                       input, zField, cellSize, power, neighborType, pointCount, distance, output, cancelProgressHandler));
        }
Esempio n. 4
0
        /// <summary>
        /// Once the parameters have been configured the Execute command can be called, it returns true if successful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input1 = _inputParam[0].Value as IFeatureSet;

            if (input1 != null)
            {
                input1.FillAttributes();
            }

            ProjectionParam source  = _inputParam[1] as ProjectionParam;
            ProjectionParam dest    = _inputParam[2] as ProjectionParam;
            ProjectionInfo  pSource = null;

            if (source != null)
            {
                pSource = source.Value;
            }

            if (dest == null)
            {
                return(false);
            }

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            return(Execute(input1, pSource, dest.Value, output, cancelProgressHandler));
        }
Esempio n. 5
0
        public void IndexModeToFeaturesClear()
        {
            IFeatureSet fs = FeatureSet.Open(_shapefiles + @"Topology_Test.shp");

            fs.FillAttributes();
            fs.Features.Clear();
            Assert.AreEqual(fs.Features.Count, 0);
            Assert.AreEqual(fs.DataTable.Rows.Count, 0);
        }
Esempio n. 6
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True, if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input = _inputParam[0].Value as IFeatureSet;

            input?.FillAttributes();

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            return(Execute(input, output, cancelProgressHandler));
        }
Esempio n. 7
0
        public static void GettingEntireAttributeTable()
        {
            IFeatureSet fs = FeatureSet.Open(@"C:\[Your File Path]\Municipalities.shp");

            fs.FillAttributes();
            DataTable dtOriginal = fs.DataTable;

            for (int row = 0; row < dtOriginal.Rows.Count; row++)
            {
                object[] original = dtOriginal.Rows[row].ItemArray;
            }
        }
Esempio n. 8
0
        public static void GettingValueFromAttributeTable()
        {
            IFeatureSet fs = FeatureSet.Open(@"C:\[Your File Path\Municipalities.shp");

            fs.FillAttributes();
            DataTable dt = fs.DataTable;

            for (int row = 0; row < dt.Rows.Count; row++)
            {
                object val = dt.Rows[row]["NAME"];
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input = _inputParam[0].Value as IFeatureSet;

            if (input != null)
            {
                input.FillAttributes();
            }

            double      tolerance = (double)_inputParam[1].Value;
            IFeatureSet output    = _outputParam[0].Value as IFeatureSet;

            return(Execute(input, tolerance, output, cancelProgressHandler));
        }
Esempio n. 10
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input = _inputParam[0].Value as IFeatureSet;

            input?.FillAttributes();

            if (!(_outputParam[0].Value is IFeatureSet output))
            {
                return(false);
            }

            Analysis.Voronoi.VoronoiPolygons(input, output, true);
            output.Save();
            return(true);
        }
Esempio n. 11
0
        /// <summary>
        /// Once the Parameter have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input = _inputParam[0].Value as IFeatureSet;

            if (input != null)
            {
                input.FillAttributes();
            }

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            DotSpatial.Analysis.Voronoi.VoronoiPolygons(input, output, true);
            output.Save();
            return(true);
        }
Esempio n. 12
0
        /// <summary>
        /// Once the parameters have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True, if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input1 = _inputParam[0].Value as IFeatureSet;

            input1?.FillAttributes();

            int index = (int)_inputParam[1].Value;

            IFeatureSet input2 = _inputParam[2].Value as IFeatureSet;

            input2?.FillAttributes();

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            return(Execute(input1, index, input2, output, cancelProgressHandler));
        }
Esempio n. 13
0
        /// <summary>
        /// Once the parameters have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True, if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input1 = _inputParam[0].Value as IFeatureSet;

            input1?.FillAttributes();

            string input2 = string.Empty;

            if (_inputParam[1] is IndexParam ip)
            {
                input2 = ip.Value;
            }

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            return(Execute(input1, input2, output, cancelProgressHandler));
        }
Esempio n. 14
0
        /// <summary>
        /// This routine takes a DotSpatial Featureset and makes a clone and then reprojects it to the requested Projection.
        /// It returns a clone of the input so the input is not altered in any way.
        /// </summary>
        /// <param name="self">This featureSet.</param>
        /// <param name="targetPrj">The projection of the target clone FeatureSet.</param>
        /// <returns>A reprojected clone of the surce FeatureSet.</returns>
        public static IFeatureSet ReprojectedClone(this IFeatureSet self, ProjectionInfo targetPrj)
        {
            // input check
            if (self == null || targetPrj == null)
            {
                return(null);
            }

            self.FillAttributes();
            IFeatureSet fsClone = self.CopyFeatures(true);

            fsClone.IndexMode = false;
            fsClone.Reproject(targetPrj);

            // success so return the reprojected clone FeatureSet
            return(fsClone);
        }
Esempio n. 15
0
        /// <summary>
        /// Once the parameters have been configured the Execute command can be called, it returns true if successful.
        /// </summary>
        /// <param name="cancelProgressHandler">The progress handler.</param>
        /// <returns>True, if executed successfully.</returns>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input1 = _inputParam[0].Value as IFeatureSet;

            input1?.FillAttributes();

            ProjectionParam source  = _inputParam[1] as ProjectionParam;
            ProjectionInfo  pSource = source?.Value;

            if (!(_inputParam[2] is ProjectionParam dest))
            {
                return(false);
            }

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            return(Execute(input1, pSource, dest.Value, output, cancelProgressHandler));
        }
Esempio n. 16
0
        /// <summary>
        /// Once the parameters have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        public override bool Execute(ICancelProgressHandler cancelProgressHandler)
        {
            IFeatureSet input1 = _inputParam[0].Value as IFeatureSet;

            if (input1 != null)
            {
                input1.FillAttributes();
            }

            IFeatureSet input2 = _inputParam[1].Value as IFeatureSet;

            if (input2 != null)
            {
                input2.FillAttributes();
            }

            IFeatureSet output = _outputParam[0].Value as IFeatureSet;

            return(Execute(input1, input2, output, cancelProgressHandler));
        }
Esempio n. 17
0
        /// <summary>
        /// This tests each feature of the input
        /// </summary>
        /// <param name="self">This featureSet</param>
        /// <param name="other">The featureSet to perform intersection with</param>
        /// <param name="joinType">The attribute join type</param>
        /// <param name="progHandler">A progress handler for status messages</param>
        /// <returns>An IFeatureSet with the intersecting features, broken down based on the join Type</returns>
        public static IFeatureSet Intersection(this IFeatureSet self, IFeatureSet other, FieldJoinType joinType, IProgressHandler progHandler)
        {
            IFeatureSet   result = null;
            ProgressMeter pm     = new ProgressMeter(progHandler, "Calculating Intersection", self.Features.Count);

            if (joinType == FieldJoinType.All)
            {
                result = CombinedFields(self, other);

                // Intersection is symmetric, so only consider I X J where J <= I
                if (!self.AttributesPopulated)
                {
                    self.FillAttributes();
                }
                if (!other.AttributesPopulated)
                {
                    other.FillAttributes();
                }

                for (int i = 0; i < self.Features.Count; i++)
                {
                    IFeature        selfFeature     = self.Features[i];
                    List <IFeature> potentialOthers = other.Select(selfFeature.Geometry.EnvelopeInternal.ToExtent());
                    foreach (IFeature otherFeature in potentialOthers)
                    {
                        selfFeature.Intersection(otherFeature, result, joinType);
                    }

                    pm.CurrentValue = i;
                }

                pm.Reset();
            }
            else if (joinType == FieldJoinType.LocalOnly)
            {
                if (!self.AttributesPopulated)
                {
                    self.FillAttributes();
                }

                result = new FeatureSet();
                result.CopyTableSchema(self);
                result.FeatureType = self.FeatureType;
                if (other.Features != null && other.Features.Count > 0)
                {
                    pm = new ProgressMeter(progHandler, "Calculating Union", other.Features.Count);
                    IFeature union = other.Features[0];
                    for (int i = 1; i < other.Features.Count; i++)
                    {
                        union           = union.Union(other.Features[i].Geometry);
                        pm.CurrentValue = i;
                    }

                    pm.Reset();
                    pm = new ProgressMeter(progHandler, "Calculating Intersections", self.NumRows());
                    Extent otherEnvelope = union.Geometry.EnvelopeInternal.ToExtent();
                    for (int shp = 0; shp < self.ShapeIndices.Count; shp++)
                    {
                        if (!self.ShapeIndices[shp].Extent.Intersects(otherEnvelope))
                        {
                            continue;
                        }

                        IFeature selfFeature = self.GetFeature(shp);
                        selfFeature.Intersection(union, result, joinType);
                        pm.CurrentValue = shp;
                    }

                    pm.Reset();
                }
            }
            else if (joinType == FieldJoinType.ForeignOnly)
            {
                if (!other.AttributesPopulated)
                {
                    other.FillAttributes();
                }

                result = new FeatureSet();
                result.CopyTableSchema(other);
                result.FeatureType = other.FeatureType;
                if (self.Features != null && self.Features.Count > 0)
                {
                    pm = new ProgressMeter(progHandler, "Calculating Union", self.Features.Count);
                    IFeature union = self.Features[0];
                    for (int i = 1; i < self.Features.Count; i++)
                    {
                        union           = union.Union(self.Features[i].Geometry);
                        pm.CurrentValue = i;
                    }

                    pm.Reset();
                    if (other.Features != null)
                    {
                        pm = new ProgressMeter(progHandler, "Calculating Intersection", other.Features.Count);
                        for (int i = 0; i < other.Features.Count; i++)
                        {
                            other.Features[i].Intersection(union, result, FieldJoinType.LocalOnly);
                            pm.CurrentValue = i;
                        }
                    }

                    pm.Reset();
                }
            }

            return(result);
        }
        /// <summary>
        /// Returns the portions of the polygons in polySF that lie within polygon as a
        /// new shapefile of polygons: resultPolySF.
        /// </summary>
        /// <param name="polygonFeatureSet">The shapefile of polygons that are to be clipped.</param>
        /// <param name="polygon">The polygon used for clipping.</param>
        /// <param name="resultFeatureSet">The result shapefile for the resulting polygons to be saved (in-memory).</param>
        /// <param name="copyAttributes">True if copying attrs</param>
        /// <returns>False if an error was encountered, true otherwise.</returns>
        public static bool ClipPolygonFeatureSetWithPolygon(
            IFeatureSet polygonFeatureSet, IFeature polygon, IFeatureSet resultFeatureSet, bool copyAttributes)
        {
            if (copyAttributes)
            {
                polygonFeatureSet.FillAttributes();
                resultFeatureSet.CopyTableSchema(polygonFeatureSet);
            }

            if (polygonFeatureSet.Features.Count != 0 && polygon.NumPoints != 0
                && polygonFeatureSet.FeatureType == FeatureType.Polygon)
            {
                int numShapes = polygonFeatureSet.Features.Count;
                for (int i = 0; i <= numShapes - 1; i++)
                {
                    polygonFeatureSet.Features[i].Intersection(polygon, resultFeatureSet, FieldJoinType.LocalOnly);
                }
            }

            return true;
        }
Esempio n. 19
0
        /// <summary>
        /// This tests each feature of the input
        /// </summary>
        /// <param name="self">This featureSet</param>
        /// <param name="other">The featureSet to perform intersection with</param>
        /// <param name="joinType">The attribute join type</param>
        /// <param name="progHandler">A progress handler for status messages</param>
        /// <returns>An IFeatureSet with the intersecting features, broken down based on the join Type</returns>
        public static IFeatureSet Intersection(this IFeatureSet self, IFeatureSet other, FieldJoinType joinType, IProgressHandler progHandler)
        {
            IFeatureSet result = null;
            ProgressMeter pm = new ProgressMeter(progHandler, "Calculating Intersection", self.Features.Count);
            if (joinType == FieldJoinType.All)
            {
                result = CombinedFields(self, other);
                // Intersection is symmetric, so only consider I X J where J <= I
                if (!self.AttributesPopulated) self.FillAttributes();
                if (!other.AttributesPopulated) other.FillAttributes();
                int i = 0;
                foreach (IFeature selfFeature in self.Features)
                {
                    List<IFeature> potentialOthers = other.Select(selfFeature.Envelope.ToExtent());
                    foreach (IFeature otherFeature in potentialOthers)
                    {
                        selfFeature.Intersection(otherFeature, result, joinType);
                    }
                    pm.CurrentValue = i;
                    i++;
                }
                pm.Reset();
            }
            if (joinType == FieldJoinType.LocalOnly)
            {
                if (!self.AttributesPopulated) self.FillAttributes();

                result = new FeatureSet();
                result.CopyTableSchema(self);
                result.FeatureType = self.FeatureType;
                IFeature union;
                pm = new ProgressMeter(progHandler, "Calculating Union", other.Features.Count);
                if (other.Features != null && other.Features.Count > 0)
                {
                    union = other.Features[0];
                    for (int i = 1; i < other.Features.Count; i++)
                    {
                        union = union.Union(other.Features[i]);
                        pm.CurrentValue = i;
                    }
                    pm.Reset();
                    pm = new ProgressMeter(progHandler, "Calculating Intersections", self.NumRows());
                    Extent otherEnvelope = new Extent(union.Envelope);
                    for (int shp = 0; shp < self.ShapeIndices.Count; shp++)
                    {
                        if (!self.ShapeIndices[shp].Extent.Intersects(otherEnvelope)) continue;
                        IFeature selfFeature = self.GetFeature(shp);
                        selfFeature.Intersection(union, result, joinType);
                        pm.CurrentValue = shp;
                    }
                    pm.Reset();
                }
            }
            if (joinType == FieldJoinType.ForeignOnly)
            {
                if (!other.AttributesPopulated) other.FillAttributes();
                result = new FeatureSet();
                result.CopyTableSchema(other);
                IFeature union;
                if (self.Features != null && self.Features.Count > 0)
                {
                    pm = new ProgressMeter(progHandler, "Calculating Union", self.Features.Count);
                    union = self.Features[0];
                    for (int i = 1; i < self.Features.Count; i++)
                    {
                        union = union.Union(self.Features[i]);
                        pm.CurrentValue = i;
                    }
                    pm.Reset();
                    if (other.Features != null)
                    {
                        pm = new ProgressMeter(progHandler, "Calculating Intersection", other.Features.Count);
                        int j = 0;
                        foreach (IFeature otherFeature in other.Features)
                        {
                            IFeature test = otherFeature.Intersection(union, result, joinType);
                            if (test.BasicGeometry != null)
                            {
                                result.Features.Add(test);
                            }
                            pm.CurrentValue = j;
                            j++;
                        }
                    }
                    pm.Reset();
                }
            }
            return result;
        }
        /// <summary>
        /// Sets up the Table to work with the specified layer.  This should be the copy,
        /// and not the original.
        /// </summary>
        /// <param name="layer"></param>
        public void Initialize(IFeatureLayer layer)
        {
            _original = layer.Symbology;
            _newScheme = _original.Copy();
            _source = layer.DataSet;
            if (!layer.DataSet.AttributesPopulated)
            {
                if (layer.DataSet.NumRows() < 100000)
                {
                    _source.FillAttributes(); // for small datasets, it is better to just load and cache it.
                }
            }

            if (_source.AttributesPopulated)
            {
                _expressionDialog.Table = _source.DataTable;
            }
            else
            {
                _expressionDialog.AttributeSource = _source;
            }

            _schemeType = GetSchemeType(layer);

            if (_schemeType != SymbolizerType.Polygon)
            {
                chkUseGradients.Visible = false;
                angGradientAngle.Visible = false;
            }
            else
            {
                chkUseGradients.Visible = true;
                angGradientAngle.Visible = true;
            }
            if (_schemeType == SymbolizerType.Point)
            {
                IPointScheme ps = _newScheme as IPointScheme;

                if (ps != null)
                {
                    IPointSymbolizer sym;
                    if (ps.Categories.Count == 0 || ps.Categories[0].Symbolizer == null)
                    {
                        sym = new PointSymbolizer();
                    }
                    else
                    {
                        sym = ps.Categories[0].Symbolizer;
                    }
                    _ignoreRefresh = true;
                    featureSizeRangeControl1.SizeRange = new FeatureSizeRange(sym, _newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize);
                    featureSizeRangeControl1.Initialize(new SizeRangeEventArgs(_newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize, sym, _newScheme.EditorSettings.UseSizeRange));
                    featureSizeRangeControl1.Scheme = ps;
                    featureSizeRangeControl1.Visible = true;
                    _ignoreRefresh = false;
                }
            }
            else if (_schemeType == SymbolizerType.Line)
            {
                ILineScheme ls = _newScheme as ILineScheme;
                if (ls != null)
                {
                    ILineSymbolizer sym;
                    if (ls.Categories.Count == 0 || ls.Categories[0].Symbolizer == null)
                    {
                        sym = new LineSymbolizer();
                    }
                    else
                    {
                        sym = ls.Categories[0].Symbolizer;
                    }
                    _ignoreRefresh = true;
                    featureSizeRangeControl1.SizeRange = new FeatureSizeRange(sym, _newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize);
                    featureSizeRangeControl1.Initialize(new SizeRangeEventArgs(_newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize, sym, _newScheme.EditorSettings.UseSizeRange));
                    featureSizeRangeControl1.Scheme = ls;
                    featureSizeRangeControl1.Visible = true;
                    _ignoreRefresh = false;
                }
            }
            else
            {
                featureSizeRangeControl1.Visible = false;
            }

            UpdateFields();
            if (_newScheme.EditorSettings.ClassificationType != ClassificationType.Quantities) return;
            nudCategoryCount.Enabled = true;
            tabScheme.Visible = true;
            dgvCategories.Height = 217;
            UpdateStatistics(false, null);
        }