Table of Contents

Class WmsLayer

Namespace
ThinkGeo.Core.Async
Assembly
ThinkGeo.Core.dll

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

public class WmsLayer : WebBasedLayer, IWmsEntity
Inheritance
WmsLayer
Implements
Inherited Members

Remarks

A Web Map Service (WMS) produces maps of spatially referenced data dynamically from geographic information. This International Standard defines a "map" to be a portrayal of geographic information as a digital image file suitable for display on a computer screen. A map is not the data itself. WMS-produced maps are generally rendered in a pictorial format such as PNG, GIF or JPEG, or occasionally as vector-based graphical elements in Scalable Vector Graphics (SVG) or Web Computer Graphics Metafile (WebCGM) formats.

Constructors

WmsLayer()

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

public WmsLayer()

Remarks

None

WmsLayer(Collection<WmsServerLayer>)

public WmsLayer(Collection<WmsServerLayer> flatWmsServerLayers)

Parameters

flatWmsServerLayers Collection<WmsServerLayer>

WmsLayer(Uri)

This is the constructor the for the class.

public WmsLayer(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.

WmsLayer(Uri, IWebProxy)

This is the constructor the for the class.

public WmsLayer(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.

WmsLayer(Uri, IWebProxy, string, WmsAxisOrder, string, bool)

This is the constructor the for the class.

public WmsLayer(Uri uri, IWebProxy webProxy, string crs = "EPSG:4326", WmsAxisOrder axisOrder = WmsAxisOrder.Default, string version = "1.3.0", bool fastMode = false)

Parameters

uri Uri

URI of the WMS server.

webProxy IWebProxy

Proxy to use for the current WMS layer.

crs string

the projected or geographic coordinate reference system to be used.

axisOrder WmsAxisOrder

the axis order of the layer

version string

version of the WMS server

fastMode bool

whether request and parse capabilities

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.

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.

AxisOrder

This property specifies the order in which the coordinate axes are arranged when making requests to a Web Map Service (WMS) server. It is used to define the spatial reference system for the layer.

public WmsAxisOrder AxisOrder { get; set; }

Property Value

WmsAxisOrder

CapabilitiesCacheTimeout

The timeout for Capabilities Cache, its 10 minutes by default

public TimeSpan CapabilitiesCacheTimeout { get; set; }

Property Value

TimeSpan

Crs

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

public string Crs { get; set; }

Property Value

string

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.

FastMode

This property gets or sets whether request and parse capabilities.

public bool FastMode { get; set; }

Property Value

bool

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.

public override bool HasBoundingBox { get; }

Property Value

bool

Remarks

The override in the WmsRasterLayer sets it to true.

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

bool

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".

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>

Examples

WmsRasterSource target = new WmsRasterSource(new Uri(localWmsServer));
target.Parameters.Add("ParameterKey", "ParameterValue");
Dim target As New WmsRasterSource(New Uri(localWmsServer))
target.Parameters.Add("ParameterKey", "ParameterValue")

Uri

This property specifies the URI of the WMS server.

public Uri Uri { get; set; }

Property Value

Uri

UserAgent

This property allows you to specify a custom user-agent request header when making requests to a Web Map Service (WMS) server. This header provides information about the client application or device and can be useful for server-side logging and analytics.

public string UserAgent { get; set; }

Property Value

string

Version

This property gets the version.

public string Version { get; }

Property Value

string

Methods

BuildWmsGetFeatureInfoUri(ScreenPointF, string, int)

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

Parameters

screenPointF ScreenPointF
infoFormat string
maxFeatures int

Returns

string

CloseAsyncCore(CancellationToken)

protected override Task CloseAsyncCore(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

DrawAsyncCore(GeoCanvas, Collection<SimpleCandidate>)

protected override Task DrawAsyncCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)

Parameters

canvas GeoCanvas
labelsInAllLayers Collection<SimpleCandidate>

Returns

Task

GetBoundingBoxCore()

This method returns the bounding box of the RasterSource.

protected override RectangleShape GetBoundingBoxCore()

Returns

RectangleShape

The bounding box of the RasterSource.

Remarks

This method returns the bounding box of the RasterSource.

Exceptions

InvalidOperationException

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

GetFeatureInfo(ScreenPointF, int, CancellationToken)

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

Parameters

screenPointF ScreenPointF
maxFeatures int
cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

GetFeatureInfoAsync(ScreenPointF, int, CancellationToken)

public Task<Dictionary<string, Collection<Feature>>> GetFeatureInfoAsync(ScreenPointF screenPointF, int maxFeatures, CancellationToken cancellationToken)

Parameters

screenPointF ScreenPointF
maxFeatures int
cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

GetFeatureInfoAsync(ScreenPointF, string, int, CancellationToken)

public Task<Dictionary<string, Collection<Feature>>> GetFeatureInfoAsync(ScreenPointF screenPointF, string infoFormat, int maxFeatures, CancellationToken cancellationToken)

Parameters

screenPointF ScreenPointF
infoFormat string
maxFeatures int
cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

GetFeatureInfoAsync(ScreenPointF, string, CancellationToken)

public Task<Dictionary<string, Collection<Feature>>> GetFeatureInfoAsync(ScreenPointF screenPointF, string infoFormat, CancellationToken cancellationToken)

Parameters

screenPointF ScreenPointF
infoFormat string
cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

GetFeatureInfoAsync(ScreenPointF, CancellationToken)

public Task<Dictionary<string, Collection<Feature>>> GetFeatureInfoAsync(ScreenPointF screenPointF, CancellationToken cancellationToken)

Parameters

screenPointF ScreenPointF
cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

GetFeatureInfoAsyncCore(ScreenPointF, string, int, CancellationToken)

protected virtual Task<Dictionary<string, Collection<Feature>>> GetFeatureInfoAsyncCore(ScreenPointF screenPointF, string infoFormat, int maxFeatures, CancellationToken cancellationToken)

Parameters

screenPointF ScreenPointF
infoFormat string
maxFeatures int
cancellationToken CancellationToken

Returns

Task<Dictionary<string, Collection<Feature>>>

GetImageAsync(RectangleShape, int, int, CancellationToken)

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

protected Task<GeoImage> GetImageAsync(RectangleShape worldExtent, int canvasWidth, int canvasHeight, CancellationToken cancellationToken)

Parameters

worldExtent RectangleShape

This parameter represents the worldExtent you want to draw.

canvasWidth int

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

canvasHeight int

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

cancellationToken CancellationToken

Returns

Task<GeoImage>

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

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.

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 an image width that is smaller than or equal to 0, we will throw an ArgumentOutOfRangeException.

ArgumentOutOfRangeException

If you pass in an 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 an image source which has not been opened, it will throw an InvalidOperationException.

GetRequestUrl(RectangleShape, int, int)

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 int

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

canvasHeight int

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

Returns

string

The request URL from the client to the WMS.

GetRequestUrlCore(RectangleShape, int, int)

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

Parameters

worldExtent RectangleShape
canvasWidth int
canvasHeight int

Returns

string

GetServerCapabilitiesXml()

This API gets the GetCapabilities document of the service.

public string GetServerCapabilitiesXml()

Returns

string

This API returns the GetCapabilities document of the service.

GetServerCrsCollection()

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

public Collection<string> GetServerCrsCollection()

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.

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.

GetServerLayers()

This method returns all layers at the server side.

public Collection<WmsServerLayer> GetServerLayers()

Returns

Collection<WmsServerLayer>

The names of all layers 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.

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.

GetServiceBaseUrl()

This API gets the WMS base url of the service.

public string GetServiceBaseUrl()

Returns

string

Returns a string reflecting the WMS base url.

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.

OnRequestedImageException(RequestedImageExceptionEventArgs)

protected virtual void OnRequestedImageException(RequestedImageExceptionEventArgs e)

Parameters

e RequestedImageExceptionEventArgs

OpenAsyncCore(CancellationToken)

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

protected override Task OpenAsyncCore(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

None

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.

Exceptions

InvalidOperationException

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

Events

RequestedImageException

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

public event EventHandler<RequestedImageExceptionEventArgs> RequestedImageException

Event Type

EventHandler<RequestedImageExceptionEventArgs>

Remarks

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