/// <summary> /// Allows equality testing for extents that is derived on the extent itself. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { IExtent other = obj as IExtent; if (other == null) { return(false); } IExtentZ zother = other as IExtentZ; // If either party claims it has no Z values, then ignore that part of the equality check. if (!HasZ || !other.HasM || zother == null) { return(base.Equals(obj)); } if (MinZ != zother.MinZ) { return(false); } if (MaxZ != zother.MaxZ) { return(false); } return(base.Equals(obj)); }
/// <summary> /// Initializes a new instance of the <see cref="RasterBounds"/> class that is georeferenced to the specified envelope. /// </summary> /// <param name="numRows">The number of rows</param> /// <param name="numColumns">The number of columns</param> /// <param name="bounds">The bounding envelope</param> public RasterBounds(int numRows, int numColumns, IExtent bounds) { _affine = new double[6]; _numRows = numRows; _numColumns = numColumns; Extent = bounds; }
public static void DrawExtent(this SpriteBatch spriteBatch, IExtent extent, Color color, Matrix transformFromWorldToCamera) { ICompositeExtent composite = extent as ICompositeExtent; if (null != composite) { DrawCompositeExtent(spriteBatch, composite, color, transformFromWorldToCamera); return; } IPolygonExtent poly = extent as IPolygonExtent; if (null != poly) { DrawPolygon(spriteBatch, poly, color, transformFromWorldToCamera); return; } ICircularExtent circle = extent as ICircularExtent; if (null != circle) { DrawCircle(spriteBatch, circle, color, transformFromWorldToCamera); return; } throw new NotImplementedException("can only draw extents that are either polygons or circles"); }
protected override bool IntersectsImpl(CollisionMode thisCollisionMode, IExtent otherExtent, CollisionMode otherCollisionMode) { switch (CollisionChecker.GetCollisionInteractionType(thisCollisionMode, otherCollisionMode)) { case CollisionInteractionType.ExtentVsInnerCircle: case CollisionInteractionType.InnerCircleVsInnerCircle: return(ExtentIntersector.AreInIntersectionCircleVsCircle(this, otherExtent)); case CollisionInteractionType.ExtentVsExtent: case CollisionInteractionType.InnerCircleVsExtent: return(ExtentIntersector.AreInIntersectionCircleVsExtent(this, otherExtent)); case CollisionInteractionType.ExtentVsPoint: case CollisionInteractionType.InnerCircleVsPoint: return(ExtentIntersector.AreInIntersectionExtentVsPoint(this, otherExtent)); case CollisionInteractionType.PointVsCircle: case CollisionInteractionType.PointVsExtent: return(ExtentIntersector.AreInIntersectionExtentVsPoint(otherExtent, this)); case CollisionInteractionType.PointVsPoint: case CollisionInteractionType.Invalid: default: return(false); } }
/// <summary> /// Allows equality testing for extents that is derived on the extent itself. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { // Check the identity case for reference equality if (base.Equals(obj)) { return(true); } IExtent other = obj as IExtent; if (other == null) { return(false); } if (MinX != other.MinX) { return(false); } if (MaxX != other.MaxX) { return(false); } if (MinY != other.MinY) { return(false); } if (MaxY != other.MaxY) { return(false); } return(true); }
/// <summary> /// Allows equality testing for extents that is derived on the extent itself. /// </summary> /// <param name="obj">The other IExtent.</param> /// <returns>True, if both are equal.</returns> public override bool Equals(object obj) { IExtent other = obj as IExtent; if (other == null) { return(false); } IExtentM mother = other as IExtentM; // If either party claims it has no M values, then w can ignore that part of the equality check. if (!HasM || !other.HasM || mother == null) { return(base.Equals(obj)); } if (MinM != mother.MinM) { return(false); } if (MaxM != mother.MaxM) { return(false); } return(base.Equals(obj)); }
public bool Intersects(IExtent other) { if (null == other) { return(false); } ICompositeExtent composite = other as ICompositeExtent; if (null != composite) { return(Intersects(composite)); } IPolygonExtent polygon = other as IPolygonExtent; if (null != polygon) { return(Intersects(polygon)); } ICircularExtent circle = other as ICircularExtent; if (null != circle) { return(Intersects(circle)); } throw new NotImplementedException("otherExtent must be either circle or polygon"); }
private void OnChildRemoved(IExtent child) { child.ParentSpace = null; child.OnChanged.Remove(_onChildExtentChanged); EnumerateAndFindBounds(); }
public void AddToExtent(IExtent extent) { lock (_extents) { _extents.Add(extent); } }
public static bool AreInIntersectionExtentVsExtent(IPolygonExtent a, IExtent b) { ICompositeExtent composite = b as ICompositeExtent; if (null != composite) { return(a.Intersects(composite)); } composite = a as ICompositeExtent; if (null != composite) { return(b.Intersects(composite)); } ICircularExtent circle = b as ICircularExtent; if (null != circle) { _tempCircleB.Reset(b); return(circle.Intersects(_tempCircleB)); } IPolygonExtent polygon = b as IPolygonExtent; if (null != polygon) { return(a.Intersects(polygon)); } throw new InvalidOperationException("Extent must be a circle or polygon"); }
private static void DrawBoundingBox(this SpriteBatch spriteBatch, IExtent extent, Color color, Matrix transformFromWorldToCamera) { _boundingBoxVertices[0] = new Vector2(extent.LowestX, extent.LowestY); _boundingBoxVertices[1] = new Vector2(extent.HighestX, extent.LowestY); _boundingBoxVertices[2] = new Vector2(extent.HighestX, extent.HighestY); _boundingBoxVertices[3] = new Vector2(extent.LowestX, extent.HighestY); spriteBatch.DrawPolygon(_boundingBoxVertices, 4, color, transformFromWorldToCamera); }
/// <summary> /// Expands this extent to include the domain of the specified extent. /// </summary> /// <param name="ext">The extent to include.</param> public virtual void ExpandToInclude(IExtent ext) { if (ext == null) { return; } ExpandToInclude(ext.MinX, ext.MaxX, ext.MinY, ext.MaxY); }
/// <summary> /// Tests if this extent is within the specified extent. /// </summary> /// <param name="ext">Extent that might contain this extent.</param> /// <returns>True if this extent is within the specified extent.</returns> /// <exception cref="ArgumentNullException">Thrown if ext is null.</exception> public virtual bool Within(IExtent ext) { if (Equals(ext, null)) { throw new ArgumentNullException(nameof(ext)); } return(Within(ext.MinX, ext.MaxX, ext.MinY, ext.MaxY)); }
/// <summary> /// Copies from the implementation of IExtent. This checks to see if IExtentM is implemented /// and if not, this only sets the X and Y bounds. /// </summary> /// <param name="extent">Extent to copy from.</param> public override void CopyFrom(IExtent extent) { base.CopyFrom(extent); if (!(extent is IExtentZ mvals) || double.IsNaN(mvals.MinZ) || double.IsNaN(mvals.MaxZ)) { MinZ = double.MaxValue; MaxZ = double.MinValue; } }
/// <summary> /// 是否包含于 /// </summary> /// <param name="extent"></param> /// <param name="env"></param> /// <returns></returns> public static bool Within(this IExtent extent, Envelope env) { if (Equals(env, null)) { throw new ArgumentNullException(nameof(env)); } return(extent.Within(env.MinX, env.MaxX, env.MinY, env.MaxY)); }
private void OnChildAdded(IExtent child) { Debug.Assert(child.ParentSpace == null, "Extent has an existing parent, remove it from its current parent before adding it to another"); child.ParentSpace = this; child.OnChanged.Add(_onChildExtentChanged); RecalculateBounds(); }
/// <summary> /// Copies from the implementation of IExtent. This checks to see if IExtentM is implemented /// and if not, this only sets the X and Y bounds. /// </summary> /// <param name="extent">The extent to copy the values from.</param> public override void CopyFrom(IExtent extent) { base.CopyFrom(extent); if (!(extent is IExtentM mvals) || (double.IsNaN(mvals.MinM) || double.IsNaN(mvals.MaxM))) { MinM = double.MaxValue; MaxM = double.MinValue; } }
public MapArgs(Rectangle rectangle, IExtent extent) { Extent = extent; Bound = rectangle; double worldWidth = extent.Width; double worldHeight = extent.Height; Dx = rectangle.Width != 0 ? worldWidth / rectangle.Width : 0; Dy = rectangle.Height != 0 ? worldHeight / rectangle.Height : 0; }
/// <summary> /// 世界坐标转像素坐标 /// </summary> /// <param name="extent"></param> /// <param name="rectangle"></param> /// <param name="coordinate"></param> /// <returns></returns> public static PointF CoordinateToPointF(IExtent extent, RectangleF rectangle, ICoordinate coordinate) { PointF point = PointF.Empty; if (extent != null && coordinate != null) { point = CoordinateToPointF(extent, rectangle, coordinate.X, coordinate.Y); } return(point); }
/// <summary> /// Tests for an intersection with the specified extent. Both this extent and the /// other must implement IExtentM and HasM must be true for both, or else just /// the X and Y are compared. /// </summary> /// <param name="ext">The other extent. If the extent doesn't implement IExtentM, then /// this comparison simply defaults to the M, X and Y intersect case.</param> /// <returns>Boolean, true if they overlap anywhere, or even touch.</returns> public override bool Intersects(IExtent ext) { IExtentZ mExt = ext as IExtentZ; if (mExt != null && ext.HasZ && HasZ && (mExt.MaxZ < MinZ || mExt.MinZ > MaxZ)) { return(false); } return(base.Intersects(ext)); }
/// <summary> /// 世界坐标转像素坐标 /// </summary> /// <param name="extent"></param> /// <param name="rectangle"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static PointF CoordinateToPointF(IExtent extent, RectangleF rectangle, double x, double y) { PointF point = PointF.Empty; if (extent != null) { point = CoordinateToPointF(extent.MinX, extent.MaxY, extent.Width, extent.Height, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, x, y); } return(point); }
private void OnDataSetChanged() { IExtent extent = null; if (DataSet != null) { extent = DataSet.Extent; } Extent = extent; }
/// <summary> /// Copies from the implementation of IExtent. This checks to see if IExtentM is implemented /// and if not, this only sets the X and Y bounds. /// </summary> /// <param name="extent"></param> public override void CopyFrom(IExtent extent) { base.CopyFrom(extent); IExtentM mvals = extent as IExtentM; if (mvals == null || (double.IsNaN(mvals.MinM) || double.IsNaN(mvals.MaxM))) { MinM = double.MaxValue; MaxM = double.MinValue; } }
/// <summary> /// Integrates the Types into the extent /// </summary> /// <param name="typeExtent">Extent to be used</param> public void Into(IExtent typeExtent) { var layerOfTypes = _dataLayerLogic.GetDataLayerOfExtent(typeExtent); var layerOfUml = _dataLayerLogic.GetMetaLayerFor(layerOfTypes); var uml = _dataLayerLogic.Get<_UML>(layerOfUml); var factory = new MofFactory(); var typeProvider = new DotNetTypeGenerator(factory, uml); var typeForZipCodes = typeProvider.CreateTypeFor(typeof (Model.ZipCode)); typeExtent.elements().add(typeForZipCodes); }
/// <summary> /// 将世界范围转为像素范围 /// </summary> /// <param name="self"></param> /// <param name="extent"></param> /// <returns></returns> public static Rectangle ExtentToRectangle(this IProj self, IExtent extent) { PointF topLeft = CoordinateToPointF(self, extent.MinX, extent.MaxY); PointF bottomRight = CoordinateToPointF(self, extent.MaxX, extent.MinY); int left = (int)topLeft.X; int top = (int)topLeft.Y; int right = (int)bottomRight.X; int bottom = (int)bottomRight.Y; return(new Rectangle(left, top, right - left, bottom - top)); }
/// <summary> /// Copies from the implementation of IExtent. This checks to see if IExtentM is implemented /// and if not, this only sets the X and Y bounds. /// </summary> /// <param name="extent"></param> public override void CopyFrom(IExtent extent) { base.CopyFrom(extent); IExtentZ mvals = extent as IExtentZ; if (mvals == null || (double.IsNaN(mvals.MinZ) || double.IsNaN(mvals.MaxZ))) { MinZ = double.MaxValue; MaxZ = double.MinValue; } }
public bool Intersects(CollisionMode thisCollisionMode, IExtent otherExtent, CollisionMode otherCollisionMode) { if ((null == otherExtent) || (thisCollisionMode == CollisionMode.None || otherCollisionMode == CollisionMode.None) || (thisCollisionMode == CollisionMode.CenterPoint && otherCollisionMode == CollisionMode.CenterPoint)) { return(false); } return(IntersectsImpl(thisCollisionMode, otherExtent, otherCollisionMode)); }
public IExtent GetExtent() { IExtent extent = null; if (OgrGeometry != null) { OSGeo.OGR.Envelope envelope = new OSGeo.OGR.Envelope(); OgrGeometry.GetEnvelope(envelope); extent = envelope.ToExtent(); } return(extent); }
/// <summary> /// Copies the MinX, MaxX, MinY, MaxY values from extent. /// </summary> /// <param name="extent">Any IExtent implementation.</param> public virtual void CopyFrom(IExtent extent) { if (Equals(extent, null)) { throw new ArgumentNullException("extent"); } MinX = extent.MinX; MaxX = extent.MaxX; MinY = extent.MinY; MaxY = extent.MaxY; }
/// <summary> /// This allows parsing the X and Y values from a string version of the extent as: 'X[-180|180], Y[-90|90]' /// Where minimum always precedes maximum. The correct M or MZ version of extent will be returned if the string has those values. /// </summary> /// <param name="text">Text that contains the extent values.</param> /// <param name="result">Extent that was created.</param> /// <param name="nameFailed">Indicates which value failed.</param> /// <returns>True if the string could be parsed to an extent.</returns> public static bool TryParse(string text, out IExtent result, out string nameFailed) { double xmin, xmax, ymin, ymax, mmin, mmax; result = new Extent(); if (text.Contains("Z")) { double zmin, zmax; nameFailed = "Z"; if (!TryExtract(text, "Z", out zmin, out zmax)) { return(false); } result.MinZ = zmin; result.MaxZ = zmax; nameFailed = "M"; if (!TryExtract(text, "M", out mmin, out mmax)) { return(false); } result.MinM = mmin; result.MaxM = mmax; } if (text.Contains("M")) { nameFailed = "M"; if (!TryExtract(text, "M", out mmin, out mmax)) { return(false); } result.MinM = mmin; result.MaxM = mmax; } else { result = new Extent(); } nameFailed = "X"; if (!TryExtract(text, "X", out xmin, out xmax)) { return(false); } result.MinX = xmin; result.MaxX = xmax; nameFailed = "Y"; if (!TryExtract(text, "Y", out ymin, out ymax)) { return(false); } result.MinY = ymin; result.MaxY = ymax; return(true); }
/// <summary> /// Tests if the specified extent is contained by the this. /// </summary> /// <param name="ext">The extent to test.</param> /// <returns>True, if the extent is contained by this.</returns> public override bool Contains(IExtent ext) { if (ext is IExtentM mExt && ext.HasM && HasM) { if (mExt.MaxM < MinM || mExt.MinM > MaxM) { return(false); } } return(base.Contains(ext)); }
/// <summary> /// Tests if this contains the specified extent. If either element /// does not support M values, then only the default XY contains test is used. /// </summary> /// <param name="ext">The extent to test.</param> /// <returns>True, if this contains the specified extent.</returns> public override bool Contains(IExtent ext) { if (ext is IExtentZ mExt && ext.HasZ && HasZ) { if (mExt.MaxZ < MinZ || mExt.MinZ > MaxZ) { return(false); } } return(base.Contains(ext)); }
/// <summary> /// The shape type is assumed to be fixed, and will control how the input extent is treated as far /// as M and Z values, rather than updating the shape type based on the extent. /// </summary> public static void SetExtent(this ShapefileHeader header, IExtent extent) { IExtentZ zExt = extent as ExtentMZ; IExtentM mExt = extent as ExtentM; if ((header.ShapeType == ShapeType.MultiPointZ || header.ShapeType == ShapeType.PointZ || header.ShapeType == ShapeType.PolygonZ || header.ShapeType == ShapeType.PolyLineZ)) { if (zExt == null || extent.HasZ == false) { header.Zmin = double.MaxValue; header.Zmax = double.MinValue; } else { header.Zmin = zExt.MinZ; header.Zmax = zExt.MaxZ; } } if (header.ShapeType == ShapeType.MultiPointM || header.ShapeType == ShapeType.PointM || header.ShapeType == ShapeType.PolygonM || header.ShapeType == ShapeType.PolyLineM) { if (mExt == null || extent.HasM == false) { header.Mmin = double.MaxValue; header.Mmax = double.MinValue; } else { header.Mmin = mExt.MinM; header.Mmax = mExt.MaxM; } } header.Xmin = extent.MinX; header.Xmax = extent.MaxX; header.Ymin = extent.MinY; header.Ymax = extent.MaxY; }
public static IEnumerable<IObject> getDescendents(IExtent extent) { return getDescendents(extent.elements()); }
private static Extent ToBrutileExtent(IExtent extent) { return new Extent(extent.MinX, extent.MinY, extent.MaxX, extent.MaxY); }
/// <summary> /// Tests if this envelope is contained by the specified envelope. If either party doesn't have /// M constraints, they will not be used for this test. /// </summary> /// <param name="ext">implementation of IExtent to compare to.</param> /// <returns></returns> public override bool Within(IExtent ext) { IExtentM mExt = ext as IExtentM; if (mExt != null && ext.HasM && HasM) { if (mExt.MaxM < MaxM) { return false; } if (mExt.MinM > MinM) { return false; } } return base.Within(ext); }
/// <summary> /// Expands this extent to include the domain of the specified extent. If the specified case /// doesn't support IExtentM or HasM is false for that extent, then this test will default /// to the XY case. /// </summary> /// <param name="ext">The extent to expand to include.</param> public override void ExpandToInclude(IExtent ext) { IExtentM mExt = ext as IExtentM; if (mExt != null && ext.HasM && HasM) { if (mExt.MinM < MinM) { MinM = mExt.MinM; } if (mExt.MaxM > MaxM) { MaxM = mExt.MaxM; } } base.ExpandToInclude(ext); }
private void CreateFromExtent(IExtent extent) { _shapeRange = new ShapeRange(FeatureType.Polygon); var xMin = extent.MinX; var yMin = extent.MinY; var xMax = extent.MaxX; var yMax = extent.MaxY; _vertices = new[] { xMin, yMax, xMax, yMax, xMax, yMin, xMin, yMin }; _shapeRange.Parts.Add(new PartRange(_vertices, 0, 0, FeatureType.Polygon) { NumVertices = 4 }); }
/// <summary> /// Creates a clockwise polygon shape from an extent /// </summary> /// <param name="extent"></param> public Shape(IExtent extent) { if (extent == null) throw new ArgumentNullException("extent"); CreateFromExtent(extent); }
/// <summary> /// Creates a clockwise polygon shape from an extent /// </summary> /// <param name="extent"></param> public Shape(IExtent extent) { if (Equals(extent, null)) throw new ArgumentNullException("extent"); _shapeRange = new ShapeRange(FeatureType.Polygon); double xMin = extent.MinX; double yMin = extent.MinY; double xMax = extent.MaxX; double yMax = extent.MaxY; _vertices = new[] { xMin, yMax, xMax, yMax, xMax, yMin, xMin, yMin }; _shapeRange.Parts.Add(new PartRange(_vertices, 0, 0, FeatureType.Polygon) {NumVertices = 4}); }
/// <summary> /// Expands this extent to include the domain of the specified extent. If the specified case /// doesn't support IExtentM or HasM is false for that extent, then this test will default /// to the M, X and Y case. /// </summary> /// <param name="ext">The extent to expand to include</param> public override void ExpandToInclude(IExtent ext) { IExtentZ mExt = ext as IExtentZ; if (mExt != null && ext.HasZ && HasZ) { if (mExt.MinZ < MinZ) MinZ = mExt.MinZ; if (mExt.MaxZ > MaxZ) MaxZ = mExt.MaxZ; } base.ExpandToInclude(ext); }
/// <summary> /// Tests for an intersection with the specified extent. Both this extent and the /// other must implement IExtentM and HasM must be true for both, or else just /// the X and Y are compared. /// </summary> /// <param name="ext">The other extent. If the extent doesn't implement IExtentM, then /// this comparison simply defaults to the X Y intersect case.</param> /// <returns>Boolean, true if they overlap anywhere, or even touch.</returns> public override bool Intersects(IExtent ext) { IExtentM mExt = ext as IExtentM; if (mExt != null && ext.HasM && HasM) { if (mExt.MaxM < MinM) { return false; } if (mExt.MinM > MaxM) { return false; } } return base.Intersects(ext); }
/// <summary> /// Tests if this envelope is contained by the specified envelope. If either party doesn't have /// M constraints, they will not be used for this test. /// </summary> /// <param name="ext">implementation of IExtent to compare to.</param> /// <returns>Boolean.</returns> public override bool Within(IExtent ext) { IExtentZ mExt = ext as IExtentZ; if (mExt != null && ext.HasZ && HasZ) { if (mExt.MaxZ < MaxZ) { return false; } if (mExt.MinZ > MinZ) { return false; } } return base.Within(ext); }
/// <summary> /// Initializes a new instance of the ExtentM class that is specially designed to work /// with shapefile formats that have a Measure value. Obviously other formats can use /// this as well. /// </summary> /// <param name="xyExtent">An extent that contains only the x and y boundaries.</param> /// <param name="minM">The minimum M.</param> /// <param name="maxM">The maximum M.</param> public ExtentM(IExtent xyExtent, double minM, double maxM) { base.CopyFrom(xyExtent); MinM = minM; MaxM = maxM; }
/// <summary> /// Copies the MinX, MaxX, MinY, MaxY values from extent. /// </summary> /// <param name="extent">Any IExtent implementation.</param> public virtual void CopyFrom(IExtent extent) { if (Equals(extent, null)) throw new ArgumentNullException("extent"); MinX = extent.MinX; MaxX = extent.MaxX; MinY = extent.MinY; MaxY = extent.MaxY; }
/// <summary> /// Tests for an intersection with the specified extent. Both this extent and the /// other must implement IExtentM and HasM must be true for both, or else just /// the X and Y are compared. /// </summary> /// <param name="ext">The other extent. If the extent doesn't implement IExtentM, then /// this comparison simply defaults to the M, X and Y intersect case.</param> /// <returns>Boolean, true if they overlap anywhere, or even touch.</returns> public override bool Intersects(IExtent ext) { IExtentZ mExt = ext as IExtentZ; if (mExt != null && ext.HasZ && HasZ && (mExt.MaxZ < MinZ || mExt.MinZ > MaxZ)) return false; return base.Intersects(ext); }
/// <summary> /// Expands this extent to include the domain of the specified extent /// </summary> /// <param name="ext">The extent to expand to include</param> public virtual void ExpandToInclude(IExtent ext) { if (ext == null) //Simplify, avoiding nested if return; if (double.IsNaN(MinX) || ext.MinX < MinX) { MinX = ext.MinX; } if (double.IsNaN(MinY) || ext.MinY < MinY) { MinY = ext.MinY; } if (double.IsNaN(MaxX) || ext.MaxX > MaxX) { MaxX = ext.MaxX; } if (double.IsNaN(MaxY) || ext.MaxY > MaxY) { MaxY = ext.MaxY; } }
/// <summary> /// Tests if this envelope is contained by the specified envelope /// </summary> /// <param name="ext">The extent to test.</param> /// <returns>Boolean.</returns> public override bool Contains(IExtent ext) { IExtentZ mExt = ext as IExtentZ; if (mExt != null && ext.HasZ && HasZ) { if (mExt.MaxZ > MaxZ || mExt.MinZ < MinZ) return false; } return base.Within(ext); }
/// <summary> /// Tests for an intersection with the specified extent /// </summary> /// <param name="ext">The other extent</param> /// <returns>Boolean, true if they overlap anywhere, or even touch</returns> public virtual bool Intersects(IExtent ext) { if (Equals(ext, null)) throw new ArgumentNullException("ext"); if (ext.MaxX < MinX) { return false; } if (ext.MaxY < MinY) { return false; } if (ext.MinX > MaxX) { return false; } return !(ext.MinY > MaxY); }
public void RemoveFromExtent(IExtent extent) { lock (_extents) { _extents.Remove(extent); } }
/// <summary> /// Tests if this envelope is contained by the specified envelope /// </summary> /// <param name="ext"></param> /// <returns></returns> public virtual bool Within(IExtent ext) { if (Equals(ext, null)) throw new ArgumentNullException("ext"); if (MinX < ext.MinX) { return false; } if (MaxX > ext.MaxX) { return false; } if (MinY < ext.MinY) { return false; } return !(MaxY > ext.MaxY); }
/// <summary> /// The shape type is assumed to be fixed, and will control how the input extent is treated as far /// as M and Z values, rather than updating the shape type based on the extent. /// </summary> public void SetExtent(IExtent extent) { IExtentZ zExt = extent as ExtentMZ; IExtentM mExt = extent as ExtentM; if ((ShapeType == ShapeType.MultiPointZ || ShapeType == ShapeType.PointZ || ShapeType == ShapeType.PolygonZ || ShapeType == ShapeType.PolyLineZ)) { if (zExt == null || extent.HasZ == false) { _zMin = double.MaxValue; _zMax = double.MinValue; } else { _zMin = zExt.MinZ; _zMax = zExt.MaxZ; } } if (ShapeType == ShapeType.MultiPointM || ShapeType == ShapeType.PointM || ShapeType == ShapeType.PolygonM || ShapeType == ShapeType.PolyLineM) { if (mExt == null || extent.HasM == false) { _mMin = double.MaxValue; _mMax = double.MinValue; } else { _mMin = mExt.MinM; _mMax = mExt.MaxM; } } _xMin = extent.MinX; _xMax = extent.MaxX; _yMin = extent.MinY; _yMax = extent.MaxY; }
/// <summary> /// Reads the file from the stream /// </summary> /// <param name="path">Path being used to load the file</param> /// <param name="extent">Extet being stored</param> /// <param name="settings">Settings being used to store it.</param> private void ReadFromStream(IExtent extent, IFactory factory, Stream stream, CSVSettings settings) { if (settings == null) { settings = new CSVSettings(); } var columns = settings.Columns; var createColumns = false; using (var streamReader = new StreamReader(stream, Encoding.GetEncoding(settings.Encoding))) { if (columns == null) { createColumns = true; } // Reads header, if necessary if (settings.HasHeader) { columns.Clear(); // Creates the column names for the headline var ignoredLine = streamReader.ReadLine(); var columnNames = SplitLine(ignoredLine, settings); foreach (var columnName in columnNames) { columns.Add(columnName); } } // Reads the data itself string line; while ((line = streamReader.ReadLine()) != null) { var values = SplitLine(line, settings); var csvObject = factory.create(null); // we now have the created object, let's fill it var valueCount = values.Count; for (var n = 0; n < valueCount; n++) { string foundColumn; // Check, if we have enough columns, if we don't have enough columns, create one if (columns.Count <= n && (createColumns || !settings.HasHeader)) { // Create new column foundColumn = $"Column {n + 1}"; columns.Add(foundColumn); } else { foundColumn = columns[n]; } csvObject.set(foundColumn, values[n]); } extent.elements().add(csvObject); } } }