/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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; }