예제 #1
0
        static XmlElement encodeResource(XmlDocument doc, Resource resource)
        {
            XmlElement e = null;

            if (resource && resource.getResourceType() != FeatureLayerResource.getStaticResourceType())
            {
                e = doc.CreateElement("", "resource", "");
                e.SetAttribute("type", resource.getResourceType());
                e.SetAttribute("name", resource.getName());
                string tags;
                foreach (string it in resource.getTags())
                {
                    tags += it + " ";
                }
                if (!string.IsNullOrEmpty(tags))
                {
                    e.SetAttribute("tags", tags);
                }

                e.AppendChild(encodeURI(doc, resource.getURI()));

                foreach (Property it in resource.getProperties())
                {
                    e.AppendChild(encodeProperty(doc, it));
                }

                if (resource.getResourceType() == SRSResource.getStaticResourceType())
                {
                    SRSResource srs = (SRSResource)resource;
                    e.AppendChild(doc.CreateTextNode(srs.getSRS().getWKT()));
                }
            }
            return(e);
        }
예제 #2
0
 static void parseSRSResource(XmlElement e, SRSResource resource)
 {
     if (resource.getSRS() == null)
     {
         string wkt = e.InnerText;
         if (!string.IsNullOrEmpty(wkt))
         {
             resource.setSRS(Registry.SRSFactory().createSRSfromWKT(wkt));
         }
     }
 }
예제 #3
0
 static void parseSRSResource(XmlElement e, SRSResource resource)
 {
     if (resource.getSRS() == null)
     {
         string wkt = e.InnerText;
         if (!string.IsNullOrEmpty(wkt))
         {
             SharpMapSpatialReferenceFactory shpsrsf = new SharpMapSpatialReferenceFactory();
             SpatialReference srs = shpsrsf.createSRSfromWKT(wkt);
             resource.setSRS(srs);
             //resource.setSRS(Registry.SRSFactory().createSRSfromWKT(wkt));
         }
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
 static void parseSRSResource(XmlElement e, SRSResource resource)
 {
     if (resource.getSRS() == null)
     {
         string wkt = e.InnerText;
         if (!string.IsNullOrEmpty(wkt))
         {
             resource.setSRS(Registry.SRSFactory().createSRSfromWKT(wkt));
         }
     }
 }
예제 #6
0
        static Resource decodeResource(XmlElement e, Project proj)
        {
            SRSResource a = new SRSResource();
            Resource resource = null;
            if (e != null)
            {
                string type = e.GetAttribute("type");
                resource = MogreGis.Registry.instance().createResourceByType(type);

                // try again with "Resource" suffix
                if (resource == null && !type.EndsWith("Resource", false, CultureInfo.InvariantCulture))
                    resource = MogreGis.Registry.instance().createResourceByType(type + "Resource");

                if (resource != null)
                {
                    resource.BaseUri = proj.getBaseURI();

                    resource.Name = e.GetAttribute("name");

                    string csv_tags = e.GetAttribute("tags");
                    if (!string.IsNullOrEmpty(csv_tags))
                    {
                        //std.istringstream iss(csv_tags);
                        //List<string> tokens = new List<string>((std.istream_iterator<string>(iss)), std.istream_iterator<string>());
                        string[] tokens = csv_tags.Split(',');
                        foreach (string i in tokens)
                            resource.addTag(i);
                    }

                    resource.addTag(e.GetAttribute("tags"));
                    XmlNodeList listuri = e.GetElementsByTagName("uri");
                    if (listuri.Count > 0)
                        resource.Uri = listuri[0].InnerText;

                    XmlNodeList prop_els = 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");
                        resource.setProperty(new Property(name, value));
                    }

                    if (resource != null && resource is SRSResource)
                    {
                        parseSRSResource(e, (SRSResource)resource);
                    }
            #if TODO_PH
                    else if (resource != null && resource is RasterResource)
                    {
                        parseRasterResource(e, (RasterResource)resource);
                    }
            #endif
                }
                else
                {
                    //TODO osgGIS.notify( osg.WARN ) << "Unknown resource type: " << type << std.endl;
                }
            }
            return resource;
        }
예제 #7
0
        static MogreGis.Resource decodeResource(XmlElement e, Project proj)
        {
            //proj = new Project();
            MogreGis.SRSResource a = new SRSResource();
            MogreGis.Resource resource = null;
            if (e != null)
            {
                string type = e.GetAttribute("type");
                resource = MogreGis.Registry.instance().createResourceByType(type);

                // try again with "Resource" suffix
                if (resource == null && !type.EndsWith("Resource", false, CultureInfo.InvariantCulture))
                    resource = MogreGis.Registry.instance().createResourceByType(type + "Resource");

                if (resource != null)
                {
                    resource.BaseUri = proj.getBaseURI();
                    resource.Uri = e.InnerText;

                    resource.Name = e.GetAttribute("name");

                    string csv_tags = e.GetAttribute("tags");
                    if (!string.IsNullOrEmpty(csv_tags))
                    {
                        //std.istringstream iss(csv_tags);
                        //List<string> tokens = new List<string>((std.istream_iterator<string>(iss)), std.istream_iterator<string>());
                        string[] tokens = csv_tags.Split(',');
                        foreach (string i in tokens)
                            resource.addTag(i);
                    }

                    resource.addTag(e.GetAttribute("tags"));
                    XmlNodeList listuri = e.GetElementsByTagName("uri");
                    if (listuri.Count > 0)
                        resource.Uri = listuri[0].InnerText;


                    XmlNodeList prop_els = 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");
                        //resource.setProperty(new Property(name, value));
                    }

                    if (resource != null && resource is SRSResource)
                    {
                        parseSRSResource(e, (SRSResource)resource);
                    }
#if TODO_PH
                    else if (resource != null && resource is RasterResource)
                    {
                        parseRasterResource(e, (RasterResource)resource);
                    }
#endif
                }
                else
                {
                    //TODO osgGIS.notify( osg.WARN ) << "Unknown resource type: " << type << std.endl;
                }
            }
            return resource;
        }
예제 #8
0
 static void parseSRSResource(XmlElement e, SRSResource resource)
 {
     if (resource.getSRS() == null)
     {
         string wkt = e.InnerText;
         if (!string.IsNullOrEmpty(wkt))
         {
             SharpMapSpatialReferenceFactory shpsrsf = new SharpMapSpatialReferenceFactory();
             SpatialReference srs = shpsrsf.createSRSfromWKT(wkt);
             resource.setSRS(srs);
             //resource.setSRS(Registry.SRSFactory().createSRSfromWKT(wkt));
         }
     }
 }