Outdated version of the documentation. Find the latest one here.

サービス

QGIS Server supports some vendor parameters and requests that greatly enhance the possibilities of customising its behavior. The following paragraphs list the vendor parameters and the environment variables supported by the server.

Web地図サービス (WMS)

GetMap

In the WMS GetMap request, QGIS Server accepts a couple of extra parameters in addition to the standard parameters according to the OGC WMS 1.3.0 specification:

  • DPI parameter: The DPI parameter can be used to specify the requested output resolution.

    例:

    http://localhost/cgi-bin/qgis_mapserv.fcgi?REQUEST=GetMap&DPI=300&...
  • IMAGE_QUALITY 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 ‣ Project Properties dialog. If you want to override it in a GetMap request you can do it using the IMAGE_QUALITY parameter:

    http://localhost/cgi-bin/qgis_mapserv.fcgi?\
     REQUEST=GetMap&FORMAT=image/jpeg&IMAGE_QUALITY=65&...
    
  • image/png; mode= can be used to override the png format. You can choose between image/png; mode=16bit, image/png; mode=8bit and image/png; mode=1bit. This can shrink the output image size quite a bit. Example:

    http://localhost/cgi-bin/qgis_mapserv.fcgi?\
     REQUEST=GetMap&FORMAT=image/png; mode=8bit&...
    
  • OPACITIES parameter: Opacity can be set on layer or group level. Allowed values range from 0 (fully transparent) to 255 (fully opaque).

    例:

    http://localhost/cgi-bin/qgis_mapserv.fcgi?\
      REQUEST=GetMap&LAYERS=mylayer1,mylayer2&OPACITIES=125,200&...
  • FILTER parameter: Subsets of layers can be selected with the FILTER parameter. 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:

    Text strings need to be enclosed with quotes (single quotes for strings, double quotes for attributes) A space between each word / special character is mandatory. Allowed Keywords and special characters are ‘AND’,’OR’,’IN’,’=’,’<’,’>=’, ‘>’,’>=’,’!=*,’(‘,’)’. Semicolons in string expressions are not allowed

    例:

    http://myserver.com/cgi/qgis_mapserv.fcgi?REQUEST=GetMap&LAYERS=mylayer1,mylayer2&FILTER=mylayer1:"OBJECTID" = 3;mylayer2:'text' = 'blabla'&....

ノート

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.

  • SELECTION parameter: The SELECTION parameter can highlight features from one or more layers. Vector features can be selected by passing comma separated lists with feature ids in GetMap and GetPrint.

    例:

    http://myserver.com/cgi/qgis_mapserv.fcgi?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

    SELECTIONパラメーターを指定したGetMapリクエストに対するサーバーの応答

It is possible to export layers in the DXF format using the GetMap Request. Only layers that have read access in the WFS service are exported in the DXF format. Here is a valid REQUEST and a documentation of the available parameters:

http://your.server.address/wms/liegenschaftsentwaesserung/abwasser_werkplan?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=Haltungen,Normschacht,Spezialbauwerke&STYLES=&CRS=EPSG%3A21781&BBOX=696136.28844801,245797.12108743,696318.91114315,245939.25832905&WIDTH=1042&HEIGHT=811&FORMAT=application/dxf&FORMAT_OPTIONS=MODE:SYMBOLLAYERSYMBOLOGY;SCALE:250&FILE_NAME=werkplan_abwasser.dxf

Parameters:

  • FORMAT=application/dxf
  • FILE_NAME=yoursuggested_file_name_for_download.dxf
  • FORMAT_OPTIONS=see options below, key:value pairs separated by Semicolon

FORMAT_OPTIONS Parameters:

  • SCALE:scale to be used for symbology rules, filters and styles (not an actual scaling of the data - data remains in the original scale).
  • MODE:NOSYMBOLOGY|FEATURESYMBOLOGY|SYMBOLLAYERSYMBOLOGY corresponds to the three export options offered in the QGIS Desktop DXF export dialog.
  • LAYERSATTRIBUTES:yourcolumn_with_values_to_be_used_for_dxf_layernames - 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.

