コード例 #1
0
ファイル: QuadTree.cs プロジェクト: milesibastos/OsmSharp
 /// <summary>
 /// Adds data to this node.
 /// </summary>
 /// <param name="point"></param>
 /// <param name="data"></param>
 internal void AddData(TPointType point, TDataType data)
 {
     if (_depth > 0)
     {
         throw new Exception("Cannot add data to a non-leaf node!");
     }
     _data.Add(new KeyValuePair <TPointType, TDataType>(point, data));
 }
コード例 #2
0
ファイル: QuadTree.cs プロジェクト: milesibastos/OsmSharp
            /// <summary>
            /// Returns the smallest quadtree node at depth zero that encompasses the given node.
            /// </summary>
            /// <param name="point"></param>
            /// <returns></returns>
            public QuadTreeNode GetOrCreateAt(TPointType point)
            {
                // return this tree if this one is at dimension 0.
                if (_depth == 0)
                {
                    return(this);
                }

                if (_middle0 > point[0])
                {     // small side of dimension 0.
                    if (_middle1 > point[1])
                    { // small side of dimension 1.
                        if (_minMin == null)
                        {
                            _minMin = new QuadTreeNode(_depth - 1,
                                                       this.Min0, this.Min1, _middle0, _middle1);
                        }
                        return(_minMin.GetOrCreateAt(point));
                    }
                    else
                    { // large side of dimension 1.
                        if (_minMax == null)
                        {
                            _minMax = new QuadTreeNode(_depth - 1,
                                                       this.Min0, _middle1, _middle0, this.Max1);
                        }
                        return(_minMax.GetOrCreateAt(point));
                    }
                }
                else
                {     // large side of dimension 0.
                    if (_middle1 > point[1])
                    { // small side of dimension 1.
                        if (_maxMin == null)
                        {
                            _maxMin = new QuadTreeNode(_depth - 1,
                                                       _middle0, this.Min1, this.Max0, _middle1);
                        }
                        return(_maxMin.GetOrCreateAt(point));
                    }
                    else
                    { // large side of dimension 1.
                        if (_maxMax == null)
                        {
                            _maxMax = new QuadTreeNode(_depth - 1,
                                                       _middle0, _middle1, this.Max0, this.Max1);
                        }
                        return(_maxMax.GetOrCreateAt(point));
                    }
                }
            }
コード例 #3
0
ファイル: QuadTree`2.cs プロジェクト: hungdluit/OsmSharp
 public QuadTree <TPointType, TDataType> .QuadTreeNode GetOrCreateAt(TPointType point)
 {
     if (this._depth == 0)
     {
         return(this);
     }
     if (this._middle0 > point[0])
     {
         if (this._middle1 > point[1])
         {
             if (this._minMin == null)
             {
                 this._minMin = new QuadTree <TPointType, TDataType> .QuadTreeNode(this._depth - 1, this.Min0, this.Min1, this._middle0, this._middle1);
             }
             return(this._minMin.GetOrCreateAt(point));
         }
         if (this._minMax == null)
         {
             this._minMax = new QuadTree <TPointType, TDataType> .QuadTreeNode(this._depth - 1, this.Min0, this._middle1, this._middle0, this.Max1);
         }
         return(this._minMax.GetOrCreateAt(point));
     }
     if (this._middle1 > point[1])
     {
         if (this._maxMin == null)
         {
             this._maxMin = new QuadTree <TPointType, TDataType> .QuadTreeNode(this._depth - 1, this._middle0, this.Min1, this.Max0, this._middle1);
         }
         return(this._maxMin.GetOrCreateAt(point));
     }
     if (this._maxMax == null)
     {
         this._maxMax = new QuadTree <TPointType, TDataType> .QuadTreeNode(this._depth - 1, this._middle0, this._middle1, this.Max0, this.Max1);
     }
     return(this._maxMax.GetOrCreateAt(point));
 }
コード例 #4
0
ファイル: QuadTree.cs プロジェクト: milesibastos/OsmSharp
 /// <summary>
 /// Returns true if the point is inside.
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 internal bool IsInsideBox(TPointType point)
 {
     return(_bounds.IsInside(point));
 }
コード例 #5
0
 public ClusterPoint(TPointType point)
 {
     Point   = point;
     Cluster = Undefined;
 }
コード例 #6
0
 /// <summary>
 /// Returns true if the point is inside.
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 internal bool IsInsideBox(TPointType point)
 {
     return(_bounds.Contains(point));
 }
コード例 #7
0
ファイル: QuadTree`2.cs プロジェクト: hungdluit/OsmSharp
 internal bool IsInsideBox(TPointType point)
 {
     return(this._bounds.Contains((PointF2D)point));
 }