FeatureCollection Class

  • FeatureCollection
  • class Esri::ArcGISRuntime::FeatureCollection

    A feature collection represents a lightweight collection of features that can be saved in a map or portal item. More...

    Header: #include <FeatureCollection.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::Object, Esri::ArcGISRuntime::Loadable, and Esri::ArcGISRuntime::JsonSerializable

    Public Functions

    FeatureCollection(QObject *parent = nullptr)
    FeatureCollection(Esri::ArcGISRuntime::Item *item, QObject *parent = nullptr)
    FeatureCollection(const QList<Esri::ArcGISRuntime::FeatureCollectionTable *> &featureCollectionTables, QObject *parent = nullptr)
    virtual ~FeatureCollection() override
    Esri::ArcGISRuntime::Item *item() const
    QFuture<void> saveAsAsync(Esri::ArcGISRuntime::Portal *portal, const QString &title, const QStringList &tags, const Esri::ArcGISRuntime::PortalFolder &folder = PortalFolder(), const QString &description = QString(), const QByteArray &thumbnailBytes = QByteArray())
    QFuture<void> saveAsync()
    Esri::ArcGISRuntime::FeatureCollectionTableListModel *tables() const

    Reimplemented Public Functions

    virtual void cancelLoad() override
    virtual void load() override
    virtual Esri::ArcGISRuntime::Error loadError() const override
    virtual Esri::ArcGISRuntime::LoadStatus loadStatus() const override
    virtual void retryLoad() override
    virtual QString toJson() const override
    virtual QJsonObject unknownJson() const override
    virtual QJsonObject unsupportedJson() const override

    Signals

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

    Static Public Members

    Esri::ArcGISRuntime::FeatureCollection *fromJson(const QString &json, QObject *parent = nullptr)

    Detailed Description

    A feature collection is typically used to hold features with mixed geometry or unstructured data. The features are stored in feature collection tables, where all the features that belong to a table share the same attribute schema (fields), geometry type, and spatial reference. The feature collection groups these different feature tables together so that you can display and manage them in a single layer.

    There are a number of ways to create a feature collection:

    • You can build a feature collection in ArcGIS Online by creating a sketch layer and saving it as part of the map. The sketch layer may contain points, lines, polygons, and associated text to describe things in the map. Because they have different schema and geometry types, these features are stored in several distinct feature collection tables.
    • You can import features into ArcGIS Online from files, such as CSV or shapefiles, and save them in a separate PortalItem (of type PortalItemType::FeatureCollection).
    • You can create a FeatureCollection programmatically by constructing an empty FeatureCollectionTable and adding features to the table.

    If you need to share the feature collection between several maps or scenes, it is best to store it as a separate portal item. If you need to make frequent (near real-time) edits to features in a collection, consider storing these in a feature service instead, because the feature collection is not refreshed until the map or portal item is reloaded. If features are used by a single map or are not subject to frequent updates, it might be best to store them directly in the map. Edits made to features stored in a map will be saved when the map is saved. Edits made to features stored in a portal item (and loaded into a map, for example) must be explicitly saved to the original portal item.

    To render the features in a map or scene, construct a FeatureCollectionLayer using the FeatureCollection and add the layer to the collection of operational layers.

    Member Function Documentation

    [explicit] FeatureCollection::FeatureCollection(QObject *parent = nullptr)

    Create a feature collection object.

    • parent - The optional parent QObject.

    [explicit] FeatureCollection::FeatureCollection(Esri::ArcGISRuntime::Item *item, QObject *parent = nullptr)

    Creates a feature collection object from a PortalItem.

    See also item.

    [explicit] FeatureCollection::FeatureCollection(const QList<Esri::ArcGISRuntime::FeatureCollectionTable *> &featureCollectionTables, QObject *parent = nullptr)

    Creates a feature collection object from a set of feature collection tables.

    See also tables.

    [override virtual] FeatureCollection::~FeatureCollection()

    Destructor.

    [override virtual] void FeatureCollection::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    See Loadable.

    [signal] void FeatureCollection::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.

    [static] Esri::ArcGISRuntime::FeatureCollection *FeatureCollection::fromJson(const QString &json, QObject *parent = nullptr)

    Creates a new FeatureCollection from its JSON representation.

    • json - The JSON text.
    • parent - The parent QObject (optional).

    Esri::ArcGISRuntime::Item *FeatureCollection::item() const

    Returns the item the feature collection has been created from.

    This is only available if the FeatureCollection is associated with a PortalItem. This is the case if the FeatureCollection had been created from an item using FeatureCollection(Esri::ArcGISRuntime::Item*, QObject*) or if the FeatureCollection had been previously saved as a PortalItem.

    {FeatureCollection(Esri::ArcGISRuntime::Item*, QObject*)}

    See also Esri::ArcGISRuntime::FeatureCollection::FeatureCollection(Esri::ArcGISRuntime::Item*, QObject*).

    [override virtual] void FeatureCollection::load()

    Reimplements: Loadable::load().

    See Loadable.

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

    Reimplements: Loadable::loadError() const.

    Returns the load error.

    See Loadable.

    See also Error.

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

    Reimplements: Loadable::loadStatus() const.

    Returns the load status.

    See Loadable.

    See also LoadStatus.

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

    Signal emitted when the loadStatus property changes.

    See also Loadable.

    [override virtual] void FeatureCollection::retryLoad()

    Reimplements: Loadable::retryLoad().

    See Loadable.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureCollection::saveAsAsync(Esri::ArcGISRuntime::Portal *portal, const QString &title, const QStringList &tags, const Esri::ArcGISRuntime::PortalFolder &folder = PortalFolder(), const QString &description = QString(), const QByteArray &thumbnailBytes = QByteArray())

    Saves the feature collection as a new PortalItem (of type PortalItemType::FeatureCollection).

    • portal - The portal to save the PortalItem to.
    • title - A title for the feature collection.
    • tags - The tags to be associated with the newly created portal item.
    • folder - The folder in which to save the feature collection. If empty, it will be added to the user's root folder.
    • description - The description of the feature collection.
    • thumbnailBytes - The thumbnail of the feature collection.

    To be saved, the FeatureCollection does not need to be associated with an existing PortalItem object but it must be loaded.

    Once saved, the item will be populated with the new portal item. Note that if the FeatureCollection already had a valid PortalItem (either because the FeatureCollection was created using a portal item or was previously saved), the item will be replaced with a new PortalItem, effectively duplicating the feature collection on the portal.

    Canceling the QFuture will not stop this operation from completing, though the QFuture will report that it is canceled and the completion handler will not be called.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> FeatureCollection::saveAsync()

    Saves any changes that have been made to the FeatureCollection to the associated PortalItem.

    Updates the FeatureCollection content data on the portal and the portal item properties stored on the portal to match those stored within the item object.

    The FeatureCollection must have been constructed using the FeatureCollection(PortalItem) constructor to associate it with a PortalItem object, or must have been previously saved using saveAsAsync(Esri::ArcGISRuntime::Portal*, const Esri::ArcGISRuntime::PortalFolder&, const QString&, const QString&, const QStringList&, const QImage&). The FeatureCollection must be loaded.

    If the portal associated with the item is not loaded, it will be loaded automatically. If the portal requires a credential that has not been supplied, it should have been previously loaded.

    Canceling the QFuture will not stop this operation from completing, though the QFuture will report that it is canceled and the completion handler will not be called.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    Esri::ArcGISRuntime::FeatureCollectionTableListModel *FeatureCollection::tables() const

    Returns the list model of tables in this FeatureCollection.

    [override virtual] QString FeatureCollection::toJson() const

    Reimplements: JsonSerializable::toJson() const.

    Returns this FeatureCollection as JSON.

    [override virtual] QJsonObject FeatureCollection::unknownJson() const

    Reimplements: JsonSerializable::unknownJson() const.

    Returns the unknown data from the source JSON.

    Unknown JSON is a dictionary of values not defined in the ArcGIS specification used to create this object but found in the source JSON. If the object is written back to JSON, any unknown JSON data is not persisted. The ArcGIS specification may be for a web map, web scene, REST API, and so on.

    See also JsonSerializable.

    [override virtual] QJsonObject FeatureCollection::unsupportedJson() const

    Reimplements: JsonSerializable::unsupportedJson() const.

    Returns the unsupported data from the source JSON.

    Unsupported JSON is a dictionary of values defined in the ArcGIS specification used to create this object but not currently used in this API. If the object is written back to JSON, any unsupported JSON data is persisted. The ArcGIS specification may be from a web map, web scene, REST API, and so on.

    See also JsonSerializable.

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