3.2. Web Map Service (WMS)

The 1.1.1 and 1.3.0 WMS standards implemented in QGIS Server provide a HTTP interface to request map or legend images generated from a QGIS project. A typical WMS request defines the QGIS project to use, the layers to render as well as the image format to generate. Basic support is also available for Styled Layer Descriptor (SLD).

Especificações:

Standard requests provided by QGIS Server:

Solicitação

Descrição

GetCapabilities

Returns XML metadata with information about the server

GetMap

Retorna um mapa

GetFeatureInfo

Recupera dados (geometria e valores) para uma localização de pixel

GetLegendGraphics

Retorna os símbolos das legendas

GetStyle(s)

Returns XML document with style description in SLD

DescribeLayer

Returns information about WFS and WCS availability respectively for vector and raster layers

Vendor requests provided by QGIS Server:

Solicitação

Descrição

GetPrint

Retorna um layout QGIS

GetProjectSettings

Returns specific information about QGIS Server

GetSchemaExtension

Returns XML metadata about optional extended capabilities

3.2.1. GetCapabilities

Standard parameters for the GetCapabilities request according to the OGC WMS 1.1.1 and 1.3.0 specifications:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetCapabilities)

VERSION

Não

Versão do serviço

The GetCapabilities request supports as well the following vendor parameters:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

Exemplo de URL:

http://localhost/qgis_server?
SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetCapabilities

3.2.2. GetMap

Standard parameters for the GetMap request according to the OGC WMS 1.1.1 and 1.3.0 specifications:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetMap)

VERSION

Sim

Versão do serviço

LAYERS

Não

Layers to display

STYLES

Não

Estilo das camadas

SRS / CRS

Sim

Sistema de referência de coordenadas

BBOX

Sim

Extensão do mapa

WIDTH

Sim

Largura da imagem em pixels

HEIGHT

Sim

Altura da imagem em pixels

FORMAT

Não

Formato de imagem

TRANSPARENT

Não

Plano de fundo transparente

SLD

Não

URL of an SLD to be used for styling

SLD_BODY

Não

In-line SLD (XML) to be used for styling

In addition to the standard ones, QGIS Server supports redlining, external WMS layers as well as the following extra parameters:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

BGCOLOR

Não

Especificar a cor de fundo

DPI

Não

Especificar a resolução de saída

IMAGE_QUALITY

Não

Compressão JPEG

OPACITIES

Não

Opacidade para camada ou grupo

FILTER

Não

Subset of features

SELECTION

Não

Highlight features

NOME_ARQUIVO

Não

File name of the downloaded file

Only for FORMAT=application/dxf

FORMAT_OPTIONS

Não

Opções do formato de arquivo especificado

Only for FORMAT=application/dxf

TILED

Não

Working in tiled mode

Exemplo de URL:

http://localhost/qgis_server?
SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetMap
&MAP=/home/qgis/projects/world.qgs
&LAYERS=mylayer1,mylayer2,mylayer3
&STYLES=style1,default,style3
&OPACITIES=125,200,125
&CRS=EPSG:4326
&WIDTH=400
&HEIGHT=400
&FORMAT=image/png
&TRANSPARENT=TRUE
&DPI=300
&TILED=TRUE

VERSÃO

Este parâmetro permite especificar a versão do serviço a ser utilizada. Os valores disponíveis para o parâmetro VERSÃO são:

  • 1.1.1

  • 1.3.0

According to the version number, slight differences have to be expected as explained later for the next parameters:

  • CRS / SRS

  • BBOX

CAMADAS

Este parâmetro permite especificar as camadas a serem exibidas no mapa. Os nomes devem ser separados por vírgula.

In addition, QGIS Server introduced some options to select layers by:

The project option allowing to select layers by their id is in QGIS Server ► WMS Capabilities menu of the Project ► Properties… dialog. Check the Use layer ids as names checkbox to activate this option.

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&LAYERS=mylayerid1,mylayerid2
&...

ESTILOS

Este parâmetro pode ser usado para especificar o estilo de uma camada para a etapa de renderização. Os estilos devem ser separados por vírgula. O nome do estilo padrão é padrão.

SRS / CRS

This parameter allows to indicate the map output Spatial Reference System in WMS 1.1.1 and has to be formed like EPSG:XXXX. Note that CRS is also supported if current version is 1.1.1.

For WMS 1.3.0, CRS parameter is preferable but SRS is also supported.

Note that if both CRS and SRS parameters are indicated in the request, then it’s the current version indicated in VERSION parameter which is decisive.

In the next case, the SRS parameter is kept whatever the VERSION parameter because CRS is not indicated:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&SRS=EPSG:2854
&...

In the next case, the SRS parameter is kept instead of CRS because of the VERSION parameter:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.1.1
&CRS=EPSG:4326
&SRS=EPSG:2854
&...

