Skip to content

Overflow/underflow issues #148

Description

@plooney

The KDtree uses x2 + y2 <= r**2. For very small x,y and r you can get issues. Should we be using float64.hypot as in rust.geo?

import numpy as np
from geoindex_rs import kdtree as kd

e = 10**(-308)
# Three points: (0, 2), (1, 3), (2, 4)
x = np.arange(0, 3)*e
y = np.arange(2, 5)*e

# When creating the builder, the total number of items must be passed
builder = kd.KDTreeBuilder(3)

# Add the points to the builder
builder.add(x, y)

# Consume the builder (sorting the index) and create the KDTree.
tree = builder.finish()

# Search within this bounding box:
results = kd.within(tree,qx=0,qy=0,r=e)

(np.hypot(x,y) < e), results.to_numpy()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions