Skip to content

RasterSourceAsync

Namespace: ThinkGeo.Core.Async

The abstract class from which all raster sources inherit. Raster sources represent raster data that can be integrated into Map Suite.

public abstract class RasterSourceAsync : ThinkGeo.Core.RasterSource

Inheritance ObjectRasterSourceRasterSourceAsync

Remarks:

None

Properties

ProjectionConverter

public ProjectionConverter ProjectionConverter { get; set; }

Property Value

ProjectionConverter

Projection

public Projection Projection { get; protected set; }

Property Value

Projection

Transparency

This property gets and sets the amount of transparency to apply to the image.

public float Transparency { get; set; }

Property Value

Single
This property gets the amount of transparency to apply to the image.

Remarks:

None

BlueTranslation

This property gets and sets the amount of blue to apply to the image.

public float BlueTranslation { get; set; }

Property Value

Single
This property gets the amount of blue to apply to the image.

Remarks:

None

RedTranslation

This property gets and sets the amount of red to apply to the image.

public float RedTranslation { get; set; }

Property Value

Single
This property gets the amount of red to apply to the image.

Remarks:

None

GreenTranslation

This property gets and sets the amount of green to apply to the image.

public float GreenTranslation { get; set; }

Property Value

Single
This property gets the amount of green to apply to the image.

Remarks:

None

IsNegative

This property gets and sets whether the image should be converted to negative (inverse colors).

public bool IsNegative { get; set; }

Property Value

Boolean
This property gets and sets whether the image should be converted to negative (inverse colors).

Remarks:

None

IsGrayscale

This property gets and sets if the image should be converted to grayscale.

public bool IsGrayscale { get; set; }

Property Value

Boolean

        This property gets and sets if the image should be converted to grayscale.

Remarks:

None

ScaleFactor

The scale factor when drawing the primitive image. For example I am looking for an image with 100100px, If the ScaleFactor is set to 2, it means the component will get the image with 200200px. We want to keep it as 1 (by default) for most cases.

public double ScaleFactor { get; set; }

Property Value

Double

IsOpen

This property returns true if the RasterSource is open and false if it is not.

public bool IsOpen { get; protected set; }

Property Value

Boolean

Remarks:

Various methods on the RasterSource require that it be in an open state. If one of those methods is called when the state is not open, the method will throw an exception. To enter the open state, you must call the RasterSource's Open method. The method will raise an exception if the current RasterSource is already open.

Methods

OpenCore()

protected void OpenCore()

CloseCore()

protected void CloseCore()

GetImageCore(RectangleShape, Int32, Int32)

protected GeoImage GetImageCore(RectangleShape worldExtent, int canvasWidth, int canvasHeight)

Parameters

worldExtent RectangleShape

canvasWidth Int32

canvasHeight Int32

Returns

GeoImage

OpenAsync()

This method opens the RasterSource so that it is initialized and ready to use.

public Task OpenAsync()

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 RasterSource. Most methods on the RasterSource will throw an exception if the state of the RasterSource is not opened. When the map draws each layer, it will open the RasterSource 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 RasterSource.

When implementing the abstract method, consider opening files for file-based sources, connecting to databases in the database-based sources and so on. You will get a chance to close these in the Close method of the RasterSource.
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()

This method opens the RasterSource so that it is initialized and ready to use.

protected abstract Task OpenAsyncCore()

Returns

Task
None

Exceptions

InvalidOperationException
In the event you attempt to call this method on a image source which has already been opened, it will throw an InvalidOperationException.

Remarks:

This protected virtual method is called from the concrete public method Open. The Open method plays an important role, as it is responsible for initializing the RasterSource. Most methods on the RasterSource will throw an exception if the state of the RasterSource is not opened. When the map draws each layer, it will open the RasterSource 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 RasterSource.

When implementing this abstract method, consider opening files for file-based sources, connecting to databases in the database-based sources and so on. You will get a chance to close these in the Close method of the RasterSource.

CloseAsync()

This method closes the RasterSource and releases any resources it was using.

public Task CloseAsync()

Returns

Task
None

Remarks:

This method is the concrete wrapper for the abstract method CloseCore. The Close method plays an important role in the life cycle of the RasterSource. 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 the Core version of 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 RasterSource 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.


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.

CloseAsyncCore()

This method opens the RasterSource so that it is initialized and ready to use.

protected Task CloseAsyncCore()

Returns

Task
None

Remarks:

This protected virtual method is called from the concrete public method Close. The Close method plays an important role in the life cycle of the RasterSource. 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 RasterSource 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.

GetImageAsync(RectangleShape, Int32, Int32)

This method returns an image based on the worldExtent and image width and height.

public Task<GeoImage> GetImageAsync(RectangleShape worldExtent, int canvasWidth, int canvasHeight)

Parameters

worldExtent RectangleShape
This parameter represents the worldExtent you want to draw.

