DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
Deveel.Data.Spatial.SqlGeometry Class Reference
Inheritance diagram for Deveel.Data.Spatial.SqlGeometry:
Deveel.Data.Sql.Objects.ISqlObject

Public Member Functions

int CompareTo (SqlGeometry other)
 
bool IsComparableTo (SqlGeometry other)
 
SqlGeometry Buffer (SqlNumber distance)
 
SqlGeometry Buffer (double distance)
 
SqlNumber Distance (SqlGeometry geometry)
 
SqlBoolean Contains (SqlGeometry other)
 
SqlBinary ToWellKnownBytes ()
 
override string ToString ()
 
SqlString ToWellKnownText ()
 

Static Public Member Functions

static bool TryParse (string text, out SqlGeometry geometry)
 
static SqlGeometry Parse (string text)
 
static bool TryParse (byte[] bytes, out SqlGeometry geometry)
 
static SqlGeometry Parse (byte[] bytes)
 

Static Public Attributes

static SqlGeometry Null = new SqlGeometry(null, true)
 

Properties

IGeometry Geometry [get, set]
 
bool IsNull [get, private set]
 
SqlString GeometryType [get]
 
SqlNumber Area [get]
 
SqlNumber Length [get]
 
SqlGeometry Boundary [get]
 
SqlGeometry Envelope [get]
 
- Properties inherited from Deveel.Data.Sql.Objects.ISqlObject
bool IsNull [get]
 Gets a boolean value indicating if the object is NULL. More...
 

Private Member Functions

 SqlGeometry (IGeometry geometry, bool isNull)
 
 SqlGeometry (IGeometry geometry)
 
int IComparable. CompareTo (object obj)
 
int IComparable< ISqlObject >. CompareTo (ISqlObject other)
 
bool ISqlObject. IsComparableTo (ISqlObject other)
 Checks if the current object is comparable with the given one. More...
 

Static Private Member Functions

static bool TryParse (string text, out SqlGeometry geometry, out Exception error)
 
static bool TryParse (byte[] bytes, out SqlGeometry geometry, out Exception error)
 

Static Private Attributes

static readonly IGeometryServices DefaultGeometryServices = new NtsGeometryServices()
 
static readonly IGeometryFactory DefaultGeometryFactory = new GeometryFactory()
 

Detailed Description

Definition at line 14 of file SqlGeometry.cs.

Constructor & Destructor Documentation

Deveel.Data.Spatial.SqlGeometry.SqlGeometry ( IGeometry  geometry,
bool  isNull 
)
inlineprivate

Definition at line 22 of file SqlGeometry.cs.

22  {
23  Geometry = geometry;
24  IsNull = isNull;
25  }
Deveel.Data.Spatial.SqlGeometry.SqlGeometry ( IGeometry  geometry)
inlineprivate

Definition at line 27 of file SqlGeometry.cs.

28  : this(geometry, false) {
29  if (geometry == null)
30  throw new ArgumentNullException("geometry");
31  }

Member Function Documentation

SqlGeometry Deveel.Data.Spatial.SqlGeometry.Buffer ( SqlNumber  distance)
inline

Definition at line 116 of file SqlGeometry.cs.

116  {
117  if (distance.IsNull)
118  return Null;
119 
120  return Buffer(distance.ToDouble());
121  }
double IConvertible. ToDouble(IFormatProvider provider)
Definition: SqlNumber.cs:317
SqlGeometry Buffer(SqlNumber distance)
Definition: SqlGeometry.cs:116
SqlGeometry Deveel.Data.Spatial.SqlGeometry.Buffer ( double  distance)
inline

Definition at line 123 of file SqlGeometry.cs.

123  {
124  var result = Geometry.Buffer(distance);
125  return new SqlGeometry(result);
126  }
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
int IComparable. Deveel.Data.Spatial.SqlGeometry.CompareTo ( object  obj)
inlineprivate

Definition at line 35 of file SqlGeometry.cs.

35  {
36  if (!(obj is SqlGeometry))
37  throw new ArgumentException();
38 
39  return CompareTo((SqlGeometry) obj);
40  }
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
int IComparable. CompareTo(object obj)
Definition: SqlGeometry.cs:35
int IComparable<ISqlObject>. Deveel.Data.Spatial.SqlGeometry.CompareTo ( ISqlObject  other)
inlineprivate

Definition at line 42 of file SqlGeometry.cs.

