Ejemplo n.º 1
0
        protected override void ParseStartElement(XmlReader reader)
        {
            Debug.Assert(reader != null, "XML layer reader must be initialized when parsing start element!");

            if (tag != Tag.STYLE)
            {
                if (reader.Name.Equals("Layer"))
                {
                    var layerParser = new LayerParser(layerCreator);
                    layerParser.Parse(reader, layerCreator.WmsCreator);
                }
                else if (reader.Name.Equals("Name"))
                {
                    tag = Tag.NAME;
                }
                else if (reader.Name.Equals("Title"))
                {
                    tag = Tag.TITLE;
                }
                else if (reader.Name.Equals("Abstract"))
                {
                    tag = Tag.ABSTRACT;
                }
                else if ((reader.Name.Equals("CRS") &&
                          layerCreator.WmsCreator.Version > ProtocolVersion.v1_1_1) ||
                         (reader.Name.Equals("SRS") &&
                          layerCreator.WmsCreator.Version <= ProtocolVersion.v1_1_1))
                {
                    tag = Tag.CRS;
                }
                else if (reader.Name.Equals("BoundingBox"))
                {
                    tag = Tag.BOUNDING_BOX;
                    // Not implemented
                }
                else if (reader.Name.Equals("Style"))
                {
                    tag = Tag.STYLE;
                    // Not implemented
                }
            }
        }
Ejemplo n.º 2
0
        protected override void ParseStartElement(XmlReader reader)
        {
            Debug.Assert(reader != null, "XML capability reader must be initialized when parsing start element!");
            Debug.Assert(creator != null, "WMSCreater must be initialized when parsing start element!");

            if (stack[0u] == Tag.CAPABILITY_FORMAT)
            {
                if (stack[1u] == Tag.SERVICE_INFO)
                {
                    if (reader.Name.Equals("Title"))
                    {
                        stack[2u] = Tag.TITLE;
                    }
                    else if (reader.Name.Equals("Abstract"))
                    {
                        stack[2u] = Tag.ABSTRACT;
                    }
                    else if (creator.Version > ProtocolVersion.v1_1_1)
                    {
                        if (reader.Name.Equals("MaxWidth"))
                        {
                            stack[2] = Tag.WIDTH;
                        }
                        else if (reader.Name.Equals("MaxHeight"))
                        {
                            stack[2] = Tag.HEIGHT;
                        }
                    }
                }
                else if (stack[1u] == Tag.CAPABILITY)
                {
                    if (stack[2u] == Tag.REQUEST)
                    {
                        if (stack[3u] == Tag.GET_MAP)
                        {
                            if (stack[4u] == Tag.FORMAT && creator.Version <= ProtocolVersion.v1_0_7)
                            {
                                creator.AddObsoleteImageFormat(reader.Name);
                            }
                            else if (reader.Name.Equals("Format"))
                            {
                                stack[4u] = Tag.FORMAT;
                            }
                        }
                        else if ((reader.Name.Equals("GetMap") && creator.Version > ProtocolVersion.v1_0_7) ||
                                 (reader.Name.Equals("Map") && creator.Version <= ProtocolVersion.v1_0_7))
                        {
                            stack[3u] = Tag.GET_MAP;
                        }
                    }
                    else if (reader.Name.Equals("Request"))
                    {
                        stack[2u] = Tag.REQUEST;
                    }
                    else if (reader.Name.Equals("Layer"))
                    {
                        if (!creator.ExistsAnyFormat())
                        {
                            throw new NoImageFormatsException();
                        }

                        var layerParser = new LayerParser();
                        layerParser.Parse(reader, creator);
                    }
                }
                else if (reader.Name.Equals("Service"))
                {
                    stack[1u] = Tag.SERVICE_INFO;
                }
                else if (reader.Name.Equals("Capability"))
                {
                    stack[1u] = Tag.CAPABILITY;
                }
            }
            else if (reader.Name.Equals("WMS_Capabilities") ||
                     reader.Name.Equals("WMT_MS_Capabilities"))
            {
                var version = reader["version"];
                if (version != null)
                {
                    if (creator.SetVersion(version))
                    {
                        if ((reader.Name.Equals("WMS_Capabilities") &&
                             creator.Version > ProtocolVersion.v1_1_1) ||
                            (reader.Name.Equals("WMT_MS_Capabilities") &&
                             creator.Version <= ProtocolVersion.v1_1_1))
                        {
                            stack[0u] = Tag.CAPABILITY_FORMAT;
                        }
                        else
                        {
                            throw new WrongRootTagException();
                        }
                    }
                    else
                    {
                        throw new VersionNotSupportedException();
                    }
                }
                else
                {
                    throw new VersionNotQuotedException();
                }
            }
            else
            {
                throw new WrongRootTagException();
            }
        }