Skip to content

< Back


WmsRasterSource

Namespace: ThinkGeo.Core

Represents an object that encapsulates a Web Map Service (WMS) source.

public class WmsRasterSource : RasterSource

Inheritance ObjectRasterSourceWmsRasterSource

Remarks:

A Web Map Service (WMS) produces maps of spatially referenced data dynamically from geographic information. This international standand defines a "map" as a portrayal of geographic information as a digital image file suitable for display on a computer screen.

A map is not the the data itself. WMS-produced maps are generally rendered in a pictorial format such as PNG or JPEG, or occasionally as vector-based graphical elements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats.

Properties

ActiveLayerNames

This property allows the active layers requested from the client to be shown on the map.

public Collection<string> ActiveLayerNames { get; }

Property Value

Collection<String>

Remarks:

When requesting a map, a client may specify the layers to be shown on the map.

ActiveStyleNames

This property allows the active styles requested from the client to be shown on the map.

public Collection<string> ActiveStyleNames { get; }

Property Value

Collection<String>

Remarks:

When requesting a map, a client may specify the styles to be shown on the map.

Uri

This property specifies the URI of the WMS server.

public Uri Uri { get; set; }

Property Value

Uri

IsTransparent

This property gets or sets whether the response map image's background color is transparent or not.

public bool IsTransparent { get; set; }

Property Value

Boolean

OutputFormat

This property gets or sets the desired output format for the map being requested from the WMS.

public string OutputFormat { get; set; }

Property Value

String

Remarks:

When requesting a map, a client may specify the output format in which to show the map. Formats are specified as MIME types such as "image/gif" or "image/png".

WebProxy

This property gets or sets the proxy used for requesting a Web Response.

public IWebProxy WebProxy { get; set; }

Property Value

IWebProxy

TimeoutInSecond

This property specifies the timeout of the web request in seconds. The default timeout value is 20 seconds.

public int TimeoutInSecond { get; set; }

Property Value

Int32

Crs

This property gets or sets the projected or geographic coordinate reference system to be used.

public string Crs { get; set; }

Property Value

String

Credentials

This property gets or sets the base authentication interface for retrieving credentials for Web Client authentication.

public ICredentials Credentials { get; set; }

Property Value

ICredentials

Exceptions

This property indicates the format in which the client wishes to be notified of service exceptions.

public string Exceptions { get; set; }

Property Value

String

Remarks:

Upon receiving a request that is invalid according to the OGC standard, the server shall issue a service exception report. The service report is meant to describe to the client application or its human user the reason(s) that the request is invalid.

Parameters

This property specifies a dictionary used to update the request sent from the client to the WMS server.

public Dictionary<string, string> Parameters { get; }

Property Value

Dictionary<String, String>

AxisOrder

public WmsAxisOrder AxisOrder { get; set; }

Property Value

WmsAxisOrder

CapabilitesCacheTimeout

public TimeSpan CapabilitesCacheTimeout { get; set; }

Property Value

TimeSpan

UserAgent

public string UserAgent { get; set; }

Property Value

String

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; }

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.

Constructors

WmsRasterSource()

This is the constructor for the class. If you use this constructor, then you need to set the required properties manually.

public WmsRasterSource()

Remarks:

None

WmsRasterSource(Uri)

This is the constructor the for the class.

public WmsRasterSource(Uri uri)

Parameters

uri Uri
URI of the WMS server.

Remarks:

This constructor initializes a new WmsRasterSource and downloads and parses the service description. In an ASP.NET application, the service description is automatically cached for 24 hours when it is not specified.

WmsRasterSource(Uri, IWebProxy)

This is the constructor the for the class.

public WmsRasterSource(Uri uri, IWebProxy webProxy)

Parameters

uri Uri
URI of the WMS server.

webProxy IWebProxy
Proxy to use for the current WMS layer.

Remarks:

This constructor initializes a new WmsRasterSource and downloads and parses the service description In an ASP.NET application, the service description is automatically cached for 24 hours when it is not specified.

