public void Gml32MultiSurfaceToGeorss4() { var fs = new FileStream(TestContext.CurrentContext.TestPath("../Samples/multisurface32-4.xml"), FileMode.Open, FileAccess.Read); var reader = XmlReader.Create(fs); var gml = GmlHelper.Deserialize(reader); fs.Close(); var geom = gml.ToGeometry(); Assert.IsTrue(geom is MultiPolygon); var georss = (GeoRssWhere)geom.ToGeoRss(); Assert.AreEqual("multipolygon", georss.Type); var georss2 = (GeoRssWhere)GeoRssHelper.Deserialize(georss.CreateReader()); Assert.AreEqual("multipolygon", georss2.Type); var geom2 = georss.ToGeometry(); Assert.IsTrue(geom2 is MultiPolygon); var json = new Feature.Feature(geom, null); }
public void GeoRssFromFile2() { var xr = XmlReader.Create(new FileStream(TestContext.CurrentContext.TestPath("../Samples/noa-ers-georss.xml"), FileMode.Open, FileAccess.Read)); MultiPolygon geom = GeoRssHelper.Deserialize(xr).ToGeometry() as MultiPolygon; Assert.IsNotNull(geom); xr = XmlReader.Create(new FileStream(TestContext.CurrentContext.TestPath("../Samples/noa-ers-georss.xml"), FileMode.Open, FileAccess.Read)); MultiPolygon geom2 = GeoRssHelper.Deserialize(xr).ToGeometry() as MultiPolygon; geom.Polygons.Add(geom2.Polygons[0]); geom.ToGeoRss(); }
public void GeoRssFromAtomFeed() { Terradue.ServiceModel.Syndication.Atom10FeedFormatter atomf = new Terradue.ServiceModel.Syndication.Atom10FeedFormatter(); atomf.ReadFrom(XmlReader.Create(new FileStream(TestContext.CurrentContext.TestPath("../Samples/landsat8.xml"), FileMode.Open, FileAccess.Read))); GeometryObject geom; foreach (var ext in atomf.Feed.Items.First().ElementExtensions) { XmlReader xr = ext.GetReader(); switch (xr.NamespaceURI) { // 1) search for georss case "http://www.georss.org/georss": geom = GeoRssHelper.Deserialize(xr).ToGeometry(); break; // 2) search for georss10 case "http://www.georss.org/georss/10": geom = GeoRss10Helper.Deserialize(xr).ToGeometry(); break; // 3) search for dct:spatial case "http://purl.org/dc/terms/": if (xr.LocalName == "spatial") { geom = WktExtensions.WktToGeometry(xr.ReadContentAsString()); } break; default: continue; } } }
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); }