예제 #1
0
 public override XElement ToXElement(string @namespace)
 {
     return(new XElement(XName.Get("StyleURL", @namespace),
                         new XAttribute(XName.Get("type"), Type),
                         new XElement(XName.Get("Format", @namespace), Format),
                         OnlineResource.ToXElement(@namespace)));
 }
예제 #2
0
파일: DataURL.cs 프로젝트: galchen/brutile
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "DataURL", Namespace))
                return;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Format":
                            Format = reader.ReadElementContentAsString();
                            break;
                        case "OnlineResource":
                            OnlineResource = new OnlineResource();
                            OnlineResource.ReadXml(reader);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
예제 #3
0
 protected DCPTypeElement(string name, XElement node, string @namespace)
     : this(name)
 {
     var element = node.Element(XName.Get("OnlineResource", @namespace));
     if (element != null)
         OnlineResource = new OnlineResource(element, @namespace);
 }
예제 #4
0
        public override void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Format":
                            Format = reader.ReadElementContentAsString();
                            break;
                        case "OnlineResource":
                            OnlineResource = new OnlineResource();
                            OnlineResource.ReadXml(reader);
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
예제 #5
0
 public override XElement ToXElement(string @namespace)
 {
     return(new XElement(XName.Get("Attribution", @namespace),
                         new XElement(XName.Get("Title", @namespace), Title),
                         OnlineResource.ToXElement(@namespace),
                         LogoURL.ToXElement(@namespace)));
 }
예제 #6
0
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "DataURL", Namespace))
            {
                return;
            }

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                    case "Format":
                        Format = reader.ReadElementContentAsString();
                        break;

                    case "OnlineResource":
                        OnlineResource = new OnlineResource();
                        OnlineResource.ReadXml(reader);
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
예제 #7
0
 public override XElement ToXElement(string @namespace)
 {
     return(new XElement(XName.Get("StyleURL", @namespace),
                         new XAttribute(XName.Get("width"), Width.ToString(NumberFormatInfo.InvariantInfo)),
                         new XAttribute(XName.Get("height"), Height.ToString(NumberFormatInfo.InvariantInfo)),
                         new XElement(XName.Get("Format", @namespace), Format),
                         OnlineResource.ToXElement(@namespace)));
 }
예제 #8
0
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, _name, Namespace))

                OnlineResource = new OnlineResource();
            OnlineResource.ReadXml(reader);
            reader.ReadEndElement();
        }
예제 #9
0
파일: StyleURL.cs 프로젝트: galchen/brutile
        public StyleURL(XElement node, string @namespace)
        {
            var element = node.Element(XName.Get("Format", @namespace));
            Format = element == null ? "png" : element.Value;

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
                OnlineResource = new OnlineResource(element, @namespace);
        }
예제 #10
0
 protected DCPTypeElement(string name, XElement node, string @namespace)
     : this(name)
 {
     var element = node.Element(XName.Get("OnlineResource", @namespace));
     if (element != null)
     {
         OnlineResource = new OnlineResource(element, @namespace);
     }
 }
예제 #11
0
 public override void ReadXml(XmlReader reader)
 {
     if (CheckEmptyNode(reader, _name, Namespace))
     {
         OnlineResource = new OnlineResource();
     }
     OnlineResource.ReadXml(reader);
     reader.ReadEndElement();
 }
예제 #12
0
 public override void WriteXml(XmlWriter writer)
 {
     writer.WriteElementString("Title", Namespace, Title);
     writer.WriteStartElement("OnlineResource", Namespace);
     OnlineResource.WriteXml(writer);
     writer.WriteEndElement();
     writer.WriteStartElement("LogoURL", Namespace);
     LogoURL.WriteXml(writer);
     writer.WriteEndElement();
 }
예제 #13
0
        public StyleSheetURL(XElement node, string @namespace)
        {
            var element = node.Element(XName.Get("Format", @namespace));

            Format = element == null ? "png" : element.Value;

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
            {
                OnlineResource = new OnlineResource(element, @namespace);
            }
        }
예제 #14
0
        public FeatureListURL(XElement node, string ns)
        {
            var element = node.Element(XName.Get("Format", ns));
            if (element == null)
                throw WmsParsingException.ElementNotFound("Format");
            Format = element.Value;

            element = node.Element(XName.Get("OnlineResource", ns));
            if (element == null)
                throw WmsParsingException.ElementNotFound("OnlineResource");
            OnlineResource = new OnlineResource(element, ns);
        }
