Skip To Content ArcGIS for Developers Sign In Dashboard

ServiceFeatureTable Class

class Esri::ArcGISRuntime::ServiceFeatureTable

A feature table created from the URL to an ArcGIS feature service. More...

Header: #include <ServiceFeatureTable>
Since: Esri::ArcGISRuntime 100.0
Inherits: Esri::ArcGISRuntime::ArcGISFeatureTable and Esri::ArcGISRuntime::RemoteResource

This class was introduced in Esri::ArcGISRuntime 100.0.

Public Functions

ServiceFeatureTable(Esri::ArcGISRuntime::Item *item, qint64 layerId, QObject *parent = nullptr)
ServiceFeatureTable(const QUrl &url, Esri::ArcGISRuntime::Credential *credential, QObject *parent = nullptr)
ServiceFeatureTable(Esri::ArcGISRuntime::ServiceFeatureTable *table, const Esri::ArcGISRuntime::RelationshipInfo &relationshipInfo, QObject *parent = nullptr)
ServiceFeatureTable(const QUrl &url, QObject *parent = nullptr)
virtual ~ServiceFeatureTable() override
Esri::ArcGISRuntime::TaskWatcher applyEdits()
double bufferFactor() const
void clearCache(bool keepLocalEdits = true)
QString definitionExpression() const
Esri::ArcGISRuntime::FeatureRequestMode featureRequestMode() const
QString geodatabaseVersion() const
Esri::ArcGISRuntime::TaskWatcher loadOrRefreshFeatures(const QList<Esri::ArcGISRuntime::Feature *> &features)
Esri::ArcGISRuntime::TaskWatcher populateFromService(const Esri::ArcGISRuntime::QueryParameters &parameters, bool clearCache, const QStringList &outFields)
Esri::ArcGISRuntime::TaskWatcher queryFeatures(const Esri::ArcGISRuntime::QueryParameters &parameters, Esri::ArcGISRuntime::QueryFeatureFields queryFeatureFields)
Esri::ArcGISRuntime::TaskWatcher queryRelatedFeatures(Esri::ArcGISRuntime::ArcGISFeature *originFeature, const Esri::ArcGISRuntime::RelatedQueryParameters &relatedQueryParameters, Esri::ArcGISRuntime::QueryFeatureFields queryFeatureFields)
Esri::ArcGISRuntime::ServiceGeodatabase *serviceGeodatabase() const
void setBufferFactor(double buffer)
void setDefinitionExpression(const QString &expression)
void setFeatureRequestMode(Esri::ArcGISRuntime::FeatureRequestMode mode)
void setGeodatabaseVersion(const QString &version)
Esri::ArcGISRuntime::TaskWatcher undoLocalEdits()

Reimplemented Public Functions

virtual Esri::ArcGISRuntime::Credential *credential() const override
virtual Esri::ArcGISRuntime::RequestConfiguration requestConfiguration() const override
virtual void setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration) override
virtual QUrl url() const override

Signals

void applyEditsCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::FeatureEditResult *> &featureEditResults)
void loadOrRefreshFeaturesCompleted(QUuid taskId)
void populateFromServiceCompleted(QUuid taskId, Esri::ArcGISRuntime::FeatureQueryResult *featureQueryResult)
void undoLocalEditsCompleted(QUuid taskId)

Detailed Description

A service feature table has a FeatureRequestMode, which controls (1) whether features are cached locally (for quicker access by map and scene layers) and (2) whether queries are performed on the local cache or on the server. You can retrieve or modify a table's feature request mode using FeatureRequestMode.

If the table's mode is FeatureRequestMode::OnInteractionCache (see FeatureRequestMode), features are requested from the server in response to user or developer interaction (pan or zoom) and are cached locally. Queries are executed on the cache or (if requested features are not resident in the cache) on the server. This mode is the default.

If the table's mode is FeatureRequestMode::OnInteractionNoCache (see FeatureRequestMode), features are always requested from the server. Features are not cached, and all queries are executed on the server.

If the table's mode is FeatureRequestMode::ManualCache (see FeatureRequestMode), you must call ServiceFeatureTable::populateFromService(), which populates the local table with the features specified by QueryParameters and containing the attributes specified by the outFields argument on ServiceFeatureTable::populateFromService(). Features are cached for the duration of the session and queries are executed against the cache.

