//------------------------------------------------------------------------------
//
// 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.Globalization;
using System.Runtime.Serialization;
namespace System.Data.Spatial
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
[DataContract]
[Serializable]
[BindableType]
public class DbGeography
{
private DbSpatialServices spatialSvcs;
private object providerValue;
internal DbGeography(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 geography values (WGS 84)
///
public static int DefaultCoordinateSystemId { get { return 4326; /* WGS 84 */ } }
///
/// Gets a representation of this DbGeography 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 DbGeography value.
///
[DataMember(Name = "Geography")]
public DbGeographyWellKnownValue 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 geography value.
/// A new DbGeography value as defined by the well known binary value with the default geography coordinate system identifier (SRID)().
/// is null.
public static DbGeography FromBinary(byte[] wellKnownBinary)
{
wellKnownBinary.CheckNull("wellKnownBinary");
return DbSpatialServices.Default.GeographyFromBinary(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known binary value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography FromBinary(byte[] wellKnownBinary, int coordinateSystemId)
{
wellKnownBinary.CheckNull("wellKnownBinary");
return DbSpatialServices.Default.GeographyFromBinary(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known binary value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography LineFromBinary(byte[] lineWellKnownBinary, int coordinateSystemId)
{
lineWellKnownBinary.CheckNull("lineWellKnownBinary");
return DbSpatialServices.Default.GeographyLineFromBinary(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known binary value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography PointFromBinary(byte[] pointWellKnownBinary, int coordinateSystemId)
{
pointWellKnownBinary.CheckNull("pointWellKnownBinary");
return DbSpatialServices.Default.GeographyPointFromBinary(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known binary value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography PolygonFromBinary(byte[] polygonWellKnownBinary, int coordinateSystemId)
{
polygonWellKnownBinary.CheckNull("polygonWellKnownBinary");
return DbSpatialServices.Default.GeographyPolygonFromBinary(polygonWellKnownBinary, coordinateSystemId);
}
///
/// Creates a new MultiLine 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography MultiLineFromBinary(byte[] multiLineWellKnownBinary, int coordinateSystemId)
{
multiLineWellKnownBinary.CheckNull("multiLineWellKnownBinary");
return DbSpatialServices.Default.GeographyMultiLineFromBinary(multiLineWellKnownBinary, coordinateSystemId);
}
///
/// Creates a new MultiPoint 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography MultiPointFromBinary(byte[] multiPointWellKnownBinary, int coordinateSystemId)
{
multiPointWellKnownBinary.CheckNull("multiPointWellKnownBinary");
return DbSpatialServices.Default.GeographyMultiPointFromBinary(multiPointWellKnownBinary, coordinateSystemId);
}
///
/// Creates a new MultiPolygon 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography MultiPolygonFromBinary(byte[] multiPolygonWellKnownBinary, int coordinateSystemId)
{
multiPolygonWellKnownBinary.CheckNull("multiPolygonWellKnownBinary");
return DbSpatialServices.Default.GeographyMultiPolygonFromBinary(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known binary value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography GeographyCollectionFromBinary(byte[] geographyCollectionWellKnownBinary, int coordinateSystemId)
{
geographyCollectionWellKnownBinary.CheckNull("geographyCollectionWellKnownBinary");
return DbSpatialServices.Default.GeographyCollectionFromBinary(geographyCollectionWellKnownBinary, 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 geography value.
/// A new DbGeography value as defined by the GML value with the default geography coordinate system identifier (SRID) ().
/// is null.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gml")]
public static DbGeography FromGml(string geographyMarkup)
{
geographyMarkup.CheckNull("geographyMarkup");
return DbSpatialServices.Default.GeographyFromGml(geographyMarkup);
}
///
/// 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography FromGml(string geographyMarkup, int coordinateSystemId)
{
geographyMarkup.CheckNull("geographyMarkup");
return DbSpatialServices.Default.GeographyFromGml(geographyMarkup, 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 geography value.
/// A new DbGeography value as defined by the well known text value with the default geography coordinate system identifier (SRID) ().
/// is null.
public static DbGeography FromText(string wellKnownText)
{
wellKnownText.CheckNull("wellKnownText");
return DbSpatialServices.Default.GeographyFromText(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known text value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography FromText(string wellKnownText, int coordinateSystemId)
{
wellKnownText.CheckNull("wellKnownText");
return DbSpatialServices.Default.GeographyFromText(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known text value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography LineFromText(string lineWellKnownText, int coordinateSystemId)
{
lineWellKnownText.CheckNull("lineWellKnownText");
return DbSpatialServices.Default.GeographyLineFromText(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known text value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography PointFromText(string pointWellKnownText, int coordinateSystemId)
{
pointWellKnownText.CheckNull("pointWellKnownText");
return DbSpatialServices.Default.GeographyPointFromText(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known text value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography PolygonFromText(string polygonWellKnownText, int coordinateSystemId)
{
polygonWellKnownText.CheckNull("polygonWellKnownText");
return DbSpatialServices.Default.GeographyPolygonFromText(polygonWellKnownText, coordinateSystemId);
}
///
/// Creates a new MultiLine 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography MultiLineFromText(string multiLineWellKnownText, int coordinateSystemId)
{
multiLineWellKnownText.CheckNull("multiLineWellKnownText");
return DbSpatialServices.Default.GeographyMultiLineFromText(multiLineWellKnownText, coordinateSystemId);
}
///
/// Creates a new MultiPoint 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography MultiPointFromText(string multiPointWellKnownText, int coordinateSystemId)
{
multiPointWellKnownText.CheckNull("multiPointWellKnownText");
return DbSpatialServices.Default.GeographyMultiPointFromText(multiPointWellKnownText, coordinateSystemId);
}
///
/// Creates a new MultiPolygon 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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography 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 DbGeography MultiPolygonFromText(string multiPolygonWellKnownText, int coordinateSystemId)
{
multiPolygonWellKnownText.CheckNull("multiPolygonWellKnownText");
return DbSpatialServices.Default.GeographyMultiPolygonFromText(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 geography value.
/// The identifier of the coordinate system that the new DbGeography value should use.
/// A new DbGeography value as defined by the well known text value with the specified coordinate system identifier.
/// is null.
/// is not valid.
public static DbGeography GeographyCollectionFromText(string geographyCollectionWellKnownText, int coordinateSystemId)
{
geographyCollectionWellKnownText.CheckNull("geographyCollectionWellKnownText");
return DbSpatialServices.Default.GeographyCollectionFromText(geographyCollectionWellKnownText, coordinateSystemId);
}
#endregion
#region Geography Instance Properties
///
/// Gets the Spatial Reference System Identifier (Coordinate System Id) of the spatial reference system used by this DbGeography value.
///
public int CoordinateSystemId { get { return this.spatialSvcs.GetCoordinateSystemId(this); } }
///
/// Gets the dimension of the given value or, if the value is a collections, the largest element dimension.
///
public int Dimension { get { return this.spatialSvcs.GetDimension(this); } }
///
/// Gets the spatial type name, as a string, of this DbGeography value.
///
public string SpatialTypeName { get { return this.spatialSvcs.GetSpatialTypeName(this); } }
///
/// Gets a Boolean value indicating whether this DbGeography value represents the empty geography.
///
public bool IsEmpty { get { return this.spatialSvcs.GetIsEmpty(this); } }
#endregion
#region Geography Well Known Format Conversion
///
/// Generates the well known text representation of this DbGeography value. Includes only Longitude and Latitude for points.
///
/// A string containing the well known text representation of this DbGeography value.
public string AsText() { return this.spatialSvcs.AsText(this); }
///
/// Generates the well known text representation of this DbGeography value. Includes Longitude, Latitude, Elevation (Z) and Measure (M) for points.
///
/// A string containing the well known text representation of this DbGeography value.
internal string AsTextIncludingElevationAndMeasure() { return this.spatialSvcs.AsTextIncludingElevationAndMeasure(this); }
///
/// Generates the well known binary representation of this DbGeography value.
///
/// A byte array containing the well known binary representation of this DbGeography value.
public byte[] AsBinary() { return this.spatialSvcs.AsBinary(this); }
// Non-OGC
///
/// Generates the Geography Markup Language (GML) representation of this DbGeography value.
///
/// A string containing the GML representation of this DbGeography value.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gml")]
public string AsGml() { return this.spatialSvcs.AsGml(this); }
#endregion
#region Geography Operations - Spatial Relation
///
/// Determines whether this DbGeography is spatially equal to the specified DbGeography argument.
///
/// The geography value that should be compared with this geography value for equality.
/// true if is spatially equal to this geography value; otherwise false.
/// is null.
public bool SpatialEquals(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.SpatialEquals(this, other);
}
///
/// Determines whether this DbGeography is spatially disjoint from the specified DbGeography argument.
///
/// The geography value that should be compared with this geography value for disjointness.
/// true if is disjoint from this geography value; otherwise false.
/// is null.
public bool Disjoint(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.Disjoint(this, other);
}
///
/// Determines whether this DbGeography value spatially intersects the specified DbGeography argument.
///
/// The geography value that should be compared with this geography value for intersection.
/// true if intersects this geography value; otherwise false.
/// is null.
public bool Intersects(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.Intersects(this, other);
}
#endregion
#region Geography Operations - Spatial Analysis
///
/// Creates a geography value representing all points less than or equal to from this DbGeography value.
///
/// A double value specifying how far from this geography value to buffer.
/// A new DbGeography value representing all points less than or equal to from this geography value.
/// is null.
public DbGeography 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 DbGeography value and another DbGeography value.
///
/// The geography 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 geography value and .
/// is null.
public double? Distance(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.Distance(this, other);
}
///
/// Computes the intersection of this DbGeography value and another DbGeography value.
///
/// The geography value for which the intersection with this value should be computed.
/// A new DbGeography value representing the intersection between this geography value and .
/// is null.
public DbGeography Intersection(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.Intersection(this, other);
}
///
/// Computes the union of this DbGeography value and another DbGeography value.
///
/// The geography value for which the union with this value should be computed.
/// A new DbGeography value representing the union between this geography value and .
/// is null.
public DbGeography Union(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.Union(this, other);
}
///
/// Computes the difference of this DbGeography value and another DbGeography value.
///
/// The geography value for which the difference with this value should be computed.
/// A new DbGeography value representing the difference between this geography value and .
/// is null.
public DbGeography Difference(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.Difference(this, other);
}
///
/// Computes the symmetric difference of this DbGeography value and another DbGeography value.
///
/// The geography value for which the symmetric difference with this value should be computed.
/// A new DbGeography value representing the symmetric difference between this geography value and .
/// is null.
public DbGeography SymmetricDifference(DbGeography other)
{
other.CheckNull("other");
return this.spatialSvcs.SymmetricDifference(this, other);
}
#endregion
#region Geography Collection
///
/// Gets the number of elements in this DbGeography value, if it represents a geography collection.
/// The number of elements in this geography value, if it represents a collection of other geography values; otherwise null.
///
public int? ElementCount { get { return this.spatialSvcs.GetElementCount(this); } }
///
/// Returns an element of this DbGeography value from a specific position, if it represents a geography collection.
/// The position within this geography value from which the element should be taken.
/// The element in this geography value at the specified position, if it represents a collection of other geography values; otherwise null.
///
public DbGeography ElementAt(int index)
{
return this.spatialSvcs.ElementAt(this, index);
}
#endregion
#region Point
///
/// Gets the Latitude coordinate of this DbGeography value, if it represents a point.
/// The Latitude coordinate value of this geography value, if it represents a point; otherwise null.
///
public double? Latitude { get { return this.spatialSvcs.GetLatitude(this); } }
///
/// Gets the Longitude coordinate of this DbGeography value, if it represents a point.
/// The Longitude coordinate value of this geography value, if it represents a point; otherwise null.
///
public double? Longitude { get { return this.spatialSvcs.GetLongitude(this); } }
///
/// Gets the elevation (Z coordinate) of this DbGeography value, if it represents a point.
/// The elevation (Z coordinate) value of this geography value, if it represents a point; otherwise null.
///
public double? Elevation { get { return this.spatialSvcs.GetElevation(this); } }
///
/// Gets the M (Measure) coordinate of this DbGeography value, if it represents a point.
/// The M (Measure) coordinate value of this geography 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 DbGeography value, which may be null if this value does not represent a curve.
///
public double? Length { get { return this.spatialSvcs.GetLength(this); } }
///
/// Gets a DbGeography value representing the start point of this value, which may be null if this DbGeography value does not represent a curve.
///
public DbGeography StartPoint { get { return this.spatialSvcs.GetStartPoint(this); } }
///
/// Gets a DbGeography value representing the start point of this value, which may be null if this DbGeography value does not represent a curve.
///
public DbGeography EndPoint { get { return this.spatialSvcs.GetEndPoint(this); } }
///
/// Gets a nullable Boolean value indicating whether this DbGeography value is closed, which may be null if this value does not represent a curve.
///
public bool? IsClosed { get { return this.spatialSvcs.GetIsClosed(this); } }
#endregion
#region LineString, Line, LinearRing
///
/// Gets the number of points in this DbGeography value, if it represents a linestring or linear ring.
/// The number of elements in this geography 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 DbGeography value from a specific position, if it represents a linestring or linear ring.
/// The position within this geography value from which the element should be taken.
/// The element in this geography value at the specified position, if it represents a linestring or linear ring; otherwise null.
///
public DbGeography PointAt(int index)
{
return this.spatialSvcs.PointAt(this, index);
}
#endregion
#region Surface
///
/// Gets a nullable double value that indicates the area of this DbGeography value, which may be null if this value does not represent a surface.
///
public double? Area { get { return this.spatialSvcs.GetArea(this); } }
#endregion
#region ToString
///
/// Returns a string representation of the geography value.
///
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "SRID={1};{0}", this.WellKnownValue.WellKnownText ?? base.ToString(), this.CoordinateSystemId);
}
#endregion
}
}