Select to view content in your preferred language

How to load .slpk file locally ??

6119
8
05-28-2018 05:50 AM
VijitWadhwa
Occasional Contributor

I want to work in the Desktop Pattern, Accordint to the documentation , we need to set elevation source using some specified formats (i.e dem, geotiff ..) and the layers to be added using .slpk format, 

Display a scene—ArcGIS Runtime SDK for .NET (WPF) | ArcGIS for Developers 

But the API Reference states that the constructor of ArcGISSceneLayer asks for URI, I want to load everything offline , there are no sample codes for offline data. Please help me with some snippets , or examples so I can work with offline 3D Data. Thanks in advance

0 Kudos
8 Replies
dotMorten_esri
Esri Notable Contributor

You can use a file uri for local data: file://c:/data/mydata.slpk

VijitWadhwa
Occasional Contributor

Hi, Thanks for the reply

0 Kudos
PeterChen1
Emerging Contributor

Hi, I tried on 100.2.1, however, i didn't see my slpk data on the scene control, the region displays gray. i generated the slpk via smart3d, anything i miss? see my code snippet below.

private void LoadSceneTest()
{
// Create new Scene
Scene myScene = new Scene();

// Set Scene's base map property
myScene.Basemap = Basemap.CreateImagery();
var _elevationSourceUrl = new Uri(@"https://scene.arcgis.com/arcgis/rest/services/BREST_DTM_1M/ImageServer");
// Create and add an elevation source for the Scene
//ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(_elevationSourceUrl);
//myScene.BaseSurface.ElevationSources.Add(elevationSrc);

Uri treespk = new System.Uri(@"F:\JointSurvey\数据\倾斜三维\SPK\海沧\spk\spk.slpk");
var treeLayer = new ArcGISSceneLayer();
// add the scene layer to the scene
treeLayer.Source = treespk;
//await treeLayer.LoadAsync();
myScene.OperationalLayers.Add(treeLayer);

// Create a camera with coordinates showing layer data
Camera camera = new Camera(24.515519999999999, 117.989097000000000, 300, 344, 0, 71.17);

// Assign the Scene to the SceneView
MySceneView.Scene = myScene;

// Set view point of scene view using camera
MySceneView.SetViewpointCameraAsync(camera);
}

I also debug the code and found that the treeLayer is loaded correctly and visible. by the way the slpk contrains 3D models from osgb format.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Your file uri should be :

Uri treespk = new System.Uri(@"file://F:/JointSurvey/数据\倾斜三维/SPK/海沧/spk/spk.slpk");

I see you commented out the treeLayer.LoadAsync() call. While you don't need it, explicitly calling it should give you an error message telling you what's wrong. Could you please share that error?

Also while I believe we fixed all Unicode issues with file paths, could you try it with a path that contains basic ASCII characters, just to make sure that's not the issue?

0 Kudos
PeterChen1
Emerging Contributor

Thanks for reply. I tried explicitly calling LoadAsync() and found that it worked correctly. the file path is not an issue.

I am a bit doubt that there is something wrong with my slpk file as it's the some result(see below snapshot) when i open it via Arcgis Earth. any clues?

by the way, the slpk contrains 3D models which is generated by smart 3d software. Could you provide some sample 'correct' slpk file for testing my code?

0 Kudos
dotMorten_esri
Esri Notable Contributor

ArcGIS Earth uses a newer build of the runtime. Could you retry with the newly released v100.3 ?

0 Kudos
PeterChen1
Emerging Contributor

Hi Morten Nielsen, I tried my another slpk and succeeded to open it using arcgis runtime 100.2.1. 

However, today after I upgrade arcgis runtime .net to v100.3, my scene layer is invisible when it was there when I was using v100.2.1,could you give me some idea on how to fix this? Below is my code snippet to load my local slpk as an ArcGISSceneLayer:

 

Uri treespk = new System.Uri(slpkPath);
var sceneLayer = new ArcGISSceneLayer();
// add the scene layer to the scene
sceneLayer.Source = treespk;
sceneLayer.Loaded += SceneLayer_Loaded;
//await sceneLayer.LoadAsync();
sceneView.Scene.OperationalLayers.Add(sceneLayer);

 

By the way, the SceneLayer_Loaded is invoked so I am sure the sceneLayer is loaded without any error, just not visible.

 

I try to load the same local slpk via arcgis earth v1.6.1, it's visible on the earth.

0 Kudos
KarthikS
Emerging Contributor

Hi, 

I tried  to load the local .slpk file. Its loaded successfully.

But 3D Object not rendered perfectly in base map.

Some gap is showing between basemap and building.

Please give us advice

0 Kudos