Beispiel #1
0
        /// <summary>Returns the centroid for the current geometry.</summary>
        /// <returns>The centroid for the current geometry.</returns>
        public ISimpleGeometry Centroid()
        {
            // Transform into SqlGeometry, calculate, then back to SqlGeography
            // We would do this if we dealt with geometries anyway. Not sure it makes much sense, though...

            return(ToGeography(SpatialGeometry.ToGeometry(this).Centroid()));
        }
Beispiel #2
0
        /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Contains(ISimpleGeometry geometry)
        {
            // Transform into SqlGeometry, then calculate
            // We would do this if we dealt with geometries anyway. Not sure it makes much sense, though...

            return(SpatialGeometry.ToGeometry(this).Contains(geometry));
        }
Beispiel #3
0
        /// <summary>Generates a geometry from its GML representation.</summary>
        /// <param name="reader">The stream from which the geometry is deserialized. </param>
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            var xdoc = new XmlDocument();

            xdoc.Load(reader);
            Gml._Geometry g = Gml._Geometry.Parse(xdoc.DocumentElement.OuterXml);

            var builder = new SpatialGeometryBuilder();

            g.Populate(builder);

            _Geometry = SpatialGeometry.ToGeometry(builder.ConstructedGeometry);
        }
Beispiel #4
0
        /// <summary>Indicates whether the 2 geometries are disjoint or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries are disjoint, or else <c>false</c>.</returns>
        public bool Disjoint(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Disjoint(other._Geometry));
        }
Beispiel #5
0
        /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
        /// <param name="geometry">The geometry to calculate the distance from.</param>
        /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
        public double Distance(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Distance(other._Geometry).Value);
        }
Beispiel #6
0
        /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Contains(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Contains(other._Geometry));
        }
Beispiel #7
0
        /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
        public bool Intersects(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Intersects(other._Geometry));
        }
Beispiel #8
0
        /// <summary>Indicates whether the current geometry overlaps the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry overlaps the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Overlaps(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Overlaps(other._Geometry));
        }
Beispiel #9
0
        /// <summary>Indicates whether the current geometry is within the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry is within the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Within(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Within(other._Geometry));
        }
Beispiel #10
0
        /// <summary>Indicates whether the 2 geometries touch themselves or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries touch themselves, or else <c>false</c>.</returns>
        public bool Touches(ISimpleGeometry geometry)
        {
            SpatialGeometry other = ToGeometry(geometry);

            return(_Geometry.Touches(other._Geometry));
        }