Browse OGC API Feature Service

View inQMLC++
View on GitHub
Sample viewer app

Browse an OGC API feature service for layers and add them to the map.

screenshot

Use case

OGC API standards are used for sharing geospatial data on the web. As an open standard, the OGC API aims to improve access to geospatial or location information and could be a good choice for sharing data internationally or between organizations. That data could be of any type, including, for example, transportation layers shared between government organizations and private businesses.

How to use the sample

Select a layer to display from the drop-down list of layers available from the OGC API service. The Daraa data is used as the default feature service, however, alternative feature services can be used.

How it works

  1. Create an OgcFeatureService object with a URL to an OGC API feature service.
  2. Obtain the OgcFeatureServiceInfo from OgcFeatureService.ServiceInfo.
  3. Create a list of feature collections from the OgcFeatureServiceInfo.FeatureCollectionInfos.
  4. When a feature collection is selected, create an OgcFeatureCollectionTable from the OgcFeatureCollectionInfo.
  5. Populate the OgcFeatureCollectionTable using PopulateFromService with QueryParameters that contain a MaxFeatures property.
  6. Create a feature layer from the feature table.
  7. Add the feature layer to the map.

Relevant API

  • OgcFeatureCollectionInfo
  • OgcFeatureCollectionTable
  • OgcFeatureService
  • OgcFeatureServiceInfo

About the data

The Daraa, Syria test data is OpenStreetMap data converted to the Topographic Data Store schema of NGA.

Additional information

See the OGC API website for more information on the OGC API family of standards.

Tags

browse, catalog, feature, layers, OGC, OGC API, service, web

Sample Code

BrowseOGCAPIFeatureService.qmlBrowseOGCAPIFeatureService.cppBrowseOGCAPIFeatureService.h
                                                                                                    
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// [WriteFile Name=BrowseOGCAPIFeatureService, Category=Layers]
// [Legal]
// Copyright 2021 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.12
import QtQuick.Controls 2.12
import Esri.Samples 1.0
import QtQuick.Layouts 1.12
import QtQuick.Dialogs 1.2

Item {
    // Declare the C++ instance which creates the map etc. and supply the view
    BrowseOGCAPIFeatureServiceSample {
        id: model
        mapView: view
    }

    // add a mapView component
    MapView {
        id: view
        anchors.fill: parent

        // Add the OGC feature service UI element
        Control {
            id: uiControl
            anchors {
                right: view.right
                top: view.top
                margins: 10
            }
            padding: 10
            background: Rectangle {
                color: "white"
                border.color: "black"
            }
            contentItem: GridLayout {
                columns: 2
                Label {
                    id: instructionLabel
                    text: "Load the service, then select a layer for display"
                    font.bold: true
                    verticalAlignment: "AlignVCenter"
                    horizontalAlignment: "AlignHCenter"
                    Layout.columnSpan: 2
                    Layout.fillWidth: true
                }
                TextField {
                    id: serviceURLBox
                    text: model.featureServiceUrl
                    Layout.fillWidth: true
                    selectByMouse: true
                }
                Button {
                    id: connectButton
                    text: "Load service"
                    enabled: !model.serviceOrFeatureLoading
                    onClicked: model.loadService(serviceURLBox.text);

                }
                ComboBox {
                    id: featureList
                    model: model.featureCollectionList
                    Layout.columnSpan: 2
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                }
                Button {
                    id: loadLayerButton
                    text: "Load selected layer"
                    enabled: !model.serviceOrFeatureLoading
                    onClicked: model.loadFeatureCollection(featureList.currentIndex);
                    Layout.columnSpan: 2
                    Layout.fillWidth: true
                }
            }
        }

        // Pop-up error message box
        MessageDialog {
            id: errorMessageBox
            title: "Error message!"
            text: model.errorMessage
            icon: StandardIcon.Warning
            visible: model.errorMessage === "" ? false : true
            onAccepted: model.errorMessage = "";
        }
    }
}

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