예제 #15
0
        public Attribution(XElement node, string @namespace)
            : this()
        {
            var element = node.Element(XName.Get("Title", @namespace));
            if (element != null) Title = element.Value;

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null) OnlineResource = new OnlineResource(element, @namespace);

            element = node.Element(XName.Get("LogoURL", @namespace));
            if (element != null) LogoURL = new LogoURL(element, @namespace);
        }
예제 #16
0
        public AuthorityURL(XElement node, string @namespace)
        {
            var att = node.Attribute("name");
            if (att == null)
                throw WmsParsingException.AttributeNotFound("name");

            Name = att.Value;

            var element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
                OnlineResource = new OnlineResource(element, @namespace);
        }
예제 #17
0
파일: LogoURL.cs 프로젝트: galchen/brutile
        public LogoURL(XElement node, string nameSpace)
        {
            var att = node.Attribute(XName.Get("width"));
            Width = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);
            att = node.Attribute(XName.Get("height"));
            Height = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);

            var element = node.Element(XName.Get("Format", nameSpace));
            Format = element == null ? "png" : element.Value;

            element = node.Element(XName.Get("OnlineResource", nameSpace));
            if (element != null)
                OnlineResource = new OnlineResource(element, nameSpace);
        }
예제 #18
0
        public override void WriteXml(XmlWriter writer)
        {
            writer.WriteElementString("Name", Namespace, Name.ToString());
            writer.WriteElementString("Title", Namespace, Title);
            if (!string.IsNullOrEmpty(Abstract))
            {
                writer.WriteElementString("Abstract", Namespace, Abstract);
            }
            if (_keywordListField != null && _keywordListField.Keyword.Count > 0)
            {
                writer.WriteStartElement("KeywordList", Namespace);
                KeywordList.WriteXml(writer);
                writer.WriteEndElement();
            }

            writer.WriteStartElement("OnlineResource", Namespace);
            OnlineResource.WriteXml(writer);
            writer.WriteEndElement();

            if (_contactInformationField != null)
            {
                writer.WriteStartElement("ContactInformation", Namespace);
                _contactInformationField.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (!string.IsNullOrEmpty(Fees))
            {
                writer.WriteElementString("Fees", Namespace, Fees);
            }

            if (!string.IsNullOrEmpty(AccessConstraints))
            {
                writer.WriteElementString("AccessConstraints", Namespace, AccessConstraints);
            }

            if (LayerLimit.HasValue)
            {
                writer.WriteElementString("LayerLimit", Namespace, LayerLimit.Value.ToString());
            }
            if (MaxWidth.HasValue)
            {
                writer.WriteElementString("MaxWidth", Namespace, MaxWidth.Value.ToString());
            }
            if (MaxHeight.HasValue)
            {
                writer.WriteElementString("MaxHeight", Namespace, MaxHeight.Value.ToString());
            }
        }
예제 #19
0
        public MetadataURL(XElement node, string @namespace)
        {
            var att = node.Attribute("type");
            if (att == null)
                throw WmsParsingException.AttributeNotFound("type");

            Type = att.Value;

            var element = node.Element(XName.Get("Format", @namespace));
            Format = element == null ? "png" : element.Value;

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
                OnlineResource = new OnlineResource(element, @namespace);
        }
예제 #20
0
        public override void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            var isEmpty = reader.IsEmptyElement;

            reader.ReadStartElement();
            if (!isEmpty)
            {
                reader.ReadStartElement("Title");
                Title = reader.ReadContentAsString();
                reader.ReadEndElement();
                OnlineResource.ReadXml(reader);
                LogoURL.ReadXml(reader);
                reader.ReadEndElement();
            }
        }
예제 #21
0
        public DataURL(XElement node, string ns)
        {
            var element = node.Element(XName.Get("Format", ns));

            if (element == null)
            {
                throw WmsParsingException.ElementNotFound("Format");
            }
            Format = element.Value;

            element = node.Element(XName.Get("OnlineResource", ns));
            if (element == null)
            {
                throw WmsParsingException.ElementNotFound("OnlineResource");
            }
            OnlineResource = new OnlineResource(element, ns);
        }
예제 #22
0
        /// <remarks> WMS-C uses the VendorSpecificCapabilities to specify the tile schema.</remarks>
        private static IEnumerable<ITileSource> ParseVendorSpecificCapabilitiesNode(
            XElement xnlVendorSpecificCapabilities, OnlineResource onlineResource)
        {
            var tileSets = new List<ITileSource>();

            var xnlTileSets = xnlVendorSpecificCapabilities.Elements(XName.Get("TileSet"));

            if (xnlTileSets != null)
            {
                foreach (var xnlTileSet in xnlTileSets)
                {
                    ITileSource tileSource = ParseTileSetNode(xnlTileSet, onlineResource);
                    tileSets.Add(tileSource);
                }
            }
            return tileSets;
        }