If the table's feature request mode is FeatureRequestMode::OnInteractionCache or FeatureRequestMode::OnInteractionNoCache, ArcGISFeatures in the table initially contain a minimum set of attributes and goemetry that omits any m-values. This is an optimization for faster rendering. To access all attributes (and geometry with m-values) in features you get from a query, do one of the following:

When used to create a FeatureLayer in a MapView, features are requested from the services in the correct spatial reference to match the spatial reference of the map.

You can use a service feature table to access non-spatial tables from feature services where FeatureTable::hasGeometry is false. The feature request mode of the table must be FeatureRequestMode::manualCache (see FeatureRequestMode), and you must call ServiceFeatureTable::populateFromService().

The parent class definition allows a service feature table to have editable attribute fields, feature templates, feature types, and editing capabilities defined in ArcGISFeatureLayerInfo::capabilities. See FeatureTemplate and FeatureType.

A service feature table might require authentication to access the service.

ServiceFeatureTable adopts the loadable pattern; many of its properties are initialized asynchronously after connecting to the service. See Loadable for more information.

See also FeatureLayer.

Member Function Documentation

ServiceFeatureTable::ServiceFeatureTable(Esri::ArcGISRuntime::Item *item, qint64 layerId, QObject *parent = nullptr)

Constructs a service feature table from a specified item.

The Item must be a PortalItem and correspond to a map service or a feature service.

  • item - An existing Item to use to create the table.
  • layerId - The layer ID of the service's layer to use to create the table.
  • parent - The parent object (optional).

This function was introduced in Esri::ArcGISRuntime 100.3.

ServiceFeatureTable::ServiceFeatureTable(const QUrl &url, Esri::ArcGISRuntime::Credential *credential, QObject *parent = nullptr)

Constructs a service feature table from a specified url, credential and an optional parent.

ServiceFeatureTable::ServiceFeatureTable(Esri::ArcGISRuntime::ServiceFeatureTable *table, const Esri::ArcGISRuntime::RelationshipInfo &relationshipInfo, QObject *parent = nullptr)

Constructs a new ServiceFeatureTable from an existing ServiceFeatureTable and a given RelationshipInfo.

  • table - The exising ServiceFeatureTable related to the ServiceFeatureTable being constructed.
  • relationshipInfo - The relationship between the existing ServiceFeatureTable and the ServiceFeatureTable being constructed.
  • parent - The parent object (optional).

This function was introduced in Esri::ArcGISRuntime 100.1.

ServiceFeatureTable::ServiceFeatureTable(const QUrl &url, QObject *parent = nullptr)

Constructs a service feature table from a specified url and an optional parent.

[signal] void ServiceFeatureTable::applyEditsCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::FeatureEditResult *> &featureEditResults)

Signal emitted when the table has finished applying edits back to the service.

  • taskId - The task ID for the asynchronous operation.
  • featureEditResults - The edit results indicating if any errors occurred when applying edits back to the service.

The returned FeatureEditResult objects have the ServiceFeatureTable as their parent.

See also Returned QObjects Parenting.

[signal] void ServiceFeatureTable::loadOrRefreshFeaturesCompleted(QUuid taskId)

Signal emitted when the load or refresh features task has completed. with data acquired from the service.

  • taskId - The task ID for the asynchronous operation.

This function was introduced in Esri::ArcGISRuntime 100.3.

[signal] void ServiceFeatureTable::populateFromServiceCompleted(QUuid taskId, Esri::ArcGISRuntime::FeatureQueryResult *featureQueryResult)

Signal emitted when the table has finished populating with data acquired from the service.

  • taskId - The task ID for the asynchronous operation.
  • featureQueryResult - A result of features that satisfied the query and have been added to the table.

The returned FeatureQueryResult objects have the ServiceFeatureTable as their parent.

See also Returned QObjects Parenting.

[signal] void ServiceFeatureTable::undoLocalEditsCompleted(QUuid taskId)

Signal emitted when all local edits since the last time applyEdits was called, are reverted.

  • taskId - The task ID for the asynchronous operation.

[override virtual] ServiceFeatureTable::~ServiceFeatureTable()

Destructor.

Esri::ArcGISRuntime::TaskWatcher ServiceFeatureTable::applyEdits()

Applies the temporary edits in the mobile geodatabase to the service.

