Skip to content

Problem with points #1

Description

@tsauerwein

Removing and searching points does not work properly. I think the problem is that the width and height of the rectangle for points is 0. For example the rectangle used to insert the point (1 1) is: {x: 1, y: 1, w: 0, h: 0}

<html>
    <head>
        <script src="RTree/src/rtree.js"></script>
        <script type="text/javascript">
            var rtee;

            function init() {
                rtree = new RTree();

                var point1 = {  'id': 1,
                                'bounds': {x: 10, y: 5, w: 0, h: 0}};
                var point2 = {  'id': 2,
                                'bounds': {x: 6, y: 7, w: 0, h: 0}};

                rtree.insert(point1.bounds, point1);
                rtree.insert(point2.bounds, point2);

                var removedCount = rtree.remove(point1.bounds, point1);
                console.log(removedCount); // output: []

                removedCount = rtree.remove({x: 9.5, y: 4.5, w: 1, h: 1}, point1);
                console.log(removedCount); // output: [Object] (leaf containing point1)


                var objects = rtree.search({x:6, y: 7, w: 1, h: 1});
                console.log(objects); // output: []

                objects = rtree.search({x:5.5, y: 6.5, w: 1, h: 1});
                console.log(objects[0]); // output: Object (point2)
            }
        </script>
    </head>
    <body onload="init()">
    </body>
</html>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions