コード例 #1
0
        private async void Initialize()
        {
            // Create a new Scene with an imagery basemap.
            Scene scene = new Scene(Basemap.CreateImagery());

            // Add a base surface with elevation data.
            Surface elevationSurface = new Surface();
            Uri     elevationService = new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

            elevationSurface.ElevationSources.Add(new ArcGISTiledElevationSource(elevationService));
            scene.BaseSurface = elevationSurface;

            // Add a scene layer.
            Uri buildingsService            = new Uri("http://scenesampleserverdev.arcgis.com/arcgis/rest/services/Hosted/buildings_Indianapolis/SceneServer");
            ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(buildingsService);

            scene.OperationalLayers.Add(buildingsLayer);

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

            // Create a camera with an interesting view.
            await buildingsLayer.LoadAsync();

            MapPoint center     = (MapPoint)GeometryEngine.Project(buildingsLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);
            Camera   viewCamera = new Camera(center.Y, center.X, 600, 120, 60, 0);

            // Set the viewpoint with the camera.
            await MySceneView.SetViewpointCameraAsync(viewCamera);
        }
コード例 #2
0
        public static async Task <Scene> CreateBerlin(ARSceneView sv)
        {
            // URL for a scene service of buildings in Brest, France
            Uri buildingsService = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Berlin/SceneServer");
            var iml = new ArcGISSceneLayer(buildingsService)
            {
                Opacity = 1
            };
            await iml.LoadAsync();

            var      observerCamera = new Esri.ArcGISRuntime.Mapping.Camera(new MapPoint(-4.49492, 48.3808, 48.2511, SpatialReferences.Wgs84), 344.488, 74.1212, 0.0);
            MapPoint center         = (MapPoint)GeometryEngine.Project(iml.FullExtent.GetCenter(), SpatialReferences.Wgs84);

            observerCamera = new Esri.ArcGISRuntime.Mapping.Camera(center.Y, center.X, 600, 120, 60, 0);
            var scene = new Scene(Basemap.CreateImagery());

            scene.InitialViewpoint = new Esri.ArcGISRuntime.Mapping.Viewpoint(observerCamera.Location, observerCamera);
            scene.OperationalLayers.Add(iml);
            scene.BaseSurface = new Surface();
            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")));
            scene.BaseSurface.NavigationConstraint = NavigationConstraint.None;
            sv.TranslationFactor = 1000;
            return(scene);
        }
コード例 #3
0
        private async void Initialize()
        {
            // Create new Scene.
            Scene myScene = new Scene {
                Basemap = Basemap.CreateImagery()
            };

            // Create and add an elevation source for the Scene.
            ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(_elevationSourceUrl);

            myScene.BaseSurface.ElevationSources.Add(elevationSrc);

            // Create new scene layer from the URL.
            ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_serviceUri);

            // Add created layer to the operational layers collection.
            myScene.OperationalLayers.Add(sceneLayer);

            // Load the layer.
            await sceneLayer.LoadAsync();

            // Get the center of the scene layer.
            MapPoint center = (MapPoint)GeometryEngine.Project(sceneLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);

            // Create a camera with coordinates showing layer data.
            Camera camera = new Camera(center.Y, center.X, 225, 240, 80, 0);

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

            // Set view point of scene view using camera.
            await MySceneView.SetViewpointCameraAsync(camera);
        }
コード例 #4
0
        public static async Task <Scene> CreateBrestFrance(ARSceneView sv)
        {
            // URL for a scene service of buildings in Brest, France
            string brestFrance         = @"https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0";
            string _elevationSourceUrl = @"https://scene.arcgis.com/arcgis/rest/services/BREST_DTM_1M/ImageServer";
            var    scene = new Scene(Basemap.CreateImagery());

            var observerCamera = new Esri.ArcGISRuntime.Mapping.Camera(new MapPoint(-4.49492, 48.3808, 48.2511, SpatialReferences.Wgs84), 344.488, 74.1212, 0.0);

            scene.InitialViewpoint = new Esri.ArcGISRuntime.Mapping.Viewpoint(observerCamera.Location, observerCamera);

            scene.BaseSurface = new Surface();
            scene.BaseSurface.BackgroundGrid.IsVisible = false;
            scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri(_elevationSourceUrl)));
            scene.BaseSurface.NavigationConstraint = NavigationConstraint.None;
            var iml = new ArcGISSceneLayer(new Uri(brestFrance))
            {
                Opacity = 1
            };

            scene.OperationalLayers.Add(iml);
            await iml.LoadAsync();

            sv.TranslationFactor = 250;
            return(scene);
        }