In the next case, the CRS parameter is kept instead of SRS because of the VERSION parameter:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&CRS=EPSG:4326
&SRS=EPSG:2854
&...

BBOX

Este parâmetro permite especificar a extensão do mapa com unidades de acordo com o SRC atual. As coordenadas devem ser separadas por vírgula.

The BBOX parameter is formed like min_a,min_b,max_a,max_b but a and b axis definition is different according to the current VERSION parameter:

  • in WMS 1.1.1, the axis ordering is always east/north

  • in WMS 1.3.0, the axis ordering depends on the CRS authority

For example in case of EPSG:4326 and WMS 1.1.1, a is the longitude (east) and b the latitude (north), leading to a request like:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.1.1
&SRS=epsg:4326
&BBOX=-180,-90,180,90
&...

But in case of WMS 1.3.0, the axis ordering defined in the EPSG database is north/east so a is the latitude and b the longitude:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&CRS=epsg:4326
&BBOX=-90,-180,90,180
&...

LARGURA

Este parâmetro permite especificar a largura em pixels da imagem de saída.

ALTURA

Este parâmetro permite especificar a altura em pixels da imagem de saída.

FORMATO

Este parâmetro pode ser usado para especificar o formato da imagem do mapa. Os valores disponíveis são:

  • jpg

  • jpeg

  • imagem/jpeg

  • imagem/png

  • image/png; mode=1bit

  • image/png; mode=8bit

  • image/png; mode=16bit

  • application/dxf: only layers that have read access in the WFS service are exported in the DXF format

    Exemplo de URL:

    http://localhost/qgisserver?
    SERVICE=WMS&VERSION=1.3.0
    &REQUEST=GetMap
    &FORMAT=application/dxf
    &LAYERS=Haltungen,Normschacht,Spezialbauwerke
    &CRS=EPSG%3A21781
    &BBOX=696136.28844801,245797.12108743,696318.91114315,245939.25832905
    &WIDTH=1042
    &HEIGHT=811
    &FORMAT_OPTIONS=MODE:SYMBOLLAYERSYMBOLOGY;SCALE:250
    &FILE_NAME=plan.dxf
    

TRANSPARENTE

Este parâmetro booleano pode ser usado para especificar a transparência do plano de fundo. Os valores disponíveis são (não diferenciam maiúsculas de minúsculas):

  • VERDADEIRO

  • FALSO

No entanto, este parâmetro é ignorado se o formato da imagem indicado com FORMATO for diferente de PNG.

BGCOLOR

This parameter allows to indicate a background color for the map image. However it cannot be combined with TRANSPARENT parameter in case of PNG images (transparency takes priority). The colour may be literal or in hexadecimal notation.

Exemplo de URL com a notação literal:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&BGCOLOR=green
&...

Exemplo de URL com a notação hexadecimal:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&BGCOLOR=0x00FF00
&...

DPI

Este parâmetro pode ser usado para especificar a resolução de saída solicitada.

QUALIDADE_IMAGEM

This parameter is only used for JPEG images. By default, the JPEG compression is -1.

You can change the default per QGIS project in the OWS Server ► WMS capabilities menu of the Project ► Properties… dialog. If you want to override it in a GetMap request you can do it using the IMAGE_QUALITY parameter.

OPACIDADES

Comma separated list of opacity values. Opacity can be set on layer or group level. Allowed values range from 0 (fully transparent) to 255 (fully opaque).

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&WIDTH=400
&HEIGHT=200
&CRS=EPSG:4326
&LAYERS=countries,places
&BBOX=42,-6,52,15
&OPACITIES=255,0
../../../_images/wms_getmap_opacities.png

Fig. 3.2 À esquerda OPACIDADES=255,0 e à direita OPACIDADES=255,255

FILTRO

A subset of layers can be selected with the FILTER parameter. The syntax is basically the same as for the QGIS subset string. However, there are some restrictions to avoid SQL injections into databases via QGIS Server. If a dangerous string is found in the parameter, QGIS Server will return the next error:

<ServiceExceptionReport>
  <ServiceException code="Security">The filter string XXXXXXXXX has been rejected because of security reasons.
  Note: Text strings have to be enclosed in single or double quotes. A space between each word / special character is mandatory.
  Allowed Keywords and special characters are IS,NOT,NULL,AND,OR,IN,=,<,=<,>,>=,!=,',',(,),DMETAPHONE,SOUNDEX.
  Not allowed are semicolons in the filter expression.</ServiceException>
</ServiceExceptionReport>

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&VERSION=1.3.0
&WIDTH=400
&HEIGHT=300
&CRS=EPSG:4326
&BBOX=41,-6,52,10
&LAYERS=countries_shapeburst,countries,places
&FILTER=countries_shapeburst,countries:"name" = 'France';places: "name" = 'Paris'
../../../_images/wms_getmap_filter.png

Fig. 3.3 Server response to a GetMap request with FILTER parameter

