Class InMemoryFeatureLayer
This layer is backed by memory and is typically used for temporary features.
public class InMemoryFeatureLayer : FeatureLayer
- Inheritance
-
InMemoryFeatureLayer
- Inherited Members
Remarks
This layer is backed by memory and is typically used for temporary features. You can use the MapShapes layer for user-drawn InternalFeatures, InternalFeatures that come from an external device such as a GPS unit, or any InternalFeatures that are not saved to disk or a database.
Constructors
InMemoryFeatureLayer()
This is a constructor for the class.
public InMemoryFeatureLayer()
Remarks
If you use this constructor, then you need to specify the FeatureSource column manually.
InMemoryFeatureLayer(IEnumerable<FeatureSourceColumn>)
public InMemoryFeatureLayer(IEnumerable<FeatureSourceColumn> featureSourceColumns)
Parameters
featureSourceColumns
IEnumerable<FeatureSourceColumn>
InMemoryFeatureLayer(IEnumerable<FeatureSourceColumn>, IEnumerable<BaseShape>)
This is a constructor for the class.
public InMemoryFeatureLayer(IEnumerable<FeatureSourceColumn> featureSourceColumns, IEnumerable<BaseShape> shapes)
Parameters
featureSourceColumns
IEnumerable<FeatureSourceColumn>This parameter is the in this class that you want to use.
shapes
IEnumerable<BaseShape>This parameter represents the shapes in this class that you want to use.
Remarks
This constructor gets the layer ready to use.
InMemoryFeatureLayer(IEnumerable<FeatureSourceColumn>, IEnumerable<Feature>)
This is a constructor for the class.
public InMemoryFeatureLayer(IEnumerable<FeatureSourceColumn> featureSourceColumns, IEnumerable<Feature> features)
Parameters
featureSourceColumns
IEnumerable<FeatureSourceColumn>This parameter is the FeatureSourceColumn in this class that you want to use.
features
IEnumerable<Feature>This parameter represents the features in this class that you want to use.
Remarks
This constructor gets the layer ready to use.
Properties
Columns
This property gets the columns of data for the InternalFeatures in this Layer.
public Collection<FeatureSourceColumn> Columns { get; }
Property Value
Remarks
You should set the column names for the data that the InternalFeatures will hold. For example, if you have some features that represent road signs, then one column you may want to add is "Sign Type". Then, for every Feature you add to the layer, you need to add the "Sign Type" and a value to the InternalFeatures' ColumnValues dictionary. If you provide this information, then you can use things like ValueStyles, Labeling, etc. based on the columns you have defined.
HasBoundingBox
This property checks to see if a Layer has a BoundingBox or not. If it has no BoundingBox, it will throw an exception when you call the GetBoundingBox() and GetFullExtent() APIs. In InMemoryFeatureLayer, we override this API and mark it as true.
public override bool HasBoundingBox { get; }
Property Value
Remarks
The default implementation in the base class returns false.
InternalFeatures
This property gets the dictionary that holds your InternalFeatures.
public GeoCollection<Feature> InternalFeatures { get; }
Property Value
Remarks
The dictionary is a quick way to access your InternalFeatures. You can easily add, remove or edit features in this dictionary and they instantly take effect in the layer. You can always use the EditTools to do the same thing, but this is a shortcut, as the data is backed in memory so it is very pliable.
Methods
BuildIndex()
This method build a spatial index for a passed group of featurs which increases access speed.
public void BuildIndex()
Clear()
This method will clear all the features included in the feature source.
public void Clear()
Exceptions
- InvalidOperationException
If you attempt to call this method on a feature source which is in a transaction, it will throw an InvalidOperationException.
- InvalidOperationException
If you attempt to call this method on a feature source which is not opened, it will throw an InvalidOperationException.
GetColumns()
This method returns the columns of data for the InternalFeatures in this Layer.
public Collection<FeatureSourceColumn> GetColumns()
Returns
Remarks
You should set the column names for the data that the InternalFeatures will hold. For example, if you have some features that represent road signs, then one column you may want to add is "Sign Type". Then, for every Feature you add to the layer, you need to add the "Sign Type" and a value to the InternalFeatures' ColumnValues dictionary. If you provide this information, then you can use things like ValueStyles, Labeling, etc. based on the columns you have defined.
OpenCore()
This method opens the Layer so that it is initialized and ready to use.
protected override void OpenCore()
Remarks
This abstract method is called from the concrete public method Open. The open
method plays an important role, as it is responsible for initializing the Layer. Most
methods on the Layer will throw an exception if the state of the Layer is not opened.
When the map draws each layer, the layer will be opened as one of its first steps; then, after it
is finished drawing with that layer, it will close it. In this way, we are sure to
release all resources used by the Layer.
When implementing the abstract method, consider opening the FeatureSource or
RasterSource. You will get a chance to close these in the Close method of the
Layer.
Exceptions
- InvalidOperationException
In the event you attempt to call this method on a Layer which has already been opened, it will throw an InvalidOperationException.