GetFeatureInfo

QGIS Server WMS GetFeatureInfo requests supports the following extra optional parameters to define the tolerance for point, line and polygon layers:

  • FI_POINT_TOLERANCE parameter: Tolerance for point layers GetFeatureInfo request, in pixels.
  • FI_LINE_TOLERANCE parameter: Tolerance for linestring layers GetFeatureInfo request, in pixels.
  • FI_POLYGON_TOLERANCE parameter: Tolerance for polygon layers GetFeatureInfo request, in pixels.

GetPrint

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

Example:

The published project has two composer maps. In the GetProjectSettings response, they are listed as possible print templates:

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

The client has now the information to request a print output:

http://myserver.com/cgi/qgis_mapserv.fcgi?...&REQUEST=GetPrint&TEMPLATE=Druckzusammenstellung 1&map0:EXTENT=xmin,ymin,xmax,ymax&map0:ROTATION=45&FORMAT=pdf&DPI=300

Parameters in the GetPrint request are:

  • <map_id>:EXTENT gives the extent for a composer map as xmin,ymin,xmax,ymax.
  • <map_id>:ROTATION map rotation in degrees
  • <map_id>:GRID_INTERVAL_X, <map_id>:GRID_INTERVAL_Y Grid line density for a composer map in x- and y-direction
  • <map_id>:SCALE Sets a mapscale to a composer map. 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
  • <map_id>:LAYERS, <map_id>:STYLES possibility to give layer and styles list for composer map (useful in case of overview maps which should have only a subset of layers)

GetLegendGraphics

いくつかの追加のパラメーターは、凡例の要素のサイズを変更できます:

  • BOXSPACE 凡例フレームと内容の間の空白(mm)

  • LAYERSPACE versical space between layers (mm)
  • LAYERTITLESPACE レイヤータイトルと後続アイテム間の垂直方向のスペース(mm)

  • SYMBOLSPACE シンボルとアイテム間の垂直方向の間隔(mm)

  • ICONLABELSPACE シンボルとラベルのテキストの間の水平スペース(ミリメートル)

  • SYMBOLWIDTH シンボルプレビューの幅(mm)

  • SYMBOLHEIGHT シンボルプレビューの高さ(mm)