In this example, the same filter "name" = 'France' is applied to layers countries and countries_shapeburst, while the filter "name" = 'Paris' is only applied to places.

Nota

It is possible to make attribute searches via GetFeatureInfo and omit the X/Y parameter if a FILTER is there. QGIS Server then returns info about the matching features and generates a combined bounding box in the XML output.

SELEÇÃO

The SELECTION parameter can highlight features from one or more layers. Vector features can be selected by passing comma separated lists with feature ids.

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&LAYERS=mylayer1,mylayer2
&SELECTION=mylayer1:3,6,9;mylayer2:1,5,6
&...

The following image presents the response from a GetMap request using the SELECTION option e.g. http://myserver.com/...&SELECTION=countries:171,65.

As those features id’s correspond in the source dataset to France and Romania they’re highlighted in yellow.

../../../_images/server_selection_parameter.png

Fig. 3.4 Server response to a GetMap request with SELECTION parameter

FORMATO-OPÇÕES

This parameter can be used to specify options for the selected format. Only for FORMAT=application/dxf. A list of key:value pairs separated by semicolon:

  • SCALE: to be used for symbology rules, filters and styles (not actual scaling of the data - data remains in the original scale).

  • MODE: corresponds to the export options offered in the QGIS Desktop DXF export dialog. Possible values are NOSYMBOLOGY, FEATURESYMBOLOGY and SYMBOLLAYERSYMBOLOGY.

  • LAYERSATTRIBUTES: specify a field that contains values for DXF layer names - if not specified, the original QGIS layer names are used.

  • USE_TITLE_AS_LAYERNAME: if enabled, the title of the layer will be used as layer name.

  • CODEC: specify a codec to be used for encoding. Default is ISO-8859-1 check the QGIS desktop DXF export dialog for valid values.

  • NO_MTEXT: Use TEXT instead of MTEXT for labels.

  • FORCE_2D: Force 2D output. This is required for polyline width.

TILED

For performance reasons, QGIS Server can be used in tiled mode. In this mode, the client requests several small fixed size tiles, and assembles them to form the whole map. Doing this, symbols at or near the boundary between two tiles may appeared cut, because they are only present in one of the tile.

Set the TILED parameter to TRUE to tell QGIS Server to work in tiled mode, and to apply the Tile buffer configured in the QGIS project (see Configurar seu projeto).

When TILED is TRUE and when a non-zero Tile buffer is configured in the QGIS project, features outside the tile extent are drawn to avoid cut symbols at tile boundaries.

TILED defaults to FALSE.

3.2.3. GetFeatureInfo

Standard parameters for the GetFeatureInfo request according to the OGC WMS 1.1.1 and 1.3.0 specifications:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetFeatureInfo)

VERSION

Não

Versão do serviço

QUERY_LAYERS

Sim

Layers to query

LAYERS

Sim

Layers to display (identical to QUERY_LAYERS)

STYLES

Não

Estilo das camadas

SRS / CRS

Sim

Sistema de referência de coordenadas

BBOX

Não

Extensão do mapa

WIDTH

Sim

Largura da imagem em pixels

HEIGHT

Sim

Altura da imagem em pixels

TRANSPARENT

Não

Plano de fundo transparente

INFO_FORMAT

Não

Output format

FEATURE_COUNT

Não

Número máximo de feições a serem retornadas

I

Não

Pixel column of the point to query

X

Não

Igual ao parâmetro I, mas em WMS 1.1.1

J

Não

Pixel row of the point to query

Y

Não

Igual ao parâmetro J, mas em WMS 1.1.1

WMS_PRECISÃO

Não

The precision (number of digits) to be used when returning geometry (see how to add geometry to feature response). The default value is -1 meaning that the precision defined in the project is used.

Além dos padrões, o QGIS Server suporta os seguintes parâmetros extras:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

FILTER

Não

Subset of features

FI_POINT_TOLERANCE

Não

Tolerância em pixels para camadas de ponto

FI_LINE_TOLERANCE

Não

Tolerância em pixels para camadas de linha

FI_POLYGON_TOLERANCE

Não

Tolerância em pixels para camadas de polígono

FILTER_GEOM

Não

Filtragem de geometria

WITH_MAPTIP

Não

Add map tips to the output

WITH_GEOMETRY

Não

Adicionar geometria à saída

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetMap
&MAP=/home/qgis/projects/world.qgs
&LAYERS=mylayer1,mylayer2,mylayer3
&CRS=EPSG:4326
&WIDTH=400
&HEIGHT=400
&INFO_FORMAT=text/xml
&TRANSPARENT=TRUE
&QUERY_LAYERS=mylayer1
&FEATURE_COUNT=3
&I=250
&J=250

INFO_FORMAT

Este parâmetro pode ser usado para especificar o formato do resultado. Os valores disponíveis são:

  • texto/xml

  • texto/html

  • text/plain

  • application/vnd.ogc.gml

  • application/json

QUERY_LAYERS

