Display OGC API Feature Collection

View inQMLC++
View on GitHub
Sample viewer app

This sample demonstrates how to display an OGC API feature collection and query features while navigating the map view.

screenshot

Use case

When panning the map view, it is necessary to query the OGC API feature table to obtain additional features within the new visible extent.

How to use the sample

Pan the map and observe how new features are loaded from the OGC API feature service.

How it works

  1. Create an OgcFeatureCollectionTable object using a URL to an OGC API feature service and a collection ID.
  2. Set the feature table's FeatureRequestMode to ManualCache so features requested from the server are cached locally.
  3. Create a FeatureLayer using the feature table and add it to the Map's operationalLayers.
  4. Every time the map view navigation completes:

    i. Create QueryParameters

    ii. Set the parameter's Geometry to the current extent of the map view.

    iii. Set the parameter's SpatialRelationship to Intersects.

    iv. Set the MaxFeatures property to 5000 (some services have a low default value for maximum features).

    v. Call OgcFeatureCollectionTable::PopulateFromService() using the query parameters from the previous steps.

Relevant API

  • OgcFeatureCollectionTable
  • QueryParameters

Additional information

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

Tags

feature, feature layer, feature table, OGC, OGC API, service, table, web

Sample Code

DisplayOgcApiFeatureCollection.qmlDisplayOgcApiFeatureCollection.cppDisplayOgcApiFeatureCollection.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
// [WriteFile Name=DisplayOgcApiFeatureCollection, 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.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0

Item {

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

    // Declare the C++ instance which creates the scene etc. and supply the view
    DisplayOgcApiFeatureCollectionSample {
        id: model
        mapView: view
    }
}

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