MobileScenePackage Class

  • MobileScenePackage
  • class Esri::ArcGISRuntime::MobileScenePackage

    A mobile scene package (.mspk file). More...

    Header: #include <MobileScenePackage.h>
    Since: Esri::ArcGISRuntime 100.5
    Inherits: Esri::ArcGISRuntime::Object and Esri::ArcGISRuntime::Loadable

    Public Functions

    MobileScenePackage(const QString &path, QObject *parent = nullptr)
    virtual ~MobileScenePackage() override
    void close()
    Esri::ArcGISRuntime::Expiration expiration() const
    Esri::ArcGISRuntime::Item *item() const
    Esri::ArcGISRuntime::LocatorTask *locatorTask() const
    QString path() const
    QList<Esri::ArcGISRuntime::Scene *> scenes() const
    QString version() 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

    Signals

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

    Static Public Members

    Esri::ArcGISRuntime::MobileScenePackage *instance()
    QFuture<void> unpackAsync(const QString &mobileScenePackageFilePath, const QString &outputDirectory)

    Detailed Description

    Mobile scene packages allow you to work with 3D scenes on a mobile device. A mobile scene package contains all of the files necessary to work with your scenes and is stored on a device as either:

    • A single archive file with an .mspk extension.
    • A directory containing an unpacked mobile scene package.

    A mobile scene package can encapsulate one or more scenes, their layers and data, transportation networks, and a locator. The mobile scene package also contains an Item with metadata about the package (description, thumbnail, etc.). You can use these packages to share scenes across ArcGIS products and to allow your users to work with scenes in the field. Mobile scene packages also allow you to continue working when you have limited connectivity.

    Starting with ArcGIS Pro 2.3 you can create mobile scene packages for use by this API. Mobile scene packages are supported up to major version 3.

    Mobile scene packages can contain links to online services, but be aware that these services will be unavailable if your device is offline. You can choose whether to use:

    Online services (such as traffic or weather) can provide excellent contextual information for your users. If the mobile scene package is going to be used in areas of poor connectivity, however, you must ensure that data critical to your workflow is stored locally on the device.

    Mobile scene packages implement the Loadable interface; you need to load the MobileScenePackage before you can access its content. Once loaded you can:

    • Determine the version of this package using the MobileScenePackage::version property. This API supports mobile scene packages up to and including major version 3. If the package is from an unsupported version it will fail to load.
    • Discover whether the package has expired using the MobileScenePackage::expiration property.
    • Access the individual scenes and display them in a SceneView.
    • Programmatically add, modify, and remove layers in the scene. Mobile scene packages, however, are read-only and these changes to scenes or layers will not be persisted to the device.

    Relevant samples:

    Member Function Documentation

    [explicit] MobileScenePackage::MobileScenePackage(const QString &path, QObject *parent = nullptr)

    Constructor that takes a file path and an optional parent.

    The path can refer to a file with an .mspk extension or a directory containing an unpacked mobile scene package.

    Note: Constructing a MobileScenePackage from a path to a .mspk file does not load the MobileScenePackage automatically. You must call load to load it explicitly.

    [override virtual] MobileScenePackage::~MobileScenePackage()

    Destructor.

    [override virtual] void MobileScenePackage::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    See Loadable.

    [since Esri::ArcGISRuntime 100.6] void MobileScenePackage::close()

    Closes a mobile scene package.

    Closes a mobile scene package and frees file locks on the underlying .mspk file or directory.

    All references to mobile scene package data (scenes, layers, tables, networks, locators, etc.) should be released before closing the package. If active references to mobile scene package data exist, this method will still close the package, but subsequent rendering and data access methods will fail. Results of accessing mobile scene package data after close are undefined.

    After closing a mobile scene package, the underlying .mspk file or directory can be moved or deleted.

    Closing a mobile scene package is not necessary if the package has not been loaded.

    This function was introduced in Esri::ArcGISRuntime 100.6.

    See also MobileMapPackage::close and Geodatabase::close.

    [signal] void MobileScenePackage::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::Expiration MobileScenePackage::expiration() const

    Gets expiration details for this mobile scene package, if provided.

    Expiration details provide:

    • The package’s expiration date and time.
    • Whether the scenes can be accessed after expiration.
    • Any messages relevant for the user.

    By publishing a package with expiration details, the author can control the experience an end-user has when they try to access information that is no longer valid. For example, for time limited data (such as major sporting events), the author can ensure that the data cannot be accessed after the expiry date.

    These expiration details can be specified when the author creates a mobile scene package using ArcGIS Pro (from version 2.4). This requires the ArcGIS Pro Publisher Extension.

    During package loading, this API will determine whether the mobile scene package was authored with expiration. If so, then this property will be populated.

    If the package has expired and was authored as ExpirationType::PreventExpiredAccess, loading will fail and you will not be able to access the scenes. The expiration details will be accessible for you to examine and/or communicate to the user.

    [static] Esri::ArcGISRuntime::MobileScenePackage *MobileScenePackage::instance()

    Returns an instance of the MobileScenePackage singleton.

    The instance is used to connect to the unpackCompleted signals. For static methods this instance will also emit the errorOccurred signal.

    You do not need to obtain the instance to call the static methods on the MobileScenePackage.

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

    Gets the mobile scene package's item describing meta-data about the package..

    The item includes the metadata that was provided by the mobile scene package author in ArcGIS Pro. This includes information such as:

    • Title
    • Snippet (summary)
    • Description
    • Tags
    • Thumbnail

    A mobile scene package's item will be an instance of a LocalItem.

    Returns nullptr if the package is not loaded.

    [override virtual] void MobileScenePackage::load()

    Reimplements: Loadable::load().

    See Loadable.

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

    Reimplements: Loadable::loadError() const.

    See Loadable.

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

    Reimplements: Loadable::loadStatus() const.

    See Loadable.

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

    Signal emitted when the load status changes for this object.

    • loadStatus - The load status of this object.

    See also Loadable.

    Esri::ArcGISRuntime::LocatorTask *MobileScenePackage::locatorTask() const

    Gets the locator contained in the mobile scene package as a LocatorTask.

    Use this task to geocode and reverse-geocode addresses and places. There is only one LocatorTask in each mobile scene package but it can be used by all scenes.

    Returns nullptr if there is no LocatorTask in the package, or the package is not loaded.

    QString MobileScenePackage::path() const

    Gets the path to the mobile scene package.

    The path can refer to a file with an .mspk extension or a directory containing an unpacked mobile scene package.

    [override virtual] void MobileScenePackage::retryLoad()

    Reimplements: Loadable::retryLoad().

    See Loadable.

    QList<Esri::ArcGISRuntime::Scene *> MobileScenePackage::scenes() const

    Gets a collection of the scenes contained in the MobileScenePackage.

    To use the scenes in a MobileScenePackage, you first need to load the package. The scenes are presented in the same order in which they were packaged with ArcGIS Pro. To display a Scene set the scene to a SceneView. This will automatically load the scene and all of its content. If you only need to access the scene's content or metadata, then you need to load it by calling GeoModel::load.

    If the package is not loaded, an empty collection is returned.

    [static, since Esri::ArcGISRuntime 200.2] QFuture<void> MobileScenePackage::unpackAsync(const QString &mobileScenePackageFilePath, const QString &outputDirectory)

    Unpacks a mobile scene package file (.mspk) to an output directory.

    • mobileScenePackageFilePath - the path to a mobile scene package file (.mspk).
    • outputDirectory - a path to a directory to write the mobile scene package contents.

    If the last level of the output_directory is not present, it will be created as part of the unpack task. The returned task can be canceled with QFuture::cancel to abort the unpack. The unpack task writes the full content of the mobile scene package to the output directory. Care should be taken on devices with limited storage space, especially if the package is very large. After unpacking, you can remove the original .mspk file from the device.

    Note that unpacking will fail if the package has expired and was authored as ExpirationType::PreventExpiredAccess.

    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.

    QString MobileScenePackage::version() const

    Returns the version of the mobile scene package.

    The mobile scene package version was set when the package was authored in ArcGIS Pro.

    This property is populated when you attempt to load the package. The version property will always be populated, for you to examine, even if the package is an unsupported version.

    This API supports mobile scene packages up to and including major version 3.

    You may wish to check the version property before trying to access specific functionality. For example:

    • Expiration details are only available in mobile scene package from version 1.1 onwards.
    • Links to online services are only available in mobile scene package from version 3.0 onwards.

    If the package fails to load, check that the version number does not exceeded the supported major version.

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