42  {
43  if (!(other is SqlGeometry))
44  throw new ArgumentException();
45 
46  return CompareTo((SqlGeometry)other);
47  }
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
int IComparable. CompareTo(object obj)
Definition: SqlGeometry.cs:35
int Deveel.Data.Spatial.SqlGeometry.CompareTo ( SqlGeometry  other)
inline

Definition at line 49 of file SqlGeometry.cs.

49  {
50  return Geometry.CompareTo(other.Geometry);
51  }
SqlBoolean Deveel.Data.Spatial.SqlGeometry.Contains ( SqlGeometry  other)
inline

Definition at line 136 of file SqlGeometry.cs.

136  {
137  if (IsNull || (other == null || other.IsNull))
138  return SqlBoolean.Null;
139 
140  return Geometry.Contains(other.Geometry);;
141  }
SqlNumber Deveel.Data.Spatial.SqlGeometry.Distance ( SqlGeometry  geometry)
inline

Definition at line 128 of file SqlGeometry.cs.

128  {
129  if (IsNull || (geometry == null || geometry.IsNull))
130  return SqlNumber.Null;
131 
132  var result = Geometry.Distance(geometry.Geometry);
133  return new SqlNumber(result);
134  }
static readonly SqlNumber Null
Definition: SqlNumber.cs:31
bool ISqlObject. Deveel.Data.Spatial.SqlGeometry.IsComparableTo ( ISqlObject  other)
inlineprivate

Checks if the current object is comparable with the given one.

Parameters
otherThe other ISqlObject to compare.
Returns
Returns true if the current object is comparable with the given one, false otherwise.

Implements Deveel.Data.Sql.Objects.ISqlObject.

Definition at line 100 of file SqlGeometry.cs.

100  {
101  if (!(other is SqlGeometry))
102  return false;
103 
104  return IsComparableTo((SqlGeometry)other);
105  }
bool ISqlObject. IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
Definition: SqlGeometry.cs:100
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
bool Deveel.Data.Spatial.SqlGeometry.IsComparableTo ( SqlGeometry  other)
inline

Definition at line 107 of file SqlGeometry.cs.

107  {
108  if (IsNull && (other == null || other.IsNull))
109  return true;
110  if (!IsNull && (other != null && !other.IsNull))
111  return false;
112 
113  return true;
114  }
static SqlGeometry Deveel.Data.Spatial.SqlGeometry.Parse ( string  text)
inlinestatic

Definition at line 196 of file SqlGeometry.cs.

196  {
197  Exception error;
198  SqlGeometry geometry;
199  if (!TryParse(text, out geometry, out error))
200  throw new FormatException(String.Format("Could not parse the input string '{0}' to a valid GEOMETRY.", text), error);
201 
202  return geometry;
203  }
A long string in the system.
static bool TryParse(string text, out SqlGeometry geometry, out Exception error)
Definition: SqlGeometry.cs:166
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
static SqlGeometry Deveel.Data.Spatial.SqlGeometry.Parse ( byte[]  bytes)
inlinestatic

Definition at line 235 of file SqlGeometry.cs.

235  {
236  Exception error;
237  SqlGeometry geometry;
238  if (!TryParse(bytes, out geometry, out error))
239  throw new FormatException("Could not parse the input bytes to a valid GEOMETRY.", error);
240 
241  return geometry;
242  }
static bool TryParse(string text, out SqlGeometry geometry, out Exception error)
Definition: SqlGeometry.cs:166
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
override string Deveel.Data.Spatial.SqlGeometry.ToString ( )
inline

Definition at line 151 of file SqlGeometry.cs.

151  {
152  if (IsNull)
153  return String.Empty;
154 
155  return ToWellKnownText().ToString();
156  }
A long string in the system.
string ToString(Encoding encoding)
Definition: SqlString.cs:182
SqlBinary Deveel.Data.Spatial.SqlGeometry.ToWellKnownBytes ( )
inline

Definition at line 143 of file SqlGeometry.cs.

143  {
144  if (IsNull)
145  return SqlBinary.Null;
146 
147  var bytes = Geometry.AsBinary();
148  return new SqlBinary(bytes);
149  }
Implements a BINARY object that handles a limited number of bytes, not exceding MaxLength.
Definition: SqlBinary.cs:27
static readonly SqlBinary Null
Definition: SqlBinary.cs:29
SqlString Deveel.Data.Spatial.SqlGeometry.ToWellKnownText ( )
inline

Definition at line 158 of file SqlGeometry.cs.

