Skip to content

AttributeError: 'Matcher' object has no attribute 'tree' when calling reverse_geocode #10

@cantodelobo

Description

@cantodelobo

AttributeError: 'Matcher' object has no attribute 'tree' when calling reverse_geocode

I have a problem when running matcher.reverse_geocode, this is the error:

Traceback (most recent call last):
  File "/mnt/d/DeepRetailWA2/probando.py", line 11, in <module>
    response2 = matcher.reverse_geocode([(-37.761993408203125, 144.97064208984375)])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/d/DeepRetailWA2/.venv/lib/python3.12/site-packages/whereabouts/Matcher.py", line 155, in reverse_geocode
    query_indices = self.tree.query(points)[1]
                    ^^^^^^^^^
AttributeError: 'Matcher' object has no attribute 'tree'

This is my code:

import json

from whereabouts.Matcher import Matcher

matcher = Matcher("au_all_sm")
response = matcher.geocode(
    ["34/121 exhibition st melbourne", "645 sydney rd brunswick"]
)
print(json.dumps(response, indent=4))

response2 = matcher.reverse_geocode([(-37.761993408203125, 144.97064208984375)])

print(json.dumps(response2, indent=4))

Expected behavior:
reverse_geocode should return the nearest address for the given coordinates.

Actual behavior:
It raises an AttributeError because the Matcher object has no attribute tree.

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