public void GeoRssPloygonTestCase() { string xml = "<georss:polygon xmlns:georss=\"http://www.georss.org/georss\">45.256 -110.45 46.46 -109.48 43.84 -109.86 45.256 -110.45</georss:polygon>"; var reader = XmlReader.Create(new StringReader(xml)); Terradue.GeoJson.GeoRss.GeoRssPolygon line = (Terradue.GeoJson.GeoRss.GeoRssPolygon)Terradue.GeoJson.GeoRss.GeoRssHelper.Deserialize(reader); var geom = line.ToGeometry(); Assert.That(geom is Polygon); Assert.That(((Polygon)geom).LineStrings[0].Positions[0] is GeographicPosition); Assert.AreEqual(45.256, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[0]).Latitude); Assert.AreEqual(-110.45, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[0]).Longitude); Assert.True(((Polygon)geom).LineStrings[0].IsClosed()); line = (GeoRssPolygon)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)); }
public void GeoRssWherePolygonTestCase() { string xml = "<georss:where xmlns:gml=\"http://www.opengis.net/gml\" xmlns:georss=\"http://www.georss.org/georss\">\n <gml:Polygon>\n <gml:exterior>\n <gml:LinearRing>\n <gml:posList count=\"4\">45.256 -110.45 46.46 -109.48 43.84 -109.86 45.256 -110.45</gml:posList>\n </gml:LinearRing>\n </gml:exterior>\n </gml:Polygon></georss:where>"; var reader = XmlReader.Create(new StringReader(xml)); Terradue.GeoJson.GeoRss.GeoRssWhere where = (Terradue.GeoJson.GeoRss.GeoRssWhere)Terradue.GeoJson.GeoRss.GeoRssHelper.Deserialize(reader); var geom = where.ToGeometry(); Assert.That(geom is Polygon); Assert.That(((Polygon)geom).LineStrings[0].Positions[0] is GeographicPosition); Assert.AreEqual(45.256, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[0]).Latitude); Assert.AreEqual(-110.45, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[0]).Longitude); where = geom.ToGeoRssWhere(); var sw = new StringWriter(); GeoRssHelper.Serialize(XmlWriter.Create(sw), where); sw.Close(); var xml1 = sw.ToString(); Assert.IsTrue(XNode.DeepEquals(XDocument.Parse(xml).Root, XDocument.Parse(xml1).Root)); }
public void GeoRssWherePointTestCase() { string xml = "<georss:where xmlns:gml=\"http://www.opengis.net/gml\" xmlns:georss=\"http://www.georss.org/georss\">\n <gml:Point>\n <gml:pos>45.256 -71.92</gml:pos>\n </gml:Point>\n </georss:where>"; var reader = XmlReader.Create(new StringReader(xml)); Terradue.GeoJson.GeoRss.GeoRssWhere where = (Terradue.GeoJson.GeoRss.GeoRssWhere)Terradue.GeoJson.GeoRss.GeoRssHelper.Deserialize(reader); var geom = where.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); where = geom.ToGeoRssWhere(); var sw = new StringWriter(); GeoRssHelper.Serialize(XmlWriter.Create(sw), where); sw.Close(); var xml1 = sw.ToString(); Assert.IsTrue(XNode.DeepEquals(XDocument.Parse(xml).Root, XDocument.Parse(xml1).Root)); }
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)); }
public void GeoRssBoxTestCase() { string xml = "<georss:box xmlns:georss=\"http://www.georss.org/georss\">42.943 -71.032 43.039 -69.856</georss:box>"; var reader = XmlReader.Create(new StringReader(xml)); Terradue.GeoJson.GeoRss.GeoRssBox box = (Terradue.GeoJson.GeoRss.GeoRssBox)Terradue.GeoJson.GeoRss.GeoRssHelper.Deserialize(reader); var geom = box.ToGeometry(); Assert.That(geom is Polygon); Assert.That(((Polygon)geom).LineStrings[0].Positions[0] is GeographicPosition); Assert.AreEqual(42.943, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[0]).Latitude); Assert.AreEqual(-71.032, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[0]).Longitude); Assert.AreEqual(42.943, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[1]).Latitude); Assert.AreEqual(-69.856, ((GeographicPosition)((Polygon)geom).LineStrings[0].Positions[1]).Longitude); Assert.True(((Polygon)geom).LineStrings[0].IsClosed()); var poly = (GeoRssPolygon)geom.ToGeoRss(); var sw = new StringWriter(); GeoRssHelper.Serialize(XmlWriter.Create(sw), poly); var xml1 = sw.ToString(); sw = new StringWriter(); GeoRssHelper.Serialize(XmlWriter.Create(sw), box); sw.Close(); xml1 = sw.ToString(); Assert.IsTrue(XNode.DeepEquals(XDocument.Parse(xml).Root, XDocument.Parse(xml1).Root)); }