This parameter specifies the layers to display on the map. Names are separated by a comma.

In addition, QGIS Server introduces options to select layers by:

  • nome curto

  • camada id

See the LAYERS parameter defined in GetMap for more information.

FEATURE_COUNT

This parameter specifies the maximum number of features per layer to return. For example if QUERY_LAYERS is set to layer1,layer2 and FEATURE_COUNT is set to 3 then a maximum of 3 features from layer1 will be returned. Likewise a maximun of 3 features from layer2 will be returned.

Por padrão, apenas 1 feição por camada é retornada.

I

This parameter, defined in WMS 1.3.0, allows you to specify the pixel column of the query point.

X

Mesmo parâmetro que I, mas definido no WMS 1.1.1.

J

This parameter, defined in WMS 1.3.0, allows you to specify the pixel row of the query point.

Y

Mesmo parâmetro que J, mas definido no WMS 1.1.1.

FI_POINT_TOLERANCE

Este parâmetro especifica a tolerância em pixels para camadas de pontos.

FI_LINE_TOLERANCE

Este parâmetro especifica a tolerância em pixels para camadas de linha.

FI_POLYGON_TOLERANCE

Este parâmetro especifica a tolerância em pixels para camadas de polígono.

FILTRAR_GEOM

This parameter specifies a WKT geometry with which features have to intersect.

WITH_MAPTIP

This parameter specifies whether to add map tips to the output.

Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

COM_GEOMETRIA

This parameter specifies whether to add geometries to the output. To use this feature you must first enable the Add geometry to feature response option in the QGIS project. See Configure your project.

Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

3.2.4. GetLegendGraphics

Standard parameters for the GetLegendGraphics request according to the OGC WMS 1.1.1 and 1.3.0 specifications:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetLegendGraphics)

VERSION

Não

Versão do serviço

LAYERS

Sim

Layers to display

STYLES

Não

Estilo das camadas

SRS / CRS

Não

Sistema de referência de coordenadas

BBOX

Não

Extensão do mapa

WIDTH

Não

Largura da imagem em pixels

HEIGHT

Não

Altura da imagem em pixels

FORMAT

Não

Formato da legenda

TRANSPARENT

Não

Plano de fundo transparente

In addition to the standard ones, QGIS Server supports extra parameters to change the size of the legend elements or the font properties for layer titles and item labels:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

SRCWIDTH

Não

Largura do mapa

SRCHEIGHT

Não

Altura do mapa

SHOWFEATURECOUNT

Não

Add feature count of features

RULE

Não

Rule symbol to render

RULELABEL

Não

Item labels rendering

BOXSPACE

Não

Space between legend frame and content (mm)

LAYERSPACE

Não

Espaço vertical entre camadas (mm)

LAYERTITLESPACE

Não

Espaço vertical entre o título da camada e os itens (mm)

SYMBOLSPACE

Não

Espaço vertical entre o símbolo e os itens (mm)

ICONLABELSPACE

Não

Espaço horizontal entre o símbolo e o rótulo (mm)

SYMBOLWIDTH

Não

Largura da pré-visualização do símbolo (mm)

SYMBOLHEIGHT

Não

Height of the symbol preview (mm)

LAYERTITLE

Não

Layer title rendering

LAYERFONTFAMILY

Não

Layer font family

LAYERFONTBOLD

Não

Layer title bold rendering

LAYERFONTSIZE

Não

Layer title font size (pt)

LAYERFONTITALIC

Não

Layer title italic rendering

LAYERFONTCOLOR

Não

Layer title color

ITEMFONTFAMILY

Não

Item font family

ITEMFONTBOLD

Não

Item label bold rendering

ITEMFONTSIZE

Não

Item label font size (pt)

ITEMFONTITALIC

Não

Item label italic rendering

ITEMFONTCOLOR

Não

Item label color

BBOX

This parameter can be used to specify the geographical area for which the legend should be built (its format is described here) but cannot be combined with the RULE parameter. The SRS/CRS parameter becomes mandatory when using the BBOX parameter.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries,airports
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326

Nota

When the BBOX parameter is defined, the legend is referred to as a content based legend.

LARGURA

This parameter is not used by default but becomes mandatory when the RULE parameter is set. In this case it allows to specify the width in pixels of the output image.

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYER=testlayer%20%C3%A8%C3%A9
&RULE=rule1
&WIDTH=30
&HEIGHT=30

ALTURA

This parameter is not used by default but becomes mandatory when the RULE parameter is set. In this case it allows to specify the height in pixels of the output image.

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYER=testlayer%20%C3%A8%C3%A9
&RULE=rule1
&WIDTH=30
&HEIGHT=30

FORMATO

Este parâmetro pode ser usado para especificar o formato da imagem da legenda. Os valores disponíveis são:

  • imagem/jpeg

  • imagem/png

  • application/json

