//------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner willa // @backupOwner [....] //------------------------------------------------------------------------------ using System.Data.Common.Internal; using System.ComponentModel.DataAnnotations; using System.Data.Spatial.Internal; using System.Diagnostics; using System.Runtime.Serialization; using System.Globalization; namespace System.Data.Spatial { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] [DataContract] [Serializable] [BindableType] public class DbGeometry { private DbSpatialServices spatialSvcs; private object providerValue; internal DbGeometry(DbSpatialServices spatialServices, object spatialProviderValue) { Debug.Assert(spatialServices != null, "Spatial services are required"); Debug.Assert(spatialProviderValue != null, "Provider value is required"); this.spatialSvcs = spatialServices; this.providerValue = spatialProviderValue; } /// /// Gets the default coordinate system id (SRID) for geometry values. /// public static int DefaultCoordinateSystemId { get { return 0; } } /// /// Gets a representation of this DbGeometry value that is specific to the underlying provider that constructed it. /// public object ProviderValue { get { return this.providerValue; } } /// /// Gets or sets a data contract serializable well known representation of this DbGeometry value. /// [DataMember(Name = "Geometry")] public DbGeometryWellKnownValue WellKnownValue { get { return this.spatialSvcs.CreateWellKnownValue(this); } set { if (this.spatialSvcs != null) { throw SpatialExceptions.WellKnownValueSerializationPropertyNotDirectlySettable(); } DbSpatialServices resolvedServices = DbSpatialServices.Default; this.providerValue = resolvedServices.CreateProviderValue(value); this.spatialSvcs = resolvedServices; } } #region Well Known Binary Static Constructors /// /// Creates a new value based on the specified well known binary value. /// /// A byte array that contains a well known binary representation of the geometry value. /// A new DbGeometry value as defined by the well known binary value with the default geometry coordinate system identifier (). /// is null. public static DbGeometry FromBinary(byte[] wellKnownBinary) { wellKnownBinary.CheckNull("wellKnownBinary"); return DbSpatialServices.Default.GeometryFromBinary(wellKnownBinary); } /// /// Creates a new value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry FromBinary(byte[] wellKnownBinary, int coordinateSystemId) { wellKnownBinary.CheckNull("wellKnownBinary"); return DbSpatialServices.Default.GeometryFromBinary(wellKnownBinary, coordinateSystemId); } /// /// Creates a new line value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry LineFromBinary(byte[] lineWellKnownBinary, int coordinateSystemId) { lineWellKnownBinary.CheckNull("lineWellKnownBinary"); return DbSpatialServices.Default.GeometryLineFromBinary(lineWellKnownBinary, coordinateSystemId); } /// /// Creates a new point value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry PointFromBinary(byte[] pointWellKnownBinary, int coordinateSystemId) { pointWellKnownBinary.CheckNull("pointWellKnownBinary"); return DbSpatialServices.Default.GeometryPointFromBinary(pointWellKnownBinary, coordinateSystemId); } /// /// Creates a new polygon value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry PolygonFromBinary(byte[] polygonWellKnownBinary, int coordinateSystemId) { polygonWellKnownBinary.CheckNull("polygonWellKnownBinary"); return DbSpatialServices.Default.GeometryPolygonFromBinary(polygonWellKnownBinary, coordinateSystemId); } /// /// Creates a new multi-line value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "MultiLine", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "multiLine", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "multi", Justification = "Match OGC, EDM")] public static DbGeometry MultiLineFromBinary(byte[] multiLineWellKnownBinary, int coordinateSystemId) { multiLineWellKnownBinary.CheckNull("multiLineWellKnownBinary"); return DbSpatialServices.Default.GeometryMultiLineFromBinary(multiLineWellKnownBinary, coordinateSystemId); } /// /// Creates a new multi-point value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "MultiPoint", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "multiPoint", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "multi", Justification = "Match OGC, EDM")] public static DbGeometry MultiPointFromBinary(byte[] multiPointWellKnownBinary, int coordinateSystemId) { multiPointWellKnownBinary.CheckNull("multiPointWellKnownBinary"); return DbSpatialServices.Default.GeometryMultiPointFromBinary(multiPointWellKnownBinary, coordinateSystemId); } /// /// Creates a new multi-polygon value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "multi", Justification = "Match OGC, EDM")] public static DbGeometry MultiPolygonFromBinary(byte[] multiPolygonWellKnownBinary, int coordinateSystemId) { multiPolygonWellKnownBinary.CheckNull("multiPolygonWellKnownBinary"); return DbSpatialServices.Default.GeometryMultiPolygonFromBinary(multiPolygonWellKnownBinary, coordinateSystemId); } /// /// Creates a new collection value based on the specified well known binary value and coordinate system identifier (SRID). /// /// A byte array that contains a well known binary representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known binary value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry GeometryCollectionFromBinary(byte[] geometryCollectionWellKnownBinary, int coordinateSystemId) { geometryCollectionWellKnownBinary.CheckNull("geometryCollectionWellKnownBinary"); return DbSpatialServices.Default.GeometryCollectionFromBinary(geometryCollectionWellKnownBinary, coordinateSystemId); } #endregion #region GML Static Constructors /// /// Creates a new value based on the specified Geography Markup Language (GML) value. /// /// A string that contains a Geography Markup Language (GML) representation of the geometry value. /// A new DbGeometry value as defined by the GML value with the default geometry coordinate system identifier (SRID) (). /// is null. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gml")] public static DbGeometry FromGml(string geometryMarkup) { geometryMarkup.CheckNull("geometryMarkup"); return DbSpatialServices.Default.GeometryFromGml(geometryMarkup); } /// /// Creates a new value based on the specified Geography Markup Language (GML) value and coordinate system identifier (SRID). /// /// A string that contains a Geography Markup Language (GML) representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the GML value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gml")] public static DbGeometry FromGml(string geometryMarkup, int coordinateSystemId) { geometryMarkup.CheckNull("geometryMarkup"); return DbSpatialServices.Default.GeometryFromGml(geometryMarkup, coordinateSystemId); } #endregion #region Well Known Text Static Constructors /// /// Creates a new value based on the specified well known text value. /// /// A string that contains a well known text representation of the geometry value. /// A new DbGeometry value as defined by the well known text value with the default geometry coordinate system identifier (SRID) (). /// is null. public static DbGeometry FromText(string wellKnownText) { wellKnownText.CheckNull("wellKnownText"); return DbSpatialServices.Default.GeometryFromText(wellKnownText); } /// /// Creates a new value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry FromText(string wellKnownText, int coordinateSystemId) { wellKnownText.CheckNull("wellKnownText"); return DbSpatialServices.Default.GeometryFromText(wellKnownText, coordinateSystemId); } /// /// Creates a new line value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry LineFromText(string lineWellKnownText, int coordinateSystemId) { lineWellKnownText.CheckNull("lineWellKnownText"); return DbSpatialServices.Default.GeometryLineFromText(lineWellKnownText, coordinateSystemId); } /// /// Creates a new point value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry PointFromText(string pointWellKnownText, int coordinateSystemId) { pointWellKnownText.CheckNull("pointWellKnownText"); return DbSpatialServices.Default.GeometryPointFromText(pointWellKnownText, coordinateSystemId); } /// /// Creates a new polygon value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry PolygonFromText(string polygonWellKnownText, int coordinateSystemId) { polygonWellKnownText.CheckNull("polygonWellKnownText"); return DbSpatialServices.Default.GeometryPolygonFromText(polygonWellKnownText, coordinateSystemId); } /// /// Creates a new multi-line value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "MultiLine", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "multiLine", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "multi", Justification = "Match OGC, EDM")] public static DbGeometry MultiLineFromText(string multiLineWellKnownText, int coordinateSystemId) { multiLineWellKnownText.CheckNull("multiLineWellKnownText"); return DbSpatialServices.Default.GeometryMultiLineFromText(multiLineWellKnownText, coordinateSystemId); } /// /// Creates a new multi-point value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "MultiPoint", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "multiPoint", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "multi", Justification = "Match OGC, EDM")] public static DbGeometry MultiPointFromText(string multiPointWellKnownText, int coordinateSystemId) { multiPointWellKnownText.CheckNull("multiPointWellKnownText"); return DbSpatialServices.Default.GeometryMultiPointFromText(multiPointWellKnownText, coordinateSystemId); } /// /// Creates a new multi-polygon value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi", Justification = "Match OGC, EDM")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "multi", Justification = "Match OGC, EDM")] public static DbGeometry MultiPolygonFromText(string multiPolygonWellKnownText, int coordinateSystemId) { multiPolygonWellKnownText.CheckNull("multiPolygonWellKnownText"); return DbSpatialServices.Default.GeometryMultiPolygonFromText(multiPolygonWellKnownText, coordinateSystemId); } /// /// Creates a new collection value based on the specified well known text value and coordinate system identifier (SRID). /// /// A string that contains a well known text representation of the geometry value. /// The identifier of the coordinate system that the new DbGeometry value should use. /// A new DbGeometry value as defined by the well known text value with the specified coordinate system identifier. /// is null. /// is not valid. public static DbGeometry GeometryCollectionFromText(string geometryCollectionWellKnownText, int coordinateSystemId) { geometryCollectionWellKnownText.CheckNull("geometryCollectionWellKnownText"); return DbSpatialServices.Default.GeometryCollectionFromText(geometryCollectionWellKnownText, coordinateSystemId); } #endregion #region Geometry Instance Properties /// /// Gets the coordinate system identifier (SRID) of the coordinate system used by this DbGeometry value. /// public int CoordinateSystemId { get { return this.spatialSvcs.GetCoordinateSystemId(this); } } /// /// Gets the boundary of this DbGeometry value. /// public DbGeometry Boundary { get { return this.spatialSvcs.GetBoundary(this); } } /// /// Gets the dimension of the given value or, if the value is a collection, the dimension of its largest element. /// public int Dimension { get { return this.spatialSvcs.GetDimension(this); } } /// /// Gets the envelope (minimum bounding box) of this DbGeometry value, as a geometry value. /// public DbGeometry Envelope { get { return this.spatialSvcs.GetEnvelope(this); } } /// /// Gets the spatial type name, as a string, of this DbGeometry value. /// public string SpatialTypeName { get { return this.spatialSvcs.GetSpatialTypeName(this); } } /// /// Gets a Boolean value indicating whether this DbGeometry value represents the empty geometry. /// public bool IsEmpty { get { return this.spatialSvcs.GetIsEmpty(this); } } /// /// Gets a Boolean value indicating whether this DbGeometry is simple. /// public bool IsSimple { get { return this.spatialSvcs.GetIsSimple(this); } } /// /// Gets a Boolean value indicating whether this DbGeometry value is considered valid. /// public bool IsValid { get { return this.spatialSvcs.GetIsValid(this); } } #endregion #region Geometry Well Known Format Conversion /// /// Generates the well known text representation of this DbGeometry value. Includes only X and Y coordinates for points. /// /// A string containing the well known text representation of this DbGeometry value. public string AsText() { return this.spatialSvcs.AsText(this); } /// /// Generates the well known text representation of this DbGeometry value. Includes X coordinate, Y coordinate, Elevation (Z) and Measure (M) for points. /// /// A string containing the well known text representation of this DbGeometry value. internal string AsTextIncludingElevationAndMeasure() { return this.spatialSvcs.AsTextIncludingElevationAndMeasure(this); } /// /// Generates the well known binary representation of this DbGeometry value. /// /// A byte array containing the well known binary representation of this DbGeometry value. public byte[] AsBinary() { return this.spatialSvcs.AsBinary(this); } // Non-OGC /// /// Generates the Geography Markup Language (GML) representation of this DbGeometry value. /// /// A string containing the GML representation of this DbGeometry value. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gml")] public string AsGml() { return this.spatialSvcs.AsGml(this); } #endregion #region Geometry Operations - Spatial Relation /// /// Determines whether this DbGeometry is spatially equal to the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value for equality. /// true if is spatially equal to this geometry value; otherwise false. /// is null. public bool SpatialEquals(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.SpatialEquals(this, other); } /// /// Determines whether this DbGeometry is spatially disjoint from the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value for disjointness. /// true if is disjoint from this geometry value; otherwise false. /// is null. public bool Disjoint(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Disjoint(this, other); } /// /// Determines whether this DbGeometry value spatially intersects the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value for intersection. /// true if intersects this geometry value; otherwise false. /// is null. public bool Intersects(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Intersects(this, other); } /// /// Determines whether this DbGeometry value spatially touches the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value. /// true if touches this geometry value; otherwise false. /// is null. public bool Touches(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Touches(this, other); } /// /// Determines whether this DbGeometry value spatially crosses the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value. /// true if crosses this geometry value; otherwise false. /// is null. public bool Crosses(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Crosses(this, other); } /// /// Determines whether this DbGeometry value is spatially within the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value for containment. /// true if this geometry value is within ; otherwise false. /// is null. public bool Within(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Within(this, other); } /// /// Determines whether this DbGeometry value spatially contains the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value for containment. /// true if this geometry value contains ; otherwise false. /// is null. public bool Contains(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Contains(this, other); } /// /// Determines whether this DbGeometry value spatially overlaps the specified DbGeometry argument. /// /// The geometry value that should be compared with this geometry value for overlap. /// true if this geometry value overlaps ; otherwise false. /// is null. public bool Overlaps(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Overlaps(this, other); } /// /// Determines whether this DbGeometry value spatially relates to the specified DbGeometry argument according to the /// given Dimensionally Extended Nine-Intersection Model (DE-9IM) intersection pattern. /// /// The geometry value that should be compared with this geometry value for relation. /// A string that contains the text representation of the (DE-9IM) intersection pattern that defines the relation. /// true if this geometry value relates to according to the specified intersection pattern matrix; otherwise false. /// or is null. public bool Relate(DbGeometry other, string matrix) { other.CheckNull("other"); matrix.CheckNull("matrix"); return this.spatialSvcs.Relate(this, other, matrix); } #endregion #region Geometry Operations - Spatial Analysis /// /// Creates a geometry value representing all points less than or equal to from this DbGeometry value. /// /// A double value specifying how far from this geometry value to buffer. /// A new DbGeometry value representing all points less than or equal to from this geometry value. /// is null. public DbGeometry Buffer(double? distance) { if (!distance.HasValue) { throw EntityUtil.ArgumentNull("distance"); } return this.spatialSvcs.Buffer(this, distance.Value); } /// /// Computes the distance between the closest points in this DbGeometry value and another DbGeometry value. /// /// The geometry value for which the distance from this value should be computed. /// A double value that specifies the distance between the two closest points in this geometry value and . /// is null. public double? Distance(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Distance(this, other); } /// /// Gets the convex hull of this DbGeometry value as another DbGeometry value. /// public DbGeometry ConvexHull { get { return this.spatialSvcs.GetConvexHull(this); } } /// /// Computes the intersection of this DbGeometry value and another DbGeometry value. /// /// The geometry value for which the intersection with this value should be computed. /// A new DbGeometry value representing the intersection between this geometry value and . /// is null. public DbGeometry Intersection(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Intersection(this, other); } /// /// Computes the union of this DbGeometry value and another DbGeometry value. /// /// The geometry value for which the union with this value should be computed. /// A new DbGeometry value representing the union between this geometry value and . /// is null. public DbGeometry Union(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Union(this, other); } /// /// Computes the difference between this DbGeometry value and another DbGeometry value. /// /// The geometry value for which the difference with this value should be computed. /// A new DbGeometry value representing the difference between this geometry value and . /// is null. public DbGeometry Difference(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.Difference(this, other); } /// /// Computes the symmetric difference between this DbGeometry value and another DbGeometry value. /// /// The geometry value for which the symmetric difference with this value should be computed. /// A new DbGeometry value representing the symmetric difference between this geometry value and . /// is null. public DbGeometry SymmetricDifference(DbGeometry other) { other.CheckNull("other"); return this.spatialSvcs.SymmetricDifference(this, other); } #endregion #region Geometry Collection /// /// Gets the number of elements in this DbGeometry value, if it represents a geometry collection. /// The number of elements in this geometry value, if it represents a collection of other geometry values; otherwise null. /// public int? ElementCount { get { return this.spatialSvcs.GetElementCount(this); } } /// /// Returns an element of this DbGeometry value from a specific position, if it represents a geometry collection. /// The position within this geometry value from which the element should be taken. /// The element in this geometry value at the specified position, if it represents a collection of other geometry values; otherwise null. /// public DbGeometry ElementAt(int index) { return this.spatialSvcs.ElementAt(this, index); } #endregion #region Point /// /// Gets the X coordinate of this DbGeometry value, if it represents a point. /// The X coordinate value of this geometry value, if it represents a point; otherwise null. /// public double? XCoordinate { get { return this.spatialSvcs.GetXCoordinate(this); } } /// /// Gets the Y coordinate of this DbGeometry value, if it represents a point. /// The Y coordinate value of this geometry value, if it represents a point; otherwise null. /// public double? YCoordinate { get { return this.spatialSvcs.GetYCoordinate(this); } } /// /// Gets the elevation (Z coordinate) of this DbGeometry value, if it represents a point. /// The elevation (Z coordinate) of this geometry value, if it represents a point; otherwise null. /// public double? Elevation { get { return this.spatialSvcs.GetElevation(this); } } /// /// Gets the Measure (M coordinate) of this DbGeometry value, if it represents a point. /// The Measure (M coordinate) value of this geometry value, if it represents a point; otherwise null. /// public double? Measure { get { return this.spatialSvcs.GetMeasure(this); } } #endregion #region Curve /// /// Gets a nullable double value that indicates the length of this DbGeometry value, which may be null if this value does not represent a curve. /// public double? Length { get { return this.spatialSvcs.GetLength(this); } } /// /// Gets a DbGeometry value representing the start point of this value, which may be null if this DbGeometry value does not represent a curve. /// public DbGeometry StartPoint { get { return this.spatialSvcs.GetStartPoint(this); } } /// /// Gets a DbGeometry value representing the start point of this value, which may be null if this DbGeometry value does not represent a curve. /// public DbGeometry EndPoint { get { return this.spatialSvcs.GetEndPoint(this); } } /// /// Gets a nullable Boolean value indicating whether this DbGeometry value is closed, which may be null if this value does not represent a curve. /// public bool? IsClosed { get { return this.spatialSvcs.GetIsClosed(this); } } /// /// Gets a nullable Boolean value indicating whether this DbGeometry value is a ring, which may be null if this value does not represent a curve. /// public bool? IsRing { get { return this.spatialSvcs.GetIsRing(this); } } #endregion #region LineString, Line, LinearRing /// /// Gets the number of points in this DbGeometry value, if it represents a linestring or linear ring. /// The number of elements in this geometry value, if it represents a linestring or linear ring; otherwise null. /// public int? PointCount { get { return this.spatialSvcs.GetPointCount(this); } } /// /// Returns an element of this DbGeometry value from a specific position, if it represents a linestring or linear ring. /// The position within this geometry value from which the element should be taken. /// The element in this geometry value at the specified position, if it represents a linestring or linear ring; otherwise null. /// public DbGeometry PointAt(int index) { return this.spatialSvcs.PointAt(this, index); } #endregion #region Surface /// /// Gets a nullable double value that indicates the area of this DbGeometry value, which may be null if this value does not represent a surface. /// public double? Area { get { return this.spatialSvcs.GetArea(this); } } /// /// Gets the DbGeometry value that represents the centroid of this DbGeometry value, which may be null if this value does not represent a surface. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Centroid", Justification = "Naming convention prescribed by OGC specification")] public DbGeometry Centroid { get { return this.spatialSvcs.GetCentroid(this); } } /// /// Gets a point on the surface of this DbGeometry value, which may be null if this value does not represent a surface. /// public DbGeometry PointOnSurface { get { return this.spatialSvcs.GetPointOnSurface(this); } } #endregion #region Polygon /// /// Gets the DbGeometry value that represents the exterior ring of this DbGeometry value, which may be null if this value does not represent a polygon. /// public DbGeometry ExteriorRing { get { return this.spatialSvcs.GetExteriorRing(this); } } /// /// Gets the number of interior rings in this DbGeometry value, if it represents a polygon. /// The number of elements in this geometry value, if it represents a polygon; otherwise null. /// public int? InteriorRingCount { get { return this.spatialSvcs.GetInteriorRingCount(this); } } /// /// Returns an interior ring from this DbGeometry value at a specific position, if it represents a polygon. /// The position within this geometry value from which the interior ring should be taken. /// The interior ring in this geometry value at the specified position, if it represents a polygon; otherwise null. /// public DbGeometry InteriorRingAt(int index) { return this.spatialSvcs.InteriorRingAt(this, index); } #endregion #region ToString /// /// Returns a string representation of the geometry value. /// public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "SRID={1};{0}", this.WellKnownValue.WellKnownText ?? base.ToString(), this.CoordinateSystemId); } #endregion } }