Пример #1
0
        protected override byte[] Write(IGeometry gIn)
        {
            var writer = new GaiaGeoWriter();

            writer.HandleOrdinates = Ordinates;
            writer.UseCompressed   = Compressed;

            var b = writer.Write(gIn);

            using (SQLiteConnection conn = new SQLiteConnection("Data Source=\"" + Name + "\""))
            {
                conn.Open();
                using (SQLiteCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO \"nts_io_spatialite\" VALUES(@P1, @P3, @P2);";
                    SQLiteParameter p1 = new SQLiteParameter("P1", DbType.Int32)
                    {
                        Value = this.Counter
                    };
                    SQLiteParameter p2 = new SQLiteParameter("P2", DbType.String)
                    {
                        Value = gIn.AsText()
                    };
                    SQLiteParameter p3 = new SQLiteParameter("P3", DbType.Binary)
                    {
                        Value = b
                    };
                    cmd.Parameters.AddRange(new[] { p1, p2, p3 });
                    cmd.ExecuteNonQuery();
                }
            }
            return(b);
        }
        public void TestIssue132Polygons()
        {
            var pts     = new[] { new Coordinate(0, 0), new Coordinate(10, 10), new Coordinate(20, 20) };
            var polys   = new IPolygon[3];
            var pm      = GeoAPI.GeometryServiceProvider.Instance.CreatePrecisionModel(10d);
            var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(pm, 4326);

            for (var i = 0; i < pts.Length; i++)
            {
                polys[i] = (IPolygon)factory.CreatePoint(pts[i]).Buffer(4d, 1);
            }
            var mp = factory.CreateMultiPolygon(polys);

            Console.WriteLine(mp);

            var gc = factory.CreateGeometryCollection(new IGeometry[] { mp });

            Console.WriteLine(gc);

            var writer = new GaiaGeoWriter();
            var buffer = writer.Write(gc);

            Console.WriteLine("Hex: {0}", WKBWriter.ToHex(buffer));

            var reader = new GaiaGeoReader(factory.CoordinateSequenceFactory, factory.PrecisionModel);
            var gc2    = reader.Read(buffer);

            Assert.IsNotNull(gc2);
            Assert.IsTrue(gc.EqualsExact(gc2));
        }
        public void TestIssue132LineStrings()
        {
            var pts   = new[] { new Coordinate(0, 0), new Coordinate(10, 10), new Coordinate(20, 20), new Coordinate(30, 30) };
            var lines = new ILineString[2];

            var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);

            for (var i = 0; i < pts.Length; i += 2)
            {
                lines[i / 2] = factory.CreateLineString(new[] { pts[i], pts[i + 1] });
            }
            var mp = factory.CreateMultiLineString(lines);

            Console.WriteLine(mp);

            var gc = factory.CreateGeometryCollection(new IGeometry[] { mp });

            Console.WriteLine(gc);

            var writer = new GaiaGeoWriter();
            var buffer = writer.Write(gc);

            Console.WriteLine("Hex: {0}", WKBWriter.ToHex(buffer));

            var reader = new GaiaGeoReader(factory.CoordinateSequenceFactory, factory.PrecisionModel);
            var gc2    = reader.Read(buffer);

            Assert.IsNotNull(gc2);
            Assert.IsTrue(gc.EqualsExact(gc2));
        }
        public void TestIssue132Points()
        {
            var pts     = new[] { new Coordinate(0, 0), new Coordinate(10, 10), new Coordinate(20, 20) };
            var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);
            var mp      = factory.CreateMultiPoint(pts);

            Console.WriteLine(mp);

            var gc = factory.CreateGeometryCollection(new IGeometry[] { mp });

            Console.WriteLine(gc);

            var writer = new GaiaGeoWriter();
            var buffer = writer.Write(gc);

            Console.WriteLine("Hex: {0}", WKBWriter.ToHex(buffer));

            var reader = new GaiaGeoReader(factory.CoordinateSequenceFactory, factory.PrecisionModel);
            var gc2    = reader.Read(buffer);

            Assert.IsNotNull(gc2);
            Assert.IsTrue(gc.EqualsExact(gc2));
        }
        protected override byte[] Write(IGeometry gIn)
        {
            var writer = new GaiaGeoWriter();
            writer.HandleOrdinates = Ordinates;
            writer.UseCompressed = Compressed;

            var b = writer.Write(gIn);
            using (SQLiteConnection conn = new SQLiteConnection("Data Source=\"" + Name + "\""))
            {
                conn.Open();
                using (SQLiteCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO \"nts_io_spatialite\" VALUES(@P1, @P3, @P2);";
                    SQLiteParameter p1 = new SQLiteParameter("P1", DbType.Int32) { Value = this.Counter };
                    SQLiteParameter p2 = new SQLiteParameter("P2", DbType.String) { Value = gIn.AsText() };
                    SQLiteParameter p3 = new SQLiteParameter("P3", DbType.Binary) { Value = b };
                    cmd.Parameters.AddRange(new[] { p1, p2, p3 });
                    cmd.ExecuteNonQuery();
                }
            }
            return b;
        }
Пример #6
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public GeometryValueConverter(GaiaGeoReader reader, GaiaGeoWriter writer)
     : base(
         g => writer.Write(g),
         b => (TGeometry)reader.Read(b))
 {
 }