Beispiel #1
0
 /// <summary>
 /// Constructor to store the information.
 /// </summary>
 /// <param name="time">DateTime time</param>
 /// <param name="data">double data value</param>
 /// <param name="xyLayerPoint">an X,Y,Layer position</param>
 /// <param name="variableID">variable ID</param>
 public DataPoint(DateTime time, double data, IXYLayerPoint xyLayerPoint, string variableID)
 {
     _time         = time;
     _data         = data;
     _xyLayerPoint = xyLayerPoint;
     _variableID   = variableID;
 }
Beispiel #2
0
        /// <summary>
        /// Returns the distance between the two points.
        /// </summary>
        /// <param name="p1">Point</param>
        /// <param name="p2">Point</param>
        /// <returns>Point to point distance</returns>
        public static double CalculatePointToPointDistance2D(IXYLayerPoint p1, ICoordinate p2)
        {
            double dx = p1.X - p2.X;
            double dy = p1.Y - p2.Y;

            return(Math.Sqrt(dx * dx + dy * dy));
        }
Beispiel #3
0
        /// <summary>
        /// Return whether the point is inside this structure.
        /// If this structure is a 1D point, then the (x,y,layer) values must be the same.
        /// </summary>
        /// <param name="pt">The point to check wether it's within this object spatially.</param>
        /// <param name="layerIndifferent">layer specific</param>
        /// <returns></returns>
        public bool PointInObject(IXYLayerPoint pt, bool layerIndifferent = false)
        {
            if (!layerIndifferent)
            {
                if (_geometry == GeometryTypes.GeometryPoint)
                {
                    double EPSILON = 0.001;
                    if (Math.Abs(pt.X - _pt1.X) < EPSILON && Math.Abs(pt.Y - _pt1.Y) < EPSILON && pt.Layer == _pt1.Layer)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else // 2D or 3D case

                if (pt.X > XMinCoordinate && pt.X < XMaxCoordinate &&
                    pt.Y > YMinCoordinate && pt.Y < YMaxCoordinate &&
                    pt.Layer == _pt1.Layer)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (_geometry == GeometryTypes.GeometryPoint)
                {
                    double EPSILON = 0.001;
                    if (Math.Abs(pt.X - _pt1.X) < EPSILON && Math.Abs(pt.Y - _pt1.Y) < EPSILON)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else // 2D or 3D case

                if (pt.X > XMinCoordinate && pt.X < XMaxCoordinate &&
                    pt.Y > YMinCoordinate && pt.Y < YMaxCoordinate)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Constructor 2D or 3D
        /// </summary>
        public SpatialDefine(IXYLayerPoint pt1, IXYLayerPoint pt2, GeometryTypes gm)
        {
            _pt1      = pt1;
            _pt2      = pt2;
            _geometry = gm;

            if (pt1.Layer != pt2.Layer)
            {
                throw new Exception("Layer number must be the same for the two points");
            }
        }
Beispiel #5
0
 /// <summary>
 /// Seaches the model coordinates to find if the given point is locaded within the model. If so, return the model index.
 /// NOTE the point is a Z LAYER!
 /// </summary>
 /// <param name="pt">a point to search for</param>
 /// <param name="modelCoordinates">Dictionary containing the model coordinates as values and the key is the model index for each coordinate.</param>
 /// <returns>Return model index if found, else return -1</returns>
 public static int ModelIndexWherePointIsLocated(IXYLayerPoint pt, IDictionary <int, ISpatialDefine> modelCoordinates)
 {
     foreach (KeyValuePair <int, ISpatialDefine> pair in modelCoordinates)
     {
         if (pair.Value.PointInObject(new XYLayerPoint(pt.X, pt.Y, pt.Layer), false))
         {
             return(pair.Key);
         }
         ;
     }
     return(-1);
 }
Beispiel #6
0
 /// <summary>
 /// Constructor 1D
 /// </summary>
 public SpatialDefine(IXYLayerPoint pt1)
 {
     _pt1      = pt1;
     _geometry = GeometryTypes.GeometryPoint;
 }
Beispiel #7
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public SpatialDefine()
 {
     _pt1      = new XYLayerPoint(-9999, -9999, -9999);
     _pt2      = new XYLayerPoint(-9999, -9999, -9999);
     _geometry = GeometryTypes.GeometryPoint;
 }
Beispiel #8
0
 /// <summary>
 /// Finds if the given point is located in the model grid.
 /// Cycles through every grid rectangle.
 /// </summary>
 /// <param name="pt">point to check if it's within the grid.</param>
 /// <param name="modelCoordinates">the model grid.</param>
 /// <param name="layerIndifferent">layer specific</param>
 /// <returns></returns>
 public static bool IsPointInModelPlain(IXYLayerPoint pt, IDictionary <int, ISpatialDefine> modelCoordinates, bool layerIndifferent = false)
 {
     return(modelCoordinates.Values.Any(rec => rec.PointInObject(new XYLayerPoint(pt.X, pt.Y, 0), layerIndifferent)));
 }