Пример #1
0
        /// <summary>
        /// 节点Check事件,用于查询图层内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void advTreeMain_AfterCheck(object sender, AdvTreeCellEventArgs e)
        {
            Node checkNode = e.Cell.Parent;

            AbstractLayer lyr = this.GetLayerByName(checkNode.Text);

            //影像图层加载
            if (lyr == null)
            {
                string path = Path.Combine(Path.GetDirectoryName(_projectPath), checkNode.Text + ".xml");
                if (File.Exists(path) == false)
                {
                    return;
                }
                DomLayerInfo lyrInfo = XmlHelper.Deserialize <DomLayerInfo>(path);
                if (lyrInfo == null)
                {
                    return;
                }
                lyr = LayerLoader.CreateDomLyr(lyrInfo, _globeView);
            }
            if (lyr != null)
            {
                lyr.Visible = e.Cell.Checked;
            }
            //飞行
            if (e.Cell.Checked)
            {
                this.LocLyrByName(checkNode.Text);
            }
        }
#pragma warning restore 0649

    public static IEnumerable <Layer> Load(string filename)
    {
        string jsonStr = File.ReadAllText(filename);

        LayerLoader loader = JsonUtility.FromJson <LayerLoader>(jsonStr);

        for (int i = 0; i < loader.layers.Length; i++)
        {
            yield return(CreateLayer(loader.layers[i]));
        }
    }
 public static void LoadLayersFile(string filename)
 {
     foreach (Layer layer in LayerLoader.Load(filename))
     {
         if (Layers.ContainsKey(layer.Id))
         {
             Layers[layer.Id] = layer;
         }
         else
         {
             Layers.Add(layer.Id, layer);
         }
     }
 }
Пример #4
0
        /// <summary>
        /// 将制定路径的shp文件加载到图层管理
        /// </summary>
        /// <param name="filePath"></param>
        public void AddShpLineLayerByPath(string filePath)
        {
            ShpLineLayer layer = LayerLoader.LoadLineShpDefault(filePath);

            this.AddShpLineLayer(layer);
            NodeModel model = new NodeModel();

            model.PNode      = advTreeMain.Nodes[0].Name;
            model.NodeName   = layer.LayerName;
            model.ShowCheck  = true;
            model.ImageIndex = 2;
            model.NodeId     = Guid.NewGuid().ToString();
            model.CanRemove  = true;
            model.Path       = filePath;
            model.BigType    = GeometryBigType.Line;
            advTreeMain.Nodes[0].Nodes.Add(CreateNode(model));
        }
Пример #5
0
        public void UnknownLayerTest()
        {
            // arrange
            KeyNotFoundException expectedException = null;
            var loader = new LayerLoader<ILayerBase<object>, object>();
            loader.Enable(null, null);

            // act
            try
            {
                loader.Get<ILayerBase<object>>();
            }
            catch (KeyNotFoundException ex)
            {
                expectedException = ex;
            }

            // assert
            Assert.IsNotNull(expectedException);
        }
Пример #6
0
        public void DoubleEnableTest()
        {
            // arrange
            InvalidOperationException expectedException = null;
            var loader = new LayerLoader<ILayerBase<object>, object>();
            loader.Enable(null, null);

            // act
            try
            {
                // try to start the loader a second time...
                loader.Enable(null, null);
            }
            catch (InvalidOperationException ex)
            {
                expectedException = ex;
            }

            // assert
            Assert.IsNotNull(expectedException);
        }
Пример #7
0
        public void UnknownLayerTest()
        {
            // arrange
            KeyNotFoundException expectedException = null;
            var loader = new LayerLoader <ILayerBase <object>, object>();

            loader.Enable(null, null);

            // act
            try
            {
                loader.Get <ILayerBase <object> >();
            }
            catch (KeyNotFoundException ex)
            {
                expectedException = ex;
            }


            // assert
            Assert.IsNotNull(expectedException);
        }
Пример #8
0
        public void DoubleEnableTest()
        {
            // arrange
            InvalidOperationException expectedException = null;
            var loader = new LayerLoader <ILayerBase <object>, object>();

            loader.Enable(null, null);

            // act
            try
            {
                // try to start the loader a second time...
                loader.Enable(null, null);
            }
            catch (InvalidOperationException ex)
            {
                expectedException = ex;
            }


            // assert
            Assert.IsNotNull(expectedException);
        }
Пример #9
0
        private IEnumerator Start()
        {
            //instantiate stored components
            downloader  = GetComponent <DownloadManager>();
            tileFactory = GetComponent <TileFactory>();
            if (tileTextureCache == null)
            {
                tileTextureCache =
                    GetComponent <TileTextureCache>(); //GameObject.Find("TileTextureCache").GetComponent<TileTextureCache>();
            }

            //start processes
            //Load the local text files used to initialize the LayerLoader
            //this is done before the information is needed because you cannot access TextAsset from a thread
            LayerLoader.Init();

            //Kick off the main xml parsing in a thread to keep the application from hanging, especially for vr
            new Thread(() =>
            {
                //get the available layers by parsing the xml
                availableLayers = LayerLoader.GetLayers();
                //let the main thread know that it is safe to try to access the layers
                parsedAvailableLayers = true;
            }).Start();
            WaitForEndOfFrame w = new WaitForEndOfFrame();

            //wait for the xml to finish parsing
            while (!parsedAvailableLayers)
            {
                yield return(w);
            }

            LoadLayer(initialLayer, initialDateTime);
            CreateRootTiles();
            StartCoroutine(UpdateTileVisibility());
        }
