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);
        }
Пример #2
0
 public OwcDisplay(Terradue.ServiceModel.Ogc.Owc.Model.OwcDisplay display) : this()
 {
     this.MmPerPixel  = display.MmPerPixel;
     this.PixelHeight = display.PixelHeight;
     this.PixelWidth  = display.PixelWidth;
 }