3.3. WFS(웹 피처 서비스)

QGIS 서버에 구현된 WFS 1.0.01.1.0 표준은 QGIS 프로젝트로부터 지리 피처를 쿼리할 수 있는 HTTP 인터페이스를 제공합니다. 전형적인 WFS 요청은 사용할 QGIS 프로젝트와 쿼리할 레이어를 정의합니다.

서비스 버전에 따른 사양 문서:

QGIS 서버가 제공하는 표준 요청:

요청

설명

GetCapabilities

서버에 대한 정보를 담은 XML 메타데이터를 반환합니다.

GetFeature

피처 집합을 반환

DescribeFeatureType

피처 유형 및 속성의 설명을 반환

Transaction

피처를 삽입, 업데이트, 삭제 가능

3.3.1. GetCapabilities

Standard parameters for the GetCapabilities request according to the OGC WFS 1.0.0 and 1.1.0 specifications:

파라미터

필수 여부

설명

SERVICE

Name of the service (WFS)

REQUEST

Name of the request (GetCapabilities)

VERSION

서비스의 버전

표준 파라미터 이외에도, QGIS 서버는 다음과 같은 추가 파라미터를 지원합니다:

파라미터

필수 여부

설명

MAP

QGIS project file

VERSION

이 파라미터는 사용할 서비스의 버전을 지정할 수 있습니다. VERSION 파라미터가 사용할 수 있는 값은 다음과 같습니다:

  • 1.0.0

  • 1.1.0

요청에서 버전을 지정하지 않을 경우, 1.1.0 을 기본값으로 사용합니다.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&...

3.3.2. GetFeature

OGC WFS 1.0.0 및 1.1.0 사양에 따른 GetFeature 요청용 표준 파라미터:

파라미터

필수 여부

설명

SERVICE

Name of the service (WFS)

REQUEST

Name of the request (GetFeature)

VERSION

서비스의 버전

TYPENAME

레이어명

FEATUREID

피처를 ID로 필터링

OUTPUTFORMAT

출력물 포맷

RESULTTYPE

산출물 유형

PROPERTYNAME

반환할 속성의 명칭

MAXFEATURES

반환할 피처의 최대 개수

SRSNAME

좌표계

FILTER

OGC 필터 인코딩

BBOX

맵 범위

SORTBY

산출물 정렬

표준 파라미터 이외에도, QGIS 서버는 다음과 같은 추가 파라미터를 지원합니다:

파라미터

필수 여부

설명

MAP

QGIS project file

STARTINDEX

페이지 번호 붙이기

GEOMETRYNAME

반환할 도형의 유형

EXP_FILTER

표현식 필터링

TYPENAME

This parameter allows to specify layer names and is mandatory if FEATUREID is not set.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=GetFeature
&TYPENAME=countries

FEATUREID

This parameter allows to specify the ID of a specific feature and is formed like typename.fid,typename.fid,....

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&FEATUREID=countries.0,places.1

XML response:

<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.qgis.org/gml http://192.168.1.15/qgisserver?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=countries,places&OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1">
  <gml:boundedBy>
    ...
  </gml:boundedBy>
  <gml:featureMember>
    <qgs:countries gml:id="countries.1">
      ...
    </qgs:countries>
  </gml:featureMember>
  <gml:featureMember>
    <qgs:places gml:id="places.1">
      ...
    </qgs:places>
  </gml:featureMember>
</wfs:FeatureCollection>

OUTPUTFORMAT

This parameter may be used to specify the format of the response. If VERSION is greater or equal than 1.1.0, GML3 is the default format. Otherwise GML2 is used.

Available values are:

  • gml2

  • text/xml; subtype=gml/2.1.2

  • gml3

  • text/xml; subtype=gml/3.1.1

  • geojson

  • application/vnd.geo+json,

  • application/vnd.geo json

  • application/geo+json

  • application/geo json

  • application/json

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&FEATUREID=countries.0
&OUTPUTFORMAT=geojson

GeoJSON response:

{
    "type":"FeatureCollection",
    "bbox":[
        -180,
        -90,
        180,
        83.6236
    ],
    "features":[
        {
            "bbox":[
                -61.891113,
                16.989719,
                -61.666389,
                17.724998
            ],
            "geometry":{
                "coordinates":[
                    "..."
                ],
                "type":"MultiPolygon"
            },
            "id":"countries.1",
            "properties":{
                "id":1,
                "name":"Antigua and Barbuda"
            },
            "type":"Feature"
        }
    ]
}

