Ważne
Tłumaczenie jest wysiłkiem społeczności QGISa przyłącz się. Ta strona jest obecnie przetłumaczona w 86.15%.
3.3. Web Feature Service (WFS)
Standardy 1.0.0 i 1.1.0 WFS zaimplementowane w narzędziu QGIS Server, zapewniają interfejs HTTP do odpytywania obiektów geograficznych z projektu QGIS. Typowe żądanie WFS definiuje który projekt QGIS ma być użyty, i które warstwy odpytane.
Dokument specyfikacji zależnie od wersji usługi:
Standardowe żądania dostarczane przez QGIS Server :
Zapytanie |
Opis |
|---|---|
Zwraca metadane XML zawierające informacje o serwerze |
|
Zwraca wybór obiektów |
|
Zwraca opis typów obiektów i właściwości |
|
Umożliwia wstawianie, aktualizowanie lub usuwanie obiektów |
3.3.1. GetCapabilities
Standardowe parametry żądania GetCapabilities zgodnie ze specyfikacjami OGC WFS 1.0.0 i 1.1.0:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Nazwa usługi (WFS) |
|
Tak |
Nazwa zapytania (GetCapabilities) |
|
Nie |
Wersje usługi |
Oprócz standardowych parametrów, QGIS Server obsługuje następujące parametry dodatkowe:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Plik projektu QGIS |
VERSION
Ten parametr pozwala określić wersję usługi, która ma zostać użyta. Dostępne wartości parametru VERSION to:
1.0.01.1.0
Jeśli w żądaniu nie określono wersji, domyślnie używana jest wersja „1.1.0”.
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&...
3.3.2. GetFeature
Standardowe parametry żądania GetFeature zgodnie ze specyfikacjami OGC WFS 1.0.0 i 1.1.0:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Nazwa usługi (WFS) |
|
Tak |
Name of the request (GetFeature) |
|
Nie |
Wersje usługi |
|
Nie |
Nazwy warstw |
|
Nie |
Filter the features by ids |
|
Nie |
Format wynikowy |
|
Nie |
Type of the result |
|
Nie |
Name of properties to return |
|
Nie |
Maksymalna liczba zwracanych obiektów |
|
Nie |
Układ współrzędnych |
|
Nie |
OGC Filter Encoding |
|
Nie |
Zasięg mapy |
|
Nie |
Sortuj wyniki |
Oprócz standardowych parametrów, QGIS Server obsługuje następujące parametry dodatkowe:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Plik projektu QGIS |
|
Nie |
Stronicowanie |
|
Nie |
Type of geometry to return |
|
Nie |
Expression filtering |
TYPENAME
Ten parametr umożliwia określenie nazw warstw i jest wymagany, jeśli nie ustawiono FEATUREID.
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=GetFeature
&TYPENAME=countries
FEATUREID
Parametr ten umożliwia określenie identyfikatora danego obiektu i ma postać typename.fid,typename.fid,....
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&FEATUREID=countries.0,places.1
Odpowiedź 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
Parametr ten może służyć do określenia formatu odpowiedzi. Jeśli VERSION jest większe lub równe 1.1.0, domyślnym formatem jest GML3. W przeciwnym razie stosowany jest format GML2.
Dostępne wartości to:
gml2text/xml; subtype=gml/2.1.2gml3text/xml; subtype=gml/3.1.1geojsonapplication/vnd.geo+json,application/vnd.geo jsonapplication/geo+jsonapplication/geo jsonapplication/json
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&FEATUREID=countries.0
&OUTPUTFORMAT=geojson
Odpowiedź 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
Parametr ten może służyć do określenia rodzaju zwracanego wyniku. Dostępne wartości to:
results: the default behaviorhits: zwraca tylko liczbę obiektów
Przykład 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.
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&TYPENAME=places
&MAXFEATURES=1000
Informacja
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.
Przykład 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
This parameter allows to specify the map extent with units according to the current CRS. Coordinates have to be separated by a comma.
The SRSNAME parameter may specify the CRS of the extent. If not
specified, the CRS of the layer is used.
Przykład 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.
Dostępne wartości dla SORTRULE w przypadku sortowania malejącego:
D+DDESC+DESC
Dostępne wartości dla SORTRULE w przypadku sortowania rosnącego:
A+AASC+ASC
Przykład 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
Parametr ten może być użyty do określenia rodzaju geometrii zwracanej dla obiektów. Dostępne wartości to:
extentcentroidnone
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=GetFeature
&GEOMETRYNAME=centroid
&...
STARTINDEX
Ten parametr jest standardem w WFS 2.0, ale stanowi rozszerzenie dla 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.
Przykład 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.
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&REQUEST=GetFeature
&TYPENAME=places,countries
&EXP_FILTER="name"='Paris';"name"='France'
3.3.3. DescribeFeatureType
Standardowe parametry żądania DescribeFeatureType zgodnie ze specyfikacjami OGC WFS 1.0.0 i 1.1.0:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Nazwa usługi (WFS) |
|
Tak |
Nazwa zapytania (DescribeFeatureType) |
|
Nie |
Wersje usługi |
|
Nie |
Format odpowiedzi |
|
Nie |
Nazwy warstw |
Oprócz standardowych parametrów, QGIS Server obsługuje następujące parametry dodatkowe:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Plik projektu QGIS |
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=DescribeFeatureType
&TYPENAME=countries
Odpowiedź wynikowa:
<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:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Nazwa usługi (WFS) |
|
Tak |
Nazwa zapytania (Transaction) |
|
Nie |
Wersje usługi |
|
Nie |
OGC Filter Encoding |
|
Nie |
Zasięg mapy |
|
Nie |
Filter the features by ids |
|
Nie |
Nazwy warstw |
Oprócz standardowych parametrów, QGIS Server obsługuje następujące parametry dodatkowe:
Parametr |
Wymagany |
Opis |
|---|---|---|
Tak |
Plik projektu QGIS |
|
Nie |
Specify the operation |
|
Nie |
Expression filtering |
OPERATION
This parameter allows to delete a feature without using a POST request with a dedicated XML document.
Przykład URL:
http://localhost/qgisserver?
SERVICE=WFS
&VERSION=1.1.0
&REQUEST=Transaction
&OPERATION=DELETE
&FEATUREID=24
Informacja
FEATUREID, BBOX and FILTER parameters are mutually exclusive and
prioritized in this order.
Dodaj obiekty
Przykład żądania POST:
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
Przykład żądania POST:
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>
Usuń obiekty
Przykład żądania POST:
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>