コード例 #5
0
ファイル: Map3D.cs プロジェクト: zarulzakuan/viewshed
        public async void Initialize()
        {
            // Create a new scene with basemap
            var myScene = new Scene(Basemap.CreateImageryWithLabels());

            // create an elevation source
            ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(_elevationSourceUrl);

            myScene.BaseSurface.ElevationSources.Add(elevationSrc);

            // create additional layer
            ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_serviceUri);

            myScene.OperationalLayers.Add(sceneLayer);

            // Set the surface placement mode for the overlay.
            graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;

            // create a red "X" marker symbol
            SimpleMarkerSceneSymbol car = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Cube, Color.Red, 20, 20, 20, SceneSymbolAnchorPosition.Bottom);

            // create a new graphic; assign the point and the symbol in the constructor


            try
            {
                // Load the layer.
                await sceneLayer.LoadAsync();

                // Get the center of the scene layer.
                MapPoint center = (MapPoint)GeometryEngine.Project(sceneLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);
                Console.WriteLine(center.ToString());
                var newPoint = new MapPoint(_positionPublisher.getX(), _positionPublisher.getY(), 0, SpatialReferences.Wgs84);

                graphic.Geometry = newPoint;
                graphic.Symbol   = car;

                graphicsOverlay.Graphics.Add(graphic);
                MainWindow.View.Map3D.GraphicsOverlays.Add(graphicsOverlay);

                // Assign the Scene to the SceneView.
                MainWindow.View.Map3D.Scene = myScene;

                ////  CAMERA ANGLE ////
                // Create a camera with coordinates showing layer data.
                // Camera camera = new Camera(center.Y, center.X, 225, 220, 80, 0);
                // Set view point of scene view using camera.
                //await Map3D.SetViewpointCameraAsync(camera);

                // create an OrbitGeoElementCameraController, pass in the target graphic and initial camera distance
                var orbitGraphicController = new OrbitGeoElementCameraController(graphic, 1000);
                MainWindow.View.Map3D.CameraController = orbitGraphicController;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
コード例 #6
0
        public void agAddBuilding()
        {
            Task.Factory.StartNew(async() =>
            {
                Uri u = new System.Uri("/mnt/sdcard/LARIAC_BUILDINGS_2014.slpk", UriKind.Relative);

                agsl = new ArcGISSceneLayer(u);
                await agsl.LoadAsync();
                this.RunOnUiThread(
                    () =>
                {
                    MySceneView.Scene.OperationalLayers.Add(agsl);
                });
            });
        }
コード例 #7
0
        public void agAddBuilding()
        {
            Task.Factory.StartNew(async() =>
            {
                Uri u = new System.Uri("LARIAC_BUILDINGS_2014.slpk", UriKind.Relative);

                agsl = new ArcGISSceneLayer(u);
                await agsl.LoadAsync();
                Application.Current.Dispatcher.Invoke(
                    () =>
                {
                    MySceneView.Scene.OperationalLayers.Add(agsl);
                });

                Debug.WriteLine("building load status: " + agsl.LoadStatus);
            });
        }
コード例 #8
0
        private async void Initialize()
        {
            // Create a new Scene with an imagery basemap.
            Scene scene = new Scene(BasemapStyle.ArcGISImageryStandard);

            // Add a base surface with elevation data.
            Surface elevationSurface = new Surface();
            Uri     elevationService = new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

            elevationSurface.ElevationSources.Add(new ArcGISTiledElevationSource(elevationService));
            scene.BaseSurface = elevationSurface;

            // Add a scene layer.
            Uri buildingsService            = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Berlin/SceneServer");
            ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(buildingsService);

            scene.OperationalLayers.Add(buildingsLayer);

            // Assign the Scene to the SceneView.
            _mySceneView.Scene = scene;

            try
            {
                // Create a camera with an interesting view.
                await buildingsLayer.LoadAsync();

                MapPoint center     = (MapPoint)GeometryEngine.Project(buildingsLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);
                Camera   viewCamera = new Camera(center.Y, center.X, 600, 120, 60, 0);

                // Set the viewpoint with the camera.
                _mySceneView.SetViewpointCamera(viewCamera);

                // Listen for taps.
                _mySceneView.GeoViewTapped += SceneViewTapped;
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
コード例 #9
0
        private async void Initialize()
        {
            // Create new Scene.
            Scene myScene = new Scene {
                Basemap = new Basemap(BasemapStyle.ArcGISImageryStandard)
            };

            // Create and add an elevation source for the Scene.
            ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(_elevationSourceUrl);

            myScene.BaseSurface.ElevationSources.Add(elevationSrc);

            // Create new scene layer from the URL.
            ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_serviceUri);

            // Add created layer to the operational layers collection.
            myScene.OperationalLayers.Add(sceneLayer);

            try
            {
                // Load the layer.
                await sceneLayer.LoadAsync();

                // Get the center of the scene layer.
                MapPoint center = (MapPoint)GeometryEngine.Project(sceneLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);

                // Create a camera with coordinates showing layer data.
                Camera camera = new Camera(center.Y, center.X, 225, 220, 80, 0);

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

                // Set view point of scene view using camera.
                await _mySceneView.SetViewpointCameraAsync(camera);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
コード例 #10
0
        private async void Initialize()
        {
            // Create a new Scene with an imagery basemap.
            Scene scene = new Scene(Basemap.CreateImagery());

            // Add a base surface with elevation data.
            Surface elevationSurface = new Surface();
            Uri     elevationService = new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

            elevationSurface.ElevationSources.Add(new ArcGISTiledElevationSource(elevationService));
            scene.BaseSurface = elevationSurface;

            // Add a scene layer.
            Uri buildingsService            = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Berlin/SceneServer");
            ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(buildingsService);

            scene.OperationalLayers.Add(buildingsLayer);

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

            try
            {
                // Create a camera with an interesting view.
                await buildingsLayer.LoadAsync();

                MapPoint center     = (MapPoint)GeometryEngine.Project(buildingsLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);
                Camera   viewCamera = new Camera(center.Y, center.X, 600, 120, 60, 0);

                // Set the viewpoint with the camera.
                MySceneView.SetViewpointCamera(viewCamera);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
        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;

            try
            {
                // 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.
                Device.StartTimer(new TimeSpan(0, 0, 0, 0, 60), () =>
                {
                    // Move the tank every time the timer elapses.
                    AnimateTank();
                    // Keep the timer running.
                    return(true);
                });

                // Allow the user to click to define a new destination.
                MySceneView.GeoViewTapped += (sender, args) => { _tankEndPoint = args.Location; };
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
コード例 #12
0
        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);
            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.
            _tankOverlay.Renderer = new SimpleRenderer
            {
                SceneProperties = { HeadingExpression = "[HEADING]" }
            };

            // 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.
            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; };
        }