public override object CreateProviderValue(DbGeographyWellKnownValue wellKnownValue)
        {
            CheckParameterNotNull("wellKnownValue", wellKnownValue);

            if (wellKnownValue.WellKnownText != null)
            {
                return(InvokeStaticFunction(
                           SqlTypes.SqlGeographyType,
                           "STGeomFromText",
                           SqlTypes.SqlCharsFromString(wellKnownValue.WellKnownText),
                           wellKnownValue.CoordinateSystemId));
            }
            else if (wellKnownValue.WellKnownBinary != null)
            {
                return(InvokeStaticFunction(
                           SqlTypes.SqlGeographyType,
                           "STGeomFromWKB",
                           SqlTypes.SqlBytesFromByteArray(wellKnownValue.WellKnownBinary),
                           wellKnownValue.CoordinateSystemId));
            }
            else
            {
                throw new ArgumentException("wellKnownValue");
            }
        }
Beispiel #2
0
        public void Verify_DbGeography_CreateProviderValue_WKB_method()
        {
            var geographyWellKnownValue = new DbGeographyWellKnownValue()
            {
                CoordinateSystemId = DefaultCoordinateSystemId,
                WellKnownBinary    = PointWKB,
                WellKnownText      = null
            };

            dynamic providerValue = spatialServices.CreateProviderValue(geographyWellKnownValue);

            Assert.Equal(PointWKT, providerValue.ToString());
        }
        /// <summary>
        /// Get sql grography object from well known text
        /// </summary>
        /// <param name="wkt">Well known text representation of the value</param>
        /// <param name="srid">The identifier associated with the coordinate system.</param>
        /// <returns></returns>
        public override object GetSqlGeography(string wkt, int srid)
        {
#if EF6
            var geo = new DbGeographyWellKnownValue
            {
                WellKnownText      = wkt,
                CoordinateSystemId = srid
            };

            return(DbSpatialServices.Default.CreateProviderValue(geo));
#endif
#if EF5
            return(DbGeography.FromText(wkt, srid));
#endif
        }
        public override DbGeographyWellKnownValue CreateWellKnownValue(DbGeography geographyValue)
        {
            geographyValue.CheckNull("geographyValue");
            var spatialValue = geographyValue.AsSpatialValue();

            DbGeographyWellKnownValue result = CreateWellKnownValue(spatialValue,
                                                                    () => SpatialExceptions.CouldNotCreateWellKnownGeographyValueNoSrid("geographyValue"),
                                                                    () => SpatialExceptions.CouldNotCreateWellKnownGeographyValueNoWkbOrWkt("geographyValue"),
                                                                    (srid, wkb, wkt) => new DbGeographyWellKnownValue()
            {
                CoordinateSystemId = srid, WellKnownBinary = wkb, WellKnownText = wkt
            });

            return(result);
        }
        public override object CreateProviderValue(DbGeographyWellKnownValue wellKnownValue)
        {
            wellKnownValue.CheckNull("wellKnownValue");

            object result = null;

            if (wellKnownValue.WellKnownText != null)
            {
                result = this.SqlTypes.SqlTypesGeographyFromText(wellKnownValue.WellKnownText, wellKnownValue.CoordinateSystemId);
            }
            else if (wellKnownValue.WellKnownBinary != null)
            {
                result = this.SqlTypes.SqlTypesGeographyFromBinary(wellKnownValue.WellKnownBinary, wellKnownValue.CoordinateSystemId);
            }
            else
            {
                throw SpatialExceptions.WellKnownGeographyValueNotValid("wellKnownValue");
            }

            return(result);
        }
Beispiel #6
0
 public override object CreateProviderValue(DbGeographyWellKnownValue wellKnownValue)
 {
     throw new NotImplementedException();
 }
 public override object CreateProviderValue(DbGeographyWellKnownValue wellKnownValue)
 {
     throw new NotImplementedException();
 }