FeatureTable Class

  • FeatureTable
  • class Esri::ArcGISRuntime::FeatureTable

    A table of features that typically represents real-world objects such as fire hydrants, roads, and forests. More...

    Public Functions

    virtual ~FeatureTable() override
    QFuture<void> addFeatureAsync(Esri::ArcGISRuntime::Feature *feature)
    QFuture<void> addFeaturesAsync(const QList<Esri::ArcGISRuntime::Feature *> &features)
    bool canAdd() const
    bool canDelete(Esri::ArcGISRuntime::Feature *feature) const
    bool canEditGeometry() const
    bool canUpdate(Esri::ArcGISRuntime::Feature *feature) const
    Esri::ArcGISRuntime::Feature *createFeature(QObject *parent = nullptr) const
    Esri::ArcGISRuntime::Feature *createFeature(const QVariantMap &attributes, const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr) const
    QFuture<void> deleteFeatureAsync(Esri::ArcGISRuntime::Feature *feature)
    QFuture<void> deleteFeaturesAsync(const QList<Esri::ArcGISRuntime::Feature *> &features)
    QString displayName() const
    Esri::ArcGISRuntime::Envelope extent() const
    Esri::ArcGISRuntime::FeatureTableType featureTableType() const
    Esri::ArcGISRuntime::Field field(const QString &fieldName) const
    QList<Esri::ArcGISRuntime::Field> fields() const
    Esri::ArcGISRuntime::GeometryType geometryType() const
    bool hasGeometry() const
    bool hasM() const
    bool hasZ() const
    bool isEditable() const
    Esri::ArcGISRuntime::Layer *layer() const
    qint64 numberOfFeatures() const
    QFuture<Esri::ArcGISRuntime::Envelope> queryExtentAsync(const Esri::ArcGISRuntime::QueryParameters &queryParameters)
    QFuture<quint64> queryFeatureCountAsync(const Esri::ArcGISRuntime::QueryParameters &queryParameters)
    QFuture<Esri::ArcGISRuntime::FeatureQueryResult *> queryFeaturesAsync(const Esri::ArcGISRuntime::QueryParameters &queryParameters, QObject *parent = nullptr)
    QFuture<Esri::ArcGISRuntime::StatisticsQueryResult *> queryStatisticsAsync(const Esri::ArcGISRuntime::StatisticsQueryParameters &statisticsQueryParameters, QObject *parent = nullptr)
    void setDisplayName(const QString &displayName)
    Esri::ArcGISRuntime::SpatialReference spatialReference() const
    QString tableName() const
    QFuture<void> updateFeatureAsync(Esri::ArcGISRuntime::Feature *feature)
    QFuture<void> updateFeaturesAsync(const QList<Esri::ArcGISRuntime::Feature *> &features)

    Reimplemented Public Functions

    virtual void cancelLoad() override
    virtual bool isPopupEnabled() const override
    virtual void load() override
    virtual Esri::ArcGISRuntime::Error loadError() const override
    virtual Esri::ArcGISRuntime::LoadStatus loadStatus() const override
    virtual Esri::ArcGISRuntime::PopupDefinition *popupDefinition() const override
    virtual void retryLoad() override
    virtual void setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition) override
    virtual void setPopupEnabled(bool popupEnabled) override

    Signals

    void doneLoading(const Esri::ArcGISRuntime::Error &loadError)
    void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

    Detailed Description

    This is the base class for a number of different feature tables, such as ServiceFeatureTable, FeatureCollectionTable, and GeoPackageFeatureTable. You can create instances of these subclasses using their constructors.

    If the hasGeometry is true, you can display the features in a Map or Scene. To do this create a FeatureLayer from the feature table and add it to the Map or Scene collection of operational layers (GeoModel::operationalLayers). The FeatureTable can also contain features that do not have a geometry (hasGeometry is false).

    FeatureTable provides methods for spatial and attribute querying (for example, queryFeaturesAsync(const Esri::ArcGISRuntime::QueryParameters&, QObject*)), and methods to add, update, and delete features (such as addFeatureAsync(Esri::ArcGISRuntime::Feature*), updateFeatureAsync(Esri::ArcGISRuntime::Feature*), and deleteFeatureAsync(Esri::ArcGISRuntime::Feature*)).

    // connect to the mouse clicked signal on the MapQuickView
    connect(m_mapView, &MapQuickView::mouseClicked, this, [this](QMouseEvent& mouseEvent)
    {
      // obtain the map point
      const double screenX = mouseEvent.position().x();
      const double screenY = mouseEvent.position().y();
      Point newPoint = m_mapView->screenToLocation(screenX, screenY);
    
      // create the feature attributes
      QMap<QString, QVariant> featureAttributes;
      featureAttributes.insert("typdamage", "Minor");
      featureAttributes.insert("primcause", "Earthquake");
    
      // create a new feature and add it to the feature table
      Feature* feature = m_featureTable->createFeature(featureAttributes, newPoint, this);
      m_featureTable->addFeatureAsync(feature).then(this, [this]()
      {
        // if add feature was successful, call apply edits
         m_featureTable->applyEditsAsync().then(this, [](const QList<FeatureEditResult*>& featureEditResults)
         {
           // Lock is a convenience wrapper that deletes the contents of the list once we leave scope.
           FeatureListResultLock lock(featureEditResults);
    
           if (lock.results.isEmpty())
             return;
    
           // obtain the first item in the list
           FeatureEditResult* featureEditResult = lock.results.first();
           // check if there were errors, and if not, log the new object ID
           if (!featureEditResult->isCompletedWithErrors())
             qDebug() << "New Object ID is:" << featureEditResult->objectId();
           else
             qDebug() << "Apply edits error.";
         });
      });
    });

    Member Function Documentation

    [override virtual] FeatureTable::~FeatureTable()

    Destructor.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureTable::addFeatureAsync(Esri::ArcGISRuntime::Feature *feature)

    Adds a feature to the table.

    • feature - The feature.

    Adding a feature that contains a Geometry causes the geometry to become simplified. This may change a single part geometry to a multipart geometry, or round off X, Y, Z, and M coordinate values that are above the resolution set by the SpatialReference.

    Adding a feature to a GeodatabaseFeatureTable in a stand-alone mobile geodatabase created with ArcGIS Pro is not supported when the table participates in a controller dataset, such as a utility network or parcel fabric. Use canAdd to determine if this operation is allowed.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureTable::addFeaturesAsync(const QList<Esri::ArcGISRuntime::Feature *> &features)

    Adds a collection of features to the table.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    bool FeatureTable::canAdd() const

    Returns true if you can add new features to the table.

    The result of this method accounts for the table's attachment and geometry capabilites, and ownership-based access control.

    Although this method may state that the table allows new features to be added, the application may not be licensed to permit this. For example, a user cannot add features to a secured feature table if the application is licensed at the Lite level (LicenseLevel::Lite).

    bool FeatureTable::canDelete(Esri::ArcGISRuntime::Feature *feature) const

    Returns true if the provided feature can be deleted from the table.

    • feature - The feature.

    The result of this method accounts for the table's attachment and geometry capabilites, and ownership-based access control.

    Although this method may state that the table allows the feature to be deleted, the application may not be licensed to permit this. For example, a user cannot delete features from a secured feature table if the application is licensed at the Lite level (LicenseLevel::Lite).

    bool FeatureTable::canEditGeometry() const

    Returns true if the feature table allows editing a feature's geometry.

    The result of this method accounts for the table's ownership-based access control.

    Although this method may state that the table allows geometry fields to be edited, the application may not be licensed to permit this. For example, a user cannot update geometry in a secured feature table if the application is licensed at the Lite level (LicenseLevel::Lite).

    bool FeatureTable::canUpdate(Esri::ArcGISRuntime::Feature *feature) const

    Returns true if the provided feature can be updated in the table.

    • feature - The feature.

    The result of this method accounts for the table's attachment and geometry capabilites, and ownership-based access control.

    Although this method may state that the table allows the feature to be updated, the application may not be licensed to permit this. For example, a user cannot update features in a secured feature table if the application is licensed at the Lite level (LicenseLevel::Lite).

    [override virtual] void FeatureTable::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    Cancels loading the metadata for the object.

    Esri::ArcGISRuntime::Feature *FeatureTable::createFeature(QObject *parent = nullptr) const

    Creates and returns a new, empty feature with an optional parent.

    The new feature is only available in memory at this point. Execute addFeatureAsync(Esri::ArcGISRuntime::Feature*) to commit the new Feature to the table.

    Esri::ArcGISRuntime::Feature *FeatureTable::createFeature(const QVariantMap &attributes, const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr) const

    Returns a new feature with the provided attribute values and, optionally, geometry.

    • attributes - The attributes.
    • geometry - The geometry.
    • parent - The parent object.

    The new feature is only available in memory at this point. Execute addFeatureAsync(Esri::ArcGISRuntime::Feature*) to commit the new Feature to the table.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureTable::deleteFeatureAsync(Esri::ArcGISRuntime::Feature *feature)

    Deletes a feature from the table.

    • feature - The feature.

    Deleting a feature from a GeodatabaseFeatureTable in a stand-alone mobile geodatabase created with ArcGIS Pro is not supported when the table participates in a controller dataset, such as a utility network or parcel fabric. Use canDelete(Esri::ArcGISRuntime::Feature*) to determine if this operation is allowed.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureTable::deleteFeaturesAsync(const QList<Esri::ArcGISRuntime::Feature *> &features)

    Deletes a collection of features from the table.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    [since Esri::ArcGISRuntime 100.3] QString FeatureTable::displayName() const

    Returns a user-friendly name that can be displayed in the UI (for example, in a Table of Contents).

    If the table is displayed with a FeatureLayer, the FeatureTable::displayName is used as the FeatureLayer::name.

    The default value is tableName.

    This function was introduced in Esri::ArcGISRuntime 100.3.

    See also setDisplayName().

    [signal] void FeatureTable::doneLoading(const Esri::ArcGISRuntime::Error &loadError)

    Signal emitted when this object is done loading.

    • loadError - Details about any error that may have occurred.

    Note: If there is a load error it will also be emitted on the errorOccurred signal.

    See also Loadable and Object.

    Esri::ArcGISRuntime::Envelope FeatureTable::extent() const

    Returns the geographic extent of features within the table.

    This is calculated differently for specific types and modes of feature tables:

    • GeodatabaseFeatureTable. This returns the extent of the features which have been cached. This extent can grow as features are added or edited, but not shrink.

    Esri::ArcGISRuntime::FeatureTableType FeatureTable::featureTableType() const

    Returns the type of feature table.

    Esri::ArcGISRuntime::Field FeatureTable::field(const QString &fieldName) const

    Returns a Field object describing the field corresponding to the provided fieldName.

    QList<Esri::ArcGISRuntime::Field> FeatureTable::fields() const

    Returns a list of Field objects representing the fields of the feature table.

    Esri::ArcGISRuntime::GeometryType FeatureTable::geometryType() const

    Returns the type of geometry of the features stored in this table.

    If hasGeometry is false, then the geometry type is GeometryType::Unknown.

    bool FeatureTable::hasGeometry() const

    Returns true if the dataset contains a geometry field.

    If true, the dataset contains geographic features. If false, the dataset contains non-spatial records, similar to a database table.

    [since Esri::ArcGISRuntime 100.2] bool FeatureTable::hasM() const

    Returns true if the feature table supports geometries with M values, false otherwise.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    [since Esri::ArcGISRuntime 100.2] bool FeatureTable::hasZ() const

    Returns true if the feature table supports geometries with Z values, false otherwise.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    bool FeatureTable::isEditable() const

    Returns true if this feature table is editable, false otherwise.

    Underlying file permissions (for subclasses such as ShapefileFeatureTable and GeodatabaseFeatureTable) can be changed while the feature table is open. In these cases the value of this property may not be accurate.

    See also ArcGISFeatureTable.

    [override virtual, since Esri::ArcGISRuntime 100.1] bool FeatureTable::isPopupEnabled() const

    Reimplements: PopupSource::isPopupEnabled() const.

    Returns a flag indicating whether the PopupDefinition defined on the PopupSource is enable / disable.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    [since Esri::ArcGISRuntime 100.7] Esri::ArcGISRuntime::Layer *FeatureTable::layer() const

    Returns the layer that displays this table, if any.

    The Layer type depends on how the feature table is created. For example, a Layer will be an AnnotationLayer if the FeatureTable is created from a table that supports annotation. See Layer for more information about the supported layer types.

    The layer will be nullptr if the feature table does not contain spatial features (where hasGeometry is false).

    This function was introduced in Esri::ArcGISRuntime 100.7.

    [override virtual] void FeatureTable::load()

    Reimplements: Loadable::load().

    Loads the metadata for the object asynchronously.

    [override virtual] Esri::ArcGISRuntime::Error FeatureTable::loadError() const

    Reimplements: Loadable::loadError() const.

    Returns the load error.

    See also Error.

    [override virtual] Esri::ArcGISRuntime::LoadStatus FeatureTable::loadStatus() const

    Reimplements: Loadable::loadStatus() const.

    Returns the load status.

    See also LoadStatus.

    [signal] void FeatureTable::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

    Signal emitted when the load status changes for this object.

    See also Loadable.

    qint64 FeatureTable::numberOfFeatures() const

    Returns the number of features in the table.

    If all the features are stored in the local table, for example with a GeodatabaseFeatureTable or a ShapefileFeatureTable, then the numberOfFeatures will return the full number of features.

    If the table is created from a service, for example, ServiceFeatureTable or WfsFeatureTable, the numberOfFeatures will only return the number of features in the local table cache. You need to populate the local table cache to return a value for numberOfFeatures. Do this by rendering the features in a Map or Scene with a FeatureLayer, or by querying the feature table. Consider the feature table's FeatureRequestMode in both cases. See ServiceFeatureTable or WfsFeatureTable for more information. If you want to return the full number of features in the service, execute queryFeatureCountAsync(const Esri::ArcGISRuntime::QueryParameters&) and pass "1=1" to the QueryParameters::whereClause.

    [override virtual, since Esri::ArcGISRuntime 100.1] Esri::ArcGISRuntime::PopupDefinition *FeatureTable::popupDefinition() const

    Reimplements: PopupSource::popupDefinition() const.

    Returns the pop-up definition.

    The PopupDefinition associated with the popup source. A nullptr if an error occurs or if the popup source is not associated with a pop-up definition.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    See also setPopupDefinition() and PopupSource.

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::Envelope> FeatureTable::queryExtentAsync(const Esri::ArcGISRuntime::QueryParameters &queryParameters)

    Determines the minimum bounding envelope that contains features satisfying the provided query parameters.

    • queryParameters - The parameters of the query.

    If no features meet the query criteria, an empty envelope is returned.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    [since Esri::ArcGISRuntime 200.2] QFuture<quint64> FeatureTable::queryFeatureCountAsync(const Esri::ArcGISRuntime::QueryParameters &queryParameters)

    Determines the count of features that satisfy the provided query parameters.

    • queryParameters - The parameters of the query.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::FeatureQueryResult *> FeatureTable::queryFeaturesAsync(const Esri::ArcGISRuntime::QueryParameters &queryParameters, QObject *parent = nullptr)

    Queries for features in this FeatureTable using the provided.

    • queryParameters - The parameters of the query.
    • parent - The optional parent QObject

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 100.2] QFuture<Esri::ArcGISRuntime::StatisticsQueryResult *> FeatureTable::queryStatisticsAsync(const Esri::ArcGISRuntime::StatisticsQueryParameters &statisticsQueryParameters, QObject *parent = nullptr)

    Calculates values for the requested statistics.

    • statisticsQueryParameters - The parameters that define the statistics, fields, and features to be used for the query.
    • parent - The optional parent QObject

    Statistics query parameters may also define fields on which results are grouped or sorted.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    See also FeatureServiceSessionType.

    [override virtual] void FeatureTable::retryLoad()

    Reimplements: Loadable::retryLoad().

    Loads or retries loading metadata for the object asynchronously.

    Will retry loading the metadata if the object is failed to load. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded. Will always call the done loading if this is called.

    [since Esri::ArcGISRuntime 100.3] void FeatureTable::setDisplayName(const QString &displayName)

    Sets the table's display name to displayName.

    This function was introduced in Esri::ArcGISRuntime 100.3.

    See also displayName().

    [override virtual, since Esri::ArcGISRuntime 100.1] void FeatureTable::setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition)

    Reimplements: PopupSource::setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition).

    Sets the popup definition to popupDefinition.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    See also popupDefinition() and PopupSource.

    [override virtual, since Esri::ArcGISRuntime 100.1] void FeatureTable::setPopupEnabled(bool popupEnabled)

    Reimplements: PopupSource::setPopupEnabled(bool popupEnabled).

    Sets whether the PopupSource is enabled to popupEnabled.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    See also isPopupEnabled() and PopupSource.

    Esri::ArcGISRuntime::SpatialReference FeatureTable::spatialReference() const

    Returns the spatial reference of the table.

    A spatial reference defines how the coordinates of a feature's Geometry correspond to locations in the real world. For more information see the SpatialReference class or the Spatial references documentation.

    QString FeatureTable::tableName() const

    Returns the name of the dataset.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureTable::updateFeatureAsync(Esri::ArcGISRuntime::Feature *feature)

    Updates a feature in the table.

    • feature - The feature.

    If you update a feature that contains a Geometry, the geometry becomes simplified. This may change a single part geometry to a multipart geometry, or round X, Y, Z, and M coordinate values that are above the resolution set by the SpatialReference.

    Updating a feature from a GeodatabaseFeatureTable in a stand-alone mobile geodatabase created with ArcGIS Pro is not supported when the table participates in a controller dataset, such as a utility network or parcel fabric. Use canUpdate(Esri::ArcGISRuntime::Feature*) to determine if this operation is allowed.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureTable::updateFeaturesAsync(const QList<Esri::ArcGISRuntime::Feature *> &features)

    Updates a collection of features in the table.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also FeatureServiceSessionType.

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