Beispiel #1
0
        public void Verify_DbGeography_CreateProviderValue_WKT_method()
        {
            var geographyWellKnownValue = new DbGeographyWellKnownValue()
            {
                CoordinateSystemId = DefaultCoordinateSystemId,
                WellKnownBinary    = null,
                WellKnownText      = PointWKT
            };

            dynamic providerValue = spatialServices.CreateProviderValue(geographyWellKnownValue);

            Assert.Equal(PointWKT, providerValue.ToString());
        }
        public void CanUseCreateProviderValueFunction()
        {
            using (DistribuitorsContext context = new DistribuitorsContext())
            {
                context.Database.Delete();
                context.Database.Create();

                context.Distributors.Add(new Distributor()
                {
                    Name  = "Graphic Design Institute",
                    point = DbGeometry.FromText("POINT(-122.336106 47.605049)"),
                });
                context.SaveChanges();

                var point = (from u in context.Distributors
                             select u.point).First();

                var geometryWellKnownValueWKT = new DbGeometryWellKnownValue()
                {
                    CoordinateSystemId = 0,
                    WellKnownBinary    = null,
                    WellKnownText      = "POINT(1 2)"
                };

                MySqlGeometry providerValue = (MySqlGeometry)spatialServices.CreateProviderValue(geometryWellKnownValueWKT);
                Assert.AreEqual("POINT(1 2)", providerValue.ToString());


                var geometryWellKnownValueWKB = new DbGeometryWellKnownValue()
                {
                    CoordinateSystemId = 0,
                    WellKnownBinary    = providerValue.Value,
                    WellKnownText      = null
                };

                MySqlGeometry providerValue_2 = (MySqlGeometry)spatialServices.CreateProviderValue(geometryWellKnownValueWKB);
                Assert.AreEqual("POINT(1 2)", providerValue_2.ToString());

                context.Database.Delete();
            }
        }