For JSON, symbols are encoded with Base64 and most other options related to layout or fonts are not taken into account because the legend must be built on the client side. The RULE parameter cannot be combined with this format.

URL example with the corresponding JSON output:

http://localhost/qgisserver?
SERVICE=WMS&
REQUEST=GetLegendGraphics&
LAYERS=airports&
FORMAT=application/json

And the corresponding JSON output:

{
  "nodes":[
    {
      "icon":"<base64 icon>",
      "title":"airports",
      "type":"layer"
    }
  ],
  "title":""
}

SRCWIDTH

This parameter may de defined when the RULE parameter is set. In this case, the SRCWIDTH value is forwarded to the underlying GetMap request as the WIDTH parameter while the WIDTH parameter of GetLegendGraphics is used for the image legend size.

SRCHEIGHT

This parameter may de defined when the RULE parameter is set. In this case, the SRCHEIGHT value is forwarded to the underlying GetMap request as the HEIGHT parameter while the HEIGHT parameter of GetLegendGraphics is used for the image legend size.

SHOWFEATURECOUNT

This parameter can be used to activate feature count in the legend. Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

Por exemplo:

../../../_images/getfeaturecount_legend.png

REGRA

This parameter is available on layers with Rule-based rendering and allows to build a legend with only the named rule symbol. It cannot be combined with BBOX parameter nor the JSON format.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=mylayer,
&RULE=myrulename

RULELABEL

This parameter allows to control the item label rendering. Available values are (not case sensitive):

  • TRUE: display item label

  • FALSE: hide item label

  • AUTO: hide item label for layers with Single symbol rendering

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries,airports
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&RULELABEL=AUTO
../../../_images/wms_getlegendgraphics_rulelabel.png

Fig. 3.5 Legend rendering without label for single symbol layers

BOXSPACE

This parameter allows to specify the space between legend frame and content in millimeters. By default, the space value is 2 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&BOXSPACE=0
../../../_images/wms_getlegendgraphics_boxspace.png

Fig. 3.6 To the left BOXSPACE=0 and to the right BOXSPACE=15

ESPAÇOCAMADA

This parameter allows to specify the vertical space between layers in millimeters. By default, the space value is 3 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&LAYERSPACE=0
../../../_images/wms_getlegendgraphics_layerspace.png

Fig. 3.7 To the left LAYERSPACE=0 and to the right LAYERSPACE=10

LAYERTITLESPACE

This parameter allows to specify the vertical space between layer title and items following in millimeters. By default the space value is 3 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&LAYERTITLESPACE=0
../../../_images/wms_getlegendgraphics_layertitlespace.png

Fig. 3.8 To the left LAYERTITLESPACE=0 and to the right LAYERTITLESPACE=10

ESPAÇOSIMBOLO

This parameter allows to specify the vertical space between symbol and item following in millimeters. By default the space value is 2 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&SYMBOLSPACE=0
../../../_images/wms_getlegendgraphics_symbolspace.png

Fig. 3.9 To the left SYMBOLSPACE=0 and to the right SYMBOLSPACE=5

ICONLABELSPACE

Este parâmetro permite especificar o espaço horizontal entre o símbolo e o texto do rótulo em milímetros. Por padrão, o valor do espaço é 2 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries,
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&ICONLABELSPACE=0
../../../_images/wms_getlegendgraphics_iconlabelspace.png

Fig. 3.10 To the left ICONLABELSPACE=0 and to the right ICONLABELSPACE=10

LARGURASIMBOLO

This parameter allows to specify the width of the symbol preview in millimeters. By default the width value is 7 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries,
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&SYMBOLWIDTH=2
../../../_images/wms_getlegendgraphics_symbolwidth.png

Fig. 3.11 To the left SYMBOLWIDTH=2 and to the right SYMBOLWIDTH=20

ALTURASIMBOLO

Este parâmetro permite especificar a altura da visualização do símbolo em milímetros. Por padrão, o valor da altura é 4 mm.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries,
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&SYMBOLHEIGHT=2
../../../_images/wms_getlegendgraphics_symbolheight.png

Fig. 3.12 To the left SYMBOLHEIGHT=2 and to the right SYMBOLHEIGHT=6

TITULOCAMADA

This parameter specifies whether to render layer title.

Available values are (not case sensitive):

  • VERDADEIRO (valor padrão)

  • FALSO

LAYERFONTFAMILY

This parameter specifies the font family to use for rendering layer title.

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries
&LAYERFONTFAMILY=monospace

CAMADAFONTENEGRITO

This parameter specifies whether the layer title is rendered in bold. Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&LAYERFONTBOLD=TRUE
../../../_images/wms_getlegendgraphics_layerfontbold.png

Fig. 3.13 Legend with LAYERFONTBOLD=TRUE

CAMADAFONTETAMANHO

This parameter specifies the font size for rendering layer title in point.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&LAYERFONTSIZE=20
../../../_images/wms_getlegendgraphics_layerfontsize.png