RESULTTYPE

이 파라미터는 산출물의 종류를 지정할 수 있습니다. 사용할 수 있는 값은 다음과 같습니다:

  • results: 기본 습성

  • hits: 피처 개수만 반환

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=GetFeature
&RESULTTYPE=hits
&...

PROPERTYNAME

This parameter may be used to specify a specific property to return. A property needs to be mapped with a TYPENAME or a FEATUREID:

Valid URL example:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&PROPERTYNAME=name
&TYPENAME=places

On the contrary, the next URL will return an exception:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&PROPERTYNAME=name
&TYPENAME=places,countries
<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" version="1.2.0">
    <ServiceException code="RequestNotWellFormed">There has to be a 1:1 mapping between each element in a TYPENAME and the PROPERTYNAME list</ServiceException>
</ServiceExceptionReport>

MAXFEATURES

This parameter allows to limit the number of features returned by the request.

참고

This parameter may be useful to improve performances when underlying vector layers are heavy.

SRSNAME

This parameter allows to indicate the response output Spatial Reference System as well as the BBOX CRS and has to be formed like EPSG:XXXX.

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&TYPENAME=places
&SRSNAME=EPSG:32620

FILTER

This parameter allows to filter the response with the Filter Encoding language defined by the OGC Filter Encoding standard.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS&
REQUEST=GetFeature&
TYPENAME=places&
FILTER=<Filter><PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>Paris</Literal></PropertyIsEqualTo></Filter>

BBOX

이 파라미터는 맵 범위를 현재 좌표계의 단위로 지정할 수 있습니다. 좌표를 쉼표로 구분해야 합니다.

The SRSNAME parameter may specify the CRS of the extent. If not specified, the CRS of the layer is used.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&TYPENAME=places
&BBOX=-11.84,42.53,8.46,50.98

The FEATUREID parameter cannot be used with the BBOX. Any attempt will result in an exception:

<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" version="1.2.0">
  <ServiceException code="RequestNotWellFormed">FEATUREID FILTER and BBOX parameters are mutually exclusive</ServiceException>
</ServiceExceptionReport>

SORTBY

This parameter allows to sort resulting features according to property values and has to be formed like propertyname SORTRULE.

Available values for SORTRULE in case of descending sorting:

  • D

  • +D

  • DESC

  • +DESC

Available values for SORTRULE in case of ascending sorting:

  • A

  • +A

  • ASC

  • +ASC

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&TYPENAME=places
&PROPERTYNAME=name
&MAXFEATURES=3
&SORTBY=name DESC

The corresponding result:

<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.qgis.org/gml http://192.168.1.15/qgisserver?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=places&OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1">
    <gml:boundedBy>
        ...
    </gml:boundedBy>
    <gml:featureMember>
        <qgs:places gml:id="places.90">
            <qgs:name>Zagreb</qgs:name>
        </qgs:places>
    </gml:featureMember>
    <gml:featureMember>
        <qgs:places gml:id="places.113">
            <qgs:name>Yerevan</qgs:name>
        </qgs:places>
    </gml:featureMember>
    <gml:featureMember>
        <qgs:places gml:id="places.111">
            <qgs:name>Yaounde</qgs:name>
        </qgs:places>
    </gml:featureMember>
</wfs:FeatureCollection>

GEOMETRYNAME

이 파라미터는 피처에 대해 반환할 도형의 종류를 지정할 수 있습니다. 사용할 수 있는 값은 다음과 같습니다:

  • extent

  • centroid

  • none

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=GetFeature
&GEOMETRYNAME=centroid
&...

STARTINDEX

This parameter is standard in WFS 2.0, but it’s an extension for WFS 1.0.0.

Actually, it can be used to skip some features in the result set and in combination with MAXFEATURES, it provides the ability to page through results.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=GetFeature
&STARTINDEX=2
&...

EXP_FILTER

This parameter allows to filter the response with QGIS expressions.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS&
REQUEST=GetFeature&
TYPENAME=places&
EXP_FILTER="name"='Paris'

3.3.3. DescribeFeatureType