canvasWidth Int32
This parameter represents the width of the image you want to draw.

canvasHeight Int32
This parameter represents the height of the image you want to draw.

Returns

Task<GeoImage>

        This method returns an image based on the worldExtent and image width and
        height.

Exceptions

ArgumentNullException
If you pass in a worldExtent that is invalid, we will throw an ArgumentNullException.

ArgumentException
If you pass in a worldExtent that is invalid, we will throw an ArgumentException.

ArgumentOutOfRangeException
If you pass in a image width that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.

ArgumentOutOfRangeException
If you pass in a image height that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.

InvalidOperationException
In the event you attempt to call this method on a image source which has not been opened, it will throw an InvalidOperationException.

Remarks:

This method is responsible for returning the image based on the parameters passed in. As the core version of this method is abstract, you will need to override it when creating your own RasterSource.


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.

GetWrappingImageLeftAsync(RectangleShape, Double, Double, RectangleShape)

internal Task<GeoImage> GetWrappingImageLeftAsync(RectangleShape boundingBox, double screenWidth, double screenHeight, RectangleShape wrappingExtent)

Parameters

boundingBox RectangleShape

screenWidth Double

screenHeight Double

wrappingExtent RectangleShape

Returns

Task<GeoImage>

GetWrappingImageRightAsync(RectangleShape, Double, Double, RectangleShape)

internal Task<GeoImage> GetWrappingImageRightAsync(RectangleShape boundingBox, double screenWidth, double screenHeight, RectangleShape wrappingExtent)

Parameters

boundingBox RectangleShape

screenWidth Double

screenHeight Double

wrappingExtent RectangleShape

Returns

Task<GeoImage>

GetImageAsyncCore(RectangleShape, Int32, Int32)

This method returns an image based on the worldExtent and image width and height.

protected abstract Task<GeoImage> GetImageAsyncCore(RectangleShape worldExtent, int canvasWidth, int canvasHeight)

Parameters

worldExtent RectangleShape
This parameter represents the worldExtent you want to draw.

canvasWidth Int32
This parameter represents the width of the image you want to draw.

canvasHeight Int32
This parameter represents the height of the image you want to draw.

Returns

Task<GeoImage>

        This method returns an image based on the worldExtent and image width and
        height.

Exceptions

ArgumentNullException
If you pass in a worldExtent that is invalid, we will throw an ArgumentNullException.

ArgumentException
If you pass in a worldExtent that is invalid, we will throw an ArgumentException.

ArgumentOutOfRangeException
If you pass in a image width that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.

ArgumentOutOfRangeException
If you pass in a image height that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.

InvalidOperationException
In the event you attempt to call this method on a image source that has not been opened, it will throw an InvalidOperationException.

Remarks:

This method is responsible for returning the image based on the parameters passed in. As the core version of this method is abstract, you will need to override it when creating our own RasterSource.

Events

OpeningRasterSource

This event is called before the opening of the RasterSource.

public event EventHandler<OpeningRasterSourceEventArgs> OpeningRasterSource;

Remarks:

This event is called before the opening of the RasterSource. Technically, this event is called after the calling of the Open method on the RasterSource, but before the protected OpenCore method.

It is typical that the RasterSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a RasterSource is in the Ajax or Post Back part of the page cycle, it will close the RasterSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the RasterSource open, knowing that we can maintain a persistent connection.

OpenedRasterSource

This event is called after the opening of the RasterSource.

public event EventHandler<OpenedRasterSourceEventArgs> OpenedRasterSource;

Remarks:

This event is called after the opening of the RasterSource. Technically, this event is called after the calling of the Open method on the RasterSource and after the protected OpenCore method is called.

It is typical that the RasterSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a RasterSource is in the Ajax or Post Back part of the page cycle, it will close the RasterSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the RasterSource open, knowing that we can maintain a persistent connection.

ClosingRasterSource

This event is called before the closing of the RasterSource.

public event EventHandler<ClosingRasterSourceEventArgs> ClosingRasterSource;

Remarks:

This event is called before the closing of the RasterSource. Technically, this event is called after the calling of the Close method on the RasterSource, but before the protected CloseCore method.

It is typical that the RasterSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a RasterSource is in the Ajax or Post Back part of the page cycle, it will close the RasterSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the RasterSource open, knowing that we can maintain a persistent connection.

ClosedRasterSource

This event is called after the closing of the RasterSource.

public event EventHandler<ClosedRasterSourceEventArgs> ClosedRasterSource;

Remarks:

This event is called after the closing of the RasterSource. Technically, this event is called after the calling of the Close method on the RasterSource and after the protected CloseCore method.

It is typical that the RasterSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a RasterSource is in the Ajax or Post Back part of the page cycle, it will close the RasterSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the RasterSource open, knowing that we can maintain a persistent connection.