Пример #10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            var pb = (LayerPresetLoader)target;

            if (isGettingLayers)
            {
                EGL.Space();
                EGL.Space();
                EGL.LabelField("Loading Layers...");
                return;
            }
            if (layersList.Count == 0)
            {
                isGettingLayers = true;
                LayerLoader.Init();
                new Thread(GetLayersList).Start();
            }
            EGL.Space();
            EGL.Space();
            EGL.LabelField("Presets");
            EGL.Space();
            for (int i = 0; i < pb.presets.Count; i++)
            {
                using (new HorizontalGroup())
                {
                    pb.presets[i].presetName =
                        EGL.TextField(
                            string.IsNullOrEmpty(pb.presets[i].presetName)
                                ? "Preset " + (i + 1)
                                : pb.presets[i].presetName, pb.presets[i].presetName);
                    if (GUILayout.Button("X"))
                    {
                        pb.presets[i] = null;
                        pb.presets.RemoveAt(i);
                        return;
                    }
                }
                EditorGUI.indentLevel++;
                EGL.LabelField("Flat Layers");
                EditorGUI.indentLevel++;
                filter = EGL.TextField("shared layer filter", filter);
                var filteredList = new List <string>(layersList);
                var preset       = pb.presets[i];
                for (int j = 0; j < pb.presets[i].layersInPreset.Count; j++)
                {
                    using (new HorizontalGroup())
                    {
                        if (layersList.Contains(pb.presets[i].layersInPreset[j]))
                        {
                            if (!string.IsNullOrEmpty(filter))
                            {
                                filteredList = layersList.Where(entry => entry.ToLower().Contains(filter.ToLower()) || entry == pb.presets[i].layersInPreset[j]).ToList();
                            }
                            pb.presets[i].layersInPreset[j] =
                                filteredList[
                                    EGL.Popup(j == 0 ? "Base Layer" : "Layer", filteredList.IndexOf(preset.layersInPreset[j]),
                                              filteredList.ToArray())];
                        }
                        else
                        {
                            return;
                        }
                        if (GUILayout.Button("X"))
                        {
                            pb.presets[i].RemoveLayer(j);
                            return;
                        }
                    }
                }
                if (pb.presets[i].layersInPreset.Count < 3)
                {
                    using (new HorizontalGroup())
                    {
                        //var nLayer = layersList[EGL.Popup("Layer", 0, layersList.ToArray())];
                        EGL.LabelField("New Overlay Layer");
                        if (GUILayout.Button("+"))
                        {
                            pb.presets[i].AddOverlayLayer(layersList[0]);
                            break;
                        }
                    }
                }
                EditorGUI.indentLevel--;
                EGL.LabelField("Volumetric Layers");
                EditorGUI.indentLevel++;
                for (int j = 0; j < pb.presets[i].volumetricLayers.Count; j++)
                {
                    using (new HorizontalGroup())
                    {
                        if (!string.IsNullOrEmpty(pb.presets[i].volumetricLayers[j]))
                        {
                            if (layersList.Contains(pb.presets[i].volumetricLayers[j]))
                            {
                                if (!string.IsNullOrEmpty(filter))
                                {
                                    filteredList = layersList.Where(entry => entry.ToLower().Contains(filter.ToLower()) || entry == pb.presets[i].volumetricLayers[j]).ToList();
                                }
                                pb.presets[i].volumetricLayers[j] =
                                    filteredList[
                                        EGL.Popup("Layer " + j, filteredList.IndexOf(preset.volumetricLayers[j]),
                                                  filteredList.ToArray())];
                            }
                            if (GUILayout.Button("X"))
                            {
                                pb.presets[i].volumetricLayers[j] = "";
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Activate"))
                            {
                                pb.presets[i].volumetricLayers[j] = "MODIS_Fires_All";
                            }
                        }
                    }
                }
                EditorGUI.indentLevel--;
                EditorGUI.indentLevel--;
                EGL.Space();
            }
            using (new HorizontalGroup())
            {
                if (GUILayout.Button("+"))
                {
                    pb.presets.Add(new Preset());
                }
            }
            if (GUI.changed)
            {
                Undo.RegisterCompleteObjectUndo(pb, "Preset change");
                EditorUtility.SetDirty(pb);
            }
        }
Пример #11
0
 private static void GetLayersList()
 {
     layersList      = new List <string>(LayerLoader.GetLayers().Keys);
     isGettingLayers = false;
 }