示例#1
0
        static Source decodeSource(XmlElement e, Project proj, int pass)
        {
            Source source = null;

            if (e != null)
            {
                if (pass == 0)
                {
                    // first pass: create the new source record
                    source = new Source();
#if TODO_DANI
                    source.setBaseURI(proj.getBaseURI());
#endif
                    source.setName(e.GetAttribute("name"));
                    source.setType(e.GetAttribute("type") == "raster" ? Source.SourceType.TYPE_RASTER : Source.SourceType.TYPE_FEATURE);
                    source.setURI(e.GetElementsByTagName("uri")[0].InnerText);
#if TODO_DANI
                    source.setFilterGraph(proj.getFilterGraph(e.GetAttribute("graph")));
#endif
                }
                else
                {
                    // second pass: reference other sources
                    source = proj.getSource(e.GetAttribute("name"));
                    source.setParentSource(proj.getSource(e.GetAttribute("parent")));
                }
            }
            return(source);
        }
示例#2
0
        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;
        }
示例#3
0
        static BuildLayerSlice decodeSlice(XmlElement e, Project proj)
        {
            BuildLayerSlice slice = null;

            if (e != null)
            {
                slice = new BuildLayerSlice();

                if (!string.IsNullOrEmpty(e.GetAttribute("min_range")))
                {
                    slice.setMinRange(float.Parse(e.GetAttribute("min_range")));
                }
                if (!string.IsNullOrEmpty(e.GetAttribute("max_range")))
                {
                    slice.setMaxRange(float.Parse(e.GetAttribute("max_range")));
                }

#if TODO_DANI
                // required filter graph:
                string graph = e.GetAttribute("graph");
                slice.setFilterGraph(proj.getFilterGraph(graph)); //TODO: warning?
#endif

                // optional source:
                slice.setSource(proj.getSource(e.GetAttribute("source")));

#if TODO_DANI
                // properties particular to this slice:
                XmlNodeList props = e.GetElementsByTagName("property");
                foreach (XmlNode i in props)
                {
                    XmlElement k_e   = (XmlElement)i;
                    string     name  = k_e.GetAttribute("name");
                    string     value = k_e.GetAttribute("value");
                    slice.getProperties().Add(new Property(name, value));
                }
#endif

                // now decode sub-slices:
                XmlNodeList slices = e.GetElementsByTagName("slice");
                foreach (XmlNode i in slices)
                {
                    BuildLayerSlice child = decodeSlice((XmlElement)i, proj);
                    if (child != null)
                    {
                        slice.getSubSlices().Add(child);
                    }
                }
            }
            return(slice);
        }
示例#4
0
        public void render3d(Project project, SceneManager sceneMgr)
        {
            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];

                //El codigo del PFC

                //**********************************************************************************************************

                //Show map

                //Filters
                FilterGraph graph = project.getFilterGraph(source.getName());
                if (graph != null)
                {
                    graph.Successors();

                    FilterEnv   env  = new FilterEnv(sceneMgr, source.getName());
                    FeatureList list = Feature.DataTableToList(features);

                    if (graph.getFilter(1) is FeatureFilter)
                    {
                        FeatureFilter filter = (FeatureFilter)graph.getFilter(1);
                        FeatureList   l      = filter.process(list, env);
                    }
                    else if (graph.getFilter(1) is FragmentFilter)
                    {
                        FragmentFilter filter = (FragmentFilter)graph.getFilter(1);
                        FragmentList   l      = filter.process(list, env);
                    }
                }

                //**********************************************************************************************************
            }
        }
示例#5
0
 static Source decodeSource(XmlElement e, Project proj, int pass)
 {
     Source source = null;
     if (e != null)
     {
         if (pass == 0)
         {
             // first pass: create the new source record
             source = new Source();
     #if TODO_DANI
             source.setBaseURI(proj.getBaseURI());
     #endif
             source.setName(e.GetAttribute("name"));
             source.setType(e.GetAttribute("type") == "raster" ? Source.SourceType.TYPE_RASTER : Source.SourceType.TYPE_FEATURE);
             source.setURI(e.GetElementsByTagName("uri")[0].InnerText);
     #if TODO_DANI
             source.setFilterGraph(proj.getFilterGraph(e.GetAttribute("graph")));
     #endif
         }
         else
         {
             // second pass: reference other sources
             source = proj.getSource(e.GetAttribute("name"));
             source.setParentSource(proj.getSource(e.GetAttribute("parent")));
         }
     }
     return source;
 }
示例#6
0
        static BuildLayerSlice decodeSlice(XmlElement e, Project proj)
        {
            BuildLayerSlice slice = null;
            if (e != null)
            {
                slice = new BuildLayerSlice();

                if (!string.IsNullOrEmpty(e.GetAttribute("min_range")))
                    slice.setMinRange(float.Parse(e.GetAttribute("min_range")));
                if (!string.IsNullOrEmpty(e.GetAttribute("max_range")))
                    slice.setMaxRange(float.Parse(e.GetAttribute("max_range")));

            #if TODO_DANI
                // required filter graph:
                string graph = e.GetAttribute("graph");
                slice.setFilterGraph(proj.getFilterGraph(graph)); //TODO: warning?
            #endif

                // optional source:
                slice.setSource(proj.getSource(e.GetAttribute("source")));

            #if TODO_DANI
                // properties particular to this slice:
                XmlNodeList props = e.GetElementsByTagName("property");
                foreach (XmlNode i in props)
                {
                    XmlElement k_e = (XmlElement)i;
                    string name = k_e.GetAttribute("name");
                    string value = k_e.GetAttribute("value");
                    slice.getProperties().Add(new Property(name, value));
                }
            #endif

                // now decode sub-slices:
                XmlNodeList slices = e.GetElementsByTagName("slice");
                foreach (XmlNode i in slices)
                {
                    BuildLayerSlice child = decodeSlice((XmlElement)i, proj);
                    if (child != null)
                        slice.getSubSlices().Add(child);
                }
            }
            return slice;
        }