Fig. 3.14 Legend with LAYERFONTSIZE=20

CAMADAFONTEITÁLICO

This parameter specifies whether the layer title is rendered in italic. Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&LAYERFONTITALIC=TRUE
../../../_images/wms_getlegendgraphics_layerfontitalic.png

Fig. 3.15 Legend with LAYERFONTITALIC=TRUE

CAMADAFONTECOR

This parameter specifies the layer title color. The color may be literal (red, green, ..) or in hexadecimal notation (0xFF0000, 0x00FF00, …).

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&LAYERFONTCOLOR=0x5f9930
../../../_images/wms_getlegendgraphics_layerfontcolor.png

Fig. 3.16 Legend with LAYERFONTCOLOR=0x5f9930

ITEMFONTFAMILY

This parameter specifies the font family to use for rendering item label.

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=countries
&ITEMFONTFAMILY=monospace

ITEMFONTENEGRITO

This parameter specifies whether the item label is rendered in bold. Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&ITEMFONTBOLD=TRUE
../../../_images/wms_getlegendgraphics_itemfontbold.png

Fig. 3.17 Legend with ITEMFONTBOLD=TRUE

ITEMFONTETAMANHO

This parameter specifies the font size for rendering layer title in point.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&ITEMFONTSIZE=20
../../../_images/wms_getlegendgraphics_itemfontsize.png

Fig. 3.18 Legend with ITEMFONTSIZE=30

ITEMFONTEITÁLICO

This parameter specifies whether the item label is rendered in italic. Available values are (not case sensitive):

  • VERDADEIRO

  • FALSO

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&ITEMFONTITALIC=TRUE
../../../_images/wms_getlegendgraphics_itemfontitalic.png

Fig. 3.19 Legend with ITEMFONTITALIC=TRUE

ITEMFONTECOR

This parameter specifies the item label color. The color may be literal (red, green, ..) or in hexadecimal notation (0xFF0000, 0x00FF00, …).

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetLegendGraphics
&LAYERS=airports,places
&BBOX=43.20,-2.93,49.35,8.32
&CRS=EPSG:4326
&TRANSPARENT=TRUE
&ITEMFONTCOLOR=0x5f9930
../../../_images/wms_getlegendgraphics_itemfontcolor.png

Fig. 3.20 Legend with ITEMFONTCOLOR=0x5f9930

3.2.5. GetStyle(s)

Standard parameters for the GetStyle (or GetStyles) request according to the OGC WMS 1.1.1 specifications:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetStyle or GetStyles)

LAYERS

Sim

Layers to query

The GetStyle request supports as well the following vendor parameters:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetStyles
&LAYERS=mylayer1,mylayer2

3.2.6. DescribeLayer

Standard parameters for the DescribeLayer request according to the OGC WMS 1.1.1 and 1.3.0 specifications:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (DescribeLayer)

LAYERS

Sim

Camadas para descrever

SLD_VERSION

Sim

Versão SLD

The DescribeLayer request supports as well the following vendor parameters:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=DescribeLayer
&SLD_VERSION=1.1.0
&LAYERS=mylayer1

The XML document looks like:

<DescribeLayerResponse xmlns="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://www.opengis.net/se" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd">
    <Version>1.1.0</Version>
    <LayerDescription>
        <owsType>wfs</owsType>
        <se:OnlineResource xlink:href="http://localhost/qgis_server" xlink:type="simple"/>
        <TypeName>
            <se:FeatureTypeName>my_vector_layer</se:FeatureTypeName>
        </TypeName>
    </LayerDescription>
    <LayerDescription>
        <owsType>wcs</owsType>
        <se:OnlineResource xlink:href="http://localhost/qgis_server" xlink:type="simple"/>
        <TypeName>
            <se:FeatureTypeName>my_raster_layer</se:FeatureTypeName>
        </TypeName>
    </LayerDescription>
</DescribeLayerResponse>

VERSÃO_SLD

Este parâmetro permite especificar a versão do SLD. Apenas o valor 1.1.0 está disponível.

3.2.7. GetPrint

QGIS Server has the capability to create print layout output in pdf or pixel format. Print layout windows in the published project are used as templates. In the GetPrint request, the client has the possibility to specify parameters of the contained layout maps and labels.

The GetPrint request supports redlining, external WMS layers as well as the following parameters:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetPrint)

VERSION

Não

Versão do serviço

LAYERS

Não

Layers to display

TEMPLATE

Sim

Layout template to use

SRS / CRS

Sim

Sistema de referência de coordenadas

FORMAT

Não

Output format

ATLAS_PK

Não

Feições Atlas

STYLES

Não

Estilo das camadas

TRANSPARENT

Não

Plano de fundo transparente

OPACITIES

Não

Opacidade para camada ou grupo

SELECTION

Não

Highlight features

mapX:EXTENT

Não

Extensão do mapa ‘X’

mapX:LAYERS

Não

