Importante

Translation is a community effort you can join. This page is currently translated at 62.69%.

3.3. Web Feature Service (WFS)

The 1.0.0 and 1.1.0 WFS standards implemented in QGIS Server provide a HTTP interface to query geographic features from a QGIS project. A typical WFS request defines the QGIS project to use and the layer to query.

Documento de especificações de acordo com o número da versão do serviço:

Requisitos padrões fornecidos pelo Servidor QGIS:

Solicitação

Descrição

GetCapabilities

Retorna metadados XML com informações sobre o servidor

GetFeature

Retorna uma seleção de feições

DescribeFeatureType

Retorna uma descrição dos tipos de características e propriedades

Transaction

Permite que feições sejam inseridas, atualizadas ou excluídas

3.3.1. GetCapabilities

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

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WFS)

REQUEST

Sim

Nome da requisição (GetCapabilities)

VERSION

Não

Versão do serviço

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

VERSION

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

  • 1.1.0

Se nenhuma versão for indicada na solicitação, 1.1.0 será usado por padrão.

Exemplo de URL:

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

3.3.2. GetFeature

Parâmetros padrão para a solicitação GetFeature de acordo com as especificações OGC WFS 1.0.0 e 1.1.0:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WFS)

REQUEST

Sim

Nome da requisição (GetFeature)

VERSION

Não

Versão do serviço

TYPENAME

Não

Nome das camadas

FEATUREID

Não

Filtrar as feições por ids

OUTPUTFORMAT

Não

Formato de Saída

RESULTTYPE

Não

Tipo do resultado

PROPERTYNAME

Não

Nome das propriedades a serem retornadas

MAXFEATURES

Não

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

SRSNAME

Não

Sistema de referência de coordenadas

FILTER

Não

Codificação de filtros OGC

BBOX

Não

Extensão do Mapa

SORTBY

Não

Classificar os resultados

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

STARTINDEX

Não

Paginação

GEOMETRYNAME

Não

Tipo de geometria para retornar

EXP_FILTER

Não

Filtragem de expressão

TYPENAME

Este parâmetro permite especificar nomes de camadas e é obrigatório se ID DA FEIÇÃO não estiver definido.

Exemplo de URL:

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

FEATUREID

Este parâmetro permite especificar a identificação de uma característica específica e é formado como ``typename.fid,typename.fid,… ``.

Exemplo de URL:

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

Resposta em XML:

<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

Este parâmetro pode ser usado para especificar o formato da resposta. Se “VERSÃO” for maior ou igual a “1.1.0”, GML3 é o formato padrão. Caso contrário, é utilizado GML2.

Os valores disponíveis são:

  • 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

Exemplo de URL:

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

Resposta de GeoJSON:

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

Este parâmetro pode ser usado para especificar o tipo de resultado a ser retornado. Os valores disponíveis são:

  • resultados: o comportamento padrão

  • “acertos”: retorna apenas uma contagem de recursos

Exemplo de 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:

Exemplo de URL válido:

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

Pelo contrário, a próxima URL retornará uma exceção:

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

Este parâmetro permite limitar o número de feições devolvidas pelo pedido.

Exemplo de URL:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&TYPENAME=places
&MAXFEATURES=1000

Nota

Este parâmetro pode ser útil para melhorar o desempenho quando as camadas vetoriais subjacentes são pesadas.

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.

Exemplo de URL:

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. For example:

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

In case of multiple typenames, filters have to be enclosed in parentheses:

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

Filter features that intersect with a polygon:

http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&VERSION=1.1.0
&TYPENAME=places
&FILTER=<Filter xmlns="http://www.opengis.net/ogc">
           <Intersects>
               <PropertyName>geometry</PropertyName>
               <Polygon xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
                   <exterior>
                       <LinearRing>
                           <posList>
                               -0.6389 42.5922
                               10.2683 51.9106
                               14.5196 41.0320
                               -0.6389 42.5922
                           </posList>
                       </LinearRing>
                   </exterior>
               </Polygon>
           </Intersects>
       </Filter>

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 SRSNAME parameter may specify the CRS of the extent. If not specified, the CRS of the layer is used.

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

Este parâmetro permite ordenar as características resultantes de acordo com os valores de propriedade e deve ser formado como nomPropriedade REGRA DE ORGANIZAÇÃO.

Valores disponíveis para REGRA DE ORGANIZAÇÃO em caso de triagem descendente:

  • D

  • +D

  • DESC

  • +DESC

Valores disponíveis para REGRA DE ORGANIZAÇÃO em caso de triagem ascendente:

  • A

  • +A

  • ASC

  • +ASC

Exemplo de URL:

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

O resultado correspondente:

<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

Este parâmetro pode ser usado para especificar o tipo de geometria a ser retornada para as feições. Os valores disponíveis são:

  • extent

  • centroid

  • none

Exemplo de URL:

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

STARTINDEX

Este parâmetro é padrão no WFS 2.0, mas é uma extensão para o WFS 1.0.0.

Na verdade, ele pode ser utilizado para pular algumas características no conjunto de resultados e, em combinação com “MAXFEIÇÕES”, ele fornece a capacidade de paginar através de resultados.

Exemplo de 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. The ; character is used to separate filters in case of multiple typenames.

Exemplo de URL:

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

3.3.3. DescribeFeatureType

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

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WFS)

REQUEST

Sim

Name of the request (DescribeFeatureType)

VERSION

Não

Versão do serviço

OUTPUTFORMAT

Não

Formato da resposta

TYPENAME

Não

Nome das camadas

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

Exemplo de URL:

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

Resposta de saída:

<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. Transação

Esta solicitação permite atualizar, apagar ou adicionar uma ou várias características graças a um documento XML. A ação deletar pode ser realizada com uma solicitação POST, bem como com o parâmetro OPERAÇÃO enquanto que as operações adicionar e a atualizar podem ser realizadas apenas através de uma solicitação POST.

Parâmetros padrão para a solicitação da Transação de acordo com as especificações OGC WFS 1.0.0 e 1.1.0:

Parâmetros

Requerido

Descrição

SERVICE

Sim

Nome do serviço (WFS)

REQUEST

Sim

Nome da solicitação (Transação)

VERSION

Não

Versão do serviço

FILTER

Não

Codificação de filtros OGC

BBOX

Não

Extensão do Mapa

FEATUREID

Não

Filtrar as feições por ids

TYPENAME

Não

Nome das camadas

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

OPERATION

Não

Especifique a operação

EXP_FILTER

Não

Filtragem de expressão

OPERATION

Este parâmetro permite excluir um recurso sem utilizar um pedido POST com um documento XML dedicado.

Exemplo de URL:

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

Nota

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

Adicionar feições

Exemplo de solicitação de POST:

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

com o documento adiciona.xml:

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

Atualizar feições

Exemplo de solicitação de POST:

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

com o documento atualiza.xml:

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

Excluir feições

Exemplo de solicitação de POST:

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

com o documento deleta.xml:

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