これらのパラメーターは、レイヤーのタイトルや項目ラベルのフォントプロパティを変更します。

  • LAYERFONTFAMILY / ITEMFONTFAMILY レイヤータイトル/項目テキストのためのフォントファミリー

  • LAYERFONTBOLD / ITEMFONTBOLD ‘TRUE’ to use a bold font
  • LAYERFONTSIZE / ITEMFONTSIZE ポイントでのフォントサイズ

  • LAYERFONTITALIC / ITEMFONTITALIC ‘TRUE’ to use italic font
  • LAYERFONTCOLOR / ITEMFONTCOLOR Hex color code (e.g. #FF0000 for red)
  • LAYERTITLE / RULELABEL (from QGIS 2.4) set them to ‘FALSE’ to get only the legend graphics without labels

Contest based legend. These parameters let the client request a legend showing only the symbols for the features falling into the requested area:

  • BBOX 凡例を構築する必要のある地域

  • CRS / SRS BBOX座標を定義するために採用された座標参照系

  • 設定されている場合** WIDTH / HEIGHT **これらは、地図ビューの画像サイズに応じてQGIS サーバーがシンボルを縮尺設定できるように、GetMapリクエストのために定義されたものと一致する必要があります。

Contest based legend features are based on the UMN MapServer implementation:

GetProjectSettings

このリクエストタイプは GetCapabilities に似ていますが、それはQGIS サーバーに対してより具体的であり、クライアントは、GetCapabilities出力では利用できない追加情報を読み取ることができます:

  • レイヤーの初期可視性

  • ベクターの属性とその編集タイプに関する情報

  • レイヤーの順序と描画順序に関する情報

  • WFSに掲載されたレイヤのリスト

Web Feature Service (WFS)

GetFeature

In the WFS GetFeature request, QGIS Server accepts two extra parameters in addition to the standard parameters according to the OGC WFS 1.0.0 specification:

  • GeometryName parameter: this parameter can be used to get the extent or the centroid as the geometry or no geometry if none if used (ie attribute only). Allowed values are extent, centroid or none.
  • StartIndex parameter: STARTINDEX is standard in WFS 2.0, but it’s an extension for WFS 1.0.0 which is the only version implemented in QGIS Server. STARTINDEX can be used to skip some features in the result set and in combination with MAXFEATURES will provide for the ability to use WFS GetFeature to page through results. Note that STARTINDEX=0 means start with

すべてのリクエストタイプでサポートされている追加パラメーター

  • FILE_NAME パラメーター:設定されている場合、サーバーの応答が指定したファイル名のファイルの添付ファイルとしてクライアントに送信されます。

  • MAP パラメーター:MapServerと同様に、 MAP パラメーターを使用してQGISプロジェクトファイルへのパスを指定できます。( qgis_mapserv.fcgi :ファイル)サーバーの実行可能ファイルの場所への絶対パスまたは相対パスを指定できます。指定されていない場合は、QGIS Serverは、サーバーの実行可能ファイルがあるディレクトリ内で.qgsファイルを検索します。

    例:

    http://localhost/cgi-bin/qgis_mapserv.fcgi?\
      REQUEST=GetMap&MAP=/home/qgis/mymap.qgs&...

ノート

QGISプロジェクトファイルをどこで検索するかをサーバーの実行可能ファイルに伝えるために、環境変数として QGIS_PROJECT_FILE を定義できます。この変数はQGISによってプロジェクトファイルが探される場所になります。定義されていない場合はリクエスト中のMAPパラメーターを使用し、最終的にはサーバーの実行可能ファイルのディレクトリを見ていきます。

the first feature, skipping none.

REDLINING

この機能は利用可能であり、 GetMap および GetPrint 要求と共に使用できます。

赤線引き地物は、リクエスト中のジオメトリとラベルに渡すのに使用できます、標準返された画像(地図)上でサーバーによって重ねあわされます。これにより、ユーザーは、標準地図にないいくつかの領域、場所などに強調(emphasis)またはコメント(ラベル)を追加することが可能になります。

要求は以下の形式で行われます。

http://qgisplatform.demo/cgi-bin/qgis_mapserv.fcgi?map=/world.qgs&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

ポリゴンとラベルが通常地図の上に描かれている、上記の要求によって出力された画像は次のとおりです:

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

レッドラインパラメーターを持つGetMapリクエストに対するサーバーの応答

このリクエストにはいくつかのパラメーターがあります。

  • HIGHLIGHT_GEOM :POINT、MULTILINESTRING、POLYGONなどを追加できます。マルチパートジオメトリをサポートしています。例は: HIGHLIGHT_GEOM=MULTILINESTRING((0 0, 0 1, 1 1)) 。座標はGetMap/GetPrint要求のCRSになければなりません。

  • HIGHLIGHT_SYMBOL :ジオメトリの輪郭をどのように表示するかを制御し、ストロークの幅、色、不透明度を変更できます。

  • HIGHLIGHT_LABELSTRING :ラベルのテキストをこのパラメーターに渡すことができます。

  • HIGHLIGHT_LABELSIZE: このパラメーターは、ラベルのサイズを制御します。

  • HIGHLIGHT_LABELCOLOR: このパラメーターは、ラベルの色を制御します。

  • HIGHLIGHT_LABELBUFFERCOLOR: このパラメーターは、ラベルバッファの色を制御します。

  • HIGHLIGHT_LABELBUFFERSIZE: このパラメーターは、ラベルバッファのサイズを制御します。