Methods

SendWebRequest(WebRequest)

protected WebResponse SendWebRequest(WebRequest webRequest)

Parameters

webRequest WebRequest

Returns

WebResponse

SendWebRequestCore(WebRequest)

protected WebResponse SendWebRequestCore(WebRequest webRequest)

Parameters

webRequest WebRequest

Returns

WebResponse

OnSendingWebRequest(SendingWebRequestEventArgs)

protected void OnSendingWebRequest(SendingWebRequestEventArgs e)

Parameters

e SendingWebRequestEventArgs

OnRequestedImageException(RequestedImageExceptionEventArgs)

protected void OnRequestedImageException(RequestedImageExceptionEventArgs e)

Parameters

e RequestedImageExceptionEventArgs

OnSentWebRequest(SentWebRequestEventArgs)

protected void OnSentWebRequest(SentWebRequestEventArgs e)

Parameters

e SentWebRequestEventArgs

GetServerLayerNames()

This method returns the names of all layers at the server side.

public Collection<string> GetServerLayerNames()

Returns

Collection<String>
The names of all layers at the server side.

Remarks:

None.

GetServerStyleNames()

This method returns the names of all styles at the server side.

public Collection<string> GetServerStyleNames()

Returns

Collection<String>
The names of all styles at the server side.

Remarks:

None.

GetServerOutputFormats()

This method returns the output format at the server side.

public Collection<string> GetServerOutputFormats()

Returns

Collection<String>
The output format at the server side.

Remarks:

None.

GetServerCrss()

This method returns the projected or geographic coordinate reference systems to be used.

public Collection<string> GetServerCrss()

Returns

Collection<String>

GetServerExceptionFormats()

This method returns the exception format at the server side.

public Collection<string> GetServerExceptionFormats()

Returns

Collection<String>
The exception format at the server side.

Remarks:

None.

GetServiceVersion()

This API gets the WMS server version of the service.

public string GetServiceVersion()

Returns

String
Returns a string reflecting the version of the service in WMS.

GetServerFeatureInfoFormats()

This API gets the WMS server FeatureInfo formats of the service.

public Collection<string> GetServerFeatureInfoFormats()

Returns

Collection<String>
This API returns the FeatureInfo formats supported on the server-side.

GetServerCapabilitiesXml()

This API gets the GetCapabilites document of the service.

public string GetServerCapabilitiesXml()

Returns

String
This API returns the GetCapabilites document of the service.

GetRequestUrl(RectangleShape, Int32, Int32)

Get the request URL from the client to the WMS.

public string GetRequestUrl(RectangleShape worldExtent, int canvasWidth, int canvasHeight)

Parameters

worldExtent RectangleShape
The world extent requested by the client to get the map.

canvasWidth Int32
The returning map width, as well as the drawing view width.

canvasHeight Int32
The returning map height, as well as the drawing view height.

Returns

String
The request URL from the client to the WMS.

GetRequestUrlCore(RectangleShape, Int32, Int32)

protected string GetRequestUrlCore(RectangleShape worldExtent, int canvasWidth, int canvasHeight)

Parameters

worldExtent RectangleShape

canvasWidth Int32

canvasHeight Int32

Returns

String

GetImageWidthCore()

This method returns the width of the image in screen coordinates.

protected int GetImageWidthCore()

Returns

Int32
The width of the image in screen coordinates.

Exceptions

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 virtual method is called from the concrete method GetImageWidth. It returns the width of the image in screen coordinates.

GetImageHeightCore()

This method returns the height of the image in screen coordinates.

protected int GetImageHeightCore()

Returns

Int32
The height of the image in screen coordinates.

Exceptions

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 virtual method is called from the concrete method GetImageHeight. It returns the height of the image in screen coordinates.

OpenCore()

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

protected void OpenCore()

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.

CloseCore()

protected void CloseCore()

GetBoundingBoxCore()

This method returns the bounding box of the RasterSource.

