internal static void Compare <T>(
     double x,
     double y,
     T expected,
     XYPointWValue <T> point)
 {
     Assert.AreEqual(x, point.X);
     Assert.AreEqual(y, point.Y);
     Assert.AreEqual(expected, point.Value);
 }
Example #2
0
        private static int SetOnLeaf(
            PointRegionQuadTreeNodeLeaf<object> leaf,
            double x,
            double y,
            XYPointWValue<TL> pointXY)
        {
            if (pointXY.X != x && pointXY.Y != y) {
                throw new IllegalStateException();
            }

            return SetOnLeaf(leaf, x, y, pointXY.Value);
        }
Example #3
0
 private static void AddToBranch(
     PointRegionQuadTreeNodeBranch branch,
     double x,
     double y,
     XYPointWValue<TL> value,
     PointRegionQuadTree<object> tree)
 {
     var quadrant = branch.Bb.GetQuadrant(x, y);
     if (quadrant == QuadrantEnum.NW) {
         branch.Nw = SetOnNode(x, y, value, branch.Nw, tree);
     }
     else if (quadrant == QuadrantEnum.NE) {
         branch.Ne = SetOnNode(x, y, value, branch.Ne, tree);
     }
     else if (quadrant == QuadrantEnum.SW) {
         branch.Sw = SetOnNode(x, y, value, branch.Sw, tree);
     }
     else {
         branch.Se = SetOnNode(x, y, value, branch.Se, tree);
     }
 }
Example #4
0
 private static void SubdividePoint(
     XYPointWValue<TL> point,
     PointRegionQuadTreeNodeBranch branch,
     PointRegionQuadTree<object> tree)
 {
     var x = point.X;
     var y = point.Y;
     var quadrant = branch.Bb.GetQuadrant(x, y);
     if (quadrant == QuadrantEnum.NW) {
         branch.Nw = SetOnNode(x, y, point, branch.Nw, tree);
     }
     else if (quadrant == QuadrantEnum.NE) {
         branch.Ne = SetOnNode(x, y, point, branch.Ne, tree);
     }
     else if (quadrant == QuadrantEnum.SW) {
         branch.Sw = SetOnNode(x, y, point, branch.Sw, tree);
     }
     else {
         branch.Se = SetOnNode(x, y, point, branch.Se, tree);
     }
 }
Example #5
0
        private static PointRegionQuadTreeNode SetOnNode(
            double x,
            double y,
            XYPointWValue<TL> value,
            PointRegionQuadTreeNode node,
            PointRegionQuadTree<object> tree)
        {
            if (node is PointRegionQuadTreeNodeLeaf<object> leaf) {
                var count = SetOnLeaf(leaf, x, y, value);
                leaf.IncCount(count);

                if (leaf.Count <= tree.LeafCapacity || node.Level >= tree.MaxTreeHeight) {
                    return leaf;
                }

                node = Subdivide(leaf, tree);
            }

            var branch = (PointRegionQuadTreeNodeBranch) node;
            AddToBranch(branch, x, y, value, tree);
            return node;
        }