Exemple #1
0
        public void CopyToAfterRemovingItem()
        {
            // arrange
            var layerCollection = new LayerCollection();
            var layer1          = new MemoryLayer();
            var layer2          = new MemoryLayer();

            layerCollection.Add(layer1);
            layerCollection.Add(layer2);

            var size  = layerCollection.Count();
            var array = new ILayer[size];

            layerCollection.Remove(layer1);

            // act
            layerCollection.CopyTo(array, 0);

            // assert
            Assert.AreEqual(2, array.Length);
            Assert.NotNull(array[0], "first element not null");
            // We have no crash but the seconds element is null.
            // This might have unpleasant consequences.
            Assert.Null(array[1], "second element IS null");
        }
        private async void ViewButton_Click(object sender, RoutedEventArgs e)
        {
            originPoint = null;
            //Change button to 2D or 3D when button is clicked
            ViewButton.Content = FindResource(ViewButton.Content == FindResource("3D") ? "2D" : "3D");
            if (ViewButton.Content == FindResource("2D"))
            {
                threeD = true;
                if (myScene == null)
                {
                    //Create a new scene
                    myScene         = new Scene(Basemap.CreateNationalGeographic());
                    sceneView.Scene = myScene;
                    // create an elevation source
                    var elevationSource = new ArcGISTiledElevationSource(new System.Uri(ELEVATION_IMAGE_SERVICE));
                    // create a surface and add the elevation surface
                    var sceneSurface = new Surface();
                    sceneSurface.ElevationSources.Add(elevationSource);
                    // apply the surface to the scene
                    sceneView.Scene.BaseSurface = sceneSurface;

                    //Exercise 3: Open mobie map package (.mmpk) and add its operational layers to the scene
                    var mmpk = await MobileMapPackage.OpenAsync(MMPK_PATH);

                    if (mmpk.Maps.Count >= 0)
                    {
                        myMap = mmpk.Maps[0];
                        LayerCollection layerCollection = myMap.OperationalLayers;

                        for (int i = 0; i < layerCollection.Count(); i++)
                        {
                            var thelayer = layerCollection[i];
                            myMap.OperationalLayers.Clear();
                            myScene.OperationalLayers.Add(thelayer);
                            sceneView.SetViewpoint(myMap.InitialViewpoint);
                            //Rotate the camera
                            Viewpoint viewpoint = sceneView.GetCurrentViewpoint(ViewpointType.CenterAndScale);
                            Esri.ArcGISRuntime.Geometry.MapPoint targetPoint = (MapPoint)viewpoint.TargetGeometry;
                            Camera camera = sceneView.Camera.RotateAround(targetPoint, 45.0, 65.0, 0.0);
                            await sceneView.SetViewpointCameraAsync(camera);
                        }
                        sceneView.Scene = myScene;
                        bufferAndQuerySceneGraphics.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;
                        sceneView.GraphicsOverlays.Add(bufferAndQuerySceneGraphics);
                        sceneRouteGraphics.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;
                        sceneView.GraphicsOverlays.Add(sceneRouteGraphics);
                    }
                }

                //Exercise 1 Once the scene has been created hide the mapView and show the sceneView
                mapView.Visibility   = Visibility.Hidden;
                sceneView.Visibility = Visibility.Visible;
            }
            else
            {
                threeD = false;
                sceneView.Visibility = Visibility.Hidden;
                mapView.Visibility   = Visibility.Visible;
            }
        }
Exemple #3
0
        public void CopyToWithNormalConditions()
        {
            // arrange
            var layerCollection = new LayerCollection();
            var layer1          = new MemoryLayer();
            var layer2          = new MemoryLayer();

            layerCollection.Add(layer1);
            layerCollection.Add(layer2);

            var size  = layerCollection.Count();
            var array = new ILayer[size];

            // act
            layerCollection.CopyTo(array, 0);

            // assert
            Assert.AreEqual(2, array.Length);
            Assert.NotNull(array[0]);
            Assert.NotNull(array[1]);
        }