Пример #1
0
        public void FromString(String s)
        {
            if (IsGeoNull(s))
            {
                geoText = EMPTY_GEOMETRY;
            }
            else
            {
                geoText = s.Trim();
            }
            try
            {
                // Parse
                _innerValue = NTSGeographyWrapper.Parse(geoText);
                // SRID, Type & Points X, Y
                if ((!NTSGeographyWrapper.IsValid(_innerValue)) && _innerValue != null)
                {
                    //_innerValue = NTSGeographyWrapper.MakeValid(_innerValue);
                }

                this.srid = NTSGeographyWrapper.Srid(_innerValue);

                this.setGXGeoType(NTSGeographyWrapper.STGeometryType(_innerValue).ToString());
                if (GeographicType == GeoGraphicTypeValue.Point)
                {
                    this.Point.Longitude = NTSGeographyWrapper.Long(_innerValue);
                    this.Point.Latitude  = NTSGeographyWrapper.Lat(_innerValue);
                }
            }
            catch (Exception ex)
            {
                if (!String.IsNullOrEmpty(ex.ToString()) && ex.HResult == -2146232832 && ex.Message.Contains("Unknown Type"))
                {
                    if (GeographicType == GeoGraphicTypeValue.Point && !String.IsNullOrEmpty(geoText))
                    {
                        _innerValue = Geospatial.FromGXLocation(geoText);
                    }
                    else
                    {
                        // Cannot parse value
                        _innerValue          = NTSGeographyWrapper.NullSQLGeography;
                        this.geoText         = "";
                        this.Point.Longitude = 0;
                        this.Point.Latitude  = 0;
                    }
                }
                else
                {
                    // Cannot parse value
                    _innerValue          = NTSGeographyWrapper.NullSQLGeography;
                    this.geoText         = "";
                    this.Point.Longitude = 0;
                    this.Point.Latitude  = 0;
                }
            }
        }
Пример #2
0
 internal static object STGeomFromText(string geoText, int sRID)
 {
     return(NTSGeographyWrapper.Parse("SRID=" + sRID.ToString() + ";" + geoText));
 }
Пример #3
0
 internal static object GeometryParse(String geoText)
 {
     return(NTSGeographyWrapper.Parse(geoText));
 }