Class MobileScenePackage
- java.lang.Object
-
- com.esri.arcgisruntime.mapping.MobileScenePackage
-
- All Implemented Interfaces:
Loadable
public final class MobileScenePackage extends java.lang.Object implements Loadable
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.
Item
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 (.tpkx) or an online basemap as the
GeoModel.getBasemap()
. - A mobile geodatabase (.geodatabase) or an online feature service as one of the
GeoModel.getOperationalLayers()
. - Local raster data (such as a DTED, GeoTIFF) or online image services as the elevation sources in a
ArcGISScene.getBaseSurface()
. 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.
Loadable
interface; you need to load theMobileScenePackage
before you can access its content. Once loaded you can:- Determine the version of this package using the
getVersion()
. 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
getExpiration()
. - 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.
scenePackage = new MobileScenePackage("file/path/MyMobileScenePackage.mspk"); scenePackage.loadAsync(); scenePackage.addDoneLoadingListener(() -> { if (scenePackage.getLoadStatus() == LoadStatus.LOADED) { sceneView.setScene(scenePackage.getScenes().get(0)); } });
- Since:
- 100.5.0
- See Also:
ArcGISScene
,Loadable
-
-
Constructor Summary
Constructors Constructor Description MobileScenePackage(java.lang.String path)
Create aMobileScenePackage
with a path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDoneLoadingListener(java.lang.Runnable listener)
Adds a listener to the loadable resource that is invoked when loading has completed.void
addLoadStatusChangedListener(LoadStatusChangedListener listener)
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.void
cancelLoad()
Cancels loading metadata for the object.void
close()
Closes a mobile scene package and frees file locks on the underlying .mspk file or directory.Expiration
getExpiration()
Gets the expiration details for this mobile scene package, if provided.Item
getItem()
The mobile scene package'sItem
describing metadata about the package.ArcGISRuntimeException
getLoadError()
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.LoadStatus
getLoadStatus()
Returns theLoadStatus
of the loadable resource.LocatorTask
getLocatorTask()
Gets the locator task if the mobile scene package has one.java.lang.String
getPath()
The path to the mobile scene package.java.util.List<ArcGISScene>
getScenes()
An unmodifiable list ofArcGISScene
objects from theMobileScenePackage
.java.lang.String
getVersion()
Gets the mobile scene package version.static ListenableFuture<java.lang.Boolean>
isDirectReadSupportedAsync(java.lang.String path)
Deprecated.As of 100.7.0, no replacement.void
loadAsync()
Loads the metadata of the loadable resource asynchronously.boolean
removeDoneLoadingListener(java.lang.Runnable listener)
Removes a done loading listener from the loadable resource.boolean
removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Removes aLoadStatusChangedListener
from the loadable resource.void
retryLoadAsync()
Loads or retries loading metadata for the object asynchronously.static ListenableFuture<java.lang.Void>
unpackAsync(java.lang.String path, java.lang.String destinationFolder)
Unpacks a mobile scene package file (.mspk) to an output directory.
-
-
-
Constructor Detail
-
MobileScenePackage
public MobileScenePackage(java.lang.String path)
Create aMobileScenePackage
with a path.The path can refer to a file with an .mspk extension or a directory containing an unpacked mobile scene package.
- Parameters:
path
- the path to a .mspk file or a folder containing an unpacked mobile scene package- Throws:
java.lang.IllegalArgumentException
- if path is null or empty- Since:
- 100.5.0
-
-
Method Detail
-
getScenes
public java.util.List<ArcGISScene> getScenes()
An unmodifiable list ofArcGISScene
objects from theMobileScenePackage
.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 aArcGISScene
set the scene to aSceneView
. 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 callingGeoModel.loadAsync()
.If the package is not loaded, an empty collection is returned.
- Returns:
- a list of scenes in the mobile scene package
- Since:
- 100.5.0
-
getItem
public Item getItem()
The mobile scene package'sItem
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
LocalItem
.Returns null if the package is not loaded.
- Returns:
Item
- Since:
- 100.5.0
-
getPath
public java.lang.String getPath()
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.
- Returns:
- path to the .mspk file or directory containing the unpacked mobile scene package
- Since:
- 100.5.0
- See Also:
MobileScenePackage(String)
-
getVersion
public java.lang.String getVersion()
Gets the mobile scene package version. It can be used to determine if an app can support the mobile scene package. 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 SDKs 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.
- Returns:
- the mobile scene package version
- Since:
- 100.5.0
-
getLocatorTask
public LocatorTask getLocatorTask()
Gets the locator task if the mobile scene package has one. ALocatorTask
from the mobile scene package.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.If a mobile scene package is made in ArcGIS Pro using multiple locator tasks, they will be merged into one in the package. A geocode result from the locator task will contain information about which original locator task it came from.
- Returns:
- the mobile scene package's locator task, or null if the package is not loaded or if no locator is in the package
- Since:
- 100.5.0
- See Also:
LocatorTask
-
getExpiration
public Expiration getExpiration()
Gets the 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.
ExpirationType.PREVENT_EXPIRED_ACCESS
, 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.- Returns:
- the expiration details for this mobile scene package, or null if the package is not loaded or no expiration date has been set
- Since:
- 100.5.0
- See Also:
Expiration
-
close
public void close()
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 calling 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.
- Since:
- 100.6.0
- See Also:
MobileMapPackage.close()
,Geodatabase.close()
-
isDirectReadSupportedAsync
@Deprecated public static ListenableFuture<java.lang.Boolean> isDirectReadSupportedAsync(java.lang.String path)
Deprecated.As of 100.7.0, no replacement. This method is no longer required as the result is always true. It can be removed from calling code, including any subsequent use ofunpackAsync(String, String)
Checks if a mobile scene package file (.mspk) contains data or functionality that can be read directly without requiring to be unpacked.Prior to ArcGIS Runtime version 100.7, some data formats (such as
RasterLayer
could only be accessed if they were unpacked from a mobile scene package file (.mspk). In these situations, this method would return false and you would need to callunpackAsync(String, String)
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. This method always returns a result of true. Since this method is no longer required it can be removed from calling code including any subsequent use ofMobileScenePackage#unpackAsync(String, String)
.- Parameters:
path
- the path to a .mspk file- Returns:
- a ListenableFuture. Add a listener to this to know when the result is ready. The result of the future indicates if direct read is supported or not.
- Throws:
java.lang.IllegalArgumentException
- if path is null or empty- Since:
- 100.5.0
-
unpackAsync
public static ListenableFuture<java.lang.Void> unpackAsync(java.lang.String path, java.lang.String destinationFolder)
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 task can be canceled with
Future.cancel(boolean)
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 original package is very large. After unpacking, you can remove the original .mspk file from the device. Note that unpacking will fail if the package is expired and was authored as
ExpirationType.PREVENT_EXPIRED_ACCESS
.- Parameters:
path
- the path to a .mspk filedestinationFolder
- the folder to place the unpacked .mspk- Returns:
- a ListenableFuture. Add a listener to this to know when the unpack is done
- Throws:
java.lang.IllegalArgumentException
- if path is null or emptyjava.lang.IllegalArgumentException
- if destinationFolder is null or empty- Since:
- 100.5.0
-
getLoadStatus
public LoadStatus getLoadStatus()
Description copied from interface:Loadable
Returns theLoadStatus
of the loadable resource.- Specified by:
getLoadStatus
in interfaceLoadable
- Returns:
- the LoadStatus of the loadable resource
-
getLoadError
public ArcGISRuntimeException getLoadError()
Description copied from interface:Loadable
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.If the resource subsequently transitions to
LoadStatus.LOADED
(for example, if a call toretryLoadAsync
completes successfully) the error is cleared out.- Specified by:
getLoadError
in interfaceLoadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
LoadStatus.FAILED_TO_LOAD
state.
-
cancelLoad
public void cancelLoad()
Description copied from interface:Loadable
Cancels loading metadata for the object.Cancels loading the metadata if the object is loading, and always invokes the done loading listener.
A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.getLoadError()
.Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.
This method does nothing if the resource is not in
LoadStatus.LOADING
state.- Specified by:
cancelLoad
in interfaceLoadable
-
loadAsync
public void loadAsync()
Description copied from interface:Loadable
Loads the metadata of the loadable resource asynchronously.The load status changes from
LoadStatus.NOT_LOADED
toLoadStatus.LOADING
. A listener can be added viaLoadable.addDoneLoadingListener(java.lang.Runnable)
that is invoked upon completion of the asynchronous load operation.If the load operation completes successfully, the load status will be
LoadStatus.LOADED
, which means the resource has loaded its metadata.If the load operation failed, the load status will be
LoadStatus.FAILED_TO_LOAD
and the error can be retrieved by callingLoadable.getLoadError()
.This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (
LoadStatus.LOADING
state) whenloadAsync
is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
is called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling
loadAsync
on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource,Loadable.retryLoadAsync()
needs to be used.A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by callingLoadable.cancelLoad()
.
-
retryLoadAsync
public void retryLoadAsync()
Description copied from interface:Loadable
Loads or retries loading metadata for the object asynchronously.Will retry loading the metadata if the object's load status is
LoadStatus.FAILED_TO_LOAD
. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.For more details on the load process see
Loadable.loadAsync()
.- Specified by:
retryLoadAsync
in interfaceLoadable
-
addDoneLoadingListener
public void addDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Adds a listener to the loadable resource that is invoked when loading has completed.The listener may be added at any point, whether the loadable resource has already completed loading or not.
- For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.
Alternatively, to be notified when there is any change in the load status, use the
Loadable.addLoadStatusChangedListener(LoadStatusChangedListener)
method instead.- Specified by:
addDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
public boolean removeDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Removes a done loading listener from the loadable resource.- Specified by:
removeDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- the listener to be removed- Returns:
- true if the listener was removed, otherwise false
-
addLoadStatusChangedListener
public void addLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the
Loadable.addDoneLoadingListener(Runnable)
method.- Specified by:
addLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
-