ServiceFeatureTable Class

  • ServiceFeatureTable
  • class Esri::ArcGISRuntime::ServiceFeatureTable

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

    Header: #include <ServiceFeatureTable.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::ArcGISFeatureTable, Esri::ArcGISRuntime::ApiKeyResource, and Esri::ArcGISRuntime::RemoteResource

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

    ServiceFeatureTable(Esri::ArcGISRuntime::Item *item, QObject *parent = nullptr)
    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::Item *item() 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 setCredential(Esri::ArcGISRuntime::Credential *credential)
    void setDefinitionExpression(const QString &expression)
    void setFeatureRequestMode(Esri::ArcGISRuntime::FeatureRequestMode mode)
    void setGeodatabaseVersion(const QString &version)
    Esri::ArcGISRuntime::TaskWatcher undoLocalEdits()

    Reimplemented Public Functions

    virtual QString apiKey() const override
    virtual Esri::ArcGISRuntime::Credential *credential() const override
    virtual Esri::ArcGISRuntime::RequestConfiguration requestConfiguration() const override
    virtual void setApiKey(const QString &apiKey) 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, 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, 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, you must call populateFromService(QueryParameters, bool, QStringList), which populates the local table with the features specified by QueryParameters and containing the attributes specified by QStringList. Features are cached for the duration of the session and queries are executed against the cache.

    If the table's feature request mode is onInteractionCache or onInteractionNoCache, ArcGISFeatures in the table initially contain a minimum set of attributes and geometry 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.

    Use ArcGISRuntimeEnvironment::serviceCurveGeometryMode to change how curve geometries are returned from the service, if supported. See ArcGISFeatureServiceInfo::isSupportsTrueCurve.

    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, and you must call populateFromService(QueryParameters, bool, QStringList).

    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.

    See also FeatureLayer.

    Member Function Documentation

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

    Creates a new service feature table object from a feature service or feature layer portal item.

    • item - A feature service or feature layer PortalItem.
    • parent - The optional parent QObject.

    If the portal item is a feature service, then the ServiceFeatureTable is created from the first layer on the service. If the portal item is a feature layer, then the ServiceFeatureTable is created from the feature layer.

    This function was introduced in Esri::ArcGISRuntime 100.14.

    See also item.

    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.

    [override virtual] QString ServiceFeatureTable::apiKey() const

    Reimplements: ApiKeyResource::apiKey() const.

    Returns the API key. See ApiKeyResource.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also setApiKey().

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

    Uploads any changes to the local table to the feature service.

    ServiceFeatureTable::applyEdits is meant to be used for single table workflows or tables without geodatabase behavior (see below). If an edit on this table can cause an edit to another table due to geodatabase behavior, it is highly recommended to use ServiceGeodatabase::applyEdits instead to prevent data inconsistency, so that dependent edits are all applied or none are (if an error occurs). For example, when tables have a composite relationship, applying the delete of a destination feature in a composite relationship deletion will only delete the destination feature on the server, therefore causing inconsistency in the data. Areas that have geodatabase behavior:

    • Composite relationships
    • Annotation feature layers
    • Utility network association deletion semantics
    • Attribute rules

    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.

    See also setCredential().

    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::Item *ServiceFeatureTable::item() const

    Returns the Item that defines the service feature table.

    {ServiceFeatureTable(Item, qint64)}

    This function was introduced in Esri::ArcGISRuntime 100.14.

    See also Esri::ArcGISRuntime::ServiceFeatureTable::ServiceFeatureTable.

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

    Loads all attributes and geometries for features not loaded, 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 is 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.

    [override virtual] void ServiceFeatureTable::setApiKey(const QString &apiKey)

    Reimplements: ApiKeyResource::setApiKey(const QString &apiKey).

    Sets the API key to apiKey. See ApiKeyResource.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also apiKey().

    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::setCredential(Esri::ArcGISRuntime::Credential *credential)

    Sets the ServiceFeatureTable's Credential to credential.

    The Credential needs to be set if the service is secured and a Credential has not already been set.

    This function was introduced in Esri::ArcGISRuntime 100.14.

    See also credential().

    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 server acknowledgment.

    ServiceFeatureTable::undoLocalEdits is meant to be used for single table workflows or tables without geodatabase behavior (see below). If the service which the table belongs to has geodatabase behavior, it is highly recommended to use ServiceGeodatabase::undoLocalEdits.

    Undoing edits in one table can cause data inconsistencies between the local cache and the service if this method is used. For example, when tables have a composite relationship, undoing only the origin feature would violate the composite relationship rule that an origin and destination feature must be either deleted together or not at all.

    Areas which have geodatabase behavior:

    • Composite relationships
    • Annotation feature layers
    • Utility network association deletion semantics
    • Attribute rules

    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.

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