Beispiel #1
0
        public void GeoRssPointTestCase()
        {
            const string xml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><georss:point xmlns:georss=\"http://www.georss.org/georss\">45.256 -71.92</georss:point>";

            var reader = XmlReader.Create(new StringReader(xml));

            Terradue.GeoJson.GeoRss.GeoRssPoint point = (Terradue.GeoJson.GeoRss.GeoRssPoint)Terradue.GeoJson.GeoRss.GeoRssHelper.Deserialize(reader);

            var geom = point.ToGeometry();

            Assert.That(geom is Point);

            Assert.That(((Point)geom).Position is GeographicPosition);

            Assert.AreEqual(45.256, ((GeographicPosition)((Point)geom).Position).Latitude);

            Assert.AreEqual(-71.92, ((GeographicPosition)((Point)geom).Position).Longitude);

            point = (GeoRssPoint)geom.ToGeoRss();
            var sw = new StringWriter();

            GeoRssHelper.Serialize(XmlWriter.Create(sw), point);

            sw.Close();

            var xml1 = sw.ToString();

            Assert.IsTrue(XNode.DeepEquals(XDocument.Parse(xml).Root, XDocument.Parse(xml1).Root));
        }
Beispiel #2
0
        public static GeometryObject ToGeometry(this GeoRssPoint georssPoint)
        {
            if (georssPoint.Item == null)
            {
                return(null);
            }

            return(new Point(new DirectPositionType()
            {
                Text = georssPoint.Item
            }.ToGeometry()));
        }