Inheritance: abstractFeaturePropertyType, IGeoRSS
Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        public static GeometryObject ToGeometry(this GeoRssWhere where)
        {
            if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is EnvelopeType)
            {
                throw new NotImplementedException();
            }

            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);
        }