Esempio n. 1
0
        public void Point_Test()
        {
            var       wktConverter = new WktConverter();
            IGeometry geom         = wktConverter.FromWkt(null, "POINT(1 2)");
            IGeometry geom2        = wktConverter.FromWkt(null, "POINT(-7330.778696 4662.77960)");

            Assert.IsInstanceOf <Point>(geom);
            Assert.IsInstanceOf <Point>(geom2);

            var p  = (Point)geom;
            var p2 = (Point)geom2;

            Assert.IsNull(p.Csid);
            AssertPoint(1, 2, p);

            AssertPoint(-7330.778696, 4662.77960, p2);
        }
Esempio n. 2
0
        public void LinestringTest()
        {
            var       wktConverter = new WktConverter();
            IGeometry geom         = wktConverter.FromWkt(null, "LINESTRING (1 1, 3 3, 2 4, 2 0)");

            Assert.IsInstanceOf <Path>(geom);

            var p = (Path)geom;

            Assert.IsNull(p.Csid);
            Assert.AreEqual(3, p.Lines.Count);
            AssertLine(1, 1, 3, 3, p.Lines[0]);
            AssertLine(3, 3, 2, 4, p.Lines[1]);
            AssertLine(2, 4, 2, 0, p.Lines[2]);
        }
Esempio n. 3
0
        public void PolygonTest()
        {
            var       wktConverter = new WktConverter();
            IGeometry geom         = wktConverter.FromWkt(null, "POLYGON((1 1, 3 3, 3 1, 1 1))");

            Assert.IsInstanceOf <Polygon>(geom);

            var p = (Polygon)geom;

            Assert.IsNull(p.Csid);
            Assert.AreEqual(3, p.Lines.Count);
            AssertLine(1, 1, 3, 3, p.Lines[0]);
            AssertLine(3, 3, 3, 1, p.Lines[1]);
            AssertLine(3, 1, 1, 1, p.Lines[2]);
        }
Esempio n. 4
0
        /// <summary>
        /// SQL Server DTO mapper accounting for SQL
        /// </summary>
        /// <param name="dataValue">Data value</param>
        /// <param name="dataValueType">Data value type</param>
        /// <param name="customMap">Converted value</param>
        /// <returns>True if mapping was successful</returns>
        public override bool TryCustomMap(object dataValue, Type dataValueType, out object customMap)
        {
            customMap = null;

            if (!dataValueType.Equals(typeof(SqlGeometry)))
            {
                return(false);
            }

            var geom = dataValue as SqlGeometry;
            int?csid = geom.STSrid.Value;

            string wkt       = geom.STAsText().ToSqlString().Value;
            var    converter = new WktConverter();

            customMap = converter.FromWkt(csid, wkt);
            return(true);
        }