/// <remarks> WMS-C uses the VendorSpecificCapabilities to specify the tile schema.</remarks> private static IEnumerable <ITileSource> ParseVendorSpecificCapabilitiesNode( XElement xVendorSpecificCapabilities, OnlineResource onlineResource) { var xTileSets = xVendorSpecificCapabilities.Elements(XName.Get("TileSet")); return(xTileSets.Select(tileSet => ParseTileSetNode(tileSet, onlineResource)).ToList()); }
private static ITileSource ParseTileSetNode(XElement xTileSet, OnlineResource onlineResource) { var styles = xTileSet.Elements("Styles").Select(xStyle => xStyle.Value).ToList(); var layers = xTileSet.Elements("Layers").Select(xLayer => xLayer.Value).ToList(); var schema = ToTileSchema(xTileSet, CreateDefaultName(layers)); var wmscRequest = new WmscRequest(new Uri(onlineResource.Href), schema, layers, styles); return(new WmscTileSource(schema, new HttpTileProvider(wmscRequest))); }
private bool newerAvailable(OnlineResource onR) { foreach (OnlineResource onRLocal in Shared.completeResourceList) { if (onRLocal.url.Equals(onR.url) && onRLocal.iteration < onR.iteration) { return(true); } } return(false); }
/// <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); }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="mgr"></param> /// <returns></returns> public override IFeature FromXml(XmlNode node, XmlNamespaceManager mgr) { if (node != null && node.HasChildNodes) { if (node.FirstChild.Attributes.Count > 0) { Id = node.FirstChild.Attributes["gml:id"].InnerText; } } var fixedDateRangeNode = node.FirstChild.SelectSingleNode("fixedDateRange", mgr); if (fixedDateRangeNode != null && fixedDateRangeNode.HasChildNodes) { FixedDateRange = new DateRange(); FixedDateRange.FromXml(fixedDateRangeNode, mgr); } var periodicDateRangeNodes = node.FirstChild.SelectNodes("periodicDateRange", mgr); if (periodicDateRangeNodes != null && periodicDateRangeNodes.Count > 0) { var dateRanges = new List <DateRange>(); foreach (XmlNode periodicDateRangeNode in periodicDateRangeNodes) { var newDateRange = new DateRange(); newDateRange.FromXml(periodicDateRangeNode, mgr); dateRanges.Add(newDateRange); } PeriodicDateRange = dateRanges.ToArray(); } var featureNameNodes = node.FirstChild.SelectNodes("featureName", mgr); if (featureNameNodes != null && featureNameNodes.Count > 0) { var featureNames = new List <FeatureName>(); foreach (XmlNode featureNameNode in featureNameNodes) { var newFeatureName = new FeatureName(); newFeatureName.FromXml(featureNameNode, mgr); featureNames.Add(newFeatureName); } FeatureName = featureNames.ToArray(); } var sourceIndicationNodes = node.FirstChild.SelectNodes("sourceIndication", mgr); if (sourceIndicationNodes != null && sourceIndicationNodes.Count > 0) { var sourceIndications = new List <SourceIndication>(); foreach (XmlNode sourceIndicationNode in sourceIndicationNodes) { if (sourceIndicationNode != null && sourceIndicationNode.HasChildNodes) { var sourceIndication = new SourceIndication(); sourceIndication.FromXml(sourceIndicationNode, mgr); sourceIndications.Add(sourceIndication); } } SourceIndication = sourceIndications.ToArray(); } var callNameNode = node.FirstChild.SelectSingleNode("callName", mgr); if (callNameNode != null && callNameNode.HasChildNodes) { CallName = callNameNode.FirstChild.InnerText; } var callSignNode = node.FirstChild.SelectSingleNode("callSign", mgr); if (callSignNode != null && callSignNode.HasChildNodes) { CallSign = callSignNode.FirstChild.InnerText; } var categoryOfCommPrefNode = node.FirstChild.SelectSingleNode("categoryOfCommPref", mgr); if (categoryOfCommPrefNode != null && categoryOfCommPrefNode.HasChildNodes) { CategoryOfCommPref = categoryOfCommPrefNode.FirstChild.InnerText; } var communicationChannelNodes = node.FirstChild.SelectNodes("communicationChannel", mgr); if (communicationChannelNodes != null && communicationChannelNodes.Count > 0) { var channels = new List <string>(); foreach (XmlNode communicationChannelNode in communicationChannelNodes) { if (communicationChannelNode != null && communicationChannelNode.HasChildNodes) { channels.Add(communicationChannelNode.FirstChild.InnerText); } } CommunicationChannel = channels.ToArray(); } var contactInstructionsNode = node.FirstChild.SelectSingleNode("contactInstructions", mgr); if (contactInstructionsNode != null && contactInstructionsNode.HasChildNodes) { ContactInstructions = contactInstructionsNode.FirstChild.InnerText; } var mmsiCodeNode = node.FirstChild.SelectSingleNode("mMSICode", mgr); if (mmsiCodeNode != null && mmsiCodeNode.HasChildNodes) { MMsiCode = mmsiCodeNode.FirstChild.InnerText; } var contactAddressNodes = node.FirstChild.SelectNodes("contactAddress", mgr); if (contactAddressNodes != null && contactAddressNodes.Count > 0) { var contactAddresses = new List <ContactAddress>(); foreach (XmlNode contactAddressNode in contactAddressNodes) { if (contactAddressNode != null && contactAddressNode.HasChildNodes) { var newContactAddress = new ContactAddress(); newContactAddress.FromXml(contactAddressNode, mgr); contactAddresses.Add(newContactAddress); } } ContactAddress = contactAddresses.ToArray(); } var informationNodes = node.FirstChild.SelectNodes("information", mgr); if (informationNodes != null && informationNodes.Count > 0) { var informations = new List <Information>(); foreach (XmlNode informationNode in informationNodes) { if (informationNode != null && informationNode.HasChildNodes) { var newInformation = new Information(); newInformation.FromXml(informationNode, mgr); informations.Add(newInformation); } } Information = informations.ToArray(); } var frequencyPairNodes = node.FirstChild.SelectNodes("frequencyPair", mgr); if (frequencyPairNodes != null && frequencyPairNodes.Count > 0) { var frequencyPairs = new List <FrequencyPair>(); foreach (XmlNode frequencyPairNode in frequencyPairNodes) { if (frequencyPairNode != null && frequencyPairNode.HasChildNodes) { var newFrequencyPair = new FrequencyPair(); newFrequencyPair.FromXml(frequencyPairNode, mgr); frequencyPairs.Add(newFrequencyPair); } } FrequencyPair = frequencyPairs.ToArray(); } var onlineResourceNodes = node.FirstChild.SelectNodes("onlineResource", mgr); if (onlineResourceNodes != null && onlineResourceNodes.Count > 0) { var onlineResources = new List <OnlineResource>(); foreach (XmlNode onlineResourceNode in onlineResourceNodes) { if (onlineResourceNode != null && onlineResourceNode.HasChildNodes) { var newOnlineResource = new OnlineResource(); newOnlineResource.FromXml(onlineResourceNode, mgr); onlineResources.Add(newOnlineResource); } } OnlineResource = onlineResources.ToArray(); } var radioCommunicationNodes = node.FirstChild.SelectNodes("radiocommunications", mgr); if (radioCommunicationNodes != null && radioCommunicationNodes.Count > 0) { var radioCommunications = new List <RadioCommunications>(); foreach (XmlNode radioCommunicationNode in radioCommunicationNodes) { if (radioCommunicationNode != null && radioCommunicationNode.HasChildNodes) { var newRadioCommunications = new RadioCommunications(); newRadioCommunications.FromXml(radioCommunicationNode, mgr); radioCommunications.Add(newRadioCommunications); } } RadioCommunications = radioCommunications.ToArray(); } var teleCommunicationNodes = node.FirstChild.SelectNodes("telecommunications", mgr); if (teleCommunicationNodes != null && teleCommunicationNodes.Count > 0) { var teleCommunications = new List <Telecommunications>(); foreach (XmlNode teleCommunicationNode in teleCommunicationNodes) { if (teleCommunicationNode != null && teleCommunicationNode.HasChildNodes) { var newTelecommunications = new Telecommunications(); newTelecommunications.FromXml(teleCommunicationNode, mgr); teleCommunications.Add(newTelecommunications); } } Telecommunications = teleCommunications.ToArray(); } var linkNodes = node.FirstChild.SelectNodes("*[boolean(@xlink:href)]", mgr); if (linkNodes != null && linkNodes.Count > 0) { var links = new List <Link>(); foreach (XmlNode linkNode in linkNodes) { var newLink = new Link(); newLink.FromXml(linkNode, mgr); links.Add(newLink); } Links = links.ToArray(); } return(this); }
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>())))); }
/// <summary> /// /// </summary> /// <returns></returns> public override IFeature DeepClone() { return(new NauticalProducts { FeatureName = FeatureName == null ? new[] { new FeatureName() } : Array.ConvertAll(FeatureName, fn => fn.DeepClone() as IFeatureName), FixedDateRange = FixedDateRange == null ? new DateRange() : FixedDateRange.DeepClone() as IDateRange, Id = Id, PeriodicDateRange = PeriodicDateRange == null ? new DateRange[0] : Array.ConvertAll(PeriodicDateRange, p => p.DeepClone() as IDateRange), SourceIndication = SourceIndication == null ? new SourceIndication() : SourceIndication.DeepClone() as ISourceIndication, TextContent = TextContent == null ? new TextContent[0] : Array.ConvertAll(TextContent, t => t.DeepClone() as ITextContent), Geometry = Geometry, Classification = Classification, Copyright = Copyright, MaximumDisplayScale = MaximumDisplayScale, HorizontalDatumReference = HorizontalDatumReference, HorizontalDatumValue = HorizontalDatumValue, VerticalDatum = VerticalDatum, SoundingDatum = SoundingDatum, ProductType = ProductType, MinimumDisplayScale = MinimumDisplayScale, IssueDate = IssueDate, Purpose = Purpose, Information = Information == null ? new Information[0] : Array.ConvertAll(Information, i => i.DeepClone() as IInformation), Price = Price == null ? new Price[0] : Array.ConvertAll(Price, p => p.DeepClone() as IPrice), ProducingAgency = ProducingAgency == null ? new ProducingAgency() : ProducingAgency.DeepClone() as IProducingAgency, PublicationNumber = PublicationNumber, DataSetName = DataSetName, Version = Version, ServiceStatus = ServiceStatus, Keywords = Keywords, ProductSpecification = ProductSpecification == null ? new ReferenceSpecification() : ProductSpecification.DeepClone() as IReferenceSpecification, OnlineResource = OnlineResource == null ? new OnlineResource() : OnlineResource.DeepClone() as IOnlineResource, ServiceSpecification = ServiceSpecification == null ? new ReferenceSpecification() : ServiceSpecification.DeepClone() as IReferenceSpecification, ServiceDesign = ServiceDesign == null ? new ReferenceSpecification() : ServiceDesign.DeepClone() as IReferenceSpecification, Links = Links == null ? new Link[0] : Array.ConvertAll(Links, l => l.DeepClone() as ILink) }); }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="mgr"></param> /// <returns></returns> public override IFeature FromXml(XmlNode node, XmlNamespaceManager mgr) { if (node != null && node.HasChildNodes) { if (node.FirstChild.Attributes.Count > 0) { Id = node.FirstChild.Attributes["gml:id"].InnerText; } } var periodicDateRangeNodes = node.FirstChild.SelectNodes("periodicDateRange", mgr); if (periodicDateRangeNodes != null && periodicDateRangeNodes.Count > 0) { var dateRanges = new List <DateRange>(); foreach (XmlNode periodicDateRangeNode in periodicDateRangeNodes) { var newDateRange = new DateRange(); newDateRange.FromXml(periodicDateRangeNode, mgr); dateRanges.Add(newDateRange); } PeriodicDateRange = dateRanges.ToArray(); } var fixedDateRangeNode = node.FirstChild.SelectSingleNode("fixedDateRange", mgr); if (fixedDateRangeNode != null && fixedDateRangeNode.HasChildNodes) { FixedDateRange = new DateRange(); FixedDateRange.FromXml(fixedDateRangeNode, mgr); } var featureNameNodes = node.FirstChild.SelectNodes("featureName", mgr); if (featureNameNodes != null && featureNameNodes.Count > 0) { var featureNames = new List <FeatureName>(); foreach (XmlNode featureNameNode in featureNameNodes) { var newFeatureName = new FeatureName(); newFeatureName.FromXml(featureNameNode, mgr); featureNames.Add(newFeatureName); } FeatureName = featureNames.ToArray(); } var sourceIndication = node.FirstChild.SelectSingleNode("sourceIndication", mgr); if (sourceIndication != null && sourceIndication.HasChildNodes) { SourceIndication = new SourceIndication(); SourceIndication.FromXml(sourceIndication, mgr); } var textContentNodes = node.FirstChild.SelectNodes("textContent", mgr); if (textContentNodes != null && textContentNodes.Count > 0) { var textContents = new List <TextContent>(); foreach (XmlNode textContentNode in textContentNodes) { if (textContentNode != null && textContentNode.HasChildNodes) { var content = new TextContent(); content.FromXml(textContentNode, mgr); textContents.Add(content); } } TextContent = textContents.ToArray(); } var classificationNode = node.FirstChild.SelectSingleNode("classification", mgr); if (classificationNode != null && classificationNode.HasChildNodes) { Classification = classificationNode.FirstChild.InnerText; } var copyrightNode = node.FirstChild.SelectSingleNode("copyright", mgr); if (copyrightNode != null && copyrightNode.HasChildNodes) { Copyright = copyrightNode.FirstChild.InnerText; } var maximumDisplayScaleNode = node.FirstChild.SelectSingleNode("maximumDisplayScale", mgr); if (maximumDisplayScaleNode != null && maximumDisplayScaleNode.HasChildNodes) { MaximumDisplayScale = maximumDisplayScaleNode.FirstChild.InnerText; } var horizontalDatumReferenceNode = node.FirstChild.SelectSingleNode("horizontalDatumReference", mgr); if (horizontalDatumReferenceNode != null && horizontalDatumReferenceNode.HasChildNodes) { HorizontalDatumReference = horizontalDatumReferenceNode.FirstChild.InnerText; } var horizontalDatumValueNode = node.FirstChild.SelectSingleNode("horizontalDatumValue", mgr); if (horizontalDatumValueNode != null && horizontalDatumValueNode.HasChildNodes) { HorizontalDatumValue = horizontalDatumValueNode.FirstChild.InnerText; } var verticalDatumNode = node.FirstChild.SelectSingleNode("verticalDatum", mgr); if (verticalDatumNode != null && verticalDatumNode.HasChildNodes) { VerticalDatum = verticalDatumNode.FirstChild.InnerText; } var soundingDatumNode = node.FirstChild.SelectSingleNode("soundingDatum", mgr); if (soundingDatumNode != null && soundingDatumNode.HasChildNodes) { SoundingDatum = soundingDatumNode.FirstChild.InnerText; } var productTypeNode = node.FirstChild.SelectSingleNode("productType", mgr); if (productTypeNode != null && productTypeNode.HasChildNodes) { ProductType = productTypeNode.FirstChild.InnerText; } var minimumDisplayScaleNode = node.FirstChild.SelectSingleNode("minimumDisplayScale", mgr); if (minimumDisplayScaleNode != null && minimumDisplayScaleNode.HasChildNodes) { MinimumDisplayScale = minimumDisplayScaleNode.FirstChild.InnerText; } var issueDateNode = node.FirstChild.SelectSingleNode("issueDate", mgr); if (issueDateNode != null && issueDateNode.HasChildNodes) { IssueDate = issueDateNode.FirstChild.InnerText; } var purposeNode = node.FirstChild.SelectSingleNode("purpose", mgr); if (purposeNode != null && purposeNode.HasChildNodes) { Purpose = purposeNode.FirstChild.InnerText; } var informationNodes = node.FirstChild.SelectNodes("information", mgr); if (informationNodes != null && informationNodes.Count > 0) { var informations = new List <Information>(); foreach (XmlNode informationNode in informationNodes) { if (informationNode != null && informationNode.HasChildNodes) { var newInformation = new Information(); newInformation.FromXml(informationNode, mgr); informations.Add(newInformation); } } Information = informations.ToArray(); } var priceNodes = node.FirstChild.SelectNodes("price", mgr); if (priceNodes != null && priceNodes.Count > 0) { var prices = new List <Price>(); foreach (XmlNode priceNode in priceNodes) { if (priceNode != null && priceNode.HasChildNodes) { var newPrice = new Price(); newPrice.FromXml(priceNode, mgr); prices.Add(newPrice); } } Price = prices.ToArray(); } var producingAgencyNode = node.FirstChild.SelectSingleNode("producingAgency", mgr); if (producingAgencyNode != null && producingAgencyNode.HasChildNodes) { ProducingAgency = new ProducingAgency(); ProducingAgency.FromXml(producingAgencyNode, mgr); } var publicationNumberNode = node.FirstChild.SelectSingleNode("publicationNumber", mgr); if (publicationNumberNode != null && publicationNumberNode.HasChildNodes) { PublicationNumber = publicationNumberNode.FirstChild.InnerText; } var dataSetNameNode = node.FirstChild.SelectSingleNode("dataSetName", mgr); if (dataSetNameNode != null && dataSetNameNode.HasChildNodes) { DataSetName = dataSetNameNode.FirstChild.InnerText; } var versionNode = node.FirstChild.SelectSingleNode("version", mgr); if (versionNode != null && versionNode.HasChildNodes) { Version = versionNode.FirstChild.InnerText; } var serviceStatusNode = node.FirstChild.SelectSingleNode("serviceStatus", mgr); if (serviceStatusNode != null && serviceStatusNode.HasChildNodes) { ServiceStatus = serviceStatusNode.FirstChild.InnerText; } var keywordsNode = node.FirstChild.SelectSingleNode("keywords", mgr); if (keywordsNode != null && keywordsNode.HasChildNodes) { Keywords = keywordsNode.FirstChild.InnerText; } var productSpecificationNode = node.FirstChild.SelectSingleNode("productSpecification", mgr); if (productSpecificationNode != null && productSpecificationNode.HasChildNodes) { ProductSpecification = new ReferenceSpecification(); ProductSpecification.FromXml(productSpecificationNode, mgr); } var onlineResourceNode = node.FirstChild.SelectSingleNode("onlineResource", mgr); if (onlineResourceNode != null && onlineResourceNode.HasChildNodes) { OnlineResource = new OnlineResource(); OnlineResource.FromXml(onlineResourceNode, mgr); } var serviceSpecificationNode = node.FirstChild.SelectSingleNode("serviceSpecification", mgr); if (serviceSpecificationNode != null && serviceSpecificationNode.HasChildNodes) { ServiceSpecification = new ReferenceSpecification(); ServiceSpecification.FromXml(serviceSpecificationNode, mgr); } var serviceDesignNode = node.FirstChild.SelectSingleNode("serviceDesign", mgr); if (serviceDesignNode != null && serviceDesignNode.HasChildNodes) { ServiceDesign = new ReferenceSpecification(); ServiceDesign.FromXml(serviceDesignNode, mgr); } var linkNodes = node.FirstChild.SelectNodes("*[boolean(@xlink:href)]", mgr); if (linkNodes != null && linkNodes.Count > 0) { var links = new List <Link>(); foreach (XmlNode linkNode in linkNodes) { var newLink = new Link(); newLink.FromXml(linkNode, mgr); links.Add(newLink); } Links = links.ToArray(); } return(this); }