private bool UpdateChildLayers(WmtsTileMatrixSet tileMatrixSet) { var layersChanged = false; var maxScale = 1.001 * ParentMap.ViewTransform.Scale; // avoid rounding issues // show all TileMatrix layers with Scale <= maxScale, at least the first layer // var currentMatrixes = tileMatrixSet.TileMatrixes .Where((matrix, i) => i == 0 || matrix.Scale <= maxScale) .ToList(); if (this != ParentMap.MapLayer) // do not load background tiles { currentMatrixes = currentMatrixes.Skip(currentMatrixes.Count - 1).ToList(); // last element only } else if (currentMatrixes.Count > MaxBackgroundLevels + 1) { currentMatrixes = currentMatrixes.Skip(currentMatrixes.Count - MaxBackgroundLevels - 1).ToList(); } var currentLayers = ChildLayers.Where(layer => currentMatrixes.Contains(layer.TileMatrix)).ToList(); Children.Clear(); foreach (var tileMatrix in currentMatrixes) { var layer = currentLayers.FirstOrDefault(l => l.TileMatrix == tileMatrix); if (layer == null) { layer = new WmtsTileMatrixLayer(tileMatrix, tileMatrixSet.TileMatrixes.IndexOf(tileMatrix)); layersChanged = true; } if (layer.SetBounds(ParentMap.ViewTransform, ParentMap.RenderSize)) { layersChanged = true; } Children.Add(layer); } return(layersChanged); }
public Layer(XElement node, string ns) { var att = node.Attribute(XName.Get("queryable")); Queryable = att != null && att.Value == "1"; att = node.Attribute(XName.Get("cascaded")); Cascaded = att != null?int.Parse(att.Value, NumberFormatInfo.InvariantInfo) : 0; att = node.Attribute(XName.Get("opaque")); Opaque = att != null && att.Value == "1"; att = node.Attribute(XName.Get("noSubsets")); NoSubsets = att != null && att.Value == "1"; att = node.Attribute(XName.Get("fixedWidth")); FixedWidth = att != null?int.Parse(att.Value, NumberFormatInfo.InvariantInfo) : 0; att = node.Attribute(XName.Get("fixedHeight")); FixedHeight = att != null?int.Parse(att.Value, NumberFormatInfo.InvariantInfo) : 0; var element = node.Element(XName.Get("Name", ns)); Name = element?.Value ?? string.Empty; element = node.Element(XName.Get("Title", ns)); Title = element?.Value ?? string.Empty; element = node.Element(XName.Get("Abstract", ns)); Abstract = element?.Value ?? string.Empty; element = node.Element(XName.Get("KeywordList", ns)); if (element != null) { _keywordListField = new KeywordList(element, ns); } foreach (var el in node.Elements(XName.Get("CRS", ns))) { _crsField.Add(el.Value); } foreach (var el in node.Elements(XName.Get("SRS", ns))) { _srsField.Add(el.Value); } element = node.Element(XName.Get("EX_GeographicBoundingBox", ns)); if (element != null) { ExGeographicBoundingBox = new ExGeographicBoundingBox(element, ns); } BoundingBox = new List <BoundingBox>(); foreach (var el in node.Elements(XName.Get("BoundingBox", ns))) { BoundingBox.Add(new BoundingBox(el, ns)); } Dimension = new List <Dimension>(); foreach (var el in node.Elements(XName.Get("Dimension", ns))) { Dimension.Add(new Dimension(el, ns)); } element = node.Element(XName.Get("Attribution", ns)); if (element != null) { Attribution = new Attribution(element, ns); } AuthorityURL = new List <AuthorityURL>(); foreach (var el in node.Elements(XName.Get("AuthorityURL", ns))) { AuthorityURL.Add(new AuthorityURL(el, ns)); } Identifier = new List <Identifier>(); foreach (var el in node.Elements(XName.Get("Identifier", ns))) { Identifier.Add(new Identifier(el, ns)); } MetadataURL = new List <MetadataURL>(); foreach (var el in node.Elements(XName.Get("MetadataURL", ns))) { MetadataURL.Add(new MetadataURL(el, ns)); } DataURL = new List <DataURL>(); foreach (var el in node.Elements(XName.Get("DataURL", ns))) { DataURL.Add(new DataURL(el, ns)); } FeatureListURL = new List <FeatureListURL>(); foreach (var el in node.Elements(XName.Get("FeatureListURL", ns))) { FeatureListURL.Add(new FeatureListURL(el, ns)); } Style = new List <Style>(); foreach (var el in node.Elements(XName.Get("Style", ns))) { Style.Add(new Style(el, ns)); } element = node.Element(XName.Get("MinScaleDenominator", ns)); if (element != null) { MinScaleDenominator = double.Parse(element.Value, NumberFormatInfo.InvariantInfo); } element = node.Element(XName.Get("MaxScaleDenominator", ns)); if (element != null) { MaxScaleDenominator = double.Parse(element.Value, NumberFormatInfo.InvariantInfo); } foreach (var layerNode in node.Elements(XName.Get("Layer", ns))) { ChildLayers.Add(new Layer(layerNode, ns)); } }