상속: IGeoRSS
예제 #1
0
        public void GeoRssLineTestCase()
        {
            string xml = "<georss:line xmlns:georss=\"http://www.georss.org/georss\">45.256 -110.45 46.46 -109.48 43.84 -109.86</georss:line>";

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

            Terradue.GeoJson.GeoRss.GeoRssLine line = (Terradue.GeoJson.GeoRss.GeoRssLine)Terradue.GeoJson.GeoRss.GeoRssHelper.Deserialize(reader);

            var geom = line.ToGeometry();

            Assert.That(geom is LineString);

            Assert.That(((LineString)geom).Positions[0] is GeographicPosition);

            Assert.AreEqual(45.256, ((GeographicPosition)((LineString)geom).Positions[0]).Latitude);

            Assert.AreEqual(-110.45, ((GeographicPosition)((LineString)geom).Positions[0]).Longitude);

            Assert.False(((LineString)geom).IsClosed());

            line = (GeoRssLine)geom.ToGeoRss();
            var sw = new StringWriter();

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

            sw.Close();

            var xml1 = sw.ToString();

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

            return(new LineString(new DirectPositionListType()
            {
                Text = georssLine.Item
            }.ToGeometry()));
        }