Exemple #1
0
        public Layer(MashupParseContext context, SourceMap.GetFilenameContext filenameContextDelegate,
                     DirtyEvent parentDirty, DirtyEvent parentReadyToLockEvent)
        {
            dirtyEvent = new DirtyEvent(parentDirty);
            XMLTagReader xMLTagReader = context.NewTagReader("Layer");

            context.ExpectIdentity(this);
            string attribute = context.reader.GetAttribute("DisplayName");

            if (attribute != null)
            {
                _displayName = attribute;
                context.GetAttributeBoolean("Expanded", ref _expanded);
                string attribute2 = context.reader.GetAttribute("SimulateTransparencyWithVEBackingLayer");
                if (attribute2 != null)
                {
                    _simulateTransparencyWithVEBackingLayer = attribute2;
                }

                while (xMLTagReader.FindNextStartTag())
                {
                    if (xMLTagReader.TagIs(SourceMap.GetXMLTag()))
                    {
                        Add(new SourceMap(context,
                                          filenameContextDelegate,
                                          dirtyEvent,
                                          parentReadyToLockEvent));
                    }
                    else
                    {
                        if (xMLTagReader.TagIs(LayerView.GetXMLTag()))
                        {
                            _lastView = new LayerView(this, context);
                        }
                        else
                        {
                            if (xMLTagReader.TagIs("LastLayerViewPosition"))
                            {
                                XMLTagReader xMLTagReader2 = context.NewTagReader("LastLayerViewPosition");
                                MapPosition  mapPosition   = null;
                                while (xMLTagReader2.FindNextStartTag())
                                {
                                    if (xMLTagReader2.TagIs(MapPosition.GetXMLTag(context.version)))
                                    {
                                        mapPosition = new MapPosition(context,
                                                                      null,
                                                                      MercatorCoordinateSystem.theInstance);
                                    }
                                }

                                if (mapPosition != null)
                                {
                                    _lastView = new LayerView(this, mapPosition);
                                }
                            }
                            else
                            {
                                if (xMLTagReader.TagIs(RenderClip.GetXMLTag()))
                                {
                                    _renderClip = new RenderClip(context);
                                }
                            }
                        }
                    }
                }

                return;
            }

            throw new InvalidMashupFile(context, "Expected displayName attribute");
        }
Exemple #2
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;
                    }
                }
            }
        }