示例#1
0
        public void ReadXML(MashupParseContext context)
        {
            XMLTagReader xMLTagReader = context.NewTagReader("S3Credentials");

            while (xMLTagReader.FindNextStartTag())
            {
                if (xMLTagReader.TagIs("AccessKeyId"))
                {
                    context.AssertUnique(_accessKeyId);
                    XMLTagReader xMLTagReader2 = context.NewTagReader("AccessKeyId");
                    _accessKeyId = context.reader.GetAttribute("Value");
                    xMLTagReader2.SkipAllSubTags();
                }
                else
                {
                    if (xMLTagReader.TagIs("SecretAccessKeyTag"))
                    {
                        context.AssertUnique(_secretAccessKey);
                        XMLTagReader xMLTagReader3 = context.NewTagReader("SecretAccessKeyTag");
                        _secretAccessKey = context.reader.GetAttribute("Value");
                        xMLTagReader3.SkipAllSubTags();
                    }
                }
            }

            context.AssertPresent(_accessKeyId, "AccessKeyId");
            context.AssertPresent(_secretAccessKey, "SecretAccessKeyTag");
        }
示例#2
0
文件: XMLUtils.cs 项目: gabilic/Oplan
        public static string ReadStringXml(MashupParseContext context, string TagName)
        {
            XMLTagReader xMLTagReader = context.NewTagReader(TagName);

            xMLTagReader.SkipAllSubTags();
            return(xMLTagReader.GetContent());
        }
示例#3
0
        public SourceMapRenderOptions(MashupParseContext context, DirtyEvent parentDirty)
        {
            dirtyEvent = new DirtyEvent(parentDirty);
            XMLTagReader xMLTagReader = context.NewTagReader("SourceMapRenderOptions");

            new MercatorCoordinateSystem();
            string attribute = context.reader.GetAttribute("MinZoom");

            if (attribute != null)
            {
                _minZoom = MercatorCoordinateSystem.theInstance.GetZoomRange()
                           .Parse(context, "MinZoom", attribute);
            }
            else
            {
                _minZoom = MercatorCoordinateSystem.theInstance.GetZoomRange().min;
            }

            _maxZoom = MercatorCoordinateSystem.theInstance.GetZoomRange()
                       .ParseAllowUndefinedZoom(context, "MaxZoom", context.reader.GetAttribute("MaxZoom"));
            if (_minZoom > _maxZoom)
            {
                throw new InvalidMashupFile(context,
                                            string.Format("MinZoom {0} > MaxZoom {1}", _minZoom, _maxZoom));
            }

            xMLTagReader.SkipAllSubTags();
        }
