Skip to content

Commit ebd1d20

Browse files
authored
Merge pull request #367 from Esri/Ting/New-Add3DTiles
[New] Add 3D tiles layer
2 parents 7d69270 + 5f56d4d commit ebd1d20

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed

Samples.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0000FB6E2BBDB17600845921 /* Add3DTilesLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0000FB6B2BBDB17600845921 /* Add3DTilesLayerView.swift */; };
11+
0000FB712BBDC01400845921 /* Add3DTilesLayerView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 0000FB6B2BBDB17600845921 /* Add3DTilesLayerView.swift */; };
1012
0005580A2817C51E00224BC6 /* SampleDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000558092817C51E00224BC6 /* SampleDetailView.swift */; };
1113
000D43162B9918420003D3C2 /* ConfigureBasemapStyleParametersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000D43132B9918420003D3C2 /* ConfigureBasemapStyleParametersView.swift */; };
1214
000D43182B993A030003D3C2 /* ConfigureBasemapStyleParametersView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 000D43132B9918420003D3C2 /* ConfigureBasemapStyleParametersView.swift */; };
@@ -443,6 +445,7 @@
443445
dstPath = "";
444446
dstSubfolderSpec = 7;
445447
files = (
448+
0000FB712BBDC01400845921 /* Add3DTilesLayerView.swift in Copy Source Code Files */,
446449
D77D9C012BB2439400B38A6C /* AugmentRealityToShowHiddenInfrastructureView.ARSceneView.swift in Copy Source Code Files */,
447450
D7A737E32BABBA2200B7C7FC /* AugmentRealityToShowHiddenInfrastructureView.swift in Copy Source Code Files */,
448451
1C2538542BABACB100337307 /* AugmentRealityToNavigateRouteView.RoutePlannerView.swift in Copy Source Code Files */,
@@ -615,6 +618,7 @@
615618
/* End PBXCopyFilesBuildPhase section */
616619

617620
/* Begin PBXFileReference section */
621+
0000FB6B2BBDB17600845921 /* Add3DTilesLayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Add3DTilesLayerView.swift; sourceTree = "<group>"; };
618622
000558092817C51E00224BC6 /* SampleDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleDetailView.swift; sourceTree = "<group>"; };
619623
000D43132B9918420003D3C2 /* ConfigureBasemapStyleParametersView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigureBasemapStyleParametersView.swift; sourceTree = "<group>"; };
620624
00181B452846AD7100654571 /* View+ErrorAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+ErrorAlert.swift"; sourceTree = "<group>"; };
@@ -851,6 +855,14 @@
851855
/* End PBXFrameworksBuildPhase section */
852856

853857
/* Begin PBXGroup section */
858+
0000FB6D2BBDB17600845921 /* Add 3D tiles layer */ = {
859+
isa = PBXGroup;
860+
children = (
861+
0000FB6B2BBDB17600845921 /* Add3DTilesLayerView.swift */,
862+
);
863+
path = "Add 3D tiles layer";
864+
sourceTree = "<group>";
865+
};
854866
0005580D281872BE00224BC6 /* Views */ = {
855867
isa = PBXGroup;
856868
children = (
@@ -935,6 +947,7 @@
935947
0074ABB228174B830037244A /* Samples */ = {
936948
isa = PBXGroup;
937949
children = (
950+
0000FB6D2BBDB17600845921 /* Add 3D tiles layer */,
938951
79D84D0C2A815BED00F45262 /* Add custom dynamic entity data source */,
939952
4D2ADC3E29C26D05003B367F /* Add dynamic entity layer */,
940953
00D4EF7E2863840D00B9CC30 /* Add feature layers */,
@@ -2681,6 +2694,7 @@
26812694
1C3B7DCB2A5F64FC00907443 /* AnalyzeNetworkWithSubnetworkTraceView.swift in Sources */,
26822695
00B042E8282EDC690072E1B4 /* SetBasemapView.swift in Sources */,
26832696
E004A6E62846A61F002A1FE6 /* StyleGraphicsWithSymbolsView.swift in Sources */,
2697+
0000FB6E2BBDB17600845921 /* Add3DTilesLayerView.swift in Sources */,
26842698
D74EA7842B6DADA5008F6C7C /* ValidateUtilityNetworkTopologyView.swift in Sources */,
26852699
E088E1742863B5F800413100 /* GenerateOfflineMapView.swift in Sources */,
26862700
0074ABC428174F430037244A /* Sample.swift in Sources */,
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2024 Esri
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import ArcGIS
16+
import SwiftUI
17+
18+
struct Add3DTilesLayerView: View {
19+
/// A scene with dark gray basemap and an OGC 3D tiles layer.
20+
@State private var scene: ArcGIS.Scene = {
21+
// Creates a scene and sets an initial viewpoint.
22+
let scene = Scene(basemapStyle: .arcGISDarkGray)
23+
let camera = Camera(
24+
latitude: 48.84553,
25+
longitude: 9.16275,
26+
altitude: 350,
27+
heading: 0,
28+
pitch: 75,
29+
roll: 0
30+
)
31+
scene.initialViewpoint = Viewpoint(boundingGeometry: camera.location, camera: camera)
32+
33+
// Creates a surface and adds an elevation source.
34+
let surface = Surface()
35+
surface.addElevationSource(ArcGISTiledElevationSource(url: .worldElevationService))
36+
37+
// Sets the surface to the scene's base surface.
38+
scene.baseSurface = surface
39+
40+
// Creates an OGC 3D tiles layer from a 3D tiles service URL.
41+
let ogc3DTileslayer = OGC3DTilesLayer(url: .stuttgart3DTiles)
42+
43+
// Adds the layer to the scene's operational layers.
44+
scene.addOperationalLayer(ogc3DTileslayer)
45+
return scene
46+
}()
47+
48+
var body: some View {
49+
SceneView(scene: scene)
50+
}
51+
}
52+
53+
private extension URL {
54+
/// The URL of a Stuttgart, Germany city 3D tiles service.
55+
static var stuttgart3DTiles: URL {
56+
URL(string: "https://tiles.arcgis.com/tiles/N82JbI5EYtAkuUKU/arcgis/rest/services/Stuttgart/3DTilesServer/tileset.json")!
57+
}
58+
59+
/// The URL of the Terrain 3D ArcGIS REST Service.
60+
static var worldElevationService: URL {
61+
URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
62+
}
63+
}
64+
65+
#Preview {
66+
Add3DTilesLayerView()
67+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Add 3D tiles layer
2+
3+
Add a layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification.
4+
5+
![Image of Add 3D tiles layer sample](add-3d-tiles-layer.png)
6+
7+
## Use case
8+
9+
One possible use case is that when added to a scene, a 3D tiles layer can assist in performing visual analysis, such as line of sight analysis. A line of sight analysis can be used to assess whether a view is obstructed between an observer and a target.
10+
11+
## How to use the sample
12+
13+
When loaded, the sample will display a scene with an `OGC3DTilesLayer`. Pan around and zoom in to observe the scene of the `Ogc3DTilesLayer`. Notice how the layer's level of detail changes as you zoom in and out from the layer.
14+
15+
## How it works
16+
17+
1. Create a scene.
18+
2. Create an `OGC3DTilesLayer` with the URL to a 3D tiles layer service.
19+
3. Add the layer to the scene's operational layers.
20+
21+
## Relevant API
22+
23+
* OGC3DTilesLayer
24+
* SceneView
25+
26+
## About the data
27+
28+
A layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification. As of ArcGIS Maps SDK for Swift 200.4, it supports analyses like viewshed and line of sight, but does not support other operations like individual feature identification.
29+
30+
The 3D Tiles Open Geospatial Consortium (OGC) specification defines a spatial data structure and a set of tile formats designed for streaming and rendering 3D geospatial content. A 3D Tiles data set, known as a tileset, defines one or more tile formats organized into a hierarchical spatial data structure. For more information, see the [OGC 3D Tiles specification](https://www.ogc.org/standard/3DTiles).
31+
32+
## Tags
33+
34+
3d tiles, layers, OGC, OGC API, scene, service
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"category": "Scenes",
3+
"description": "Add a layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification.",
4+
"ignore": false,
5+
"images": [
6+
"add-3d-tiles-layer.png"
7+
],
8+
"keywords": [
9+
"3d tiles",
10+
"OGC",
11+
"OGC API",
12+
"layers",
13+
"scene",
14+
"service",
15+
"OGC3DTilesLayer",
16+
"SceneView"
17+
],
18+
"redirect_from": [],
19+
"relevant_apis": [
20+
"OGC3DTilesLayer",
21+
"SceneView"
22+
],
23+
"snippets": [
24+
"Add3DTilesLayerView.swift"
25+
],
26+
"title": "Add 3D tiles layer"
27+
}
75.9 KB
Loading

0 commit comments

Comments
 (0)