예제 #23
0
        public AuthorityURL(XElement node, string @namespace)
        {
            var att = node.Attribute("name");

            if (att == null)
            {
                throw WmsParsingException.AttributeNotFound("name");
            }

            Name = att.Value;

            var element = node.Element(XName.Get("OnlineResource", @namespace));

            if (element != null)
            {
                OnlineResource = new OnlineResource(element, @namespace);
            }
        }
예제 #24
0
        public LogoURL(XElement node, string nameSpace)
        {
            var att = node.Attribute(XName.Get("width"));

            Width  = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);
            att    = node.Attribute(XName.Get("height"));
            Height = int.Parse(att.Value, NumberFormatInfo.InvariantInfo);

            var element = node.Element(XName.Get("Format", nameSpace));

            Format = element == null ? "png" : element.Value;

            element = node.Element(XName.Get("OnlineResource", nameSpace));
            if (element != null)
            {
                OnlineResource = new OnlineResource(element, nameSpace);
            }
        }
예제 #25
0
        public MetadataURL(XElement node, string @namespace)
        {
            var att = node.Attribute("type");

            if (att == null)
            {
                throw WmsParsingException.AttributeNotFound("type");
            }

            Type = att.Value;

            var element = node.Element(XName.Get("Format", @namespace));

            Format = element == null ? "png" : element.Value;

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
            {
                OnlineResource = new OnlineResource(element, @namespace);
            }
        }
예제 #26
0
        public Attribution(XElement node, string @namespace)
            : this()
        {
            var element = node.Element(XName.Get("Title", @namespace));

            if (element != null)
            {
                Title = element.Value;
            }

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
            {
                OnlineResource = new OnlineResource(element, @namespace);
            }

            element = node.Element(XName.Get("LogoURL", @namespace));
            if (element != null)
            {
                LogoURL = new LogoURL(element, @namespace);
            }
        }
예제 #27
0
        private static ITileSource ParseTileSetNode(XElement xnlTileSet, OnlineResource onlineResource)
        {
            var schema = new TileSchema();

            var xnStyles = xnlTileSet.Elements("Styles");
            var styles = xnStyles.Select(xnStyle => xnStyle.Value).ToList();

            var xnLayers = xnlTileSet.Elements("Layers");
            var layers = xnLayers.Select(xnLayer => xnLayer.Value).ToList();

            schema.Name = CreateDefaultName(layers);

            var xnSrs = xnlTileSet.Element("SRS");
            if (xnSrs != null)
                schema.Srs = xnSrs.Value;

            var xnWidth = xnlTileSet.Element("Width");
            if (xnWidth != null)
            {
                int width;
                if (!Int32.TryParse(xnWidth.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out width))
                    throw new ArgumentException("Invalid width on tileset '" + schema.Name + "'");
                schema.Width = width;
            }

            var xnHeight = xnlTileSet.Element("Height");
            if (xnHeight != null)
            {
                int height;
                if (!Int32.TryParse(xnHeight.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out height))
                    throw new ArgumentException("Invalid width on tileset '" + schema.Name + "'");
                schema.Height = height;
            }

            var xnFormat = xnlTileSet.Element("Format");
            if (xnFormat != null)
                schema.Format = xnFormat.Value;

            var xnBoundingBox = xnlTileSet.Element("BoundingBox");
            if (xnBoundingBox != null)
            {
                double minx, miny, maxx, maxy;
                if (!double.TryParse(xnBoundingBox.Attribute("minx").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) &
                    !double.TryParse(xnBoundingBox.Attribute("miny").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) &
                    !double.TryParse(xnBoundingBox.Attribute("maxx").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) &
                    !double.TryParse(xnBoundingBox.Attribute("maxy").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy))
                {
                    throw new ArgumentException("Invalid LatLonBoundingBox on tileset '" + schema.Name + "'");
                }

                schema.Extent = new Extent(minx, miny, maxx, maxy);

                //In WMS-C the origin is defined as the lower left corner of the boundingbox
                schema.OriginX = minx;
                schema.OriginY = miny;
            }

            var xnResolutions = xnlTileSet.Element("Resolutions");
            if (xnResolutions != null)
            {
                var count = 0;
                string[] resolutions = xnResolutions.Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var resolutionStr in resolutions)
                {
                    double resolution;
                    if (!Double.TryParse(resolutionStr, NumberStyles.Any, CultureInfo.InvariantCulture, out resolution))
                        throw new ArgumentException("Invalid resolution on tileset '" + schema.Name + "'");
                    schema.Resolutions[count] = new Resolution { Id = count.ToString(), UnitsPerPixel = resolution };
                    count++;
                }
            }

            return new WmscTileSource(schema, new WebTileProvider(new WmscRequest(new Uri(onlineResource.Href), schema, layers, styles, new Dictionary<string, string>())));
        }
