Load WFS with XML query

View inQMLC++
View on GitHub
Sample viewer app

Load a WFS feature table using an XML query.

screenshot

Use case

Runtime QueryParameters objects can't represent all possible queries that can be made against a WFS feature service. For example, Runtime query parameters don't support wildcard searches. You can provide queries as raw XML strings, allowing you to access query functionality not available with QueryParameters.

How to use the sample

Run the sample and view the data loaded from the the WFS feature table.

How it works

  1. Create a WfsFeatureTable and a FeatureLayer to visualize the table.
  2. Set the feature request mode to ManualCache.
  3. Call populateFromServiceWithXml to populate the table with only those features returned by the XML query.

Relevant API

  • FeatureLayer
  • WfsFeatureTable
  • WfsFeatureTable.axisOrder
  • WfsFeatureTable.populateFromServiceWithXml

About the data

This service shows trees in downtown Seattle and the surrounding area. An XML-encoded GetFeature request is used to limit results to only trees of the genus Tilia.

For additional information, see the underlying service on ArcGIS Online.

Tags

feature, OGC, query, service, web, WFS, XML

Sample Code

LoadWfsXmlQuery.qml
                                                                         
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// [WriteFile Name=LoadWfsXmlQuery, Category=Layers]
// [Legal]
// Copyright 2019 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import Esri.ArcGISRuntime 100.12

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    readonly property string xmlQueryString :
     '
     <wfs:GetFeature service="WFS" version="2.0.0"
     xmlns:Seattle_Downtown_Features="https://dservices2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/services/Seattle_Downtown_Features/WFSServer"
     xmlns:wfs="http://www.opengis.net/wfs/2.0"
     xmlns:fes="http://www.opengis.net/fes/2.0"
     xmlns:gml="http://www.opengis.net/gml/3.2">
     <wfs:Query typeNames="Seattle_Downtown_Features:Trees">
     <fes:Filter>
     <fes:PropertyIsLike wildCard="*" escapeChar="\">
     <fes:ValueReference>Trees:SCIENTIFIC</fes:ValueReference>
     <fes:Literal>Tilia *</fes:Literal>
     </fes:PropertyIsLike>
     </fes:Filter>
     </wfs:Query>
     </wfs:GetFeature>
     '

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            Basemap {
                initStyle: Enums.BasemapStyleArcGISNavigation
            }

            FeatureLayer {
                WfsFeatureTable {
                    id: wfsFeatureTable
                    url: "https://dservices2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/services/Seattle_Downtown_Features/WFSServer?service=wfs&request=getcapabilities"
                    tableName: "Seattle_Downtown_Features:Trees"
                    featureRequestMode: Enums.FeatureRequestModeManualCache
                    onLoadStatusChanged: {
                        if (loadStatus !== Enums.LoadStatusLoaded)
                            return;

                        // populate the table with XML Query
                        populateFromServiceWithXml(xmlQueryString, true);

                        // set the viewpoint to the center of the extent
                        mapView.setViewpointGeometryAndPadding(extent, 50);
                    }
                }
            }
        }
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.