public static IGeometryObject ToGeometry(this GeoRssWhere where) { if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is EnvelopeType) { return(((EnvelopeType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is CircleByCenterPointType) { throw new NotImplementedException(); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is LineStringType) { return(((LineStringType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is PointType) { return(((PointType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is PolygonType) { return(((PolygonType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiPolygonType) { return(((MultiPolygonType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiCurveType) { return(((MultiCurveType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiPolygonType) { return(((MultiCurveType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiSurfaceType) { return(((MultiSurfaceType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiPointType) { return(((MultiPointType) where.Item[0]).ToGeometry()); } if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiLineStringType) { return(((MultiLineStringType) where.Item[0]).ToGeometry()); } return(null); }
public void LocationTest() { PicasaEntry target = new PicasaEntry(); // TODO: Initialize to an appropriate value GeoRssWhere expected = new GeoRssWhere(); GeoRssWhere actual; target.Location = expected; actual = target.Location; Assert.AreEqual(expected, actual); }
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); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs an authentication test, iterates all entries</summary> ////////////////////////////////////////////////////////////////////// [Test] public void QueryPhotosTest() { Tracing.TraceMsg("Entering PhotosQueryPhotosTest"); PhotoQuery query = new PhotoQuery(); PicasaService service = new PicasaService("unittests"); if (this.defaultPhotosUri != null) { if (this.userName != null) { service.Credentials = new GDataCredentials(this.userName, this.passWord); } GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory)this.factory; factory.MethodOverride = true; service.RequestFactory = this.factory; query.Uri = new Uri(this.defaultPhotosUri); PicasaFeed feed = service.Query(query); ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("PhotoAuthTest")); if (feed != null && feed.Entries.Count > 0) { Tracing.TraceMsg("Found a Feed " + feed.ToString()); DisplayExtensions(feed); foreach (PicasaEntry entry in feed.Entries) { Tracing.TraceMsg("Found an entry " + entry.ToString()); DisplayExtensions(entry); GeoRssWhere w = entry.Location; if (w != null) { Tracing.TraceMsg("Found an location " + w.Latitude + w.Longitude); } ExifTags tags = entry.Exif; if (tags != null) { Tracing.TraceMsg("Found an exif block "); } MediaGroup group = entry.Media; if (group != null) { Tracing.TraceMsg("Found a media Group"); if (group.Title != null) { Tracing.TraceMsg(group.Title.Value); } if (group.Keywords != null) { Tracing.TraceMsg(group.Keywords.Value); } if (group.Credit != null) { Tracing.TraceMsg(group.Credit.Value); } if (group.Description != null) { Tracing.TraceMsg(group.Description.Value); } } PhotoAccessor photo = new PhotoAccessor(entry); Assert.IsTrue(entry.IsPhoto, "this is a photo entry, it should have the kind set"); Assert.IsTrue(photo != null, "this is a photo entry, it should convert to PhotoEntry"); Assert.IsTrue(photo.AlbumId != null); Assert.IsTrue(photo.Height > 0); Assert.IsTrue(photo.Width > 0); } } factory.MethodOverride = false; } }