158  {
159  if (IsNull)
160  return SqlString.Null;
161 
162  var text = Geometry.AsText();
163  return new SqlString(text);
164  }
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
static bool Deveel.Data.Spatial.SqlGeometry.TryParse ( string  text,
out SqlGeometry  geometry,
out Exception  error 
)
inlinestaticprivate

Definition at line 166 of file SqlGeometry.cs.

166  {
167  if (String.IsNullOrEmpty(text)) {
168  geometry = Null;
169  error = new ArgumentNullException("text");
170  return false;
171  }
172 
173  try {
174  var reader = new WKTReader(DefaultGeometryFactory);
175 
176  IGeometry g;
177  using (var textReader = new StringReader(text)) {
178  g = reader.Read(textReader);
179  }
180 
181  geometry = new SqlGeometry(g);
182  error = null;
183  return true;
184  } catch (Exception ex) {
185  geometry = Null;
186  error = ex;
187  return false;
188  }
189  }
A long string in the system.
static readonly IGeometryFactory DefaultGeometryFactory
Definition: SqlGeometry.cs:19
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22
static bool Deveel.Data.Spatial.SqlGeometry.TryParse ( string  text,
out SqlGeometry  geometry 
)
inlinestatic

Definition at line 191 of file SqlGeometry.cs.

191  {
192  Exception error;
193  return TryParse(text, out geometry, out error);
194  }
static bool TryParse(string text, out SqlGeometry geometry, out Exception error)
Definition: SqlGeometry.cs:166
static bool Deveel.Data.Spatial.SqlGeometry.TryParse ( byte[]  bytes,
out SqlGeometry  geometry 
)
inlinestatic

Definition at line 205 of file SqlGeometry.cs.

205  {
206  Exception error;
207  return TryParse(bytes, out geometry, out error);
208  }
static bool TryParse(string text, out SqlGeometry geometry, out Exception error)
Definition: SqlGeometry.cs:166
static bool Deveel.Data.Spatial.SqlGeometry.TryParse ( byte[]  bytes,
out SqlGeometry  geometry,
out Exception  error 
)
inlinestaticprivate

Definition at line 210 of file SqlGeometry.cs.

210  {
211  if (bytes == null) {
212  geometry = Null;
213  error = new ArgumentNullException("bytes");
214  return false;
215  }
216 
217  IGeometry g;
218 
219  try {
220  var reader = new WKBReader(DefaultGeometryServices);
221  using (var stream = new MemoryStream(bytes)) {
222  g = reader.Read(stream);
223  }
224 
225  geometry = new SqlGeometry(g);
226  error = null;
227  return true;
228  } catch (Exception ex) {
229  error = ex;
230  geometry = Null;
231  return false;
232  }
233  }
static readonly IGeometryServices DefaultGeometryServices
Definition: SqlGeometry.cs:18
SqlGeometry(IGeometry geometry, bool isNull)
Definition: SqlGeometry.cs:22

Member Data Documentation

readonly IGeometryFactory Deveel.Data.Spatial.SqlGeometry.DefaultGeometryFactory = new GeometryFactory()
staticprivate

Definition at line 19 of file SqlGeometry.cs.

readonly IGeometryServices Deveel.Data.Spatial.SqlGeometry.DefaultGeometryServices = new NtsGeometryServices()
staticprivate

Definition at line 18 of file SqlGeometry.cs.

SqlGeometry Deveel.Data.Spatial.SqlGeometry.Null = new SqlGeometry(null, true)
static

Definition at line 15 of file SqlGeometry.cs.

Property Documentation

SqlNumber Deveel.Data.Spatial.SqlGeometry.Area
get

Definition at line 64 of file SqlGeometry.cs.

SqlGeometry Deveel.Data.Spatial.SqlGeometry.Boundary
get

Definition at line 82 of file SqlGeometry.cs.

SqlGeometry Deveel.Data.Spatial.SqlGeometry.Envelope
get

Definition at line 91 of file SqlGeometry.cs.

IGeometry Deveel.Data.Spatial.SqlGeometry.Geometry
getsetprivate

Definition at line 33 of file SqlGeometry.cs.

SqlString Deveel.Data.Spatial.SqlGeometry.GeometryType
get

Definition at line 55 of file SqlGeometry.cs.

bool Deveel.Data.Spatial.SqlGeometry.IsNull
getprivate set

Definition at line 53 of file SqlGeometry.cs.

SqlNumber Deveel.Data.Spatial.SqlGeometry.Length
get

Definition at line 73 of file SqlGeometry.cs.


The documentation for this class was generated from the following file: