Exemplo n.º 1
0
        public double STDistance(Geospatial x)
        {
            if (_innerValue != null && x.InnerValue != null &&
                !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
                !x.InnerValue.ToString().Equals(EMPTY_GEOGRAPHY))
            {
                try
                {
                    return(((SqlDouble)(ClassLoader.Invoke(_innerValue, "STDistance", new object[] { x.InnerValue }))).Value);
                }
                catch (Exception ex)
                {
                    GXLogging.Debug(log, "Error calling Distance() exception:");
                    GXLogging.Debug(log, ex.ToString());
                    return(0);
                }
            }
            else
            {
                if (_innerValue == null)
                {
                    GXLogging.Debug(log, "STDistance: _innerValue is not valid");
                }
                else
                {
                    GXLogging.Debug(log, "STDistance: x.InnerValue is not valid");
                }

                return(0);
            }
        }
Exemplo n.º 2
0
 public Boolean STIntersect(Geospatial x)
 {
     if (_innerValue != null && x.InnerValue != null &&
         !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
         !x.InnerValue.ToString().Equals(EMPTY_GEOGRAPHY))
     {
         try
         {
             return(((SqlBoolean)(ClassLoader.Invoke(_innerValue, "STIntersects", new object[] { x.InnerValue }))).Equals(SqlBoolean.True));
         }
         catch (Exception ex)
         {
             GXLogging.Debug(log, "Error calling Intersect() exception:");
             GXLogging.Debug(log, ex.ToString());
             return(false);
         }
     }
     else
     {
         if (_innerValue == null)
         {
             GXLogging.Debug(log, "STIntersect: _innerValue is not valid");
         }
         else
         {
             GXLogging.Debug(log, "STIntersect: x.InnerValue is not valid");
         }
         return(false);
     }
 }
Exemplo n.º 3
0
        internal static decimal GetIfxDecimal(IDataReader reader, int i)
        {
            decimal result;
            string  ifxDecimal = ClassLoader.Invoke(reader, "GetIfxDecimal", new object[] { i }).ToString();

            Decimal.TryParse(ifxDecimal, NumberStyles.Number, CultureInfo.InvariantCulture, out result);
            return(result);
        }
Exemplo n.º 4
0
        internal static object STGeomFromText(string geoText, int sRID)
        {
            object cwPolygon    = SQLGeographyWrapper.GeometryParse(geoText);
            object stStartPoint = ClassLoader.Invoke(cwPolygon, "STStartPoint", null);
            object validPolygon = ClassLoader.Invoke(cwPolygon, "MakeValid", null);

            cwPolygon = ClassLoader.Invoke(validPolygon, "STUnion", new object[] { stStartPoint });
            object stAsText = ClassLoader.Invoke(cwPolygon, "STAsText", null);

            return(ClassLoader.InvokeStatic(SQLGeographyWrapper.GeoAssembly, SQLGeographyWrapper.SqlGeographyClass, "STGeomFromText", new object[] { stAsText, sRID }));
        }
Exemplo n.º 5
0
 internal static bool IsValid(object instance)
 {
     try
     {
         return(((SqlBoolean)ClassLoader.Invoke(instance, "STIsValid", null)).Value);
     }
     catch (MissingMethodException ex) {
         GXLogging.Debug(log, "IsValid not Found: " + ex.Message);
         return(true);
     }
 }
Exemplo n.º 6
0
 internal static decimal GetIfxDecimal(IDataReader reader, int i)
 {
     try
     {
         decimal result;
         string  ifxDecimal = ClassLoader.Invoke(reader, "GetIfxDecimal", new object[] { i }).ToString();
         Decimal.TryParse(ifxDecimal, NumberStyles.Number, CultureInfo.InvariantCulture, out result);
         return(result);
     }catch (Exception)
     {
         return(Convert.ToInt64(reader.GetValue(i)));
     }
 }
Exemplo n.º 7
0
 public double STArea()
 {
     if (_innerValue != null &&
         !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
         GeographicType == GeoGraphicTypeValue.Polygon)
     {
         try {
             return(((SqlDouble)(ClassLoader.Invoke(_innerValue, "STArea", Array.Empty <object>()))).Value);
         }
         catch (Exception ex) {
             GXLogging.Debug(log, "Error calling Area() exception:");
             GXLogging.Debug(log, ex.ToString());
             return(0);
         }
     }
     else
     {
         GXLogging.Debug(log, "STArea: _innerValue is not valid");
         return(0);
     }
 }
Exemplo n.º 8
0
        ArrayList geoToArray(String geoType, Object geoInstance)
        {
            ArrayList ArrayOfPoints = new ArrayList();

            if (geoType.Equals("MultiPoint") || geoType.Equals("LineString"))
            {
                SqlInt32 points = (SqlInt32)ClassLoader.Invoke(geoInstance, "STNumPoints", null);
                for (int i = 1; i <= points.Value; i++)
                {
                    double[] CurrentPoint = new double[2];
                    object   currentPoint = ClassLoader.Invoke(geoInstance, "STPointN", new object[] { i });
                    CurrentPoint[0] = SQLGeographyWrapper.Long(currentPoint);
                    CurrentPoint[1] = SQLGeographyWrapper.Lat(currentPoint);
                    ArrayOfPoints.Add(CurrentPoint);
                }
            }
            else if (geoType.Equals("Point"))
            {
                object currentPoint = ClassLoader.Invoke(geoInstance, "STPointN", new object[] { 1 });
                ArrayOfPoints.Add(SQLGeographyWrapper.Long(currentPoint));
                ArrayOfPoints.Add(SQLGeographyWrapper.Lat(currentPoint));
            }
            else if (geoType.Equals("Polygon"))
            {
                SqlInt32 rings = (SqlInt32)ClassLoader.Invoke(geoInstance, "NumRings", null);
                for (int j = 1; j <= rings.Value; j++)
                {
                    ArrayList RingArray   = new ArrayList();
                    object    currentRing = ClassLoader.Invoke(geoInstance, "RingN", new object[] { j });
                    SqlInt32  p           = (SqlInt32)ClassLoader.Invoke(currentRing, "STNumPoints", null);

                    for (int i = 1; i < p.Value; i++)
                    {
                        double[] CurrentPoint = new double[2];
                        object   currentPoint = ClassLoader.Invoke(currentRing, "STPointN", new object[] { i });
                        CurrentPoint[0] = SQLGeographyWrapper.Long(currentPoint);
                        CurrentPoint[1] = SQLGeographyWrapper.Lat(currentPoint);
                        RingArray.Add(CurrentPoint);
                    }
                    ArrayOfPoints.Add(RingArray);
                }
            }
            else if (geoType.Equals("MultiLineString"))
            {
                SqlInt32 geoms = (SqlInt32)ClassLoader.Invoke(geoInstance, "STNumGeometries", null);
                for (int j = 1; j <= geoms.Value; j++)
                {
                    object currentgeom = ClassLoader.Invoke(geoInstance, "STGeometryN", new object[] { j });
                    ArrayOfPoints.Add(geoToArray("LineString", currentgeom));
                }
            }
            else if (geoType.Equals("MultiPolygon"))
            {
                SqlInt32 geoms = (SqlInt32)ClassLoader.Invoke(geoInstance, "STNumGeometries", null);
                for (int j = 1; j <= geoms.Value; j++)
                {
                    object currentgeom = ClassLoader.Invoke(geoInstance, "STGeometryN", new object[] { j });
                    ArrayOfPoints.Add(geoToArray("Polygon", currentgeom));
                }
            }
            return(ArrayOfPoints);
        }
Exemplo n.º 9
0
 internal static object STGeometryType(object instance)
 {
     return(ClassLoader.Invoke(instance, "STGeometryType", null));
 }
Exemplo n.º 10
0
 internal static object MakeValid(object instance)
 {
     return(ClassLoader.Invoke(instance, "MakeValid", null));
 }
Exemplo n.º 11
0
 public static string Suggest(string phrase)
 {
     return((string)ClassLoader.Invoke(m_SpellingInstance, "Suggest", new object[] { phrase }));
 }
Exemplo n.º 12
0
 public static bool BuildDictionary()
 {
     return((bool)ClassLoader.Invoke(m_SpellingInstance, "BuildDictionary", null));
 }
Exemplo n.º 13
0
 public static SearchResult Search(string query, int itemsPerPage, int pageNumber, IGxContext context)
 {
     return((SearchResult)ClassLoader.Invoke(m_SearcherInstance, "Search", new object[] { query, itemsPerPage, pageNumber, context }));
 }
Exemplo n.º 14
0
 public static bool RemoveEntity(string entityType)
 {
     return((bool)ClassLoader.Invoke(m_IndexerInstance, "RemoveEntity", new object[] { entityType }));
 }
Exemplo n.º 15
0
 public static bool RemoveContent(object obj)
 {
     return((bool)ClassLoader.Invoke(m_IndexerInstance, "RemoveContent", new object[] { obj }));
 }
Exemplo n.º 16
0
 public static bool UpdateContent(object obj, GxContentInfo contentInfo)
 {
     return((bool)ClassLoader.Invoke(m_IndexerInstance, "UpdateContent", new object[] { obj, contentInfo }));
 }