Class LayerAsync
This class is the base class for all types of Layers.
public abstract class LayerAsync : Layer
- Inheritance
-
LayerAsync
- Derived
- Inherited Members
Remarks
The Layer class is where all other types of layers are inherited from. It
provides the base set of functionality. Though all Layers inherit from this class, we
strongly suggest if you decide to create your own layer type that you consider
inheriting from the higher level RasterLayer for image-based layers and FeatureLayer for
feature-based layers. They provide a rich set of default operations for the various
types of layers and are simple to inherit from.
As it is abstract, there are a number of methods you need to implement. The first is
DrawCore. In this method, you are responsible for drawing the layer's representation.
The other two required methods are OpenCore and CloseCore. These open and close the Layer. In
the Open, you are responsible for getting the layer ready for drawing. You should open
any file references, etc. In the Close, you need to clean up all file handles, close
other objects etc. It is important that the Close puts the class in a state where it can
be re-opened in the future. It is different than Dispose, as closed Layers will still
exist and can be re-opened later in the mapping life cycle. Many methods (in the layer
and in higher level objects) will require that the Layer be open before these methods
are called, otherwise they will throw an exception.
Constructors
LayerAsync()
This is the default constructor for the Layer.
protected LayerAsync()
Remarks
None
Methods
CloseAsync(CancellationToken)
This method closes the Layer and releases any resources it was using.
public Task CloseAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken
Returns
- Task
None
Remarks
This abstract method is called from the concrete public method Close. The close
method plays an important role in the life cycle of the Layer. It may be called after
drawing to release any memory and other resources that were allocated since the Open
method was called.
If you override this method, it is recommended that you take the following things
into account: This method may be called multiple times, so we suggest you write the method so
that that a call to a closed Layer is ignored and does not generate an error.
We also suggest that in the Close you free all resources that have been opened.
Remember that the object will not be destroyed, but will be re-opened possibly in the
near future.
CloseAsyncCore(CancellationToken)
protected virtual Task CloseAsyncCore(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
CloseCore()
[Obsolete("Please use its async version instead for better efficiency and responsiveness. This sync version will no longer be available after 13.3.")]
protected override void CloseCore()
DrawAsync(GeoCanvas, Collection<SimpleCandidate>)
This method draws the Layer.
public Task DrawAsync(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
Parameters
canvas
GeoCanvasThis parameter is the view object or a NativeImage to draw on.
labelsInAllLayers
Collection<SimpleCandidate>This parameter represents the labels used for collision detection and duplication checking.
Returns
- Task
None
Remarks
This method is the concrete wrapper for the abstract method DrawCore. This
method draws the representation of the layer based on the extent you provided.
As this is a concrete public method that wraps a Core method, we reserve the right
to add events and other logic to pre- or post-process data returned by the Core version
of the method. In this way, we leave our framework open on our end, but also allow you
the developer to extend our logic to suit your needs. If you have questions about this,
please contact our support team as we would be happy to work with you on extending our
framework.
Exceptions
- ArgumentNullException
If you pass a null as the worldExtent, we will throw an ArgumentNullException.
- ArgumentNullException
If you pass a null as the geoImageOrNativeImage, we will throw an ArgumentNullException.
- ArgumentNullException
If you pass a null as the labeledInLayers, we will throw an ArgumentNullException.
- ArgumentOutOfRangeException
If you pass in a mapUnit that is not defined in the enumeration, it will throw a ArgumentOutOfRangeException.
DrawAsyncCore(GeoCanvas, Collection<SimpleCandidate>)
protected abstract Task DrawAsyncCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
Parameters
canvas
GeoCanvaslabelsInAllLayers
Collection<SimpleCandidate>
Returns
DrawCore(GeoCanvas, Collection<SimpleCandidate>)
[Obsolete("Please use its async version instead for better efficiency and responsiveness. This sync version will no longer be available after 13.3.")]
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
Parameters
canvas
GeoCanvaslabelsInAllLayers
Collection<SimpleCandidate>
OpenAsync(CancellationToken)
This method opens the Layer so that it is initialized and ready to use.
public Task OpenAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken
Returns
- Task
None
Remarks
This method is the concrete wrapper for the abstract method OpenCore. 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.
As this is a concrete public method that wraps a Core method, we reserve the right
to add events and other logic to pre- or post-process data returned by the Core version
of the method. In this way, we leave our framework open on our end, but also allow you
the developer to extend our logic to suit your needs. If you have questions about this,
please contact our support team as we would be happy to work with you on extending our
framework.
OpenAsyncCore(CancellationToken)
This method opens the Layer so that it is initialized and ready to use.
protected virtual Task OpenAsyncCore(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
- Task
None
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.
OpenCore()
[Obsolete("Please use its async version instead for better efficiency and responsiveness. This sync version will no longer be available after 13.3.")]
protected override void OpenCore()