Camadas do mapa ‘X’

mapX:STYLES

Não

Layers’ style of the map ‘X’

mapX:SCALE

Não

Layers’ scale of the map ‘X’

mapX:ROTATION

Não

Rotação do mapa ‘X’

mapX:GRID_INTERVAL_X

Não

Grid interval on x axis of the map ‘X’

mapX:GRID_INTERVAL_Y

Não

Grid interval on y axis of the map ‘X’

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetPrint
&MAP=/home/qgis/projects/world.qgs
&CRS=EPSG:4326
&FORMAT=png
&TEMPLATE=Layout%201
&map0:EXTENT=-180,-90,180,90
&map0:LAYERS=mylayer1,mylayer2,mylayer3
&map0:OPACITIES=125,200,125
&map0:ROTATION=45

Note that the layout template may contain more than one map. In this way, if you want to configure a specific map, you have to use mapX: parameters where X is a positive number that you can retrieve thanks to the GetProjectSettings request.

Por exemplo:

<WMS_Capabilities>
...
<ComposerTemplates xsi:type="wms:_ExtendedCapabilities">
<ComposerTemplate width="297" height="210" name="Druckzusammenstellung 1">
<ComposerMap width="171" height="133" name="map0"/>
<ComposerMap width="49" height="46" name="map1"/></ComposerTemplate>
</ComposerTemplates>
...
</WMS_Capabilities>

MODELO

This parameter can be used to specify the name of a layout template to use for printing.

FORMATO

Este parâmetro especifica o formato da imagem do mapa. Os valores disponíveis são:

  • png (valor padrão)

  • imagem/png

  • jpg

  • jpeg

  • imagem/jpeg

  • svg

  • imagem/svg

  • image/svg+xml

  • pdf

  • application/pdf

Se o parâmetro FORMATO for diferente de um desses valores, uma exceção será retornada.

ATLAS_PK

This parameter allows activation of Atlas rendering by indicating which features we want to print. In order to retrieve an atlas with all features, the * symbol may be used (according to the maximum number of features allowed in the project configuration).

When FORMAT is pdf, a single PDF document combining the feature pages is returned. For all other formats, a single page is returned.

mapX:EXTENT

This parameter specifies the extent for a layout map item as xmin,ymin,xmax,ymax.

mapX:ROTATION

Este parâmetro especifica a rotação do mapa em graus.

mapX:GRID_INTERVAL_X

This parameter specifies the grid line density in the X direction.

mapX:GRID_INTERVAL_Y

This parameter specifies the grid line density in the Y direction.

mapaX:ESCALA

This parameter specifies the map scale for a layout map item. This is useful to ensure scale based visibility of layers and labels even if client and server may have different algorithms to calculate the scale denominator.

mapaX:CAMADAS

This parameter specifies the layers for a layout map item. See GetMap Layers for more information on this parameter.

mapaX:ESTILOS

This parameter specifies the layers’ styles defined in a specific layout map item. See GetMap Styles for more information on this parameter.

3.2.8. GetProjectSettings

This request type works similar to GetCapabilities, but it is more specific to QGIS Server and allows a client to read additional information which are not available in the GetCapabilities output:

  • visibilidade inicial das camadas

  • information about vector attributes and their edit types

  • information about layer order and drawing order

  • list of layers published in WFS

  • show if a group in the layer tree is mutually exclusive

The GetProjectSettings request supports the following parameters:

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetProjectSettings)

3.2.9. GetSchemaExtension

The GetSchemaExtension request allows to retrieve optional extended capabilities and operations of the WMS service such as implemented by QGIS Server.

Parâmetros

Requerido

Descrição

MAP

Sim

arquivo de projeto QGIS

SERVICE

Sim

Nome do serviço (WMS)

REQUEST

Sim

Name of the request (GetSchemaExtension)

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetSchemaExtension

The XML document looks like:

<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wms="http://www.opengis.net/wms" xmlns:qgs="http://www.qgis.org/wms" targetNamespace="http://www.qgis.org/wms" elementFormDefault="qualified" version="1.0.0">
    <import namespace="http://www.opengis.net/wms" schemaLocation="http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd"/>
    <element name="GetPrint" type="wms:OperationType" substitutionGroup="wms:_ExtendedOperation"/>
    <element name="GetStyles" type="wms:OperationType" substitutionGroup="wms:_ExtendedOperation"/>
</schema>

3.2.10. External WMS layers

QGIS Server allows including layers from external WMS servers in WMS GetMap and WMS GetPrint requests. This is especially useful if a web client uses an external background layer in the web map. For performance reasons, such layers should be directly requested by the web client (not cascaded via QGIS server). For printing however, these layers should be cascaded via QGIS server in order to appear in the printed map.

