Exemple #1
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 SharpGeometryBuilder();

            g.Populate(builder);

            _Geometry = SharpGeometry.ToGeometry(builder.ConstructedGeometry);
        }
        /// <summary>Returns the geometry defined by the specified WKB representation, in the specified coordinate system.</summary>
        /// <param name="data">The WKB representation of the geometry.</param>
        /// <param name="system">The coordinate system of the WKB representation.</param>
        public void Parse(byte[] data, ICoordinateSystem system)
        {
            Debug.Assert(system != null);
            if (system == null)
            {
                throw new ArgumentNullException("system");
            }

            var g = SmGeometries.Geometry.GeomFromWKB(data);

            g.SpatialReference = CoordinateSystemUtils.Convert(system);

            if ((TargetSystem != null) && !system.IsEquivalentTo(TargetSystem))
            {
                _Geometry = null;
                var orig = new SharpGeometry(g);
                orig.Populate(this);
            }
            else
            {
                _Geometry = new SharpGeometry(g);
            }
        }
        /// <summary>Returns the geometry defined by the specified WKB representation, in the specified coordinate system.</summary>
        /// <param name="data">The WKB representation of the geometry.</param>
        /// <param name="system">The coordinate system of the WKB representation.</param>
        public void Parse(byte[] data, ICoordinateSystem system)
        {
            Debug.Assert(system!=null);
            if (system==null)
                throw new ArgumentNullException("system");

            var g=SmGeometries.Geometry.GeomFromWKB(data);
            g.SpatialReference=CoordinateSystemUtils.Convert(system);

            if ((TargetSystem!=null) && !system.IsEquivalentTo(TargetSystem))
            {
                _Geometry=null;
                var orig=new SharpGeometry(g);
                orig.Populate(this);
            } else
                _Geometry=new SharpGeometry(g);
        }
Exemple #4
0
 /// <summary>Converts the specified <paramref name="geometry" /> into a <see cref="SmGeometries.Geometry" />.</summary>
 /// <param name="geometry">The geometry to convert.</param>
 /// <returns>The converted geometry.</returns>
 public static SmGeometries.Geometry ToGeometry(SharpGeometry geometry)
 {
     return(geometry._Geometry);
 }
Exemple #5
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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Contains(other._Geometry));
        }
Exemple #6
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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Overlaps(other._Geometry));
        }
Exemple #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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Intersects(other._Geometry));
        }
Exemple #8
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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Within(other._Geometry));
        }
Exemple #9
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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Touches(other._Geometry));
        }
Exemple #10
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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Disjoint(other._Geometry));
        }
Exemple #11
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)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Distance(other._Geometry));
        }
Exemple #12
0
 /// <summary>Converts the specified <paramref name="geometry" /> into a <see cref="SmGeometries.Geometry" />.</summary>
 /// <param name="geometry">The geometry to convert.</param>
 /// <returns>The converted geometry.</returns>
 public static SmGeometries.Geometry ToGeometry(SharpGeometry geometry)
 {
     return geometry._Geometry;
 }