当前位置: 首页>>代码示例>>C#>>正文


C# Data.FeatureSet类代码示例

本文整理汇总了C#中DotSpatial.Data.FeatureSet的典型用法代码示例。如果您正苦于以下问题:C# FeatureSet类的具体用法?C# FeatureSet怎么用?C# FeatureSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FeatureSet类属于DotSpatial.Data命名空间,在下文中一共展示了FeatureSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Project

 public static IGeometry Project(IGeometry geometry, ProjectionInfo pStart, ProjectionInfo pEnd)
 {
     var featureSet = new FeatureSet();
     featureSet.AddFeature(geometry.ToDotSpatial());
     featureSet.Projection = pStart;
     featureSet.Reproject(pEnd);
     return
         GeometryConverter.ToGeoAPI(
             ((featureSet.Features[0].BasicGeometry as DotSpatial.Topology.IGeometry)));
 }
开发者ID:shaahink,项目名称:GeoToolkit,代码行数:10,代码来源:GeoJsonHelper.cs

示例2: Buffer

        /// <summary>
        /// Creates a new polygon featureset that is created by buffering each of the individual shapes.
        /// </summary>
        /// <param name="self">The IFeatureSet to buffer</param>
        /// <param name="distance">The double distance to buffer</param>
        /// <param name="copyAttributes">Boolean, if this is true, then the new featureset will have
        /// the same attributes as the original.</param>
        /// <returns>The newly created IFeatureSet</returns>
        public static IFeatureSet Buffer(this IFeatureSet self, double distance, bool copyAttributes)
        {
            // Dimension the new, output featureset.  Buffered shapes are polygons, even if the
            // original geometry is a point or a line.
            IFeatureSet result = new FeatureSet(FeatureType.Polygon);

            result.CopyTableSchema(self);
            result.Projection = self.Projection;
            // Cycle through the features, and buffer each one separately.
            foreach (IFeature original in self.Features)
            {
                // Actually calculate the buffer geometry.
                IFeature buffer = original.Buffer(distance);

                // Add the resulting polygon to the featureset
                result.Features.Add(buffer);

                // If copyAttributes is true, then this will copy those attributes from the original.
                if (copyAttributes)
                {
                    // Accessing the attributes should automatically load them from the datasource if
                    // they haven't been loaded already.
                    buffer.CopyAttributes(original);
                }
            }
            return result;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:35,代码来源:FeatureSetExt.cs

示例3: RandomPoints

 /// <summary>
 /// Creates a specified number of random point features inside a single polygon feature. 
 /// </summary>
 /// <param name="ConstrainingFeature">Random points will be generated inside this polygon feature.</param>
 /// <param name="NumberOfPoints">The number of points to be randomly generated.</param>
 /// <returns>A point feature set with the randomly created features.</returns>
 public static FeatureSet RandomPoints(Feature ConstrainingFeature, int NumberOfPoints)
 {
     //This function generates random points within the boundaries of one polygon feature
     FeatureSet fsOut = new FeatureSet();
     fsOut.FeatureType = FeatureType.Point;
     Coordinate c = new Coordinate();
     Random r = new Random();
     int i = 0;
     while (i < NumberOfPoints)
     {
         c = new Coordinate();
         //make a random point somewhere in the rectangular extents of the feature
         double rndx = r.Next(0, 100000) / 100000.0;
         double rndy = r.Next(0, 100000) / 100000.0;
         c.X = rndx * (ConstrainingFeature.Envelope.Right() - ConstrainingFeature.Envelope.Left()) + ConstrainingFeature.Envelope.Left();
         c.Y = rndy * (ConstrainingFeature.Envelope.Top() - ConstrainingFeature.Envelope.Bottom()) + ConstrainingFeature.Envelope.Bottom();
         //check if the point falls within the polygon featureset
         if (ConstrainingFeature.Intersects(c))
         {
             fsOut.AddFeature(new Feature(c));
             i++;
         }
     }
     return fsOut;
 }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:31,代码来源:RandomGeometry.cs

示例4: CreateFromFeatureSet

        public void CreateFromFeatureSet(FeatureSet fs, string imgField, string OnCLickFiled,string aRefField, string OnMouseOverField, string OnMouseOutField, string dxField, string dyField)
        {

            SetMarkNumber(fs.Features.Count);

            int i = 0;

            foreach (Feature f in fs.Features)
            {
                if (f.Coordinates.Count>0)
                {
                    _crds[i] = f.Coordinates[0];
                    _imgs[i] = Convert.ToString(f.DataRow[imgField]);
                    
                    if (OnCLickFiled != "" & OnCLickFiled != null) _OnClick[i] = Convert.ToString(f.DataRow[OnCLickFiled]);
                    if (aRefField != "" & aRefField != null) _aRef[i] = Convert.ToString(f.DataRow[aRefField]);
                    if (OnMouseOverField != "" & OnMouseOverField != null) _OnMouseOver[i] = Convert.ToString(f.DataRow[OnMouseOverField]);
                    if (OnMouseOutField != "" & OnMouseOutField != null) _OnMouseOut[i] = Convert.ToString(f.DataRow[OnMouseOutField]);

                    _dxy[i].X = Convert.ToInt32(f.DataRow[dxField]);
                    _dxy[i].Y = Convert.ToInt32(f.DataRow[dyField]);
                }

                i++;
            }

        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:27,代码来源:WebMarkers.cs

示例5: ClassifyPoint

        public PointClassification ClassifyPoint(double latitude, double longitude)
        {
            FeatureSet pFeatureSet = new FeatureSet();
            pFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;

            DotSpatial.Topology.Point pPoint = new DotSpatial.Topology.Point(longitude, latitude);
            FeatureSet pPointFeatureSet = new FeatureSet(DotSpatial.Topology.FeatureType.Point);
            pPointFeatureSet.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
            pPointFeatureSet.AddFeature(pPoint);

            Extent pAffectedExtent = null;
            var result = fsWorldCountries.Select(pPointFeatureSet.Extent, out pAffectedExtent);

            foreach (IFeature feature in result)
            {
                PointClassification classification = new PointClassification();
                classification.CountryCode = feature.DataRow["ADM0_A3"].ToString();
                if (classification.CountryCode.Length == 3) classification.CountryCode = ConvertISOCountryCode(classification.CountryCode);
                classification.CountrySubdivision = feature.DataRow["NAME"].ToString();
                classification.CountryName = feature.DataRow["ADMIN"].ToString();
                return classification;
            }

            return null;
            // System.Diagnostics.Debug.WriteLine(featureL);
        }
开发者ID:solarpete,项目名称:ocm-system,代码行数:26,代码来源:SpatialAnalysis.cs

示例6: CombinedFields

 /// <summary>
 /// Generates an empty featureset that has the combined fields from this featureset
 /// and the specified featureset.
 /// </summary>
 /// <param name="self">This featureset</param>
 /// <param name="other">The other featureset to combine fields with.</param>
 /// <returns></returns>
 public static IFeatureSet CombinedFields(this IFeatureSet self, IFeatureSet other)
 {
     IFeatureSet result = new FeatureSet(self.FeatureType);
     Dictionary<string, DataColumn> resultColumns = new Dictionary<string, DataColumn>();
     foreach (DataColumn dc in self.DataTable.Columns)
     {
         string name = dc.ColumnName;
         int i = 1;
         while (resultColumns.ContainsKey(name))
         {
             name = dc.ColumnName + i;
             i++;
         }
         resultColumns.Add(name, dc);
     }
     foreach (DataColumn dc in other.DataTable.Columns)
     {
         string name = dc.ColumnName;
         int i = 1;
         while (resultColumns.ContainsKey(name))
         {
             name = dc.ColumnName + i;
             i++;
         }
         resultColumns.Add(name, dc);
     }
     foreach (KeyValuePair<string, DataColumn> pair in resultColumns)
     {
         result.DataTable.Columns.Add(new DataColumn(pair.Key, pair.Value.DataType));
     }
     return result;
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:39,代码来源:FeatureSetExt.cs

示例7: LineFeatureSetParam

 /// <summary>
 /// Creates a new Line Feature Set parameter
 /// </summary>
 /// <param name="name">The name of the parameter</param>
 public LineFeatureSetParam(string name)
 {
     Name = name;
     Value = new FeatureSet();
     ParamVisible = ShowParamInModel.Always;
     ParamType = "DotSpatial LineFeatureSet Param";
     DefaultSpecified = false;
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:12,代码来源:LineFeatureSetParam.cs

示例8: AppendFeatures

 /// <summary>
 /// Add the features from SourceFeatures to the TargetFeatures feature set. 
 /// </summary>
 /// <param name="TargetFeatures">Feature set to which features will be added.</param>
 /// <param name="SourceFeatures">Source of features to add to the target feature set. </param>
 /// <returns>A point feature set with the randomly created features.</returns>
 public static FeatureSet AppendFeatures(FeatureSet TargetFeatures, FeatureSet SourceFeatures)
 {
     //Add the features from SourceFeatures to the TargetFeatures feature set
     //Note: we use the ShapeIndices here rather than for each feature in featureset.features as a memory management technique.
     //Dan Ames 2/27/2013
     IFeature SF;
     for (Int16 j = 0; j <= SourceFeatures.ShapeIndices.Count - 1; j++)
     {
         SF = SourceFeatures.GetFeature(j);
         TargetFeatures.AddFeature(SF).CopyAttributes(SourceFeatures.GetFeature(j));   //by default this will try to copy attributes over that have the same name.
     }
     return TargetFeatures;
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:19,代码来源:Overlay.cs

示例9: GetAttributes_WithFieldNames

        public void GetAttributes_WithFieldNames()
        {
            var fs = new FeatureSet(FeatureType.Point);
            fs.DataTable.Columns.Add("Column1");
            fs.DataTable.Columns.Add("Column2");
            fs.AddFeature(new Point(0, 0));

            var fl = new PointLayer(fs);

            var target = new IndexSelection(fl);
            var attributesTable = target.GetAttributes(0, 1, new[] {"Column1"});
            Assert.AreEqual(1, attributesTable.Columns.Count);
            Assert.AreEqual("Column1", attributesTable.Columns[0].ColumnName);
        }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:14,代码来源:IndexSelectionTests.cs

示例10: DelaunayLines

 /// <summary>
 /// The Voronoi Graph calculation creates a delaunay tesselation where
 /// each point is effectively converted into triangles.
 /// </summary>
 /// <param name="points">The points to use for creating the tesselation.</param>
 /// <returns>The generated line featureset.</returns>
 public static IFeatureSet DelaunayLines(IFeatureSet points)
 {
     double[] vertices = points.Vertex;
     VoronoiGraph gp = Fortune.ComputeVoronoiGraph(vertices);
     FeatureSet result = new FeatureSet();
     foreach (VoronoiEdge edge in gp.Edges)
     {
         Coordinate c1 = edge.RightData.ToCoordinate();
         Coordinate c2 = edge.LeftData.ToCoordinate();
         LineString ls = new LineString(new List<Coordinate> { c1, c2 });
         Feature f = new Feature(ls);
         result.AddFeature(f);
     }
     return result;
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:21,代码来源:Voronoi.cs

示例11: Project

 public static System.Data.Entity.Spatial.DbGeometry Project(System.Data.Entity.Spatial.DbGeometry source,
     ProjectionInfo pStart, ProjectionInfo pEnd)
 {
     var wkt = source.WellKnownValue.WellKnownText;
     var wktReader = new WKTReader();
     var geometry = wktReader.Read(wkt);
     var featureSet = new FeatureSet();
     featureSet.Features.Add(geometry.ToDotSpatial());
     featureSet.Projection = pStart;
     featureSet.Reproject(pEnd);
     var projected =
         (featureSet.Features.First().BasicGeometry as IGeometry).ToGeoAPI();
     var wktWriter = new WKTWriter();
     var projectedWkt = wktWriter.Write(projected);
     return System.Data.Entity.Spatial.DbGeometry.FromText(projectedWkt);
 }
开发者ID:shaahink,项目名称:GeoToolkit,代码行数:16,代码来源:DbGeometryHelper.cs

示例12: VoronoiLines

        /// <summary>
        /// The Voronoi Graph calculation creates the lines that form a voronoi diagram.
        /// </summary>
        /// <param name="points">The points to use for creating the tesselation.</param>
        /// <returns>An IFeatureSet that is the resulting set of lines in the diagram.</returns>
        public static IFeatureSet VoronoiLines(IFeatureSet points)
        {
            double[] vertices = points.Vertex;
            VoronoiGraph gp = Fortune.ComputeVoronoiGraph(vertices);

            HandleBoundaries(gp, points.Extent.ToEnvelope());

            FeatureSet result = new FeatureSet();
            foreach (VoronoiEdge edge in gp.Edges)
            {
                Coordinate c1 = edge.VVertexA.ToCoordinate();
                Coordinate c2 = edge.VVertexB.ToCoordinate();
                LineString ls = new LineString(new List<Coordinate> { c1, c2 });
                Feature f = new Feature(ls);
                result.AddFeature(f);
            }
            return result;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:23,代码来源:Voronoi.cs

示例13: backgroundWorker1_DoWork

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            changeButtonStatus(false);

            if (!string.IsNullOrEmpty(textBox1.Text))
            {

                Feature f = new Feature();
                fs = new FeatureSet(f.FeatureType);

                var dataTable = new DataTable();

                dataTable.Columns.Add(new DataColumn("X", typeof(double)));
                dataTable.Columns.Add(new DataColumn("Y", typeof(double)));
                dataTable.Columns.Add(new DataColumn("Z", typeof(double)));

                for (int i = 0; i < textBox1.Lines.Length; i++)
                {
                    var data = textBox1.Lines[i].Split(',').Where(c => !string.IsNullOrEmpty(c))
                        .Select(c => Convert.ToDouble(c)).ToArray();

                    if (data.Length == 3)
                    {
                        var c = new Coordinate(data);
                        //var c = new Coordinate(Convert.ToDouble(data[0]), Convert.ToDouble(data[1]), Convert.ToDouble(data[2]));
                        fs.Features.Add(c);

                        dataTable.Rows.Add(data[0],data[1],data[2]);
                    }

                    backgroundWorker1.ReportProgress((i + 1));

                }


                dataTable.TableName = "ImportData";
                fs.DataTable = dataTable;
                fs.Name = "Imported Data";
            }

            changeButtonStatus(true);
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:42,代码来源:ImportXYZForm.cs

示例14: EraseFeatures

        /// <summary>
        /// Erase features from one feature set where they are intersected by another feature set. 
        /// </summary>
        /// <param name="TargetFeatures">Features which will be erased in part or whole.</param>
        /// <param name="SourceFeatures">Features which represent areas to erase.</param>
        /// <param name="cancelProgressHandler">Optional parameter to report progress and cancel entire process if needed.</param>
        /// <returns>A point feature set with the randomly created features.</returns>
        public static FeatureSet EraseFeatures(IFeatureSet TargetFeatures, IFeatureSet SourceFeatures, ICancelProgressHandler cancelProgressHandler = null)
        {
            if (TargetFeatures == null || SourceFeatures == null)
            {
                return null;
            }
            //Erase features from one feature set where they are intersected by another feature set
            //Note: we use the ShapeIndices here rather than for each feature in featureset.features as a memory management technique.
            //The current version does not preserve any attribute info. 
            //Dan Ames 2/27/2013
            FeatureSet ResultFeatures = new FeatureSet();                   //the resulting featureset
            IFeature TF, SF;                                                //a single output feature
            ResultFeatures.CopyTableSchema(TargetFeatures);                 //set up the data table in the new feature set

            for (Int16 i = 0; i <= TargetFeatures.ShapeIndices.Count - 1; i++)
            {
                TF = TargetFeatures.GetFeature(i);                          //get the full undifferenced feature
                for (Int16 j = 0; j <= SourceFeatures.ShapeIndices.Count - 1; j++)
                {
                    SF = SourceFeatures.GetFeature(j);
                    if (SF.Envelope.Intersects(TF.Envelope))
                    {
                        TF = TF.Difference(SF);                             //clip off any pieces of SF that overlap FR
                    }
                    if (TF == null)
                    {                                                       //sometimes difference leaves nothing left of a feature
                        break;
                    }
                }
                if (TF != null)
                {
                    ResultFeatures.AddFeature(TF).CopyAttributes(TargetFeatures.GetFeature(i));  //add the fully clipped feature to the results
                }
                if (cancelProgressHandler != null)
                {
                    if (cancelProgressHandler.Cancel) { return null; }
                    int progress = Convert.ToInt32(i * 100 / TargetFeatures.ShapeIndices.Count);
                    cancelProgressHandler.Progress(String.Empty, progress, String.Empty);
                }
            }
            return ResultFeatures;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:49,代码来源:Overlay.cs

示例15: CreatefilterFeatureSet

        private IFeatureSet CreatefilterFeatureSet()
        { 
            IFeatureSet  data1 = new FeatureSet(FeatureType.Point);
            data1.Projection = _originalData.Projection;
            data1.DataTable.Columns.Add(new System.Data.DataColumn(this.Field, typeof(double)));
            data1.DataTable.Columns.Add(new System.Data.DataColumn("Repeat", typeof(string)));
            List<int> listt = _originalData.SelectIndexByAttribute(Filterfields);
           


            foreach (int index in listt)
            {
                IFeature fea1 = _originalData.GetFeature(index);
                IFeature d=data1.AddFeature((IBasicGeometry)fea1);
                d.DataRow[this.Field] = fea1.DataRow[this.Field];
            }


            return data1;
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:20,代码来源:CheckDataInputFilter.cs


注:本文中的DotSpatial.Data.FeatureSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。