/// <summary> /// Creates a provider-specific value compatible with this spatial services implementation based on the specified well known <see cref="DbGeometry"/> representation. /// </summary> /// <param name="wellKnownValue">An instance of <see cref="DbGeometryWellKnownValue"/> that contains the well known representation of a geometry value.</param> /// <returns>A provider-specific value that encodes the information contained in <paramref name="wellKnownValue"/> in a fashion compatible with this spatial services implementation.</returns> /// <exception cref="ArgumentNullException"><paramref name="wellKnownValue"/> is null.</exception> public abstract object CreateProviderValue(DbGeometryWellKnownValue wellKnownValue);
public override object CreateProviderValue(DbGeometryWellKnownValue wellKnownValue) { wellKnownValue.CheckNull("wellKnownValue"); return new ReadOnlySpatialValues(wellKnownValue.CoordinateSystemId, wellKnownValue.WellKnownText, wellKnownValue.WellKnownBinary, gmlValue: null); }
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(); } }
public override object CreateProviderValue(DbGeometryWellKnownValue wellKnownValue) { if (wellKnownValue == null) throw new ArgumentNullException("wellKnownValue"); if (wellKnownValue.WellKnownText != null) { var mysqlGeometry = new MySqlGeometry(true); MySqlGeometry.TryParse(wellKnownValue.WellKnownText.ToString(), out mysqlGeometry); return mysqlGeometry; } else if (wellKnownValue.WellKnownBinary != null) { var mysqlGeometry = new MySqlGeometry(MySqlDbType.Geometry, wellKnownValue.WellKnownBinary); return mysqlGeometry; } return null; }
public void Verify_DbGeometry_CreateProviderValue_WKB_method() { var geometryWellKnownValue = new DbGeometryWellKnownValue() { CoordinateSystemId = DefaultCoordinateSystemId, WellKnownBinary = PointWKB, WellKnownText = null }; dynamic providerValue = spatialServices.CreateProviderValue(geometryWellKnownValue); Assert.Equal(PointWKT, providerValue.ToString()); }
public override object CreateProviderValue(DbGeometryWellKnownValue wellKnownValue) { CheckParameterNotNull("wellKnownValue", wellKnownValue); if (wellKnownValue.WellKnownText != null) { return InvokeStaticFunction( SqlTypes.SqlGeometryType, "STGeomFromText", SqlTypes.SqlCharsFromString(wellKnownValue.WellKnownText), wellKnownValue.CoordinateSystemId); } else if (wellKnownValue.WellKnownBinary != null) { return InvokeStaticFunction( SqlTypes.SqlGeometryType, "STGeomFromWKB", SqlTypes.SqlBytesFromByteArray(wellKnownValue.WellKnownBinary), wellKnownValue.CoordinateSystemId); } else { throw new ArgumentException("wellKnownValue"); } }
public override object CreateProviderValue(DbGeometryWellKnownValue wellKnownValue) { wellKnownValue.CheckNull("wellKnownValue"); return(new ReadOnlySpatialValues(wellKnownValue.CoordinateSystemId, wellKnownValue.WellKnownText, wellKnownValue.WellKnownBinary, gmlValue: null)); }