ArcGIS Runtime SDK for iOS: AGSMobileScenePackage Class Reference
ArcGIS Runtime SDK for iOS  100.12
AGSMobileScenePackage Class Reference

Description

A mobile scene package.

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 AGSItem object with metadata about the package (description, thumbnail, etc.). You can use these packages to share scenes across the ArcGIS platform 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 in ArcGIS Runtime. This version of ArcGIS Runtime will support any mobile scene package 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:

  • A tile package (.tpk, .tpkx, .vtpk) or an online basemap as the AGSScene::basemap property
  • A mobile geodatabase (.geodatabase) or an online feature service as one of the AGSGeoModel::operationalLayers
  • Local raster data (such as a DTED, GeoTIFF) or online image services as the elevation sources in the AGSScene::baseSurface propety. 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 AGSLoadable interface; you need to load the AGSMobileScenePackage object before you can access its content.

Once loaded you can:

  • Determine the version of this package using the AGSMobileScenePackage::version property. ArcGIS Runtime currently 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 AGSMobileScenePackage::expiration property
  • Access the individual scenes and display them in an AGSSceneView object
  • 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.
    Since
    100.5
Inheritance diagram for AGSMobileScenePackage:
AGSLoadableBase AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(void) - close
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(instancetype) - initWithFileURL:
 
(instancetype) - initWithName:
 
(void) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(void) - retryLoadWithCompletion:
 

Class Methods

(id< AGSCancelable >) + checkDirectReadSupportForMobileScenePackageAtFileURL:completion:
 
(instancetype) + mobileScenePackageWithFileURL:
 
(instancetype) + mobileScenePackageWithName:
 
(id< AGSCancelable >) + unpackMobileScenePackageAtFileURL:outputDirectory:completion:
 

Properties

AGSExpirationexpiration
 
NSURL * fileURL
 
AGSItemitem
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
AGSLocatorTasklocatorTask
 
NSArray< AGSScene * > * scenes
 
NSString * version
 

Method Documentation

◆ cancelLoad

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

◆ checkDirectReadSupportForMobileScenePackageAtFileURL:completion:

+ (id<AGSCancelable>) checkDirectReadSupportForMobileScenePackageAtFileURL: (NSURL *)  fileURL
completion: (void(^)(BOOL isDirectReadSupported, NSError *__nullable error))  completion 

Checks if the package can be read directly without requiring to be unpacked. isDirectReadSupported will always be YES after deprecation in version 100.7.

Prior to ArcGIS Runtime version 100.7, some data formats (such as AGSRasterLayer) could only be accessed if they were unpacked from a mobile scene package file (.mspk). In these situations, isDirectReadSupported would be NO and you would need to call AGSMobileScenePackage::unpackWithMobileScenePackageFileURL:outputDirectory:completion: to unpack the mspk file.

From version 100.7 and onwards this limitation has been removed allowing the data to be read directly from the mobile scene package. isDirectReadSupported is always YES.

Since this method is no longer required it can be removed from calling code including any subsequent use of AGSMobileScenePackage::unpackWithMobileScenePackageFileURL:outputDirectory:completion:.

Parameters
fileURLThe file URL to the .mspk file
completionA block that is invoked with information about whether direct read is supported if the operation succeeds, or an error if it fails.
Returns
An operation that can be canceled.
See also
AGSMobileScenePackage::unpackWithMobileScenePackageFileURL:outputDirectory:completion:
Since
100.5
Deprecated:
100.7 This method is no longer required as the result is always true. It can be removed from calling code including any subsequent use of AGSMobileScenePackage::unpackWithMobileScenePackageFileURL:outputDirectory:completion:.

Provided by category AGSMobileScenePackage(AGSDeprecated).

◆ close

- (void) 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, 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 closing it 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.

See also
- close (AGSMobileMapPackage), - close (AGSGeodatabase)
Since
100.6

◆ doCancelLoading

- (void) doCancelLoading

Never call this method directly. The framework calls this method on a background thread when cancelLoad (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to cancel loading their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) at the end passing in an error representing NSUserCancelledError.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ doStartLoading:

- (void) doStartLoading: (BOOL)  retrying

Never call this method directly. The framework calls this method on a background thread when loadWithCompletion: (AGSLoadable-p) or retryLoadWithCompletion: (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to load their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) upon completion, passing in the error if any.

