/// <summary> /// Initializes a new instance of the <see cref="T:Terradue.Tep.ThematicApplicationCached"/> class. /// </summary> /// <param name="context">Context.</param> /// <param name="identifier">Identifier.</param> /// <param name="domainid">Domainid.</param> /// <param name="feed">Feed.</param> public ThematicApplicationCached(IfyContext context, string identifier, int domainid, string feed) : base(context) { this.UId = identifier; this.DomainId = domainid; this.TextFeed = feed; this.Feed = ThematicAppCachedFactory.GetOwsContextAtomFeed(feed); }
public void Issue1() { OwsContextAtomFeed feed = new OwsContextAtomFeed(); /// entries List <OwsContextAtomEntry> items = new List <OwsContextAtomEntry>(); OwsContextAtomEntry item = new OwsContextAtomEntry(); feed.Publisher = "manu"; item.Publisher = "manu"; items.Add(item); feed.Items = items; MemoryStream stream = new MemoryStream(); SerializationTest.SerializeToStream(feed, stream); stream.Seek(0, SeekOrigin.Begin); XDocument doc = XDocument.Load(stream); Assert.AreEqual("manu", doc.Element(XName.Get("feed", OwcNamespaces.Atom)) .Element(XName.Get("publisher", OwcNamespaces.Dc)).Value); Assert.AreEqual("manu", doc.Element(XName.Get("feed", OwcNamespaces.Atom)) .Elements(XName.Get("entry", OwcNamespaces.Atom)).First() .Element(XName.Get("publisher", OwcNamespaces.Dc)).Value); }
public void DateExtensions() { var feed = AtomFeed.Load(XmlReader.Create(File.OpenRead("../in/offeringdateext.xml"))); OwsContextAtomFeed ows = new OwsContextAtomFeed(feed.Feed, true); SerializationTest.SerializeToStream(ows, Console.OpenStandardOutput()); }
/// <summary> /// Gets the ows context atom feed. /// </summary> /// <returns>The ows context atom feed.</returns> /// <param name="s">S.</param> public static OwsContextAtomFeed GetOwsContextAtomFeed(string s) { var atomFormatter = new Atom10FeedFormatter(); XmlReader xmlreader = XmlReader.Create(new StringReader(s)); atomFormatter.ReadFrom(xmlreader); var feed = new OwsContextAtomFeed(atomFormatter.Feed, true); return(feed); }
/// <summary> /// Gets the ows context atom feed. /// </summary> /// <returns>The ows context atom feed.</returns> /// <param name="s">S.</param> public static OwsContextAtomFeed GetOwsContextAtomFeed(Stream s) { var sr = XmlReader.Create(s); Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(); atomFormatter.ReadFrom(sr); sr.Close(); var feed = new OwsContextAtomFeed(atomFormatter.Feed, true); return(feed); }
/// <summary> /// Posts the index of the atom feed to. /// </summary> /// <returns><c>true</c>, if atom feed to index was posted, <c>false</c> otherwise.</returns> /// <param name="context">Context.</param> /// <param name="feed">Feed.</param> /// <param name="index">Index.</param> /// <param name="username">Username.</param> /// <param name="apikey">Apikey.</param> public static bool PostAtomFeedToIndex(IfyContext context, OwsContextAtomFeed feed, string index, string username, string apikey) { using (var stream = new MemoryStream()) { var sw = System.Xml.XmlWriter.Create(stream); Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter((SyndicationFeed)feed); atomFormatter.WriteTo(sw); sw.Flush(); sw.Close(); stream.Seek(0, SeekOrigin.Begin); return(PostStreamToIndex(context, stream, index, username, apikey)); } }
public void DeserializeGeotiff() { FileStream geotiff = new FileStream("../in/geotiff.xml", FileMode.Open); OwsContextAtomFeed feed = DeserializeFromStream(geotiff); Assert.AreEqual("GeoTIFF Example", feed.Title.Text); Assert.AreEqual(2, feed.Items.First().Offerings.Count()); Assert.AreEqual("image/tiff", feed.Items.First().Offerings.First().Contents.First().Type); Assert.AreEqual("ftp://ftp.remotesensing.org/pub/geotiff/samples/gdal_eg/cea.tif", feed.Items.First().Offerings.First().Contents.First().Url.ToString()); Assert.AreEqual("ftp://ftp.remotesensing.org/pub/geotiff/samples/pci_eg/acea.tif", feed.Items.First().Offerings.Last().Contents.First().Url.ToString()); }
public override AtomItem ToAtomItem(NameValueCollection parameters) { var atomFormatter = new Atom10FeedFormatter(); XmlReader xmlreader = XmlReader.Create(new StringReader(TextFeed = this.TextFeed)); atomFormatter.ReadFrom(xmlreader); var feed = new OwsContextAtomFeed(atomFormatter.Feed, true); var item = feed.Items.First(); var result = new AtomItem(item); if (parameters["admin"] != null && parameters["admin"] == "true") { try{ var wpsOverviews = ThematicAppFactory.GetWpsServiceOverviews(context, item); if (wpsOverviews.Count > 0) { result.ElementExtensions.Add("wps", "https://standards.terradue.com", wpsOverviews); } }catch (Exception) {} try{ var collOverviews = ThematicAppFactory.GetDataCollectionOverview(context, item); if (collOverviews.Count > 0) { result.ElementExtensions.Add("collection", "https://standards.terradue.com", collOverviews); } }catch (Exception) {} try{ if (this.Domain != null) { var community = ThematicCommunity.FromId(context, this.DomainId); var comOverview = new CommunityOverview { Identifier = community.Identifier, Title = community.Name, Icon = community.IconUrl }; result.ElementExtensions.Add("community", "https://standards.terradue.com", comOverview); } }catch (Exception) {} try{ var editorUrl = string.Format("{0}/{1}/{2}", context.GetConfigValue("ellip.editor-url"), this.Index, this.UId); result.Links.Add(new SyndicationLink(new Uri(editorUrl), "related", "geobrowser editor", "application/html", 0)); }catch (Exception) {} } return(result); }
/// <summary> /// Creates or update the cached app /// </summary> /// <returns>The or update.</returns> /// <param name="entry">Entry.</param> /// <param name="domainid">Domainid.</param> public ThematicApplicationCached CreateOrUpdateCachedApp(OwsContextAtomEntry entry, int domainid, string index = null) { var appCategory = entry.Categories.FirstOrDefault(l => l.Label == "App"); if (appCategory == null) { return(null); } var identifier = GetIdentifierFromFeed(entry); var appcached = new ThematicApplicationCached(context); appcached.UId = identifier; if (index != null) { appcached.Index = index; } else { appcached.DomainId = domainid; } try { appcached.Load(); } catch (Exception) { } var feed = new OwsContextAtomFeed(); feed.Items = new List <OwsContextAtomEntry> { entry }; appcached.Index = index; appcached.Feed = feed; appcached.TextFeed = System.Text.RegularExpressions.Regex.Replace(GetOwsContextAtomFeedAsString(feed), @"\p{Cs}", ""); appcached.Searchable = System.Text.RegularExpressions.Regex.Replace(GetSearchableTextFromAtomEntry(entry), @"\p{Cs}", ""); appcached.LastUpdate = entry.LastUpdatedTime.DateTime; if (appcached.DomainId == 0 && domainid > 0) { appcached.DomainId = domainid; } appcached.Store(); return(appcached); }
/// <summary> /// Refreshs the cached app. /// </summary> /// <param name="feed">Feed.</param> /// <param name="index">Index.</param> /// <param name="uid">Uid.</param> /// <param name="domainId">Domain identifier.</param> public void RefreshCachedApp(OwsContextAtomFeed feed, string index, string uid, int domainId) { var entry = feed.Items.First <OwsContextAtomEntry>(); var appCategory = entry.Categories.FirstOrDefault(l => l.Label == "App"); if (appCategory == null) { return; } var appcached = new ThematicApplicationCached(context); appcached.UId = uid; if (index != null) { appcached.Index = index; } else { appcached.DomainId = domainId; } try { appcached.Load(); } catch (Exception) { } appcached.Index = index; appcached.Feed = feed; appcached.TextFeed = GetOwsContextAtomFeedAsString(feed); appcached.Searchable = GetSearchableTextFromAtomEntry(entry); appcached.LastUpdate = entry.LastUpdatedTime.DateTime == DateTime.MinValue ? DateTime.UtcNow : entry.LastUpdatedTime.DateTime; if (appcached.DomainId == 0 && domainId > 0) { appcached.DomainId = domainId; } appcached.Store(); return; }
/// <summary> /// Gets the ows context atom feed as string. /// </summary> /// <returns>The ows context atom feed as string.</returns> /// <param name="feed">Feed.</param> public static string GetOwsContextAtomFeedAsString(OwsContextAtomFeed feed, string format = "atom") { string result = ""; using (MemoryStream stream = new MemoryStream()) { var sw = System.Xml.XmlWriter.Create(stream); if (format == "json") { } else { Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter((SyndicationFeed)feed); atomFormatter.WriteTo(sw); sw.Flush(); sw.Close(); stream.Seek(0, SeekOrigin.Begin); StreamReader reader = new StreamReader(stream, Encoding.UTF8); result = reader.ReadToEnd(); } } return(result); }
/// <summary> /// Transform the current object to OwsContextAtomFeed. /// </summary> /// <returns>The ows context atom feed.</returns> public OwsContextAtomFeed ToOwsContextAtomFeed() { OwsContextAtomFeed feed = new OwsContextAtomFeed(); feed.Title = new TextSyndicationContent(this.Title); feed.Description = new TextSyndicationContent(this.Abstract); feed.Id = this.Id; feed.LastUpdatedTime = this.UpdateDate; feed.Language = this.Language; feed.Publisher = this.Publisher; feed.Copyright = new TextSyndicationContent(this.Rights); feed.Where = this.AreaOfInterest.ToGeoRssWhere(); feed.Date = this.TimeIntervalOfInterest; if (this.SpecReference != null) { feed.Links.Add(new Terradue.ServiceModel.Syndication.SyndicationLink(this.SpecReference, "profile", "OWC Context document specification reference", null, this.SpecReference.AbsoluteUri.Length)); } //TODO: validate type of ContextMetadata if (this.ContextMetadata != null) { feed.Links.Add(this.ContextMetadata); } if (this.Authors != null) { foreach (string author in this.Authors) { feed.Authors.Add(new SyndicationPerson(null, author, null)); } } if (this.Creator != null) { if (this.Creator.CreatorApplication != null) { feed.Generator = this.Creator.CreatorApplication.Title; } feed.Display = new Terradue.ServiceModel.Ogc.Owc.AtomEncoding.OwcDisplay(this.Creator.CreatorDisplay); } if (this.Keywords != null) { foreach (string kw in this.Keywords) { feed.Categories.Add(new SyndicationCategory(kw)); } } if (this.Resources != null) { System.Collections.ObjectModel.Collection <OwsContextAtomEntry> items = new System.Collections.ObjectModel.Collection <OwsContextAtomEntry>(); foreach (Resource resource in this.Resources) { items.Add(resource.ToContextAtomEntry()); } feed.Items = items; } // feed.ElementExtensions = Extension.ToAtom(); //TODO: implement return(feed); }
private AtomFeed CreateFeedForMetalink(XmlNode any, string identifier, string baseurl, IfyContext context) { OwsContextAtomFeed feed = new OwsContextAtomFeed(); List <OwsContextAtomEntry> entries = new List <OwsContextAtomEntry> (); XmlDocument doc = new XmlDocument(); doc.LoadXml(any.OuterXml); XmlNamespaceManager xmlns = new XmlNamespaceManager(doc.NameTable); xmlns.AddNamespace("ml", "http://www.metalinker.org"); var onlineResource = doc.SelectNodes("ml:metalink/ml:files/ml:file/ml:resources/ml:url", xmlns); var createddate = doc.SelectSingleNode("ml:metalink/ml:files/ml:file/ml:releasedate", xmlns).InnerText; var self = baseurl + "/proxy/wps/" + identifier + "/search"; var search = baseurl + "/proxy/wps/" + identifier + "/description"; feed.Id = self; feed.Title = new Terradue.ServiceModel.Syndication.TextSyndicationContent("Wps job results"); feed.Date = new DateTimeInterval { StartDate = Convert.ToDateTime(createddate), EndDate = Convert.ToDateTime(createddate) }; foreach (XmlNode node in onlineResource) { string url = node.InnerText; context.LogDebug(this, "Url = " + url); Uri remoteUri = new Uri(url); OwsContextAtomEntry entry = new OwsContextAtomEntry(); //link is an OWS context, we add it as is Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(); if (url.Contains(".atom")) { NetworkCredential credentials = null; var uri = new UriBuilder(url); if (!string.IsNullOrEmpty(uri.UserName) && !string.IsNullOrEmpty(uri.Password)) { credentials = new NetworkCredential(uri.UserName, uri.Password); } HttpWebRequest atomRequest = WpsProvider.CreateWebRequest(url, credentials, context.Username); atomRequest.Accept = "*/*"; atomRequest.UserAgent = "Terradue TEP"; try { using (var atomResponse = (HttpWebResponse)atomRequest.GetResponse()) { using (var atomResponseStream = new MemoryStream()) { using (var stream = atomResponse.GetResponseStream()) stream.CopyTo(atomResponseStream); atomResponseStream.Seek(0, SeekOrigin.Begin); var sr = XmlReader.Create(atomResponseStream); atomFormatter.ReadFrom(sr); sr.Close(); } } } catch (Exception e) { context.LogError(this, e.Message, e); throw e; } return(new AtomFeed(atomFormatter.Feed)); } //we build the OWS context entry.Id = node.InnerText.Contains("/") ? node.InnerText.Substring(node.InnerText.LastIndexOf("/") + 1) : node.InnerText; entry.Title = new Terradue.ServiceModel.Syndication.TextSyndicationContent(remoteUri.AbsoluteUri); entry.PublishDate = new DateTimeOffset(Convert.ToDateTime(createddate)); entry.LastUpdatedTime = new DateTimeOffset(Convert.ToDateTime(createddate)); entry.Date = new DateTimeInterval { StartDate = Convert.ToDateTime(createddate), EndDate = Convert.ToDateTime(createddate) }; entry.ElementExtensions.Add("identifier", OwcNamespaces.Dc, entry.Id); entry.Links.Add(Terradue.ServiceModel.Syndication.SyndicationLink.CreateMediaEnclosureLink(remoteUri, "application/octet-stream", 0)); List <OwcOffering> offerings = new List <OwcOffering> (); OwcOffering offering = new OwcOffering(); OwcContent content = new OwcContent(); content.Url = remoteUri; string extension = remoteUri.AbsoluteUri.Substring(remoteUri.AbsoluteUri.LastIndexOf(".") + 1); switch (extension.ToLower()) { case "gif": content.Type = "image/gif"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/gif"; break; case "gtiff": content.Type = "image/tiff"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/geotiff"; break; case "jpeg": content.Type = "image/jpg"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/jpg"; break; case "png": content.Type = "image/png"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/png"; break; case "tgz": content.Type = "application/tar+gzip"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/tgz"; break; default: content.Type = "application/octet-stream"; offering.Code = ""; break; } List <OwcContent> contents = new List <OwcContent> (); contents.Add(content); offering.Contents = contents.ToArray(); offerings.Add(offering); entry.Offerings = offerings; entries.Add(entry); } feed.Items = entries; AtomFeed atomfeed = new AtomFeed(feed); atomfeed.Title = feed.Title; atomfeed.Description = feed.Description; var urib = new UriBuilder(baseurl); urib.Path += "/proxy/wps/" + identifier + "/description"; atomfeed.Links.Add(new Terradue.ServiceModel.Syndication.SyndicationLink(urib.Uri, "search", "OpenSearch Description link", "application/opensearchdescription+xml", 0)); return(atomfeed); }
public void SerializeFromModel() { Terradue.ServiceModel.Ogc.Owc.Model.Context context = new Terradue.ServiceModel.Ogc.Owc.Model.Context(); context.Abstract = "Test ows context"; context.Publisher = "engue"; context.Authors = new List <string> { "author" }; // display Terradue.ServiceModel.Ogc.Owc.Model.OwcDisplay display = new Terradue.ServiceModel.Ogc.Owc.Model.OwcDisplay() { PixelWidth = 800, PixelHeight = 600, MmPerPixel = 100 }; context.Creator = new Terradue.ServiceModel.Ogc.Owc.Model.Creator(); context.Creator.CreatorDisplay = display; // date DateTimeInterval interval = new DateTimeInterval(); interval.StartDate = DateTime.Parse("2010-05-30T05:54:34+02"); interval.EndDate = DateTime.Parse("2010-05-31T20:20:20.000Z"); context.TimeIntervalOfInterest = interval; // georss GeoRssWhere georss = (GeoRssWhere)GeoRssHelper.Deserialize(XmlReader.Create(new StringReader("<georss:where xmlns:georss=\"http://www.georss.org/georss\">\n<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\">\n<gml:exterior>\n<gml:LinearRing>\n<gml:posList>45 -2 45 8 55 8 55 -2 45 -2</gml:posList>\n</gml:LinearRing>\n</gml:exterior>\n</gml:Polygon>\n</georss:where>"))); context.AreaOfInterest = georss.ToGeometry(); /// entries context.Resources = new List <Terradue.ServiceModel.Ogc.Owc.Model.Resource>(); Terradue.ServiceModel.Ogc.Owc.Model.Resource resource = new Terradue.ServiceModel.Ogc.Owc.Model.Resource(); resource.Publisher = "engue"; List <Terradue.ServiceModel.Ogc.Owc.Model.Offering> offerings = new List <Terradue.ServiceModel.Ogc.Owc.Model.Offering>(); Terradue.ServiceModel.Ogc.Owc.Model.Offering offering = new Terradue.ServiceModel.Ogc.Owc.Model.Offering(); offering.Operation = new Collection <Terradue.ServiceModel.Ogc.Owc.Model.Operation>(); Terradue.ServiceModel.Ogc.Owc.Model.Operation op = new Terradue.ServiceModel.Ogc.Owc.Model.Operation(); op.Code = "GetCapabilities"; op.RequestURL = new Uri("http://ows.genesi-dec.eu/geoserver/385d7d71-650a-414b-b8c7-739e2c0b5e76/wms?SERVICE=WMS&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilitiesVERSION=1.3.0&REQUEST=GetCapabilities"); offering.Operation.Add(op); offering.Code = new Uri("http://ows.genesi-dec.eu/geoserver"); offerings.Add(offering); resource.Offerings = offerings; context.Resources.Add(resource); MemoryStream stream = new MemoryStream(); OwsContextAtomFeed feed = context.ToOwsContextAtomFeed(); SerializeToStream(feed, stream); stream.Seek(0, SeekOrigin.Begin); SerializeToStream(feed, Console.Out); XDocument doc = XDocument.Load(stream); Assert.NotNull(doc.Element(XName.Get("feed", OwcNamespaces.Atom))); Assert.NotNull(doc.Element(XName.Get("feed", OwcNamespaces.Atom)).Element(XName.Get("display", OwcNamespaces.Owc))); Assert.AreEqual("2010-05-30T03:54:34.0000000Z/2010-05-31T20:20:20.0000000Z", doc.Element(XName.Get("feed", OwcNamespaces.Atom)).Element(XName.Get("date", OwcNamespaces.Dc)).Value); }
public void Serialize() { OwsContextAtomFeed feed = new OwsContextAtomFeed(); // display OwcDisplay display = new OwcDisplay() { PixelWidth = 800, PixelHeight = 600, MmPerPixel = 100 }; var displayAny = new System.Collections.Generic.List <XmlElement>(); display.Any = displayAny.ToArray(); feed.Display = display; // date DateTimeInterval interval = new DateTimeInterval(); interval.StartDate = DateTime.Parse("2010-05-30T05:54:34+02"); interval.EndDate = DateTime.Parse("2010-05-31T20:20:20.000Z"); feed.Date = interval; // georss GeoRssWhere georss = (GeoRssWhere)GeoRssHelper.Deserialize(XmlReader.Create(new StringReader("<georss:where xmlns:georss=\"http://www.georss.org/georss\">\n<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\">\n<gml:exterior>\n<gml:LinearRing>\n<gml:posList>45 -2 45 8 55 8 55 -2 45 -2</gml:posList>\n</gml:LinearRing>\n</gml:exterior>\n</gml:Polygon>\n</georss:where>"))); feed.Where = georss; /// entries List <OwsContextAtomEntry> items = new List <OwsContextAtomEntry>(); OwsContextAtomEntry item = new OwsContextAtomEntry(); List <OwcOffering> offerings = new List <OwcOffering>(); OwcOffering offering = new OwcOffering(); List <XmlElement> offeringAny = new List <XmlElement>(); offering.Any = offeringAny.ToArray(); List <OwcOperation> ops = new List <OwcOperation>(); ops.Add(new OwcOperation("GetCapabilities", new Uri("http://ows.genesi-dec.eu/geoserver/385d7d71-650a-414b-b8c7-739e2c0b5e76/wms?SERVICE=WMS&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilitiesVERSION=1.3.0&REQUEST=GetCapabilities"))); ops.Add(new OwcOperation("GetCapabilities2", new Uri("http://ows.genesi-dec.eu/geoserver/385d7d71-650a-414b-b8c7-739e2c0b5e76/wms?SERVICE=WMS&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilitiesVERSION=1.3.0&REQUEST=GetCapabilities"))); offering.Operations = ops.ToArray(); offerings.Add(offering); item.Offerings = offerings; items.Add(item); feed.Items = items; MemoryStream stream = new MemoryStream(); SerializeToStream(feed, stream); stream.Seek(0, SeekOrigin.Begin); SerializeToStream(feed, Console.Out); XDocument doc = XDocument.Load(stream); Assert.NotNull(doc.Element(XName.Get("feed", OwcNamespaces.Atom))); Assert.NotNull(doc.Element(XName.Get("feed", OwcNamespaces.Atom)).Element(XName.Get("display", OwcNamespaces.Owc))); Assert.AreEqual("2010-05-30T03:54:34.0000000Z/2010-05-31T20:20:20.0000000Z", doc.Element(XName.Get("feed", OwcNamespaces.Atom)).Element(XName.Get("date", OwcNamespaces.Dc)).Value); }
public void SerializeWithAny() { OwsContextAtomFeed feed = new OwsContextAtomFeed(); OwsContextAtomEntry entry = new OwsContextAtomEntry(); var items = new List <OwsContextAtomEntry>(); items.Add(entry); var offering = new OwcOffering(); List <OwcOperation> operations = new List <OwcOperation>(); Uri executeUri = new Uri("http://localhost/wps?"); Terradue.ServiceModel.Ogc.Owc.AtomEncoding.OwcOperation operation = new OwcOperation { Method = "POST", Code = "Execute", RequestUrl = executeUri }; List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >(); Parameters.Add(new KeyValuePair <string, string>("manu", "test")); Execute execute = new Execute(); execute.Identifier = new CodeType { Value = "id" }; execute.DataInputs = new List <InputType>(); foreach (var param in Parameters) { InputType input = new InputType(); input.Identifier = new CodeType { Value = param.Key }; input.Data = new DataType { Item = new LiteralDataType { Value = param.Value } }; execute.DataInputs.Add(input); } MemoryStream ms = new MemoryStream(); XmlWriter writer = XmlWriter.Create(ms); new System.Xml.Serialization.XmlSerializer(typeof(Execute)).Serialize(writer, execute); writer.Flush(); ms.Seek(0, SeekOrigin.Begin); XmlDocument doc = new XmlDocument(); doc.Load(ms); XmlElement any = (XmlElement)doc.DocumentElement.CloneNode(true); operation.Request = new OwcContent(); ((OwcContent)operation.Request).Any = any; operations.Add(operation); offering.Operations = operations.ToArray(); entry.Offerings = new List <OwcOffering> { offering }; entry.Categories.Add(new SyndicationCategory("WpsOffering")); entry.Summary = new TextSyndicationContent("summary"); entry.ElementExtensions.Add("identifier", "http://purl.org/dc/elements/1.1/", "id"); feed.Items = items; SerializeToStream(feed, Console.Out); }
private AtomFeed CreateFeedForRDF(XmlNode any, string identifier, string baseurl) { OwsContextAtomFeed feed = new OwsContextAtomFeed(); List <OwsContextAtomEntry> entries = new List <OwsContextAtomEntry> (); XmlDocument doc = new XmlDocument(); doc.LoadXml(any.OuterXml); XmlNamespaceManager xmlns = new XmlNamespaceManager(doc.NameTable); xmlns.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); xmlns.AddNamespace("dclite4g", "http://xmlns.com/2008/dclite4g#"); xmlns.AddNamespace("dc", "http://purl.org/dc/elements/1.1/"); xmlns.AddNamespace("dct", "http://purl.org/dc/terms/"); var onlineResource = doc.SelectNodes("rdf:RDF/dclite4g:DataSet/dclite4g:onlineResource", xmlns); var createddate = doc.SelectSingleNode("rdf:RDF/dclite4g:DataSet/dct:created", xmlns).InnerText; var modifieddate = doc.SelectSingleNode("rdf:RDF/dclite4g:DataSet/dct:modified", xmlns).InnerText; feed.Title = new Terradue.ServiceModel.Syndication.TextSyndicationContent(doc.SelectSingleNode("rdf:RDF/dclite4g:DataSet/dc:title", xmlns).InnerText); feed.Description = new Terradue.ServiceModel.Syndication.TextSyndicationContent(doc.SelectSingleNode("rdf:RDF/dclite4g:DataSet/dc:subject", xmlns).InnerText); feed.Date = new DateTimeInterval { StartDate = Convert.ToDateTime(modifieddate), EndDate = Convert.ToDateTime(modifieddate) }; for (int i = 0; i < onlineResource.Count; i++) { string id = onlineResource [i].ChildNodes [0].Attributes.GetNamedItem("rdf:about").InnerText; Uri remoteUri = new Uri(id); OwsContextAtomEntry entry = new OwsContextAtomEntry(); entry.Id = remoteUri.AbsoluteUri; entry.Title = new Terradue.ServiceModel.Syndication.TextSyndicationContent(remoteUri.AbsoluteUri); entry.PublishDate = new DateTimeOffset(Convert.ToDateTime(modifieddate)); entry.LastUpdatedTime = new DateTimeOffset(Convert.ToDateTime(modifieddate)); entry.Date = new DateTimeInterval { StartDate = Convert.ToDateTime(modifieddate), EndDate = Convert.ToDateTime(modifieddate) }; entry.ElementExtensions.Add("identifier", OwcNamespaces.Dc, identifier); entry.Links.Add(Terradue.ServiceModel.Syndication.SyndicationLink.CreateMediaEnclosureLink(remoteUri, "application/octet-stream", 0)); List <OwcOffering> offerings = new List <OwcOffering> (); OwcOffering offering = new OwcOffering(); OwcContent content = new OwcContent(); content.Url = remoteUri;; string extension = remoteUri.AbsoluteUri.Substring(remoteUri.AbsoluteUri.LastIndexOf(".") + 1); switch (extension.ToLower()) { case "gif": content.Type = "image/gif"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/gif"; break; case "gtiff": content.Type = "image/tiff"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/geotiff"; break; case "jpeg": content.Type = "image/jpg"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/jpg"; break; case "png": content.Type = "image/png"; offering.Code = "http://www.opengis.net/spec/owc-atom/1.0/req/png"; break; default: content.Type = "application/octet-stream"; offering.Code = null; break; } List <OwcContent> contents = new List <OwcContent> (); contents.Add(content); offering.Contents = contents.ToArray(); offerings.Add(offering); entry.Offerings = offerings; entries.Add(entry); } feed.Items = entries; AtomFeed atomfeed = new AtomFeed(feed); atomfeed.Title = feed.Title; atomfeed.Description = feed.Description; var urib = new UriBuilder(baseurl); urib.Path += "/proxy/wps/" + identifier + "/description"; atomfeed.Links.Add(new Terradue.ServiceModel.Syndication.SyndicationLink(urib.Uri, "search", "OpenSearch Description link", "application/opensearchdescription+xml", 0)); return(atomfeed); }