protected RectangleShape GetBoundingBoxCore()

Returns

RectangleShape
The bounding box of the RasterSource.

Exceptions

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 returns the bounding box of the RasterSource.

GetImageCore(RectangleShape, Int32, Int32)

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

protected GeoImage GetImageCore(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

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 our own RasterSource.

BuildWmsGetFeatureInfoUri(ScreenPointF, String, Int32)

protected Uri BuildWmsGetFeatureInfoUri(ScreenPointF screenPointF, string infoFormat, int maxFeatures)

Parameters

screenPointF ScreenPointF

infoFormat String

maxFeatures Int32

Returns

Uri

GetFeatureInfo(ScreenPointF)

public Dictionary<string, Collection<Feature>> GetFeatureInfo(ScreenPointF screenPointF)

Parameters

screenPointF ScreenPointF

Returns

Dictionary<String, Collection<Feature>>

GetFeatureInfo(ScreenPointF, String)

public Dictionary<string, Collection<Feature>> GetFeatureInfo(ScreenPointF screenPointF, string infoFormat)

Parameters

screenPointF ScreenPointF

infoFormat String

Returns

Dictionary<String, Collection<Feature>>

GetFeatureInfo(ScreenPointF, Int32)

public Dictionary<string, Collection<Feature>> GetFeatureInfo(ScreenPointF screenPointF, int maxFeatures)

Parameters

screenPointF ScreenPointF

maxFeatures Int32

Returns

Dictionary<String, Collection<Feature>>

GetFeatureInfo(ScreenPointF, String, Int32)

public Dictionary<string, Collection<Feature>> GetFeatureInfo(ScreenPointF screenPointF, string infoFormat, int maxFeatures)

Parameters

screenPointF ScreenPointF

infoFormat String

maxFeatures Int32

Returns

Dictionary<String, Collection<Feature>>

GetFeatureInfoCore(ScreenPointF, String, Int32)

protected Dictionary<string, Collection<Feature>> GetFeatureInfoCore(ScreenPointF screenPointF, string infoFormat, int maxFeatures)

Parameters

screenPointF ScreenPointF

infoFormat String

maxFeatures Int32

Returns

Dictionary<String, Collection<Feature>>

XDs=(WebRequest)

internal Dictionary<string, Collection<Feature>> XDs=(WebRequest reqeust)

Parameters

reqeust WebRequest

Returns

Dictionary<String, Collection<Feature>>

XTs=(WebRequest)

internal Dictionary<string, Collection<Feature>> XTs=(WebRequest request)

Parameters

request WebRequest

Returns

Dictionary<String, Collection<Feature>>

Xjs=(XmlDocument)

internal Dictionary<string, Collection<Feature>> Xjs=(XmlDocument xmlDocument)

Parameters

xmlDocument XmlDocument

Returns

Dictionary<String, Collection<Feature>>

Xzs=(XmlDocument)

internal Dictionary<string, Collection<Feature>> Xzs=(XmlDocument xmlDocument)

Parameters

xmlDocument XmlDocument

Returns

Dictionary<String, Collection<Feature>>

Events

SendingWebRequest

This event is called before sending the reqeust for raster image.

public event EventHandler<SendingWebRequestEventArgs> SendingWebRequest;

Remarks:

This event is called before sending the reqeust for raster image.
It is typical that user want to get the url of reqeust and modify it according to their requirements. For example, user could create a signiture for it, and verify it on the server side.

RequestedImageException

This event is called afer the image request done with some OnSendingWebRequest.

public event EventHandler<RequestedImageExceptionEventArgs> RequestedImageException;

Remarks:

This event is called before sending the reqeust for raster image.
It is typical that user want to get the url of reqeust and modify it according to their requirements. For example, user could create a signiture for it, and verify it on the server side.

SentWebRequest

This event is called after sent the request for raster image and the HttpWebResponse has come back.

public event EventHandler<SentWebRequestEventArgs> SentWebRequest;

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.


< Back