Пример #1
0
 private void Configure(IFeatureList features, IFeatureScheme scheme)
 {
     _featureList = features;
     _scheme      = scheme;
     //features.FeatureAdded += new EventHandler<FeatureEventArgs>(features_FeatureAdded);
     //features.FeatureRemoved += new EventHandler<FeatureEventArgs>(features_FeatureRemoved);
 }
Пример #2
0
 /// <summary>
 /// If the feature type is specified, then this will automatically generate a new feature from the specified coordinates.
 /// This will not work unless the featuretype is specified.
 /// </summary>
 /// <param name="self">This IFeatureList</param>
 /// <param name="points">
 /// The list or array of coordinates to build into a new feature.
 /// If the feature type is point, then this will create separate features for each coordinate.
 /// For polygons, all the points will be assumed to be in the shell.
 /// </param>
 /// <exception cref="UnspecifiedFeaturetypeException">Thrown if the current FeatureType for the shapefile is unspecified.</exception>
 public static void Add(this IFeatureList self, IEnumerable <Coordinate> points)
 {
     if (self.Parent.FeatureType == FeatureType.Unspecified)
     {
         throw new UnspecifiedFeaturetypeException();
     }
     if (self.Parent.FeatureType == FeatureType.Point)
     {
         self.SuspendEvents();
         foreach (Coordinate point in points)
         {
             self.Add(new Feature(new Point(point)));
         }
         self.ResumeEvents();
     }
     if (self.Parent.FeatureType == FeatureType.Line)
     {
         self.Add(new Feature(new LineString(points)));
     }
     if (self.Parent.FeatureType == FeatureType.Polygon)
     {
         self.Add(new Feature(new Polygon(points)));
     }
     if (self.Parent.FeatureType == FeatureType.MultiPoint)
     {
         self.Add(new Feature(new MultiPoint(points)));
     }
 }
Пример #3
0
        /// <summary>
        /// If the feature type is specified, then this will automatically generate a new feature from the specified coordinates.
        /// This will not work unless the featuretype is specified.
        /// </summary>
        /// <param name="self">This IFeatureList</param>
        /// <param name="points">
        /// The list or array of coordinates to build into a new feature.
        /// If the feature type is point, then this will create separate features for each coordinate.
        /// For polygons, all the points will be assumed to be in the shell.
        /// </param>
        /// <exception cref="UnspecifiedFeaturetypeException">Thrown if the current FeatureType for the shapefile is unspecified.</exception>
        public static void Add(this IFeatureList self, IEnumerable <Coordinate> points)
        {
            switch (self.Parent.FeatureType)
            {
            case FeatureType.Unspecified:
                throw new UnspecifiedFeaturetypeException();

            case FeatureType.Point:
                self.SuspendEvents();
                foreach (Coordinate point in points)
                {
                    self.Add(new Feature(new Point(point)));
                }

                self.ResumeEvents();
                break;

            case FeatureType.Line:
                self.Add(new Feature(new LineString(points as Coordinate[])));
                break;

            case FeatureType.Polygon:
                self.Add(new Feature(new Polygon(new LinearRing(points as Coordinate[]))));
                break;

            case FeatureType.MultiPoint:
                self.Add(new Feature(new MultiPoint(points.CastToPointArray())));
                break;
            }
        }
Пример #4
0
 private void Configure(IFeatureList features, IFeatureScheme scheme)
 {
     _featureList = features;
     _scheme = scheme;
     //features.FeatureAdded += new EventHandler<FeatureEventArgs>(features_FeatureAdded);
     //features.FeatureRemoved += new EventHandler<FeatureEventArgs>(features_FeatureRemoved);
 }
Пример #5
0
 /// <summary>
 /// This adds the coordinates and specifies what sort of feature type should be added.
 /// </summary>
 /// <param name="self">This IFeatureList</param>
 /// <param name="points">The list or array of coordinates to be added after it is built into the appropriate feature.</param>
 /// <param name="featureType">The feature type.</param>
 public static void Add(this IFeatureList self, IEnumerable <Coordinate> points, FeatureType featureType)
 {
     if (self.Parent.FeatureType == FeatureType.Unspecified)
     {
         self.Parent.FeatureType = featureType;
     }
     self.Add(points);
 }
Пример #6
0
 /// <summary>
 /// adding a single coordinate will assume that the feature type should be point for this featureset, even
 /// if it has not already been specified.
 /// </summary>
 /// <param name="self">This IFeatureList</param>
 /// <param name="point">The point to add to the featureset</param>
 /// <exception cref="FeatureTypeMismatchException">Thrown when the feature type already exists, there are already features in the featureset and the featuretype is not equal to point.</exception>
 public static void Add(this IFeatureList self, Coordinate point)
 {
     if (self.Parent.FeatureType != FeatureType.Point && self.Count > 0)
     {
         throw new FeatureTypeMismatchException();
     }
     self.Parent.FeatureType = FeatureType.Point;
     self.Add(new Feature(new Point(point)));
 }
