public void render2d(Project project, PictureBox picBox) { SharpMap.Map myMap = new SharpMap.Map(); foreach (BuildLayer layer in project.getLayers()) { Source source = layer.getSource(); BoundingBox envelope = new BoundingBox(-1000.0, -1000.0, 1000.0, 1000.0);//TODO FeatureDataSet ds = new FeatureDataSet(); source.DataSource.Open(); source.DataSource.ExecuteIntersectionQuery(envelope, ds); source.DataSource.Close(); FeatureDataTable features = (FeatureDataTable)ds.Tables[0]; string label = "Trace test:\n"; foreach (FeatureDataRow row in features) { foreach (Object item in row.ItemArray) label += " - " + item; label += "\n"; } setLabel(label); //Show map //Filters FilterGraph graph = project.getFilterGraph(source.getName()); if (graph != null) { foreach (FeatureFilter filter in graph.getFilters()) { //aplicar filtro segun el tipo Mogre.DefaultSceneManagerFactory dsmf = new DefaultSceneManagerFactory(); Mogre.SceneManager sm = dsmf.CreateInstance("scenemanager"); FilterEnv env = new FilterEnv(sm, "env"); foreach (MogreGis.Resource resource in project.getResources()) { env.getSession().Resources.addResource(resource); } FeatureList list = Feature.DataTableToList(features); filter.process(list, env); //falta devolver la lista y procesarla *************************************** } } SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer(layer.getName()); myLayer.DataSource = source.DataSource; myMap.Layers.Add(myLayer); } myMap.Size = new Size(picBox.Width, picBox.Height); myMap.ZoomToExtents(); picBox.Image = myMap.GetMap(); this.map = myMap; }
public void merge(Project src) { #if TODO_DANI getScripts().AddRange(src.getScripts()); getFilterGraphs().AddRange(src.getFilterGraphs()); getSources().AddRange(src.getSources()); getTerrains().AddRange(src.getTerrains()); getLayers().AddRange(src.getLayers()); getTargets().AddRange(src.getTargets()); getResources().AddRange(src.getResources()); #endif }
static Terrain decodeTerrain(XmlElement e, Project proj) { Terrain terrain = null; if (e != null) { terrain = new Terrain(); terrain.setBaseURI(proj.getBaseURI()); terrain.setName(e.GetAttribute("name")); terrain.setURI(e.GetElementsByTagName("uri")[0].InnerText); SRSResource resource = findSRSResource(proj.getResources(), e.GetAttribute("srs")); if (resource != null) { terrain.setExplicitSRS(resource.getSRS()); } } return(terrain); }
public void merge(Project src) { #if TODO_DANI getScripts().AddRange(src.getScripts()); getFilterGraphs().AddRange(src.getFilterGraphs()); getSources().AddRange(src.getSources()); getTerrains().AddRange(src.getTerrains()); getLayers().AddRange(src.getLayers()); getTargets().AddRange(src.getTargets()); getResources().AddRange(src.getResources()); #endif }
static Terrain decodeTerrain(XmlElement e, Project proj) { Terrain terrain = null; if (e != null) { terrain = new Terrain(); terrain.setBaseURI(proj.getBaseURI()); terrain.setName(e.GetAttribute("name")); terrain.setURI(e.GetElementsByTagName("uri")[0].InnerText); SRSResource resource = findSRSResource(proj.getResources(), e.GetAttribute("srs")); if (resource != null) terrain.setExplicitSRS(resource.getSRS()); } return terrain; }
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; }
static XmlElement encodeProject(XmlDocument doc, Project project) { XmlElement e = doc.CreateElement("project"); if (e != null) { e.SetAttribute("name", project.getName()); e.SetAttribute("workdir", project.getWorkingDirectory()); /* includes merges another project into this one, not possible to write it back // includes XmlNodeList includes = e.GetElementsByTagName( "include" ); for( XmlNodeList.const_iterator j = includes.begin(); j != includes.end(); j++ ) { decodeInclude( XmlElement( j.get() ), project ); } */ foreach (Script it in project.getScripts()) { XmlElement sub_e = encodeScript(doc, it); if (sub_e != null) e.AppendChild(sub_e); } foreach (Resource it in project.getResources()) { XmlElement sub_e = encodeResource(doc, it); if (sub_e != null) e.AppendChild(sub_e); } foreach (FilterGraph it in project.getFilterGraphs()) { XmlElement sub_e = encodeFilterGraph(doc, it); if (sub_e != null) e.AppendChild(sub_e); } foreach (Terrain it in project.getTerrains()) { XmlElement sub_e = encodeTerrain(doc, it); if (sub_e != null) e.AppendChild(sub_e); } foreach (Source it in project.getSources()) { XmlElement sub_e = encodeSource(doc, it); if (sub_e != null) e.AppendChild(sub_e); } foreach (BuildLayer it in project.getLayers()) { XmlElement sub_e = encodeLayer(doc, it); if (sub_e != null) e.AppendChild(sub_e); } foreach (BuildTarget it in project.getTargets()) { XmlElement sub_e = encodeTarget(doc, it, project); if (sub_e != null) e.AppendChild(sub_e); } foreach (RuntimeMap it in project.getMaps()) { XmlElement sub_e = encodeRuntimeMap(doc, it); if (sub_e != null) e.AppendChild(sub_e); } } return e; }
public void render2d(Project project, PictureBox picBox) { SharpMap.Map myMap = new SharpMap.Map(); foreach (BuildLayer layer in project.getLayers()) { Source source = layer.getSource(); BoundingBox envelope = new BoundingBox(-1000.0, -1000.0, 1000.0, 1000.0);//TODO FeatureDataSet ds = new FeatureDataSet(); source.DataSource.Open(); source.DataSource.ExecuteIntersectionQuery(envelope, ds); source.DataSource.Close(); FeatureDataTable features = (FeatureDataTable)ds.Tables[0]; string label = "Trace test:\n"; foreach (FeatureDataRow row in features) { foreach (Object item in row.ItemArray) { label += " - " + item; } label += "\n"; } setLabel(label); //Show map //Filters FilterGraph graph = project.getFilterGraph(source.getName()); if (graph != null) { foreach (FeatureFilter filter in graph.getFilters()) { //aplicar filtro segun el tipo Mogre.DefaultSceneManagerFactory dsmf = new DefaultSceneManagerFactory(); Mogre.SceneManager sm = dsmf.CreateInstance("scenemanager"); FilterEnv env = new FilterEnv(sm, "env"); foreach (MogreGis.Resource resource in project.getResources()) { env.getSession().Resources.addResource(resource); } FeatureList list = Feature.DataTableToList(features); filter.process(list, env); //falta devolver la lista y procesarla *************************************** } } SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer(layer.getName()); myLayer.DataSource = source.DataSource; myMap.Layers.Add(myLayer); } myMap.Size = new Size(picBox.Width, picBox.Height); myMap.ZoomToExtents(); picBox.Image = myMap.GetMap(); this.map = myMap; }
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); }
static XmlElement encodeProject(XmlDocument doc, Project project) { XmlElement e = doc.CreateElement("project"); if (e != null) { e.SetAttribute("name", project.getName()); e.SetAttribute("workdir", project.getWorkingDirectory()); /* * includes merges another project into this one, not possible to write it back * // includes * XmlNodeList includes = e.GetElementsByTagName( "include" ); * for( XmlNodeList.const_iterator j = includes.begin(); j != includes.end(); j++ ) * { * decodeInclude( XmlElement( j.get() ), project ); * } */ foreach (Script it in project.getScripts()) { XmlElement sub_e = encodeScript(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (Resource it in project.getResources()) { XmlElement sub_e = encodeResource(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (FilterGraph it in project.getFilterGraphs()) { XmlElement sub_e = encodeFilterGraph(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (Terrain it in project.getTerrains()) { XmlElement sub_e = encodeTerrain(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (Source it in project.getSources()) { XmlElement sub_e = encodeSource(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (BuildLayer it in project.getLayers()) { XmlElement sub_e = encodeLayer(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (BuildTarget it in project.getTargets()) { XmlElement sub_e = encodeTarget(doc, it, project); if (sub_e != null) { e.AppendChild(sub_e); } } foreach (RuntimeMap it in project.getMaps()) { XmlElement sub_e = encodeRuntimeMap(doc, it); if (sub_e != null) { e.AppendChild(sub_e); } } } return(e); }