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); }
/// <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))); } }
/// <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; } }
/// <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); }
/// <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))); }
/// <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); }
private void WriterRecords(IFeatureList featureList) { int offset = 100; foreach (var feature in featureList) { var curContentLength = GetRecordLength(feature); WriterRecord(offset, curContentLength); offset += curContentLength; } }
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); }
/// <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); }
/// <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; }
/// <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(); }
/// <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); }
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. }
/// <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. }
/// <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; }
/// <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); }
/// <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(); } }
/// <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(); } }
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(); }