QGIS Server это свободная реализация сервера WMS версии 1.3 и WFS версии 1.0.0, которая кроме того имеет дополнительные возможности для тематического картографирования. QGIS Server является написаным на С++ приложением FastCGI/CGI (Common Gateway Interface), которое работает совместно с веб-сервером (например, Apache или Lighttpd). Разработка сервера была профинансирована проектами Orchestra ЕС, Sany и администрацией города Устер (Швейцария).
Он использует QGIS для отрисовки карты и ГИС-логики. Графическая подсистема реализована при помощи библиотеки Qt, это же позволило получить кроссплатформенность. В отличие от других WMS-решений, QGIS Server использует картографические правила в SLD/SE и как язык конфигурирования сервера, и для описания пользовательских картографических правил.
Кроме того, проект QGIS Server предоставляет расширение «Publish to Web» для QGIS, при помощи которого можно экспортировать текущие слои и символику в проект для QGIS Server (включая правила отображения в формате SLD).
Так как QGIS и QGIS Server используют одни и те же библиотеки визуализации, карта, опубликованная в Интернет, выглядит точно так же, как и в настольной ГИС. Модуль «Publish to Web» поддерживает базовую символику, более сложные правила картографической визуализации задаются вручную. В качестве конфигурационных файлов используется стандарт SLD и его расширения, таким образом, необходимо знать только один стандартизированный язык, что значительно уменьшает сложность создания карт для Интернет.
В следующих версиях руководства будет приведена инструкция по базовой настройке сервера. В настоящее же время получить больше информации можно по следующим ссылкам:
В этом разделе кратко описан процесс установки на Debian Squeeze. Бинарные сборки существуют и для многих других операционных систем. Если вы скомпилировали сервер WMS самостоятельно, обратитесь к ранее приведенным сайтам.
Кроме самой QGIS и сервера WMS нужен еще и web-сервер, в нашем случае apache2. Установить необходимые пакеты со всеми зависимостями можно при помощи aptitude или apt-get install. После установки необходимо убедиться, что и web-сервер, и сервер WMS работают правильно. Запустите web-сервер, выполнив команду /etc/init.d/apache2 start. Откройте браузер и введите адрес: http://localhost. Если apache запущен и работает “правильно, в окне браузера отобразится текст «It works!».
Теперь можно перейти к проверке работоспособности сервера WMS. Исполняемый файл qgis_mapserv.fcgi расположенный в /usr/lib/cgi-bin/qgis_mapserv.fcgi является стандартным шаблоном WMS и отображает границы штатов США. Добавьте адрес http://localhost/cgi-bin/qgis_mapserv.fcgi к списку серверов WMS QGIS, как это описано в разделе Выбор WMS/WMTS-серверов.
Figure Server 1:
Для создания нового сервера WMS/WFS нужно создать проект QGIS и добавить в него какие-то данные. В этом примере мы будем использовать shape-файл alaska.shp из демонстрационного набора данных QGIS. Загрузим shape-файл в проект, настроим цвета и стиль оформления слоя, а также зададим систему координат проекта.
Figure Server 2:
Then go to the OWS Server menu of the
Project ‣ Project Properties dialog and give
some information about the OWS in the fields under
Service Capabilities.
This will appear in the GetCapabilities response of the WMS or WFS.
If you don’t check Service capabilities
QGIS Server will use the information given in the wms_metadata.xml file
located in the cgi-bin folder.
In the WMS capabilities section you can define
the extent advertised in the WMS GetCapabilities response by entering
the minimum and maximum X and Y values in the fields under
Advertised extent.
Clicking Use Current Canvas Extent sets these values to the
extent currently displayed in the QGIS map canvas.
By checking CRS restrictions you can restrict
in which coordinate reference systems (CRS) QGIS Server will offer
to render maps.
Use the
button below to select those CRS
from the Coordinate Reference System Selector, or click Used
to add the CRS used in the QGIS project to the list.
If you have print composers defined in your project they will be listed in the
GetCapabilities response, and they can be used by the GetPrint request to
create prints, using one of the print composer layouts as a template.
This is a QGIS specific extension to the WMS 1.3.0 specification.
If you want to exclude any print composer from being published by the WMS,
check Exclude composers and click the
button below.
Then select a print composer from the Select print composer dialog
in order to add it to the excluded composers list.
If you want to exclude any layer or layer group from being published by the
WMS, check Exclude Layers and click the
button below.
This opens the Select restricted layers and groups dialog which
allows you to choose the layers and groups that you don’t want to be published.
Use the shift or control key if you want to select multiple entries at once.
If you wish you can check Add WKT geometry to feature
info response.
This will include in the GetFeatureInfo response the geometries of the features
in a text format.
If you want QGIS Server to advertise specific request URLs in the WMS
GetCapabilities response, enter the corresponding URL in the
Advertised URL field.
Furthermore you can restrict the maximum size of the maps returned by the
GetMap request by entering the maximum width and height into the respective
fields under Maximums for GetMap request.
In the WFS capabilities area you can select the layers that you want to provide as WFS, and specify if they will allow the update, insert and delete operations. If you enter a URL in the Advertised URL field of the WFS capabilities section, QGIS Server will advertise this specific URL in the WFS GetCapabilities response.
Now save the session in a project file alaska.qgs. To provide the project as a WMS/WFS, we create a new folder /usr/lib/cgi-bin/project with admin privileges and add the project file alaska.qgs and a copy of the qgis_mapserv.fcgi file - that’s all.
Now we test our project WMS and WFS, add the WMS and WFS as described in Загрузка WMS/WMTS-слоёв and Клиент WFS и WFS-T to QGIS and load the WMS. The URL is:
http://localhost/cgi-bin/project/qgis_mapserv.fcgi
For vector layers, the Fields menu of the Layer ‣ Properties dialog allows you to define for each attribute if it will be published or not. By default all the attributes are published by your WMS and WFS. If you want a specific attribute not to be published, uncheck the corresponding check box in the WMS or WFS column.
You can overlay watermarks over the maps produced by your WMS by adding text annotations or SVG annotations to the project file. See sec_annotations for instructions on creating annotations. For annotations to be displayed as watermarks on the WMS output, the Fixed map position check box in the Annotation text dialog must be unchecked. This can be accessed by double clicking the annotation while one of the annotation tools is active. For SVG annotations you will either need to set the project to save absolute paths (in the General menu of the Project ‣ Project Properties dialog) or to manually modify the path to the SVG image in a way that it represents a valid relative path.
In the WMS GetMap request QGIS Server accepts a couple of extra parameters in addition to the standard parameters according to the OCG WMS 1.3.0 specification:
MAP parameter: Similar to MapServer, the MAP parameter can be used to specify the path to the QGIS project file. You can specify an absolute path or a path relative to the location of the server executable (qgis_mapserv.fcgi). If not specified, QGIS Server searches for .qgs files in the directory where the server executable is located.
Пример:
http://localhost/cgi-bin/qgis_mapserv.fcgi?\
REQUEST=GetMap&MAP=/home/qgis/mymap.qgs&...
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&...
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&...