Пример #1
0
        public Geospatial(String value)
        {
            String s = value.ToString();

            initInstanceVars();
            this.FromString(s);
            // serttype
            this.setGXGeoType(NTSGeographyWrapper.STGeometryType(_innerValue).ToString());
        }
Пример #2
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;
                }
            }
        }
Пример #3
0
        public Geospatial(object value)
        {
            Geospatial geo = value as Geospatial;

            if (geo != null)
            {
                this.InnerValue = geo.InnerValue;
                // settype
                this.setGXGeoType(NTSGeographyWrapper.STGeometryType(_innerValue).ToString());
                this.srid = geo.srid;
            }
            else
            {
                String s = value.ToString();
                new Geospatial(s);
            }
        }