Exemplo n.º 1
0
        static XmlElement encodeRuntimeMap(XmlDocument doc, RuntimeMap rmap)
        {
#if TODO
            XmlElement e = null;
            if (rmap != null)
            {
                e = doc.CreateElement("map");
                e.SetAttribute("name", rmap.getName());
                if (rmap.getTerrain() != null)
                {
                    e.SetAttribute("terrain", rmap.getTerrain().getName());
                }

                foreach (RuntimeMapLayer it in rmap.getMapLayers())
                {
                    e.AppendChild(encodeRuntimeMapLayer(doc, it));
                }
            }
            return(e);
#endif
            throw new NotImplementedException();
        }
Exemplo n.º 2
0
        static RuntimeMap decodeRuntimeMap(XmlElement e, Project proj)
        {
            RuntimeMap map = null;

            if (e != null)
            {
                map = new RuntimeMap();
                map.setName(e.GetAttribute("name"));
                map.setTerrain(proj.getTerrain(e.GetAttribute("terrain")));

                XmlNodeList map_layers = e.GetElementsByTagName("maplayer");
                foreach (XmlNode i in map_layers)
                {
                    XmlElement      e2        = (XmlElement)i;
                    RuntimeMapLayer map_layer = decodeRuntimeMapLayer(e2, proj);
                    if (map_layer != null)
                    {
                        map.getMapLayers().Add(map_layer);
                    }
                }
            }
            return(map);
        }
Exemplo n.º 3
0
        static Project decodeProject(XmlElement e, string source_uri)
        {
            if (e == null || !e.Name.Equals("project"))
            {
                throw new ApplicationException("First XML element must be <project/> tag");
            }

            Project project = null;

            if (e != null)
            {
                project = new Project();
                project.setSourceURI(source_uri);
                project.setName(e.GetAttribute("name"));
                project.setWorkingDirectory(e.GetAttribute("workdir"));

#if TODO_DANI //includes
                // includes
                XmlNodeList includes = e.GetElementsByTagName("include");
                foreach (XmlNode j in includes)
                {
                    decodeInclude((XmlElement)j, project);
                }
#endif
                // scripts
                XmlNodeList scripts = e.GetElementsByTagName("script");
                foreach (XmlNode j in scripts)
                {
                    Script script = decodeScript((XmlElement)j, project);
                    if (script != null)
                    {
                        project.getScripts().Add(script);
                    }
                }

                //some project variables.
                XmlNodeList engines = e.GetElementsByTagName("scriptEngine");
                foreach (XmlElement engine in engines)
                {
                    Registry.instance().LoadAndRegistryEngine(engine.GetAttribute("Class"), engine.GetAttribute("Assembly"));
                }

                XmlNodeList nl = e.GetElementsByTagName("mogreRender");
                foreach (XmlElement n in nl)
                {
                    decodeMogreRender(n, project);
                }

#if !TODO_DANI //resources
                // resources
                XmlNodeList resources = e.GetElementsByTagName("resource");
                foreach (XmlNode j in resources)
                {
                    Resource resource = decodeResource((XmlElement)j, project);
                    if (resource != null)
                    {
                        project.getResources().Add(resource);
                    }
                }
#endif

                // graphs
                XmlNodeList graphs = e.GetElementsByTagName("graph");
                foreach (XmlNode j in graphs)
                {
                    FilterGraph graph = decodeFilterGraph((XmlElement)j, project);
                    if (graph != null)
                    {
                        project.getFilterGraphs().Add(graph);
                    }
                }

#if TODO_DANI //terrains
                // terrains (depends on resources)
                XmlNodeList terrains = e.GetElementsByTagName("terrain");
                foreach (XmlNode j in terrains)
                {
                    Terrain terrain = decodeTerrain((XmlElement)j, project);
                    if (terrain != null)
                    {
                        project.getTerrains().Add(terrain);
                    }
                }
#endif

                // sources - 2 passes, since a source can reference another source
                XmlNodeList sources = e.GetElementsByTagName("source");
                foreach (XmlNode j in sources)
                {
                    // TODO Dani, meter esto en un try catch

                    Source source = decodeSource((XmlElement)j, project, 0);
                    if (source != null)
                    {
                        project.getSources().Add(source);

#if TODO_DANI
                        // also add each source as a feature layer resource
                        Resource resource = MogreGis.Registry.instance().createResourceByType("FeatureLayerResource");
                        resource.setBaseURI(project.getBaseURI());
                        resource.setURI(source.getURI());
                        resource.setName(source.getName());
                        project.getResources().Add(resource);
#endif
                    }
                }
                foreach (XmlNode j in sources)
                {
                    decodeSource((XmlElement)j, project, 1);
                }

                //#if TODO_DANI //layers

                // layers
                XmlNodeList layers = e.GetElementsByTagName("layer");
                foreach (XmlNode j in layers)
                {
                    BuildLayer layer = decodeLayer((XmlElement)j, project);
                    if (layer != null)
                    {
                        project.getLayers().Add(layer);

                        // automatically add a target for this layer alone:
                        BuildTarget layer_target = new BuildTarget();
                        layer_target.setName(layer.getName());
                        layer_target.addLayer(layer);
                        project.getTargets().Add(layer_target);
                    }
                }

                //#endif

#if TODO_DANI //targets
                // targets
                XmlNodeList targets = e.GetElementsByTagName("target");
                foreach (XmlNode j in targets)
                {
                    BuildTarget target = decodeTarget((XmlElement)j, project);
                    if (target != null)
                    {
                        project.getTargets().Add(target);
                    }
                }
#endif

#if TODO_DANI //maps
                // maps
                XmlNodeList maps = e.GetElementsByTagName("map");
                foreach (XmlNode j in maps)
                {
                    RuntimeMap map = decodeRuntimeMap((XmlElement)j, project);
                    if (map != null)
                    {
                        project.getMaps().Add(map);
                    }
                }
#endif
            }
            return(project);
        }