Пример #7
0
        /// <summary>
        /// This method will attempt to add the specified geometry to the list.
        /// If the feature type is currently unspecified, this will specify the feature type.
        /// </summary>
        /// <param name="self">This feature list</param>
        /// <param name="geometry">The geometry to create a new feature from.</param>
        /// <exception cref="FeatureTypeMismatchException">Thrown if the new geometry does not match the currently specified feature type.  </exception>
        public static void Add(this IFeatureList self, IBasicGeometry geometry)
        {
            Feature f = new Feature(geometry);

            if (f.FeatureType != self.Parent.FeatureType && self.Parent.FeatureType != FeatureType.Unspecified)
            {
                throw new FeatureTypeMismatchException();
            }
            self.Add(f);
        }
Пример #8
0
        private void WriterRecords(IFeatureList featureList)
        {
            int offset = 100;

            foreach (var feature in featureList)
            {
                var curContentLength = GetRecordLength(feature);
                WriterRecord(offset, curContentLength);
                offset += curContentLength;
            }
        }
Пример #9
0
        private static bool IsPointInShape(Coordinate point, IFeatureList features)
        {
            foreach (var feature in features)
            {
                if (!PointInBoundingBox(point, feature.Coordinates))
                {
                    continue;
                }
                if (PointInPolygon(point, feature.Coordinates.ToArray()))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #10
0
 /// <summary>
 /// Creates a new instance of DrawingFilter without using any chunks.  The use chunks
 /// value will be false, and sub-categories will not be selected based on the chunk.
 /// </summary>
 public DrawingFilter(IFeatureList features, IFeatureScheme scheme)
 {
     _useChunks = false;
     _chunkSize = -1;
     Configure(features, scheme);
 }
Пример #11
0
        /// <summary>
        /// Occurs when setting the feature list, allowing events to be connected
        /// </summary>
        /// <param name="features">
        /// </param>
        protected virtual void OnIncludeFeatures(IFeatureList features)
        {
            if (features == null) return;

            features.FeatureAdded += FeaturesFeatureAdded;
            features.FeatureRemoved += FeaturesFeatureRemoved;
        }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeatureSet"/> class.
 /// This doesn't do anything exactly because there is no file-specific information yet
 /// </summary>
 public FeatureSet()
 {
     IndexMode = false; // this is false unless we are loading it from a specific shapefile case.
     _featureLookup = new Dictionary<DataRow, IFeature>();
     _features = new FeatureList(this);
     _features.FeatureAdded += FeaturesFeatureAdded;
     _features.FeatureRemoved += FeaturesFeatureRemoved;
     _dataTable = new DataTable();
 }
Пример #13
0
 /// <summary>
 /// Creates a new instance of DrawingFilter, sub-dividing the features into chunks.
 /// regardless of selection or category, chunks simply subdivide the filter
 /// into chunks of equal size.
 /// </summary>
 public DrawingFilter(IFeatureList features, IFeatureScheme scheme, int chunkSize)
 {
     _useChunks = true;
     _chunkSize = chunkSize;
     Configure(features, scheme);
 }
Пример #14
0
 protected void FeaturesFromVertices()
 {
     _features = new FeatureList(this);
     _features.IncludeAttributes = false; // load these on demand later.
     _features.SuspendEvents();
     for (int shp = 0; shp < ShapeIndices.Count; shp++)
     {
         _features.Add(GetFeature(shp));
     }
     _features.ResumeEvents();
     _features.IncludeAttributes = true; // from this point on, any features that get added will also add a datarow to the data-Table.
 }
Пример #15
0
        /// <summary>
        /// Calculates the features from the shape indices and vertex array
        /// </summary>
        protected void FeaturesFromVertices()
        {
            if (_features == null)
            {
                _features = new FeatureList(this) { IncludeAttributes = false };
            }
            else
            {
                // need to preserve event handler already attached to this feature list
                _features.Clear();
                _features.IncludeAttributes = false;
            }

            _features.SuspendEvents();
            for (int shp = 0; shp < ShapeIndices.Count; shp++)
            {
                _features.Add(GetFeature(shp));
                if (AttributesPopulated)
                {
                    // Don't force population if we haven't populated yet, but
                    // definitely assign the DataRow if it already exists.
                    _features[shp].DataRow = DataTable.Rows[shp];
                }
            }

            _features.ResumeEvents();
            _features.IncludeAttributes = true;

            // from this point on, any features that get added will also add a DataRow to the DataTable.
        }
Пример #16
0
 /// <summary>
 /// Creates a new instance of DrawingFilter, sub-dividing the features into chunks.
 /// regardless of selection or category, chunks simply subdivide the filter
 /// into chunks of equal size.
 /// </summary>
 public DrawingFilter(IFeatureList features, IFeatureScheme scheme, int chunkSize)
 {
     _useChunks = true;
     _chunkSize = chunkSize;
     Configure(features, scheme);
 }
Пример #17
0
 /// <summary>
 /// Occurs when removing the feature list, allowing events to be disconnected
 /// </summary>
 /// <param name="features"></param>
 protected virtual void OnExcludeFeatures(IFeatureList features)
 {
     if (_features == null) return;
     _features.FeatureAdded -= FeaturesFeatureAdded;
     _features.FeatureRemoved -= FeaturesFeatureRemoved;
 }
Пример #18
0
 /// <summary>
 /// Creates a new instance of DrawingFilter without using any chunks.  The use chunks
 /// value will be false, and sub-categories will not be selected based on the chunk.
 /// </summary>
 public DrawingFilter(IFeatureList features, IFeatureScheme scheme)
 {
     _useChunks = false;
     _chunkSize = -1;
     Configure(features, scheme);
 }
Пример #19
0
        /// <summary>
        /// Disposes the unmanaged memory objects.
        /// </summary>
        /// <param name="disposeManagedResources">If this is true, managed resources are set to null.</param>
        protected override void Dispose(bool disposeManagedResources)
        {
            if (disposeManagedResources)
            {
                _features = null;
                Filename = null;
                _m = null;
                _shapeIndices = null;
                _vertices = null;
                _z = null;
            }
            if (_dataTable != null)
                _dataTable.Dispose();

            base.Dispose(disposeManagedResources);
        }
Пример #20
0
 /// <summary>
 /// Creates a new FeatureSet using a given list of IFeatures.
 /// This will copy the existing features, rather than removing
 /// them from their parent feature set.
 /// </summary>
 /// <param name="inFeatures">The list of IFeatures</param>
 public FeatureSet(IList<IFeature> inFeatures)
 {
     _progressHandler = Components.DataManager.DefaultDataManager.ProgressHandler;
     _progressMeter = new ProgressMeter(_progressHandler);
     _dataTable = new DataTable();
     _dataTable.RowDeleted += DataTableRowDeleted;
     
     if (inFeatures.Count > 0)
     {
         FeatureType = inFeatures[0].FeatureType;
     }
     _features = new FeatureList(this);
     if (inFeatures.Count > 0)
     {
         if (inFeatures[0].ParentFeatureSet != null)
         {
             CopyTableSchema(inFeatures[0].ParentFeatureSet);
         }
         else
         {
             if (inFeatures[0].DataRow != null)
             {
                 CopyTableSchema(inFeatures[0].DataRow.Table);
             }
         }
         _features.SuspendEvents(); 
         foreach (IFeature f in inFeatures)
         {
             IFeature myFeature = f.Copy();
             _features.Add(myFeature);
         }
         _features.ResumeEvents();
     }
 }
Пример #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FeatureSet"/> class.
        /// Creates a new FeatureSet using a given list of IFeatures.
        /// This will copy the existing features, rather than removing
        /// them from their parent feature set.
        /// </summary>
        /// <param name="inFeatures">
        /// The list of IFeatures
        /// </param>
        public FeatureSet(IList<IFeature> inFeatures)
            : this()
        {
            _dataTable = new DataTable();
            _dataTable.RowDeleted += DataTableRowDeleted;

            if (inFeatures.Count > 0)
            {
                FeatureType = inFeatures[0].FeatureType;
            }

            _features = new FeatureList(this);
            if (inFeatures.Count > 0)
            {
                if (inFeatures[0].ParentFeatureSet != null)
                {
                    CopyTableSchema(inFeatures[0].ParentFeatureSet);
                }
                else
                {
                    if (inFeatures[0].DataRow != null)
                    {
                        CopyTableSchema(inFeatures[0].DataRow.Table);
                    }
                }

                _features.SuspendEvents();
                foreach (IFeature f in inFeatures)
                {
                    IFeature myFeature = f.Copy();
                    _features.Add(myFeature);
                }

                _features.ResumeEvents();
            }
        }
Пример #22
0
 private void Configure()
 {
     _indexMode = false; // this is false unless we are loading it from a specific shapefile case.
     _featureLookup = new Dictionary<DataRow, IFeature>();
     _progressHandler = Components.DataManager.DefaultDataManager.ProgressHandler;
     _progressMeter = new ProgressMeter(_progressHandler);
     _features = new FeatureList(this);
     _features.FeatureAdded += FeaturesFeatureAdded;
     _features.FeatureRemoved += FeaturesFeatureRemoved;
     _dataTable = new DataTable();
 }