@@ -97,7 +97,7 @@ extension AugmentRealityToNavigateRouteView {
9797 private( set) var routeGraphicsOverlay = GraphicsOverlay ( )
9898
9999 /// The elevation surface set to the base surface of the scene.
100- private( set ) var elevationSurface : Surface = {
100+ private let elevationSurface : Surface = {
101101 let elevationSurface = Surface ( )
102102 elevationSurface. navigationConstraint = . unconstrained
103103 elevationSurface. opacity = 0
@@ -177,25 +177,22 @@ extension AugmentRealityToNavigateRouteView {
177177 /// - polyline: The polyline geometry of the route.
178178 /// - Returns: A polyline with adjusted elevation.
179179 private func addingElevation( _ z: Double , to polyline: Polyline ) async throws -> Polyline ? {
180- if let densifiedPolyline = GeometryEngine . densify ( polyline, maxSegmentLength: 0.3 ) as? Polyline {
181- let polylineBuilder = PolylineBuilder ( spatialReference: densifiedPolyline. spatialReference)
182- for part in densifiedPolyline. parts {
183- for point in part. points {
184- let elevation = try await elevationSurface. elevation ( at: point)
185- let newPoint = GeometryEngine . makeGeometry ( from: point, z: elevation + z)
186- // Put the new point 3 meters above the ground elevation.
187- polylineBuilder. add ( newPoint)
188- }
180+ guard let densifiedPolyline = GeometryEngine . densify ( polyline, maxSegmentLength: 0.3 ) as? Polyline else { return nil }
181+ let polylineBuilder = PolylineBuilder ( spatialReference: densifiedPolyline. spatialReference)
182+ for part in densifiedPolyline. parts {
183+ for point in part. points {
184+ let elevation = try await elevationSurface. elevation ( at: point)
185+ let newPoint = GeometryEngine . makeGeometry ( from: point, z: elevation + z)
186+ // Put the new point 3 meters above the ground elevation.
187+ polylineBuilder. add ( newPoint)
189188 }
190- return polylineBuilder. toGeometry ( )
191- } else {
192- return nil
193189 }
190+ return polylineBuilder. toGeometry ( )
194191 }
195192
196193 /// Starts navigating the route.
197194 func startNavigation( ) async throws {
198- guard let routeResult = routeResult else { return }
195+ guard let routeResult else { return }
199196 routeTracker = RouteTracker (
200197 routeResult: routeResult,
201198 routeIndex: 0 ,
@@ -237,7 +234,7 @@ extension AugmentRealityToNavigateRouteView {
237234
238235 /// Monitors the asynchronous stream of voice guidances.
239236 private func trackVoiceGuidance( ) async {
240- guard let routeTracker = routeTracker else { return }
237+ guard let routeTracker else { return }
241238 for try await voiceGuidance in routeTracker. voiceGuidances {
242239 speechSynthesizer. stopSpeaking ( at: . word)
243240 speechSynthesizer. speak ( AVSpeechUtterance ( string: voiceGuidance. text) )
0 commit comments