/// <summary> /// Enlarges the boundary of the Envelope so that it contains other. /// </summary> /// <remarks>Does nothing if other is wholly on or within the boundaries.</remarks> /// <param name="other">The Envelope to merge with</param> public void ExpandToInclude(Envelope other) { if (other.IsNull()) { return; } if (IsNull()) { _minX = other.MinX; _maxX = other.MaxX; _minY = other.MinY; _maxY = other.MaxY; } else { if (other._minX < _minX) { _minX = other._minX; } if (other._maxX > _maxX) { _maxX = other._maxX; } if (other._minY < _minY) { _minY = other._minY; } if (other._maxY > _maxY) { _maxY = other._maxY; } } }
/// <summary> /// Converts an envnelope to a geometry. /// </summary> /// <param name="envelope">The Envelope to convert to a Geometry.</param> /// <param name="precisionModel">The specification of the grid of allowable points for the new Geometry.</param> /// <param name="SRID">The ID of the Spatial Reference System used by the Envelope.</param> /// <returns>an empty Point (for null Envelopes), a Point (when min x = max x and min y = max y) /// or a Polygon (in all other cases)</returns> /// <exception cref="TopologyException"> if coordinates is not a closed linestring, that is, if the /// first and last coordinates are not equal.</exception> public static Geometry ToGeometry(Envelope envelope, PrecisionModel precisionModel, int SRID) { if (envelope.IsNull()) { return(new Point(null, precisionModel, SRID)); } if (envelope.MinX == envelope.MaxX && envelope.MinY == envelope.MaxY) { return(new Point(new Coordinate(envelope.MinX, envelope.MinY), precisionModel, SRID)); } Coordinates coords = new Coordinates(); coords.Add(new Coordinate(envelope.MinX, envelope.MinY)); coords.Add(new Coordinate(envelope.MaxX, envelope.MinY)); coords.Add(new Coordinate(envelope.MaxX, envelope.MaxY)); coords.Add(new Coordinate(envelope.MinX, envelope.MaxY)); coords.Add(new Coordinate(envelope.MinX, envelope.MinY)); return(new Polygon(new LinearRing(coords, precisionModel, SRID), precisionModel, SRID)); }
/// <summary> /// Determines if the two objects are of the same type and if they contain the elements. /// </summary> /// <param name="other">The other object to be compared.</param> /// <returns>A bool containing either true of false based on the equality of the two objects.</returns> public override bool Equals(Object other) { bool returnValue = false; Envelope env = other as Envelope; if (env != null) { if (IsNull()) { returnValue = env.IsNull(); } else { returnValue = _maxX == env.MaxX && _maxY == env.MaxY && _minX == env.MinX && _minY == env.MinY; } } return(returnValue); }
/// <summary> /// Gets the extents of the Geometry. /// </summary> /// <param name="minX">The minimum X value.</param> /// <param name="minY">The minimum Y value.</param> /// <param name="maxX">The maximum X value.</param> /// <param name="maxY">The maximum Y value.</param> public virtual void Extent2D(out double minX, out double minY, out double maxX, out double maxY) { //If the member variable is null get the Envelope if(_envelope == null) { GetEnvelopeInternal(); } //if the envelope is null get all zeros if(!_envelope.IsNull()) { minX = _envelope.MinX; minY = _envelope.MinY; maxX = _envelope.MaxX; maxY = _envelope.MaxY; } else { minX = 0; minY = 0; maxX = 0; maxY = 0; } }
public void Insert( Envelope itemEnv, object item ) { if ( itemEnv.IsNull() ) { return; } base.Insert( itemEnv, item ); }
/// <summary> /// Enlarges the boundary of the Envelope so that it contains other. /// </summary> /// <remarks>Does nothing if other is wholly on or within the boundaries.</remarks> /// <param name="other">The Envelope to merge with</param> public void ExpandToInclude(Envelope other) { if (other.IsNull()) { return; } if (IsNull()) { _minX = other.MinX; _maxX = other.MaxX; _minY = other.MinY; _maxY = other.MaxY; } else { if (other._minX < _minX) { _minX = other._minX; } if (other._maxX > _maxX) { _maxX = other._maxX; } if (other._minY < _minY) { _minY = other._minY; } if (other._maxY > _maxY) { _maxY = other._maxY; } } }
/// <summary> /// Converts an envnelope to a geometry. /// </summary> /// <param name="envelope">The Envelope to convert to a Geometry.</param> /// <param name="precisionModel">The specification of the grid of allowable points for the new Geometry.</param> /// <param name="SRID">The ID of the Spatial Reference System used by the Envelope.</param> /// <returns>an empty Point (for null Envelopes), a Point (when min x = max x and min y = max y) /// or a Polygon (in all other cases)</returns> /// <exception cref="TopologyException"> if coordinates is not a closed linestring, that is, if the /// first and last coordinates are not equal.</exception> public static Geometry ToGeometry(Envelope envelope, PrecisionModel precisionModel, int SRID) { if ( envelope.IsNull() ) { return new Point( null, precisionModel, SRID ); } if ( envelope.MinX == envelope.MaxX && envelope.MinY == envelope.MaxY ) { return new Point( new Coordinate(envelope.MinX, envelope.MinY), precisionModel, SRID ); } Coordinates coords = new Coordinates(); coords.Add( new Coordinate( envelope.MinX, envelope.MinY ) ); coords.Add( new Coordinate( envelope.MaxX, envelope.MinY ) ); coords.Add( new Coordinate( envelope.MaxX, envelope.MaxY ) ); coords.Add( new Coordinate( envelope.MinX, envelope.MaxY ) ); coords.Add( new Coordinate( envelope.MinX, envelope.MinY ) ); return new Polygon( new LinearRing( coords, precisionModel, SRID), precisionModel, SRID); }