Standard parameters for the DescribeFeatureType request according to the OGC WFS 1.0.0 and 1.1.0 specifications:

파라미터

필수 여부

설명

SERVICE

Name of the service (WFS)

REQUEST

Name of the request (DescribeFeatureType)

VERSION

서비스의 버전

OUTPUTFORMAT

Format of the response

TYPENAME

레이어명

표준 파라미터 이외에도, QGIS 서버는 다음과 같은 추가 파라미터를 지원합니다:

파라미터

필수 여부

설명

MAP

QGIS project file

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=DescribeFeatureType
&TYPENAME=countries

Output response:

<schema xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:qgs="http://www.qgis.org/gml" xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" version="1.0" elementFormDefault="qualified">
  <import schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" namespace="http://www.opengis.net/gml"/>
  <element type="qgs:countriesType" substitutionGroup="gml:_Feature" name="countries"/>
  <complexType name="countriesType">
    <complexContent>
      <extension base="gml:AbstractFeatureType">
        <sequence>
          <element minOccurs="0" type="gml:MultiPolygonPropertyType" maxOccurs="1" name="geometry"/>
          <element type="long" name="id"/>
          <element nillable="true" type="string" name="name"/>
        </sequence>
      </extension>
    </complexContent>
  </complexType>
</schema>

3.3.4. Transaction

This request allows to update, delete or add one or several features thanks to a XML document. The delete action may be achieved with a POST request as well as with the OPERATION parameter while the add and the update operations may be achieved through POST request only.

Standard parameters for the Transaction request according to the OGC WFS 1.0.0 and 1.1.0 specifications:

파라미터

필수 여부

설명

SERVICE

Name of the service (WFS)

REQUEST

Name of the request (Transaction)

VERSION

서비스의 버전

FILTER

OGC 필터 인코딩

BBOX

맵 범위

FEATUREID

피처를 ID로 필터링

TYPENAME

레이어명

표준 파라미터 이외에도, QGIS 서버는 다음과 같은 추가 파라미터를 지원합니다:

파라미터

필수 여부

설명

MAP

QGIS project file

OPERATION

Specify the operation

EXP_FILTER

표현식 필터링

OPERATION

This parameter allows to delete a feature without using a POST request with a dedicated XML document.

URL 예시:

http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=Transaction
&OPERATION=DELETE
&FEATUREID=24

참고

FEATUREID, BBOX and FILTER parameters are mutually exclusive and prioritized in this order.

Add features

POST request example:

wget --post-file=add.xml "http://localhost/qgisserver?SERVICE=WFS&REQUEST=Transaction"

with the add.xml document:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/wfs" updateSequence="0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" xmlns:gml="http://www.opengis.net/gml"  xmlns:ows="http://www.opengis.net/ows">
  <wfs:Insert idgen="GenerateNew">
    <qgs:places>
      <qgs:geometry>
        <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
          <gml:coordinates decimal="." cs="," ts=" ">-4.6167,48.3833</gml:coordinates>
        </gml:Point>
      </qgs:geometry>
      <qgs:name>Locmaria-Plouzané</qgs:name>
    </qgs:places>
  </wfs:Insert>
</wfs:Transaction>

Update features

POST request example:

wget --post-file=update.xml "http://localhost/qgisserver?SERVICE=WFS&REQUEST=Transaction"

with the update.xml document:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/wfs" updateSequence="0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" xmlns:gml="http://www.opengis.net/gml"  xmlns:ows="http://www.opengis.net/ows">
    <wfs:Update typeName="places">
      <wfs:Property>
          <wfs:Name>name</wfs:Name>
          <wfs:Value>Lutece</wfs:Value>
      </wfs:Property>
      <ogc:Filter>
          <ogc:FeatureId fid="24"/>
      </ogc:Filter>
    </wfs:Update>
</wfs:Transaction>

Delete features

POST request example:

wget --post-file=delete.xml "http://localhost/qgisserver?SERVICE=WFS&REQUEST=Transaction"

with the delete.xml document:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/wfs" updateSequence="0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" xmlns:gml="http://www.opengis.net/gml"  xmlns:ows="http://www.opengis.net/ows">
    <wfs:Delete typeName="places">
        <ogc:Filter>
            <ogc:FeatureId fid="24"/>
        </ogc:Filter>
    </wfs:Delete>
</wfs:Transaction>