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, Colors.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 Device.StartTimer(new TimeSpan(0, 0, 0, 0, 60), () => { // Move the taxi every time the timer elapses AnimationTimer_Elapsed(this, null); // Keep the timer running return(true); }); // 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) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private void Initialize() { // Create new Scene. Scene myScene = new Scene { // Set the Scene's basemap property. Basemap = Basemap.CreateImagery() }; // Create a camera with coordinates showing layer data. Camera camera = new Camera(48.389124348393182, -4.4595173327138591, 140, 322, 74, 0); // Assign the Scene to the SceneView. MySceneView.Scene = myScene; // Create ElevationSource from elevation data Uri. ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Create scene layer from the Brest, France scene server. var sceneLayer = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer")); MySceneView.Scene.OperationalLayers.Add(sceneLayer); // Add elevationSource to BaseSurface's ElevationSources. MySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera. MySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes. _drapedBillboardedOverlay = new GraphicsOverlay(); _drapedBillboardedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedBillboarded; MySceneView.GraphicsOverlays.Add(_drapedBillboardedOverlay); _drapedFlatOverlay = new GraphicsOverlay(); _drapedFlatOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedFlat; GraphicsOverlay relativeToSceneOverlay = new GraphicsOverlay(); relativeToSceneOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.RelativeToScene; MySceneView.GraphicsOverlays.Add(relativeToSceneOverlay); GraphicsOverlay relativeToSurfaceOverlay = new GraphicsOverlay(); relativeToSurfaceOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(relativeToSurfaceOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location. MapPoint sceneRelatedPoint = new MapPoint(-4.4610562, 48.3902727, 70, camera.Location.SpatialReference); MapPoint surfaceRelatedPoint = new MapPoint(-4.4609257, 48.3903965, 70, camera.Location.SpatialReference); // Create a red triangle symbol. var triangleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.FromArgb(255, 255, 0, 0), 10); // Create a text symbol for each elevation mode. TextSymbol drapedBillboardedText = new TextSymbol("DRAPED BILLBOARDED", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); drapedBillboardedText.OffsetY += 20; TextSymbol drapedFlatText = new TextSymbol("DRAPED FLAT", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); drapedFlatText.OffsetY += 20; TextSymbol relativeToSurfaceText = new TextSymbol("RELATIVE TO SURFACE", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); relativeToSurfaceText.OffsetY += 20; TextSymbol relativeToSceneText = new TextSymbol("RELATIVE TO SCENE", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); relativeToSceneText.OffsetY -= 20; TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); absoluteText.OffsetY += 20; // Add the point graphic and text graphic to the corresponding graphics overlay. _drapedBillboardedOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); _drapedBillboardedOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, drapedBillboardedText)); _drapedFlatOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); _drapedFlatOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, drapedFlatText)); relativeToSceneOverlay.Graphics.Add(new Graphic(sceneRelatedPoint, triangleSymbol)); relativeToSceneOverlay.Graphics.Add(new Graphic(sceneRelatedPoint, relativeToSceneText)); relativeToSurfaceOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); relativeToSurfaceOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, relativeToSurfaceText)); absoluteOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, absoluteText)); }
private async void Initialize() { // Create the scene with an imagery basemap. MySceneView.Scene = new Scene(Basemap.CreateImagery()); // Add the elevation surface. ArcGISTiledElevationSource tiledElevationSource = new ArcGISTiledElevationSource(_elevationUri); Surface baseSurface = new Surface { ElevationSources = { tiledElevationSource } }; MySceneView.Scene.BaseSurface = baseSurface; // Add buildings. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUri); MySceneView.Scene.OperationalLayers.Add(sceneLayer); await sceneLayer.LoadAsync(); // Configure the graphics overlay for the tank and add the overlay to the SceneView. _tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(_tankOverlay); // Configure the heading expression for the tank; this will allow the // viewshed to update automatically based on the tank's position. SimpleRenderer renderer3D = new SimpleRenderer(); renderer3D.SceneProperties.HeadingExpression = "[HEADING]"; _tankOverlay.Renderer = renderer3D; // Create the tank graphic - get the model path. string modelPath = GetModelPath(); // - Create the symbol and make it 10x larger (to be the right size relative to the scene). ModelSceneSymbol tankSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 10); // - Adjust the position. tankSymbol.Heading = 90; // - The tank will be positioned relative to the scene surface by its bottom. // This ensures that the tank is on the ground rather than partially under it. tankSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // - Create the graphic. _tank = new Graphic(new MapPoint(28.047199, -26.189105, SpatialReferences.Wgs84), tankSymbol); // - Update the heading. _tank.Attributes["HEADING"] = 0.0; // - Add the graphic to the overlay. _tankOverlay.Graphics.Add(_tank); // Create a viewshed for the tank. GeoElementViewshed geoViewshed = new GeoElementViewshed( geoElement: _tank, horizontalAngle: 90.0, verticalAngle: 40.0, minDistance: 0.1, maxDistance: 250.0, headingOffset: 0.0, pitchOffset: 0.0) { // Offset viewshed observer location to top of tank. OffsetZ = 3.0 }; // Create the analysis overlay and add to the scene. AnalysisOverlay overlay = new AnalysisOverlay(); overlay.Analyses.Add(geoViewshed); MySceneView.AnalysisOverlays.Add(overlay); // Create a camera controller to orbit the tank. OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(_tank, 200.0) { CameraPitchOffset = 45.0 }; // - Apply the camera controller to the SceneView. MySceneView.CameraController = cameraController; // Create a timer; this will enable animating the tank. Timer animationTimer = new Timer(60) { Enabled = true, AutoReset = true }; // - Move the tank every time the timer expires. animationTimer.Elapsed += (o, e) => { AnimateTank(); }; // - Start the timer. animationTimer.Start(); // Allow the user to click to define a new destination. MySceneView.GeoViewTapped += (sender, args) => { _tankEndPoint = args.Location; }; }
//============地图展示 private async void Initialize() { LoadData(); //=====================放球站============= // Create overlay to where graphics are shown GraphicsOverlay overlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(overlay); try { await CreatePictureMarkerSymbolFromResources(overlay); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } //================== 二维场景探空仪展示 ============== //加载图片 int count = Global.DectorNamelist.Count; if (count > 0) { for (int i = 0; i < count; i++) { Assembly currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( this.GetType(), "qiqiu.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 35; pinSymbol.Height = 35; //位置 int index = 0; double positionOffset = 0.01 * index; MapPoint point = new MapPoint(111, 30, 0, SpatialReferences.Wgs84); // Create the graphic from the geometry and the symbol. Graphic _plane2D; _plane2D = new Graphic(point, pinSymbol); // Add the graphic to the overlay. overlay.Graphics.Add(_plane2D); Dector2D.Add(_plane2D); } } //==========================场景基础地图=========== // Create a new Scene with an imagery basemap Scene myScene = new Scene(Basemap.CreateImagery()); // Create a scene layer to show buildings in the Scene ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(new Uri(_buildingsServiceUrl)); myScene.OperationalLayers.Add(buildingsLayer); // Create an elevation(海拔) source for the Scene ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(new Uri(_elevationSourceUrl)); myScene.BaseSurface.ElevationSources.Add(elevationSrc); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); myScene.BaseSurface.ElevationSources.Add(elevationSource); // Add the Scene to the SceneView MySceneView.Scene = myScene; //======================三维探空仪==================== // Create the graphics overlay. GraphicsOverlay overlay1 = new GraphicsOverlay(); //=====放球站====== try { await CreatePictureMarkerSymbolFromResources(overlay1); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } MySceneView.GraphicsOverlays.Add(overlay1); if (Global.DectorNamelist.Count > 0) { for (int i = 0; i < Global.DectorNamelist.Count; i++) { GraphicsOverlay dectoroverlay = new GraphicsOverlay(); // Set the surface placement mode for the overlay. dectoroverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MapPoint point = new MapPoint(111, 30, 0, SpatialReferences.Wgs84); SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Blue, 20); Graphic _plane3D; // Create the graphic from the geometry and the symbol. _plane3D = new Graphic(point, circleSymbol); // Add the graphic to the overlay. dectoroverlay.Graphics.Add(_plane3D); // Show the graphics overlay in the scene. MySceneView.GraphicsOverlays.Add(dectoroverlay); Dector3D.Add(_plane3D); /* * * _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 30.0) * { * CameraPitchOffset = 75.0 * }; * MySceneView.CameraController = _orbitCameraController; */ } } //===========跟随相机控制======== //================加载探空仪位置信息=========== //==================动态更新=============== _animationTimer = new Timer(2000) { Enabled = true, AutoReset = true }; //动态更新探空仪位置 _animationTimer.Elapsed += AnimatePlane; //====二维预测轨迹===== //SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4); // _overlay.Renderer = new SimpleRenderer(lineSymbol); // MyMapView.GraphicsOverlays.Add(_overlay); //==========三维预测轨迹========= // SimpleLineSymbol lineSymbol1 = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4); // _overlay1.Renderer = new SimpleRenderer(lineSymbol1); // // Set the surface placement mode for the overlay. for (int i = 0; i < Global.DectorNamelist.Count; i++) { GraphicsOverlay _overlay1 = new GraphicsOverlay(); GraphicsOverlay _overlay = new GraphicsOverlay(); _overlay1.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; //MySceneView.GraphicsOverlays.Add(_overlay1); MySceneView.GraphicsOverlays.Add(_overlay1); MyMapView.GraphicsOverlays.Add(_overlay); Dector3Doverlay.Add(_overlay1); Dector2Doverlay.Add(_overlay); } //===================三维地图初始视点================ heading = 344.488; // Set the viewpoint with a new camera focused on the castle in Brest observerCamera = new Camera(new MapPoint(112, 29, 2495, SpatialReferences.Wgs84), heading, 74.1212, 0.0); await MySceneView.SetViewpointCameraAsync(observerCamera); //====================通过鼠标点击改变三维地图视点================== MyMapView.GeoViewTapped += Map_Tapped; if (Global.namelist.Count > 0) { string[] strArr = new string[3]; string sArguments = @"station.py"; //调用的python的文件名字 strArr[0] = Global.lonlist[0].ToString(); strArr[1] = Global.latlist[0].ToString(); strArr[2] = Global.radiuslist[0].ToString(); RunPythonScript(sArguments, "-u", strArr); } }
private void Initialize() { // Create the scene with the imagery basemap. Scene myScene = new Scene(Basemap.CreateImagery()); _mySceneView.Scene = myScene; // Add the surface elevation. Surface mySurface = new Surface(); mySurface.ElevationSources.Add(new ArcGISTiledElevationSource(_localElevationImageService)); myScene.BaseSurface = mySurface; // Add the scene layer. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUrl); myScene.OperationalLayers.Add(sceneLayer); // Create the MapPoint representing the initial location. MapPoint initialLocation = new MapPoint(-4.5, 48.4, 56.0); // Create the location viewshed analysis. _viewshed = new LocationViewshed( initialLocation, _headingSlider.Progress, _pitchSlider.Progress, _horizontalAngleSlider.Progress, _verticalAngleSlider.Progress, _minimumDistanceSlider.Progress, _maximumDistanceSlider.Progress); // Create a camera based on the initial location. Camera camera = new Camera(initialLocation, 200.0, 20.0, 70.0, 0.0); // Apply the camera to the scene view. _mySceneView.SetViewpointCamera(camera); // Create an analysis overlay for showing the viewshed analysis. _analysisOverlay = new AnalysisOverlay(); // Add the viewshed analysis to the overlay. _analysisOverlay.Analyses.Add(_viewshed); // Create a symbol for the viewpoint. _viewpointSymbol = SimpleMarkerSceneSymbol.CreateSphere(System.Drawing.Color.Blue, 10, SceneSymbolAnchorPosition.Center); // Add the symbol to the viewpoint overlay. _viewpointOverlay = new GraphicsOverlay { SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) }; _viewpointOverlay.Graphics.Add(new Graphic(initialLocation, _viewpointSymbol)); // Add the analysis overlay to the SceneView. _mySceneView.AnalysisOverlays.Add(_analysisOverlay); // Add the graphics overlay _mySceneView.GraphicsOverlays.Add(_viewpointOverlay); // Update the frustum outline color. // The frustum outline shows the volume in which the viewshed analysis is performed. Viewshed.FrustumOutlineColor = System.Drawing.Color.Blue; // Subscribe to tap events to enable moving the observer. _mySceneView.GeoViewTapped += MySceneViewOnGeoViewTapped; }
private void Initialize() { // Create a scene with elevation. Surface sceneSurface = new Surface(); sceneSurface.ElevationSources.Add(new ArcGISTiledElevationSource(_worldElevationService)); Scene myScene = new Scene(Basemap.CreateTopographic()) { BaseSurface = sceneSurface }; // Create and add a building layer. ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(_buildingService); myScene.OperationalLayers.Add(buildingsLayer); // Create and add an analysis overlay. AnalysisOverlay measureAnalysisOverlay = new AnalysisOverlay(); MySceneView.AnalysisOverlays.Add(measureAnalysisOverlay); // Create an initial distance measurement and show it. MapPoint start = new MapPoint(-4.494677, 48.384472, 24.772694, SpatialReferences.Wgs84); MapPoint end = new MapPoint(-4.495646, 48.384377, 58.501115, SpatialReferences.Wgs84); _distanceMeasurement = new LocationDistanceMeasurement(start, end); measureAnalysisOverlay.Analyses.Add(_distanceMeasurement); // Keep the UI updated. _distanceMeasurement.MeasurementChanged += (o, e) => { // This is needed because measurement change events occur on a non-UI thread and this code accesses UI object. Device.BeginInvokeOnMainThread(() => { // Update the labels with new values in the format {value} {unit system}. DirectMeasureLabel.Text = $"{_distanceMeasurement.DirectDistance.Value:F} {_distanceMeasurement.DirectDistance.Unit.Abbreviation}"; VerticalMeasureLabel.Text = $"{_distanceMeasurement.VerticalDistance.Value:F} {_distanceMeasurement.VerticalDistance.Unit.Abbreviation}"; HorizontalMeasureLabel.Text = $"{_distanceMeasurement.HorizontalDistance.Value:F} {_distanceMeasurement.HorizontalDistance.Unit.Abbreviation}"; }); }; // Configure the unit system selection box. UnitSystemCombo.ItemsSource = Enum.GetValues(typeof(UnitSystem)); UnitSystemCombo.SelectedItem = _distanceMeasurement.UnitSystem; // Update the unit system selection. UnitSystemCombo.SelectedIndexChanged += (sender, args) => { _distanceMeasurement.UnitSystem = (UnitSystem)UnitSystemCombo.SelectedItem; }; // Show the scene in the view. MySceneView.Scene = myScene; MySceneView.SetViewpointCamera(new Camera(start, 200, 0, 45, 0)); // Subscribe to tap events to enable updating the measurement. MySceneView.GeoViewTapped += MySceneView_GeoViewTapped; }
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); // 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; }
private async void Initialize() { // Create the scene with an imagery basemap. _mySceneView.Scene = new Scene(Basemap.CreateImagery()); // Add the elevation surface. ArcGISTiledElevationSource tiledElevationSource = new ArcGISTiledElevationSource(_elevationUri); _mySceneView.Scene.BaseSurface = new Surface { ElevationSources = { tiledElevationSource } }; // Add buildings. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUri); _mySceneView.Scene.OperationalLayers.Add(sceneLayer); // Configure the graphics overlay for the tank and add the overlay to the SceneView. _tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; _mySceneView.GraphicsOverlays.Add(_tankOverlay); // Configure the heading expression for the tank; this will allow the // viewshed to update automatically based on the tank's position. _tankOverlay.Renderer = new SimpleRenderer { SceneProperties = { HeadingExpression = "[HEADING]" } }; try { // Create the tank graphic - get the model path. string modelPath = DataManager.GetDataFolder("07d62a792ab6496d9b772a24efea45d0", "bradle.3ds"); // - Create the symbol and make it 10x larger (to be the right size relative to the scene). ModelSceneSymbol tankSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 10); // - Adjust the position. tankSymbol.Heading = 90; // - The tank will be positioned relative to the scene surface by its bottom. // This ensures that the tank is on the ground rather than partially under it. tankSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // - Create the graphic. _tank = new Graphic(new MapPoint(28.047199, -26.189105, SpatialReferences.Wgs84), tankSymbol); // - Update the heading. _tank.Attributes["HEADING"] = 0.0; // - Add the graphic to the overlay. _tankOverlay.Graphics.Add(_tank); // Create a viewshed for the tank. GeoElementViewshed geoViewshed = new GeoElementViewshed( geoElement: _tank, horizontalAngle: 90.0, verticalAngle: 40.0, minDistance: 0.1, maxDistance: 250.0, headingOffset: 0.0, pitchOffset: 0.0) { // Offset viewshed observer location to top of tank. OffsetZ = 3.0 }; // Create the analysis overlay and add to the scene. AnalysisOverlay overlay = new AnalysisOverlay(); overlay.Analyses.Add(geoViewshed); _mySceneView.AnalysisOverlays.Add(overlay); // Create and use a camera controller to orbit the tank. _mySceneView.CameraController = new OrbitGeoElementCameraController(_tank, 200.0) { CameraPitchOffset = 45.0 }; // Create a timer; this will enable animating the tank. _animationTimer = new Timer(60) { Enabled = true, AutoReset = true }; } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private void Initialize() { // Create the scene with the imagery basemap. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Add the surface elevation. Surface mySurface = new Surface(); mySurface.ElevationSources.Add(new ArcGISTiledElevationSource(_localElevationImageService)); _mySceneView.Scene.BaseSurface = mySurface; // Add the scene layer. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUrl); _mySceneView.Scene.OperationalLayers.Add(sceneLayer); // Create the MapPoint representing the initial location. MapPoint initialLocation = new MapPoint(-4.5, 48.4, 56.0); // Create the location viewshed analysis. _viewshed = new LocationViewshed( initialLocation, 0, 60, 75, 90, 11, 1500); _settingsVC = new ViewshedLocationSettingsController(_viewshed); _settingsButton.Enabled = true; // Create a camera based on the initial location. Camera camera = new Camera(initialLocation, 200.0, 20.0, 70.0, 0.0); // Apply the camera to the scene view. _mySceneView.SetViewpointCamera(camera); // Create an analysis overlay for showing the viewshed analysis. _analysisOverlay = new AnalysisOverlay(); // Add the viewshed analysis to the overlay. _analysisOverlay.Analyses.Add(_viewshed); // Create a symbol for the viewpoint. _viewpointSymbol = SimpleMarkerSceneSymbol.CreateSphere(Color.Blue, 10, SceneSymbolAnchorPosition.Center); // Add the symbol to the viewpoint overlay. _viewpointOverlay = new GraphicsOverlay { SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) }; _viewpointOverlay.Graphics.Add(new Graphic(initialLocation, _viewpointSymbol)); // Add the analysis overlay to the SceneView. _mySceneView.AnalysisOverlays.Add(_analysisOverlay); // Add the graphics overlay _mySceneView.GraphicsOverlays.Add(_viewpointOverlay); // Update the frustum outline color. // The frustum outline shows the volume in which the viewshed analysis is performed. Viewshed.FrustumOutlineColor = Color.Blue; }
private async void Initialize() { // Create scene Scene myScene = new Scene(Basemap.CreateImageryWithLabels()); // 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, Colors.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(await 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 _geoLine.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; // Set the viewpoint MySceneView.SetViewpoint(new Viewpoint(_observerPoint, 1000)); }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // ¼ÓÔØoperationalLayers ͼ²ã if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; layers.Clear(); for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); string Content = $"ͼ²ã{LayerCount} £º {GrouplLayers_title}"; sceneView.Scene.OperationalLayers.Add(Scenelayer); layers.Add(new ItemLayer(Content)); //Label lab = new Label { Content = $"ͼ²ã{LayerCount} £º {GrouplLayers_title}" }; } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); string Content = $"ͼ²ã{LayerCount} £º {operational_title}"; layers.Add(new ItemLayer(Content)); //Label lab = new Label { Content = $"ͼ²ã{LayerCount} £º {operational_title}" }; } } if (layers.Count > 0) { Context context = this.BaseContext; ListLayerAdapter adapter = new ListLayerAdapter(layers, context); listLayer.Adapter = adapter; } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // ¼ÓÔص×ͼ baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // ¼ÓÔØ¸ß³Ì elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // ¼ÓÔØÊéÇ© slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; bks.Clear(); for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); double targetGeometry_x = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["x"]; double targetGeometry_y = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["y"]; double targetGeometry_z = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["z"]; double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; int SRID = (int)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["spatialReference"]["latestWkid"]; MapPoint cmpt = new MapPoint(slidesx, slidesy, slidesz, SpatialReference.Create(SRID)); Camera camera = new Camera(cmpt, slides_heading, slides_tilt, 0); MapPoint mp = new MapPoint(targetGeometry_x, targetGeometry_y, targetGeometry_z, SpatialReference.Create(SRID)); Viewpoint vp = new Viewpoint(mp, camera); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); ItemBookMark itembk = new ItemBookMark(bkname, bkimage, bk); bks.Add(itembk); } if (bks.Count > 0) { Context context = this.BaseContext; ListBookAdapter adapter = new ListBookAdapter(bks, context); listBookMark.Adapter = adapter; } } double initCamera_x = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["x"]; double initCamera_y = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["y"]; double initCamera_z = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["z"]; double initCamera_heading = (double)jo["initialState"]["viewpoint"]["camera"]["heading"]; double initCamera_tilt = (double)jo["initialState"]["viewpoint"]["camera"]["tilt"]; int initSRID = (int)jo["initialState"]["viewpoint"]["camera"]["position"]["spatialReference"]["latestWkid"]; MapPoint initcmpt = new MapPoint(initCamera_x, initCamera_y, initCamera_z, SpatialReference.Create(initSRID)); Camera initCamera = new Camera(initcmpt, initCamera_heading, initCamera_tilt, 0); await _sceneLeftView.SetViewpointCameraAsync(initCamera, TimeSpan.FromSeconds(10)); } catch (Exception ex) { } }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // 加载operationalLayers 图层 if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {GrouplLayers_title}" }; //this.listLayer.Items.Add(lab); } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {operational_title}" }; //this.listLayer.Items.Add(lab); } } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // 加载底图 baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // 加载高程 elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // 加载书签 slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); Viewpoint vp = Viewpoint.FromJson(sttt); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); // Camera ca = new Camera(); // Label lab = new Label { Content = $"书签{bookMarkCount} : {bkname}" }; //lab.Tag = vp; //lab.MouseDown += Lab_MouseDown; // this.listbookMark.Items.Add(lab); //double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; //double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; //double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; //double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; //double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; } } string initialState = JsonConvert.SerializeObject(jo["initialState"]["viewpoint"]); Viewpoint initialViewpoint = Viewpoint.FromJson(initialState); await sceneView.SetViewpointAsync(initialViewpoint, TimeSpan.FromSeconds(10)); } catch { } }