private async void Initialize() { // Create scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { // Set initial viewpoint. InitialViewpoint = new Viewpoint(_observerPoint, 1000000) }; // Create the elevation source. ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene. myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer. ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene. myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene. // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted. GraphicsOverlay overlay = new GraphicsOverlay { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point. SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, System.Drawing.Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol. _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay. overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene. _mySceneView.GraphicsOverlays.Add(overlay); try { // Add the taxi to the scene. // Get the path to the model. string taxiModelPath = DataManager.GetDataFolder("3af5cfec0fd24dac8d88aea679027cb9", "dolmus.3ds"); // Create the model symbol for the taxi. ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(taxiModelPath)); // Set the anchor position for the mode; ensures that the model appears above the ground. taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol. _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay. overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building). // Create the analysis. _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives. TargetOffsetZ = 2 }; // Create the analysis overlay. AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay. myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene. _mySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi. Timer timer = new Timer(120); // Move the taxi every time the timer expires. timer.Elapsed += AnimationTimer_Elapsed; // Keep the timer running continuously. timer.AutoReset = true; // Start the timer. timer.Start(); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible. _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view. _mySceneView.Scene = myScene; } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Create scene Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { // Set initial viewpoint InitialViewpoint = new Viewpoint(_observerPoint, 1600) }; // Create the elevation source ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene MySceneView.GraphicsOverlays.Add(overlay); try { // Add the taxi to the scene // Create the model symbol for the taxi ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(GetModelUri())); // Set the anchor position for the mode; ensures that the model appears above the ground taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building) // Create the analysis _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives TargetOffsetZ = 2 }; // Create the analysis overlay AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene MySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi Timer animationTimer = new Timer(60) { Enabled = true, AutoReset = true }; // Move the taxi every time the timer expires animationTimer.Elapsed += AnimationTimer_Elapsed; // Start the timer animationTimer.Start(); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view MySceneView.Scene = myScene; } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
private async void Initialize() { // Create scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { InitialViewpoint = new Viewpoint(_observerPoint, 1000000) }; // Create the elevation source. ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene. myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer. ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene. myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene. // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted. GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point. SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol. _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay. overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene. MySceneView.GraphicsOverlays.Add(overlay); // Add the taxi to the scene. // Create the model symbol for the taxi. ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(DataManager.GetDataFolder("3af5cfec0fd24dac8d88aea679027cb9", "dolmus.3ds"))); // Set the anchor position for the mode; ensures that the model appears above the ground. taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol. _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay. overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building). // Create the analysis. _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives. TargetOffsetZ = 2 }; // Create the analysis overlay. AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay. myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene. MySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi. Windows.UI.Xaml.DispatcherTimer animationTimer = new Windows.UI.Xaml.DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 0, 60) }; // Move the taxi every time the timer expires. animationTimer.Tick += AnimationTimer_Tick; // Start the timer. animationTimer.Start(); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible. _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view. MySceneView.Scene = myScene; }