External layers can be added to the LAYERS parameter as EXTERNAL_WMS:<layername>. The parameters for the external WMS layers (e.g. url, format, dpiMode, crs, layers, styles) can later be given as service parameters <layername>:<parameter>. In a GetMap request, this might look like this:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetMap
&LAYERS=EXTERNAL_WMS:basemap,layer1,layer2
&OPACITIES=100,200,255
&STYLES=,,
&basemap:url=http://externalserver.com/wms.fcgi
&basemap:format=image/jpeg
&basemap:dpiMode=7
&basemap:crs=EPSG:2056
&basemap:layers=orthofoto
&basemap:styles=default

Similarly, external layers can be used in GetPrint requests:

http://localhost/qgisserver?
SERVICE=WMS
&REQUEST=GetPrint
&TEMPLATE=A4
&map0:layers=EXTERNAL_WMS:basemap,layer1,layer2
&map0:EXTENT=<minx,miny,maxx,maxy>
&OPACITIES=100,200,255
&basemap:url=http://externalserver.com/wms.fcgi
&basemap:format=image/jpeg
&basemap:dpiMode=7
&basemap:crs=EPSG:2056
&basemap:layers=orthofoto
&basemap:styles=default

3.2.11. Redlining

This feature is available and can be used with GetMap and GetPrint requests.

The redlining feature can be used to pass geometries and labels in the request which are overlapped by the server over the standard returned image (map). This permits the user to put emphasis or maybe add some comments (labels) to some areas, locations etc. that are not in the standard map.

The GetMap request is in the format:

http://localhost/qgisserver?
SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetMap
&HIGHLIGHT_GEOM=POLYGON((590000 5647000, 590000 6110620, 2500000 6110620, 2500000 5647000, 590000 5647000))
&HIGHLIGHT_SYMBOL=<StyledLayerDescriptor><UserStyle><Name>Highlight</Name><FeatureTypeStyle><Rule><Name>Symbol</Name><LineSymbolizer><Stroke><SvgParameter name="stroke">%23ea1173</SvgParameter><SvgParameter name="stroke-opacity">1</SvgParameter><SvgParameter name="stroke-width">1.6</SvgParameter></Stroke></LineSymbolizer></Rule></FeatureTypeStyle></UserStyle></StyledLayerDescriptor>
&HIGHLIGHT_LABELSTRING=Write label here
&HIGHLIGHT_LABELSIZE=16
&HIGHLIGHT_LABELCOLOR=%23000000
&HIGHLIGHT_LABELBUFFERCOLOR=%23FFFFFF
&HIGHLIGHT_LABELBUFFERSIZE=1.5

The GetPrint equivalent is in the format (note that mapX: parameter is added to tell which map has redlining):

http://localhost/qgisserver?
SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetPrint
&map0:HIGHLIGHT_GEOM=POLYGON((590000 5647000, 590000 6110620, 2500000 6110620, 2500000 5647000, 590000 5647000))
&map0:HIGHLIGHT_SYMBOL=<StyledLayerDescriptor><UserStyle><Name>Highlight</Name><FeatureTypeStyle><Rule><Name>Symbol</Name><LineSymbolizer><Stroke><SvgParameter name="stroke">%23ea1173</SvgParameter><SvgParameter name="stroke-opacity">1</SvgParameter><SvgParameter name="stroke-width">1.6</SvgParameter></Stroke></LineSymbolizer></Rule></FeatureTypeStyle></UserStyle></StyledLayerDescriptor>
&map0:HIGHLIGHT_LABELSTRING=Write label here
&map0:HIGHLIGHT_LABELSIZE=16
&map0:HIGHLIGHT_LABELCOLOR=%23000000
&map0:HIGHLIGHT_LABELBUFFERCOLOR=%23FFFFFF
&map0:HIGHLIGHT_LABELBUFFERSIZE=1.5

Here is the image outputed by the above request in which a polygon and a label are drawn on top of the normal map:

../../../_images/server_redlining.png

Fig. 3.21 Server response to a GetMap request with redlining parameters

Você pode ver que há vários parâmetros nesta solicitação:

  • HIGHLIGHT_GEOM: You can add POINT, MULTILINESTRING, POLYGON etc. It supports multipart geometries. Here is an example: HIGHLIGHT_GEOM=MULTILINESTRING((0 0, 0 1, 1 1)). The coordinates should be in the CRS of the GetMap/GetPrint request.

  • HIGHLIGHT_SYMBOL: This controls how the geometry is outlined and you can change the stroke width, color and opacity.

  • HIGHLIGHT_LABELSTRING: You can pass your labeling text to this parameter.

  • HIGHLIGHT_LABELSIZE: This parameter controls the size of the label.

  • HIGHLIGHT_LABELFONT: This parameter controls the font of the label (e.g. Arial)

  • HIGHLIGHT_LABELCOLOR: This parameter controls the label color.

  • HIGHLIGHT_LABELBUFFERCOLOR: This parameter controls the label buffer color.

  • HIGHLIGHT_LABELBUFFERSIZE: This parameter controls the label buffer size.