Applies edits to attributes, geometry, and attachments.

Returns a TaskWatcher for the asynchronous operation.

double ServiceFeatureTable::bufferFactor() const

Returns the factor used to determine the size of the buffer around the map's current extent for which data is retrieved from the service.

The bufferFactor property only applies to FeatureRequestMode::OnInteractionCache

Data is not retrieved again until either it expires or the map extent changes and is no longer located in the buffered extent. The buffer factor can be a value up to 10. If it is set to 0 or 1, every time the map extent is changed, data for that extent will be requested from the service.

The default value is 2.0.

See also setBufferFactor().

void ServiceFeatureTable::clearCache(bool keepLocalEdits = true)

Clears all the data in the table, including any temporary edits.

keepLocalEdits If true, then edited rows in the table won't be cleared.

[override virtual] Esri::ArcGISRuntime::Credential *ServiceFeatureTable::credential() const

Reimplements: RemoteResource::credential() const.

Returns the security credential used to access the feature service.

Only applicable if the service is secured.

QString ServiceFeatureTable::definitionExpression() const

Returns the expression used for filtering features queried in this table.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also setDefinitionExpression().

Esri::ArcGISRuntime::FeatureRequestMode ServiceFeatureTable::featureRequestMode() const

Returns the mode on how data should be retrieved from the service.

The default value is FeatureRequestMode::OnInteractionCache.

See also setFeatureRequestMode().

QString ServiceFeatureTable::geodatabaseVersion() const

Returns the geodatabase version.

See also setGeodatabaseVersion().

Esri::ArcGISRuntime::TaskWatcher ServiceFeatureTable::loadOrRefreshFeatures(const QList<Esri::ArcGISRuntime::Feature *> &features)

Loads all attributes and geometries for unloaded features, and refetches attributes and geometries for previously loaded features.

All features loaded or refreshed by this method will have m-values if defined by the service. Note that an m-value might be NaN. Any feature requested, but not returned, by the server will have its object id cleared (set to an invalid negative value) to indicate it is no longer associated with the service feature table.

After calling this method, any non-applied edits on the table will be lost.

This method will not refresh feature attachments. Use ArcGISFeature::attachments to retrieve attachments.

Returns a TaskWatcher for the asynchronous operation. Connect to the loadOrRefreshFeaturesCompleted signal to know when the task completes.

features. The list of features to be loaded/refreshed. Any features which were not returned by the service will have their OBJECTID cleared to indicate they are no longer associated with the table.

Note: This method will not refresh feature attachments. Use AttachmentListModel::fetchAttachments on each feature to retrieve attachments instead.

Note: After calling this method, any non-applied local edits on the table will be lost.

This function was introduced in Esri::ArcGISRuntime 100.3.

Esri::ArcGISRuntime::TaskWatcher ServiceFeatureTable::populateFromService(const Esri::ArcGISRuntime::QueryParameters &parameters, bool clearCache, const QStringList &outFields)

Queries the feature service and places the resulting features in the local table, which is cached for the duration of the session.

  • parameters. Options for controlling the operation.
  • clearCache. If true, ServiceFeatureTable::clearCache will be called before populating the local table. If false, the resulting features will be appended to the local table.
  • outFields. Each string is the name of a field to be used when populating the cache. If the array contains the single element "*", then all fields will be used.

The ServiceFeatureTable must have its ServiceFeatureTable::featureRequestMode() set to FeatureRequestMode::ManualCache.

This method is useful for non-geographic data. It's also helpful when you want to avoid accessing the service for a feature whose geometry is in the current extent of the map or scene.

Specifying an empty QStringList for outFields results in the minimum set of fields being used when populating the local table. This is the same set of attributes described for FeatureRequestMode::OnInteractionCache or FeatureRequestMode.OnInteractionNoCache. See FeatureRequestMode.

Esri::ArcGISRuntime::TaskWatcher ServiceFeatureTable::queryFeatures(const Esri::ArcGISRuntime::QueryParameters &parameters, Esri::ArcGISRuntime::QueryFeatureFields queryFeatureFields)

Queries features from this table's cache and/or from the feature service used to create this table.

If the request mode of the table is FeatureRequestMode::ManualCache (see FeatureRequestMode), then the query is always performed on the local table. If the mode is FeatureRequestMode::OnInteractionCache, then the query is performed on the local cache, provided that the geometries of the features are within an extent that has been cached; otherwise, the query is performed on the server.