示例#4
0
        public CrunchedLayer(MashupParseContext context)
        {
            displayName = context.reader.GetAttribute(Layer.GetLayerDisplayNameTag());
            XMLTagReader xMLTagReader = context.NewTagReader(Layer.GetXMLTag());

            while (xMLTagReader.FindNextStartTag())
            {
                if (xMLTagReader.TagIs("RangeDescriptors"))
                {
                    XMLTagReader xMLTagReader2 = context.NewTagReader("RangeDescriptors");
                    xMLTagReader2.SkipAllSubTags();
                }
                else
                {
                    if (xMLTagReader.TagIs("DefaultView"))
                    {
                        XMLTagReader xMLTagReader3 = context.NewTagReader("DefaultView");
                        defaultView = LatLonZoom.ReadFromAttributes(context, MercatorCoordinateSystem.theInstance);
                        xMLTagReader3.SkipAllSubTags();
                    }
                    else
                    {
                        if (xMLTagReader.TagIs("SourceMapInfoList"))
                        {
                            XMLTagReader xMLTagReader4 = context.NewTagReader("SourceMapInfoList");
                            while (xMLTagReader4.FindNextStartTag())
                            {
                                if (xMLTagReader4.TagIs(SourceMapInfo.GetXMLTag()))
                                {
                                    sourceMapRecords.Add(
                                        new SourceMapRecord(new SourceMapInfo(context, new DirtyEvent())));
                                }
                            }
                        }
                        else
                        {
                            if (xMLTagReader.TagIs("SourceMapRecordList"))
                            {
                                XMLTagReader xMLTagReader5 = context.NewTagReader("SourceMapRecordList");
                                while (xMLTagReader5.FindNextStartTag())
                                {
                                    if (xMLTagReader5.TagIs(SourceMapRecord.GetXMLTag()))
                                    {
                                        sourceMapRecords.Add(new SourceMapRecord(context));
                                    }
                                }
                            }
                            else
                            {
                                if (xMLTagReader.TagIs(RenderedTileNamingScheme.GetXMLTag()))
                                {
                                    namingScheme = RenderedTileNamingScheme.ReadXML(context);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
文件: XMLUtils.cs 项目: gabilic/Oplan
        public static Size ReadSize(MashupParseContext context)
        {
            XMLTagReader xMLTagReader = context.NewTagReader("Size");
            Size         result       = new Size(context.GetRequiredAttributeInt("Width"), context.GetRequiredAttributeInt("Height"));

            xMLTagReader.SkipAllSubTags();
            return(result);
        }
示例#6
0
        public RenderToFileOptions(MashupParseContext context, DirtyEvent parentDirtyEvent, string byTagName)
        {
            XMLTagReader xMLTagReader = context.NewTagReader(byTagName);

            this._outputFolder = new DirtyString(parentDirtyEvent);
            this.outputFolder  = context.GetRequiredAttribute(RenderToFileOptions.OutputFolderAttr);
            xMLTagReader.SkipAllSubTags();
        }
示例#7
0
        public LocalDocumentDescriptor(MashupParseContext context, string pathBase)
        {
            XMLTagReader xMLTagReader      = context.NewTagReader(GetXMLTag());
            string       requiredAttribute = context.GetRequiredAttribute(LocalDocumentFilenameAttr);

            _filename   = Path.Combine(pathBase, requiredAttribute);
            _pageNumber = context.GetRequiredAttributeInt(LocalDocumentPageNumberAttr);
            xMLTagReader.SkipAllSubTags();
        }
示例#8
0
            public ManifestSuperBlock(MashupParseContext context, TellManifestDirty tellDirty)
            {
                this.tellDirty = tellDirty;
                XMLTagReader xMLTagReader = context.NewTagReader(GetXmlTag());

                _nextUnassignedBlockId = context.GetRequiredAttributeInt("NextUnassignedBlockId");
                _splitThreshold        = context.GetRequiredAttributeInt("SplitThreshold");
                xMLTagReader.SkipAllSubTags();
            }
示例#9
0
        public SourceMapLegendFrame(MashupParseContext context)
        {
            XMLTagReader xMLTagReader = context.NewTagReader(GetXMLTag());

            filename          = context.GetRequiredAttribute("Filename");
            loadedSize.Width  = context.GetRequiredAttributeInt("Width");
            loadedSize.Height = context.GetRequiredAttributeInt("Height");
            useLoadedSize     = true;
            xMLTagReader.SkipAllSubTags();
        }
示例#10
0
        public bool FindNextStartTag()
        {
            if (done)
            {
                return(false);
            }

            if (empty)
            {
                done = true;
                return(false);
            }

            if (reader.NodeType == XmlNodeType.Element && lastStart != null &&
                lastStart == reader.Name)
            {
                ignoredTags.Add(lastStart);
                XMLTagReader xMLTagReader =
                    new XMLTagReader(reader, lastStart, ignoredTags, context);
                xMLTagReader.SkipAllSubTags();
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    lastStart = reader.Name;
                    context.mostRecentXTRTagIs = null;
                    return(true);
                }

                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.Name == tag)
                    {
                        done = true;
                        return(false);
                    }

                    throw new InvalidMashupFile(reader,
                                                string.Format("Bad Mashup file!  XML tag {0} improperly closed with </{1}> (line {2})",
                                                              tag,
                                                              reader.Name,
                                                              reader.LineNumber));
                }
                else
                {
                    string value = reader.Value;
                    content.Append(value);
                }
            }

            throw new InvalidMashupFile(reader, "Unexpected end of file");
        }
示例#11
0
            public ManifestRecord(MashupParseContext context, ManifestBlock block)
            {
                this.block = block;
                XMLTagReader xMLTagReader = context.NewTagReader("ManifestRecord");

                path                    = context.GetRequiredAttribute("Path");
                _fileExists             = context.GetRequiredAttributeBoolean("FileExists");
                _fileLength             = context.GetRequiredAttributeLong("FileLength");
                indirectManifestBlockId = context.GetRequiredAttributeInt("IndirectManifestBlockId");
                xMLTagReader.SkipAllSubTags();
            }
示例#12
0
        public RenderToS3Options(MashupParseContext context, DirtyEvent parentDirtyEvent)
        {
            XMLTagReader xMLTagReader = context.NewTagReader(RenderToS3Options.xmlTag);

            this._s3credentialsFilename = new DirtyString(parentDirtyEvent);
            this.s3credentialsFilename  = context.GetRequiredAttribute(RenderToS3Options.attr_s3credentialsFilename);
            this._s3bucket     = new DirtyString(parentDirtyEvent);
            this.s3bucket      = context.GetRequiredAttribute(RenderToS3Options.attr_s3bucket);
            this._s3pathPrefix = new DirtyString(parentDirtyEvent);
            this.s3pathPrefix  = context.GetRequiredAttribute(RenderToS3Options.attr_s3pathPrefix);
            xMLTagReader.SkipAllSubTags();
        }
示例#13
0
        public Pixel(MashupParseContext context)
        {
            this.p.r = 0;
            this.p.g = 0;
            this.p.b = 0;
            this.p.a = 0;
            XMLTagReader xMLTagReader = context.NewTagReader("PixelValues");

            this.p.r = (byte)Pixel.byteRange.Parse(context, "r");
            this.p.g = (byte)Pixel.byteRange.Parse(context, "g");
            this.p.b = (byte)Pixel.byteRange.Parse(context, "b");
            this.p.a = (byte)Pixel.byteRange.Parse(context, "a");
            xMLTagReader.SkipAllSubTags();
        }
示例#14
0
        private void TryOneFetchFormatString()
        {
            try
            {
                HttpWebRequest httpWebRequest =
                    (HttpWebRequest)WebRequest.Create(BuildConfig.theConfig.veFormatUpdateURL);
                httpWebRequest.Timeout = 5000;
                HttpWebResponse httpWebResponse;
                try
                {
                    httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                }
                catch (WebException)
                {
                    return;
                }

                if (httpWebResponse.StatusCode == HttpStatusCode.OK)
                {
                    Stream             responseStream     = httpWebResponse.GetResponseStream();
                    XmlTextReader      reader             = new XmlTextReader(responseStream);
                    MashupParseContext mashupParseContext = new MashupParseContext(reader);
                    using (mashupParseContext)
                    {
                        while (mashupParseContext.reader.Read())
                        {
                            if (mashupParseContext.reader.NodeType == XmlNodeType.Element &&
                                mashupParseContext.reader.Name == "VEUrlFormat")
                            {
                                XMLTagReader xMLTagReader = mashupParseContext.NewTagReader("VEUrlFormat");
                                formatString     = mashupParseContext.GetRequiredAttribute("FormatString");
                                generationNumber = mashupParseContext.GetRequiredAttributeInt("GenerationNumber");
                                xMLTagReader.SkipAllSubTags();
                                break;
                            }
                        }

                        mashupParseContext.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                D.Sayf(0, "VEUrlFormat fetch failed with unexpected {0}", new object[] { ex });
            }
        }
示例#15
0
        public SourceMapInfo(MashupParseContext context, DirtyEvent parentDirty)
        {
            dirtyEvent = new DirtyEvent(parentDirty);
            XMLTagReader xMLTagReader = context.NewTagReader(GetXMLTag());

            while (xMLTagReader.FindNextStartTag())
            {
                if (xMLTagReader.TagIs("MapFileURL"))
                {
                    if (context.version == SourceMapInfoAsCharDataSchema.schema)
                    {
                        _mapFileURL = XMLUtils.ReadStringXml(context, "MapFileURL");
                    }
                    else
                    {
                        XMLTagReader xMLTagReader2 = context.NewTagReader("MapFileURL");
                        _mapFileURL = context.GetRequiredAttribute("url");
                        xMLTagReader2.SkipAllSubTags();
                    }
                }
                else
                {
                    if (xMLTagReader.TagIs("MapHomePage"))
                    {
                        if (context.version == SourceMapInfoAsCharDataSchema.schema)
                        {
                            _mapHomePage = XMLUtils.ReadStringXml(context, "MapHomePage");
                        }
                        else
                        {
                            XMLTagReader xMLTagReader3 = context.NewTagReader("MapHomePage");
                            _mapHomePage = context.GetRequiredAttribute("url");
                            xMLTagReader3.SkipAllSubTags();
                        }
                    }
                    else
                    {
                        if (xMLTagReader.TagIs("MapDescription"))
                        {
                            _mapDescription = XMLUtils.ReadStringXml(context, "MapDescription");
                        }
                    }
                }
            }
        }
        public static RenderedTileNamingScheme ReadXML(MashupParseContext context)
        {
            XMLTagReader xMLTagReader = context.NewTagReader("TileNamingScheme");
            string       attribute    = context.reader.GetAttribute("Type");
            string       attribute2   = context.reader.GetAttribute("FilePrefix");
            string       attribute3   = context.reader.GetAttribute("FileSuffix");

            xMLTagReader.SkipAllSubTags();
            if (attribute == null || attribute2 == null || attribute3 == null)
            {
                throw new InvalidMashupFile(context, string.Format("Invalid contents in {0} tag.", "TileNamingScheme"));
            }
            if (attribute == VENamingScheme.SchemeName)
            {
                return(new VENamingScheme(attribute2, attribute3));
            }
            throw new InvalidMashupFile(context, "Unknown type: " + attribute);
        }
示例#17
0
 public bool FindNextStartTag()
 {
     if (this.done)
     {
         return false;
     }
     if (this.empty)
     {
         this.done = true;
         return false;
     }
     if (this.reader.NodeType == XmlNodeType.Element && this.lastStart != null && this.lastStart == this.reader.Name)
     {
         this.ignoredTags.Add(this.lastStart);
         XMLTagReader xMLTagReader = new XMLTagReader(this.reader, this.lastStart, this.ignoredTags, this.context);
         xMLTagReader.SkipAllSubTags();
     }
     while (this.reader.Read())
     {
         if (this.reader.NodeType == XmlNodeType.Element)
         {
             this.lastStart = this.reader.Name;
             this.context.mostRecentXTRTagIs = null;
             return true;
         }
         if (this.reader.NodeType == XmlNodeType.EndElement)
         {
             if (this.reader.Name == this.tag)
             {
                 this.done = true;
                 return false;
             }
             throw new InvalidMashupFile(this.reader, string.Format("Bad Mashup file!  XML tag {0} improperly closed with </{1}> (line {2})", this.tag, this.reader.Name, this.reader.LineNumber));
         }
         else
         {
             string value = this.reader.Value;
             this.content.Append(value);
         }
     }
     throw new InvalidMashupFile(this.reader, "Unexpected end of file");
 }
示例#18
0
        public LatLonZoom(MashupParseContext context, CoordinateSystemIfc coordSys)
        {
            XMLTagReader xMLTagReader = context.NewTagReader("LatLonZoom");

            try
            {
                if (context.reader.GetAttribute("zoom") == null)
                {
                    throw new InvalidLLZ(context, "Missing zoom attribute");
                }

                try
                {
                    _zoom = coordSys.GetZoomRange()
                            .ParseAllowUndefinedZoom(context, "zoom", context.reader.GetAttribute("zoom"));
                }
                catch (InvalidMashupFile invalidMashupFile)
                {
                    throw new InvalidLLZ(context, invalidMashupFile.Message);
                }

                bool flag = false;
                _latlon = default(LatLon);
                while (xMLTagReader.FindNextStartTag())
                {
                    if (xMLTagReader.TagIs(LatLon.GetXMLTag()))
                    {
                        _latlon = new LatLon(context, coordSys);
                        flag    = true;
                    }
                }

                if (!flag)
                {
                    throw new InvalidLLZ(context, "Missing LatLong Tag");
                }
            }
            finally
            {
                xMLTagReader.SkipAllSubTags();
            }
        }
示例#19
0
        public MapRectangle(MashupParseContext context, CoordinateSystemIfc coordSys)
        {
            XMLTagReader  reader = context.NewTagReader("MapRectangle");
            List <LatLon> list   = new List <LatLon>();

            while (reader.FindNextStartTag())
            {
                if (reader.TagIs(LatLon.GetXMLTag()))
                {
                    list.Add(new LatLon(context, coordSys));
                }
            }
            reader.SkipAllSubTags();
            if (list.Count != 2)
            {
                throw new InvalidMashupFile(context, string.Format("{0} should contain exactly 2 {1} subtags", "MapRectangle", LatLon.GetXMLTag()));
            }
            this.ll0 = list[0];
            this.ll1 = list[1];
            this.AssertOrder();
        }
示例#20
0
        public FadeOptions(MashupParseContext context, DirtyEvent dirty)
        {
            this.dirty = dirty;
            XMLTagReader xMLTagReader = context.NewTagReader("FadeOptions");

            this._fadeBase = FadeOptions.FadeRange.Parse(context, "DefaultValue");
            while (xMLTagReader.FindNextStartTag())
            {
                if (xMLTagReader.TagIs("FadeAtZoom"))
                {
                    XMLTagReader xMLTagReader2        = context.NewTagReader("FadeAtZoom");
                    int          requiredAttributeInt = context.GetRequiredAttributeInt("ZoomLevel");
                    double       value = FadeOptions.FadeRange.Parse(context, "FadeValue");
                    if (this._zoomToFadeMap.ContainsKey(requiredAttributeInt))
                    {
                        throw new InvalidMashupFile(context, string.Format("Fade specified twice for zoom level {0}", requiredAttributeInt));
                    }
                    this._zoomToFadeMap[requiredAttributeInt] = value;
                    xMLTagReader2.SkipAllSubTags();
                }
            }
        }
示例#21
0
        public RenderOptions(MashupParseContext context, DirtyEvent parentDirtyEvent,
                             ref SingleMaxZoomForEntireMashupCompatibilityBlob blob)
        {
            dirtyEvent = new DirtyEvent(parentDirtyEvent);
            XMLTagReader xMLTagReader = context.NewTagReader(RenderOptionsTag);

            while (xMLTagReader.FindNextStartTag())
            {
                if (context.version == SingleMaxZoomForEntireMashupSchema.schema &&
                    xMLTagReader.TagIs(SingleMaxZoomForEntireMashupSchema.ZoomLevelsTag))
                {
                    blob = new SingleMaxZoomForEntireMashupCompatibilityBlob();
                    XMLTagReader xMLTagReader2 = context.NewTagReader(SingleMaxZoomForEntireMashupSchema.ZoomLevelsTag);
                    string       attribute;
                    if ((attribute = context.reader.GetAttribute(SingleMaxZoomForEntireMashupSchema.MinZoomTag)) !=
                        null)
                    {
                        blob.minZoom = MercatorCoordinateSystem.theInstance.GetZoomRange().Parse(context,
                                                                                                 SingleMaxZoomForEntireMashupSchema.MinZoomTag,
                                                                                                 attribute);
                    }

                    if ((attribute = context.reader.GetAttribute(SingleMaxZoomForEntireMashupSchema.MaxZoomTag)) !=
                        null)
                    {
                        blob.maxZoom = MercatorCoordinateSystem.theInstance.GetZoomRange().Parse(context,
                                                                                                 SingleMaxZoomForEntireMashupSchema.MaxZoomTag,
                                                                                                 attribute);
                    }

                    xMLTagReader2.SkipAllSubTags();
                }
                else
                {
                    if (xMLTagReader.TagIs(RenderToFileOptions.xmlTag))
                    {
                        _renderToOptions = new RenderToFileOptions(context, dirtyEvent);
                    }
                    else
                    {
                        if (xMLTagReader.TagIs(compatibility_RenderToFileOutputTag))
                        {
                            _renderToOptions = new RenderToFileOptions(context,
                                                                       dirtyEvent,
                                                                       compatibility_RenderToFileOutputTag);
                        }
                        else
                        {
                            if (xMLTagReader.TagIs(RenderToS3Options.xmlTag))
                            {
                                _renderToOptions = new RenderToS3Options(context, dirtyEvent);
                            }
                            else
                            {
                                if (xMLTagReader.TagIs(OutputTileTypeTag))
                                {
                                    XMLTagReader xMLTagReader3 = context.NewTagReader(OutputTileTypeTag);
                                    outputTileType =
                                        OutputTileType.Parse(context.reader.GetAttribute(OutputTileTypeAttr));
                                    xMLTagReader3.SkipAllSubTags();
                                }
                                else
                                {
                                    if (xMLTagReader.TagIs(PublishSourceDataTag))
                                    {
                                        XMLTagReader xMLTagReader4 = context.NewTagReader(PublishSourceDataTag);
                                        publishSourceData =
                                            context.GetRequiredAttributeBoolean(PublishSourceDataValueAttr);
                                        xMLTagReader4.SkipAllSubTags();
                                    }
                                    else
                                    {
                                        if (xMLTagReader.TagIs(PermitCompositionTag))
                                        {
                                            XMLTagReader xMLTagReader5 = context.NewTagReader(PermitCompositionTag);
                                            permitComposition =
                                                context.GetRequiredAttributeBoolean(PermitCompositionValueAttr);
                                            xMLTagReader5.SkipAllSubTags();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#22
0
        public void ReadXML(MashupParseContext context)
        {
            XMLTagReader xMLTagReader = context.NewTagReader("MapGrinderMashupFile");

            context.version = MashupXMLSchemaVersion.ReadXMLAttribute(context.reader);
            SingleMaxZoomForEntireMashupCompatibilityBlob singleMaxZoomForEntireMashupCompatibilityBlob = null;
            string text = null;

            while (xMLTagReader.FindNextStartTag())
            {
                if (context.version != MonolithicMapPositionsSchema.schema && xMLTagReader.TagIs(LayerList.GetXMLTag()))
                {
                    layerList = new LayerList(context,
                                              GetFilenameContext,
                                              dirtyEvent,
                                              readyToLockEvent);
                }
                else
                {
                    if (context.version == MonolithicMapPositionsSchema.schema &&
                        xMLTagReader.TagIs(SourceMap.GetXMLTag()))
                    {
                        if (layerList != null && layerList.Count > 0)
                        {
                            throw new InvalidMashupFile(context,
                                                        string.Format("Multiple SourceMaps in Version {0} file.",
                                                                      context.version.versionNumberString));
                        }

                        SourceMap sourceMap = new SourceMap(context,
                                                            GetFilenameContext,
                                                            dirtyEvent,
                                                            readyToLockEvent);
                        layerList = new LayerList(dirtyEvent);
                        layerList.AddNewLayer();
                        layerList.First.Add(sourceMap);
                    }
                    else
                    {
                        if (xMLTagReader.TagIs(RenderOptions.GetXMLTag()))
                        {
                            renderOptions = new RenderOptions(context,
                                                              dirtyEvent,
                                                              ref singleMaxZoomForEntireMashupCompatibilityBlob);
                        }
                        else
                        {
                            if (xMLTagReader.TagIs(LastViewTag))
                            {
                                XMLTagReader xMLTagReader2 = context.NewTagReader(LastViewTag);
                                text = context.reader.GetAttribute(LastView_TargetIdAttr);
                                xMLTagReader2.SkipAllSubTags();
                            }
                        }
                    }
                }
            }

            lastView = new NoView();
            if (text != null)
            {
                object obj = context.FetchObjectByIdentity(text);
                if (obj != null && obj is LastViewIfc)
                {
                    lastView = ((LastViewIfc)obj).lastView;
                }
            }

            if (renderOptions == null)
            {
                if (context.version != MonolithicMapPositionsSchema.schema)
                {
                    context.warnings.Add(new MashupFileWarning("RenderOptions tag absent."));
                }

                renderOptions = new RenderOptions(dirtyEvent);
            }

            if (singleMaxZoomForEntireMashupCompatibilityBlob != null)
            {
                D.Assert(context.version == SingleMaxZoomForEntireMashupSchema.schema);
                foreach (Layer current in layerList)
                {
                    foreach (SourceMap current2 in current)
                    {
                        current2.sourceMapRenderOptions.maxZoom = singleMaxZoomForEntireMashupCompatibilityBlob.maxZoom;
                    }
                }
            }
        }