Query data from an OGC API feature service using CQL filters.
Use case
CQL (Common Query Language) is an OGC-created query language used to query for subsets of features. Use CQL filters to narrow geometry results from an OGC feature table.
How to use the sample
Enter a CQL query. Press the "Apply query" button to see the query applied to the OGC API features shown on the map.
How it works
- Create an
OgcFeatureCollectionTable
object using a URL to an OGC API feature service and a collection ID. - Create a
QueryParameters
object. - Set the
QueryParameters.WhereClause
property. - Set the
QueryParameters.MaxFeatures
property. - Create
Datetime
objects for the start time and end time being queried. - Create a
TimeExtent
object using the start and endDatetime
objects. Set theQueryParameters.TimeExtent
property - Populate the
OgcFeatureCollectionTable
usingPopulateFromServiceAsync()
with the customQueryParameters
created in the previous steps. - Use
MapView.SetViewpointGeometryAsync()
with theOgcFeatureCollectionTable.Extent
to view the newly-queried features.
Relevant API
- OgcFeatureCollectionTable
- QueryParameters
- TimeExtent
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. See the CQL documentation to learn more about the common query language.
Tags
browse, catalog, common query language, CQL, feature table, filter, OGC, OGC API, query, service, web
Sample Code
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.QueryCQLFilters.QueryCQLFilters"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.ColumnSpan="2"
FontWeight="Bold"
Foreground="Black"
Text="Populate query parameters" />
<TextBlock Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Text="Where clause:" />
<ComboBox x:Name="WhereClauseBox"
Grid.Row="1"
Grid.Column="1"
Margin="5"
HorizontalAlignment="Stretch"
IsEditable="True" />
<TextBlock Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Text="Max features:" />
<TextBox x:Name="MaxFeaturesBox"
Grid.Row="2"
Grid.Column="1"
Margin="5" />
<CheckBox x:Name="DateBox"
Grid.Row="3"
Grid.ColumnSpan="2"
Margin="5"
Checked="DateBox_Checked"
Content="Time extent:"
IsChecked="True"
Unchecked="DateBox_Checked" />
<DatePicker x:Name="StartDatePicker"
Grid.Row="4"
Grid.ColumnSpan="2"
Margin="5" />
<DatePicker x:Name="EndDatePicker"
Grid.Row="5"
Grid.ColumnSpan="2"
Margin="5" />
<Button x:Name="ApplyQuery"
Grid.Row="6"
Grid.Column="0"
Margin="5"
Click="ApplyQuery_Click"
Content="Apply query" />
<Button x:Name="ResetQuery"
Grid.Row="6"
Grid.Column="1"
Margin="5"
Click="ResetQuery_Click"
Content="Reset" />
<TextBlock x:Name="NumberOfReturnedFeatures"
Grid.Row="7"
Grid.ColumnSpan="2" />
<ProgressBar x:Name="LoadingProgressBar"
Grid.Row="8"
Grid.ColumnSpan="2"
Height="10"
Margin="5"
IsEnabled="True"
IsIndeterminate="True"
Visibility="Visible" />
</Grid>
</Border>
</Grid>
</UserControl>