If the mode is FeatureRequestMode::OnInteractionNoCache (see FeatureRequestMode), the query is always performed on the server.

The QueryFeatureFields constants control which fields will be included with the returned features:

  • A table whose feature request mode is FeatureRequestMode::manualCache contains all fields that you specified when calling ServiceFeatureTable::populateFromService().
  • A table whose feature request mode is FeatureRequestMode::OnInteractionCache or FeatureRequestMode::OnInteractionNoCache initially contains features with a minimum set of attributes required for rendering. You must load a feature to access all its attributes. The convenience constant QueryFeatureFields::LoadAll automatically loads the returned features into the local table, which makes all attributes available. See QueryFeatureFields.
  • parameters - The query parameters.
  • queryFeatureFields - Queries for related features in this service feature table using the provided parameters and query feature fields.

Returns a TaskWatcher for the asynchronous task.

Esri::ArcGISRuntime::TaskWatcher ServiceFeatureTable::queryRelatedFeatures(Esri::ArcGISRuntime::ArcGISFeature *originFeature, const Esri::ArcGISRuntime::RelatedQueryParameters &relatedQueryParameters, Esri::ArcGISRuntime::QueryFeatureFields queryFeatureFields)

Queries for features related to the given feature using the given related query parameters and query feature fields.

  • originFeature - The feature whose related features are to be queried.
  • relatedQueryParameters - The related query parameters.
  • queryFeatureFields - An enumeration indicating which fields to return from the query.

Returns a TaskWatcher for the asynchronous task.

This function was introduced in Esri::ArcGISRuntime 100.1.

[override virtual] Esri::ArcGISRuntime::RequestConfiguration ServiceFeatureTable::requestConfiguration() const

Reimplements: RemoteResource::requestConfiguration() const.

Returns the RequestConfiguration in use by this ServiceFeatureTable.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setRequestConfiguration().

Esri::ArcGISRuntime::ServiceGeodatabase *ServiceFeatureTable::serviceGeodatabase() const

Returns the service geodatabase this service feature table is part of.

This function was introduced in Esri::ArcGISRuntime 100.9.

void ServiceFeatureTable::setBufferFactor(double buffer)

Sets the buffer factor used to determine the size of the buffer around the map's current extent for which data is retrieved from the service.

See also bufferFactor.

void ServiceFeatureTable::setDefinitionExpression(const QString &expression)

Sets an expression which is a SQL statement where clause to filter out the features to be queried.

The definition expression string uses the SQL-92 WHERE clause syntax. Be sure to escape special characters in the expression string as required for your platform. The DATE keyword expects the date format yyyy-mm-dd and the TIMESTAMP keyword expects the time stamp format yyyy-mm-dd hh:mm:ss. See the ArcGIS Blog article Querying Feature Services Date-Time Queries for more information.

  • expression - The where clause expression.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also definitionExpression().

void ServiceFeatureTable::setFeatureRequestMode(Esri::ArcGISRuntime::FeatureRequestMode mode)

Sets the mode on how data should be retrieved from the service.

The default is FeatureRequestMode::OnInteractionCache.

You cannot change the feature request mode after the table is successfully loaded.

See also featureRequestMode().

void ServiceFeatureTable::setGeodatabaseVersion(const QString &version)

Sets the geodatabase version to version.

See also geodatabaseVersion().

[override virtual] void ServiceFeatureTable::setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration)

Reimplements: RemoteResource::setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration).

Sets configuration parameters used for network requests sent by this ServiceFeatureTable to requestConfiguration.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also requestConfiguration().

Esri::ArcGISRuntime::TaskWatcher ServiceFeatureTable::undoLocalEdits()

Undoes all of the local edits since the last successful applyEdits.

All features that were added, updated, or deleted after the last successfully completed applyEdits will revert back to their original state; thus, any in-memory feature(s) must be discarded in favor of a new query result.

Returns a TaskWatcher for the asynchronous task.

This function was introduced in Esri::ArcGISRuntime 100.3.

[override virtual] QUrl ServiceFeatureTable::url() const

Reimplements: RemoteResource::url() const.

Returns the URL of an individual layer or table in an ArcGIS map or feature service whose data needs to be accessed or edited.


Feedback on this topic?