예제 #28
0
파일: Service.cs 프로젝트: galchen/brutile
 public override void ReadXml(XmlReader reader)
 {
     if (CheckEmptyNode(reader, "Service", string.Empty, true))
         throw WmsParsingException.ElementNotFound("Service");
    
     while (!reader.EOF)
     {
         if (reader.IsStartElement())
         {
             switch (reader.LocalName)
             {
                 case "Name":
                     string name = reader.ReadElementContentAsString();
                     const string prefix = "ogc:";
                     if (name.ToLower().StartsWith(prefix)) name = name.Substring(prefix.Length);
                     Name = (ServiceName)Enum.Parse(typeof(ServiceName), name , true);
                     break;
                 case "Title":
                     Title = reader.ReadElementContentAsString();
                     break;
                 case "Abstact":
                     Abstract = reader.ReadElementContentAsString();
                     break;
                 case "KeywordList":
                     KeywordList = new KeywordList();
                     KeywordList.ReadXml(reader);
                     break;
                 case "OnlineResource":
                     OnlineResource = new OnlineResource();
                     OnlineResource.ReadXml(reader);
                     break;
                 case "ContactInformation":
                     ContactInformation = new ContactInformation();
                     ContactInformation.ReadXml(reader);
                     break;
                 case "Fees":
                     Fees = reader.ReadElementContentAsString();
                     break;
                 case "AccessConstraints":
                     AccessConstraints = reader.ReadElementContentAsString();
                     break;
                 case "LayerLimit":
                     LayerLimit = reader.ReadElementContentAsInt();
                     break;
                 case "MaxWidth":
                     MaxWidth = reader.ReadElementContentAsInt();
                     break;
                 case "MaxHeight":
                     MaxHeight = reader.ReadElementContentAsInt();
                     break;
                 default:
                     reader.Skip();
                     break;
             }
         }
         else
         {
             reader.Read();
         }
     }
 }
예제 #29
0
파일: Service.cs 프로젝트: galchen/brutile
        public Service(XElement node, string @namespace)
        {
            XElement element;
            if (ParseName)
            {
                element = node.Element(XName.Get("Name", @namespace));
                if (element == null)
                    throw WmsParsingException.ElementNotFound("Name");
                var value = element.Value;
                if (value.StartsWith("OGC:")) value = value.Substring(4);
                try
                {
                    Name = (ServiceName) Enum.Parse(typeof (ServiceName), value, true);
                }
                catch (System.Exception exception)
                {
                    throw new WmsParsingException(String.Format("Invalid service name: {0}. Must be WMS", value),
                                                  exception);
                }

                if (Name != ServiceName.WMS)
                    throw new WmsParsingException(String.Format("Invalid service name: {0}. Must be WMS", value));
            }

            element = node.Element(XName.Get("Title", @namespace));
            if (element == null)
                throw WmsParsingException.ElementNotFound("Title");
            Title = element.Value;

            element = node.Element(XName.Get("Abstract", @namespace));
            Abstract = element != null ? element.Value : string.Empty;

            element = node.Element(XName.Get("KeywordList", @namespace));
            if (element != null)
                KeywordList = new KeywordList(element, @namespace);

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
                OnlineResource = new OnlineResource(element, @namespace);

            element = node.Element(XName.Get("ContactInformation", @namespace));
            if (element != null)
                ContactInformation = new ContactInformation(element, @namespace);

            element = node.Element(XName.Get("Fees", @namespace));
            Fees = element != null ? element.Value : string.Empty;

            element = node.Element(XName.Get("AccessConstraints", @namespace));
            AccessConstraints = element != null ? element.Value : string.Empty;

            element = node.Element(XName.Get("LayerLimit", @namespace));
            if (element == null)
                LayerLimit = null;
            else
                LayerLimit = int.Parse(element.Value, NumberFormatInfo.InvariantInfo);

            element = node.Element(XName.Get("MaxWidth", @namespace));
            if (element == null)
                MaxWidth = null;
            else
                MaxWidth = int.Parse(element.Value, NumberFormatInfo.InvariantInfo);

            element = node.Element(XName.Get("MaxHeight", @namespace));
            if (element == null)
                MaxHeight = null;
            else
                MaxHeight = int.Parse(element.Value, NumberFormatInfo.InvariantInfo);
        }