示例#7
0
        static FilterGraph decodeFilterGraph(XmlElement e, Project proj)
        {
            FilterGraph graph = null;
            if (e != null)
            {
                string name = e.GetAttribute("name");
                //TODO: assert name
            #if TODO_DANI
                string parent_name = e.GetAttribute("inherits");
                if (!string.IsNullOrEmpty(parent_name))
                {
                    FilterGraph parent_graph = proj.getFilterGraph(parent_name);
                    if (parent_graph == null)
                    {
                        //osgGIS.notify( osg.WARN )
                        //    << "Parent graph \"" << parent_name << "\" not found for graph \""
                        //    << name << "\"" << std.endl;
                    }
                    else
                    {
                        graph = (FilterGraph)parent_graph;
                        //TODO...
                    }
                }
                else
                {
            #endif
                graph = new FilterGraph();
                graph.setName(name);

                XmlNodeList filter_els = e.GetElementsByTagName("filter");
                foreach (XmlNode i in filter_els)
                {
                    XmlElement f_e = (XmlElement)i;

                    string type = f_e.GetAttribute("type");

                    Filter f = MogreGis.Registry.instance().createFilterByType(type);

                    // try again with "Filter" suffix
                    if (f == null && !type.EndsWith("Filter", false, System.Globalization.CultureInfo.InvariantCulture))
                        f = MogreGis.Registry.instance().createFilterByType(type + "Filter");
                    if (f != null)
                    {
                        XmlNodeList prop_els = f_e.GetElementsByTagName("property");
                        foreach (XmlNode k in prop_els)
                        {
                            XmlElement k_e = (XmlElement)k;
                            string name_ = k_e.GetAttribute("name");
                            string value_ = k_e.GetAttribute("value");
                            f.setProperty(new Property(name_, value_));
                        }
                        graph.appendFilter(f);
                    }
                }
            #if TODO_DANI
                }
            #endif
            }

            return graph;
            #if TODO_DANI
            #endif
            throw new NotImplementedException();
        }
示例#8
0
        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;
        }
示例#9
0
        static FilterGraph decodeFilterGraph(XmlElement e, Project proj)
        {
            FilterGraph graph = null;

            if (e != null)
            {
                string name = e.GetAttribute("name");
                //TODO: assert name
#if TODO_DANI
                string parent_name = e.GetAttribute("inherits");
                if (!string.IsNullOrEmpty(parent_name))
                {
                    FilterGraph parent_graph = proj.getFilterGraph(parent_name);
                    if (parent_graph == null)
                    {
                        //osgGIS.notify( osg.WARN )
                        //    << "Parent graph \"" << parent_name << "\" not found for graph \""
                        //    << name << "\"" << std.endl;
                    }
                    else
                    {
                        graph = (FilterGraph)parent_graph;
                        //TODO...
                    }
                }
                else
                {
#endif
                graph = new FilterGraph();
                graph.setName(name);

                XmlNodeList filter_els = e.GetElementsByTagName("filter");
                foreach (XmlNode i in filter_els)
                {
                    XmlElement f_e = (XmlElement)i;

                    string type = f_e.GetAttribute("type");

                    Filter f = MogreGis.Registry.instance().createFilterByType(type);

                    // try again with "Filter" suffix
                    if (f == null && !type.EndsWith("Filter", false, System.Globalization.CultureInfo.InvariantCulture))
                    {
                        f = MogreGis.Registry.instance().createFilterByType(type + "Filter");
                    }
                    if (f != null)
                    {
                        XmlNodeList prop_els = f_e.GetElementsByTagName("property");
                        foreach (XmlNode k in prop_els)
                        {
                            XmlElement k_e    = (XmlElement)k;
                            string     name_  = k_e.GetAttribute("name");
                            string     value_ = k_e.GetAttribute("value");
                            f.setProperty(new Property(name_, value_));
                        }
                        graph.appendFilter(f);
                    }
                }
#if TODO_DANI
            }
#endif
            }

            return(graph);

#if TODO_DANI
#endif
            throw new NotImplementedException();
        }
示例#10
0
        public void render3d(Project project, SceneManager sceneMgr)
        {
            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];

                //El codigo del PFC

                //**********************************************************************************************************

                //Show map

                //Filters
                FilterGraph graph = project.getFilterGraph(source.getName());
                if (graph != null)
                {

                    graph.Successors();

                    FilterEnv env = new FilterEnv(sceneMgr, source.getName());
                    FeatureList list = Feature.DataTableToList(features);

                    if (graph.getFilter(1) is FeatureFilter)
                    {
                        FeatureFilter filter = (FeatureFilter)graph.getFilter(1);
                        FeatureList l = filter.process(list, env);
                    }
                    else if (graph.getFilter(1) is FragmentFilter)
                    {
                        FragmentFilter filter = (FragmentFilter)graph.getFilter(1);
                        FragmentList l = filter.process(list, env);
                    }

                }
         
                //**********************************************************************************************************

            }

            

        }