Parameters
retryingflag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p).
Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ initWithFileURL:

- (instancetype) initWithFileURL: (NSURL *)  fileURL

Creates an object with the specified mobile scene package (.mspk file) on disk or a directory containing an unpacked mobile scene package.

Parameters
fileURLto the mobile scene package.
Since
100.5

◆ initWithName:

- (instancetype) initWithName: (NSString *)  name

Creates an object with the name of a mobile scene package (.mspk file), excluding the ".mspk" extension, within the application bundle or shared documents directory.

Parameters
nameof the mobile scene package (excluding the .mspk extension)
Since
100.5

◆ loadDidFinishWithError:

- (void) loadDidFinishWithError: (nullable NSError *)  error

Only subclasses should call this method in doStartLoading: (AGSLoadableBase(ForSubclassEyesOnly)) and doCancelLoading (AGSLoadableBase(ForSubclassEyesOnly)) when done loading or failed to load.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ loadWithCompletion:

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

◆ mobileScenePackageWithFileURL:

+ (instancetype) mobileScenePackageWithFileURL: (NSURL *)  fileURL

Creates an object with the specified mobile scene package (.mspk file) on disk or a directory containing an unpacked mobile scene package.

Parameters
fileURLThe file URL to the mobile scene package.
Returns
A new mobile scene package object.
Since
100.5

◆ mobileScenePackageWithName:

+ (instancetype) mobileScenePackageWithName: (NSString *)  name

Creates an object with the name of a mobile scene package (.mspk file), excluding the ".mspk" extension, within the application bundle or shared documents directory.

Parameters
nameThe name of the mobile scene package (excluding the .mspk extension).
Returns
A new mobile scene package object.
Since
100.5

◆ onLoadStatusChanged

- (void) onLoadStatusChanged

Never call this method directly. The framework calls this method on a background thread when AGSLoadable::loadStatus changes is called. Subclasses can optionally implement this to know when their loading status has changed.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ retryLoadWithCompletion:

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

◆ unpackMobileScenePackageAtFileURL:outputDirectory:completion:

+ (id<AGSCancelable>) unpackMobileScenePackageAtFileURL: (NSURL *)  fileURL
outputDirectory: (NSURL *)  outputDirectory
completion: (void(^)(NSError *__nullable error))  completion 

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

If the last level of the output directory is not present, it will be created as part of the unpack task. The returned operation can be canceled 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 AGSExpirationTypePreventExpiredAccess.

Parameters
fileURLThe file URL to .mspk file
outputDirectoryThe output directory specifying where to unpack the package. If the last component of the directory location does not exist, it will be created during unpacking.
completionA block that is invoked when the operation completes.
Returns
An operation that can be canceled.
Since
100.5

Property Documentation

◆ expiration

- (AGSExpiration*) expiration
readnonatomicstrong

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, the ArcGIS Runtime 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 AGSExpirationTypePreventExpiredAccess, 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.

Since
100.5

◆ fileURL

- (NSURL*) fileURL
readnonatomicstrong

The URL of the mobile scene package (.mspk file) on disk or a directory containing an unpacked mobile scene package.

Since
100.5

◆ item

- (AGSItem*) item
readnonatomicstrong

The mobile scene package's AGSItem object describing metadata 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 an AGSLocalItem. Returns nil if the package is not loaded.

See also
AGSItem
Since
100.5

◆ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

◆ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

◆ locatorTask

- (AGSLocatorTask*) locatorTask
readnonatomicstrong

An AGSLocatorTask object from the mobile scene package.

Use this task to geocode and reverse-geocode addresses and places. There is only one AGSLocatorTask object in each mobile scene package, but it can be used by all scenes. Returns nil if there is no AGSLocatorTask in the package, or the package is not loaded.

See also
AGSLocatorTask
Since
100.5

◆ scenes

- (NSArray<AGSScene*>*) scenes
readnonatomiccopy

An array of AGSScene objects from the AGSMobileScenePackage object.

To use the scenes in an AGSMobileScenePackage object, 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 an AGSScene object set the scene to an AGSSceneView object. 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 AGSScene::load method. If the package is not loaded, an empty array is returned.

See also
NSArray, AGSScene
Since
100.5

◆ version

- (NSString*) version
readnonatomiccopy

The mobile scene package's version.

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.

ArcGIS Runtime currently 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.

Since
100.5