예제 #30
0
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "Service", string.Empty, true))
            {
                throw WmsParsingException.ElementNotFound("Service");
            }

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                    case "Name":
                        string       name   = reader.ReadElementContentAsString();
                        const string prefix = "ogc:";
                        if (name.ToLower().StartsWith(prefix))
                        {
                            name = name.Substring(prefix.Length);
                        }
                        Name = (ServiceName)Enum.Parse(typeof(ServiceName), name, true);
                        break;

                    case "Title":
                        Title = reader.ReadElementContentAsString();
                        break;

                    case "Abstact":
                        Abstract = reader.ReadElementContentAsString();
                        break;

                    case "KeywordList":
                        KeywordList = new KeywordList();
                        KeywordList.ReadXml(reader);
                        break;

                    case "OnlineResource":
                        OnlineResource = new OnlineResource();
                        OnlineResource.ReadXml(reader);
                        break;

                    case "ContactInformation":
                        ContactInformation = new ContactInformation();
                        ContactInformation.ReadXml(reader);
                        break;

                    case "Fees":
                        Fees = reader.ReadElementContentAsString();
                        break;

                    case "AccessConstraints":
                        AccessConstraints = reader.ReadElementContentAsString();
                        break;

                    case "LayerLimit":
                        LayerLimit = reader.ReadElementContentAsInt();
                        break;

                    case "MaxWidth":
                        MaxWidth = reader.ReadElementContentAsInt();
                        break;

                    case "MaxHeight":
                        MaxHeight = reader.ReadElementContentAsInt();
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }
예제 #31
0
        public Service(XElement node, string @namespace)
        {
            XElement element;

            if (ParseName)
            {
                element = node.Element(XName.Get("Name", @namespace));
                if (element == null)
                {
                    throw WmsParsingException.ElementNotFound("Name");
                }
                var value = element.Value;
                if (value.StartsWith("OGC:"))
                {
                    value = value.Substring(4);
                }
                try
                {
                    Name = (ServiceName)Enum.Parse(typeof(ServiceName), value, true);
                }
                catch (System.Exception exception)
                {
                    throw new WmsParsingException(String.Format("Invalid service name: {0}. Must be WMS", value),
                                                  exception);
                }

                if (Name != ServiceName.WMS)
                {
                    throw new WmsParsingException(String.Format("Invalid service name: {0}. Must be WMS", value));
                }
            }

            element = node.Element(XName.Get("Title", @namespace));
            if (element == null)
            {
                throw WmsParsingException.ElementNotFound("Title");
            }
            Title = element.Value;

            element  = node.Element(XName.Get("Abstract", @namespace));
            Abstract = element != null ? element.Value : string.Empty;

            element = node.Element(XName.Get("KeywordList", @namespace));
            if (element != null)
            {
                KeywordList = new KeywordList(element, @namespace);
            }

            element = node.Element(XName.Get("OnlineResource", @namespace));
            if (element != null)
            {
                OnlineResource = new OnlineResource(element, @namespace);
            }

            element = node.Element(XName.Get("ContactInformation", @namespace));
            if (element != null)
            {
                ContactInformation = new ContactInformation(element, @namespace);
            }

            element = node.Element(XName.Get("Fees", @namespace));
            Fees    = element != null ? element.Value : string.Empty;

            element           = node.Element(XName.Get("AccessConstraints", @namespace));
            AccessConstraints = element != null ? element.Value : string.Empty;

            element = node.Element(XName.Get("LayerLimit", @namespace));
            if (element == null)
            {
                LayerLimit = null;
            }
            else
            {
                LayerLimit = int.Parse(element.Value, NumberFormatInfo.InvariantInfo);
            }

            element = node.Element(XName.Get("MaxWidth", @namespace));
            if (element == null)
            {
                MaxWidth = null;
            }
            else
            {
                MaxWidth = int.Parse(element.Value, NumberFormatInfo.InvariantInfo);
            }

            element = node.Element(XName.Get("MaxHeight", @namespace));
            if (element == null)
            {
                MaxHeight = null;
            }
            else
            {
                MaxHeight = int.Parse(element.Value, NumberFormatInfo.InvariantInfo);
            }
        }