tomasbedrich / pycaching

A Python 3 interface for working with Geocaching.com website.
https://pycaching.readthedocs.io/
GNU Lesser General Public License v3.0
61 stars 46 forks source link

Unexpected results when searching caches from a point #227

Closed SteveMan67 closed 11 months ago

SteveMan67 commented 11 months ago

With this code,

import pycaching
from pycaching.cache import Type
from pycaching.geo import Point

geocaching = pycaching.login("user", "pass")

point = geocaching.geocode("Tulsa")

for cache in geocaching.search(point, limit=10):
    print(cache.name)
    print(cache.location.format_decimal())

It gives me results like this:

En la senda al Orlando Bravo #08 -27.25155, -65.894667 al crater!!!! -33.15815, -65.3901 Natural Arch Viewpoint 53.418867, -118.8868 Kennelly's Lake Put-in 45.288267, -77.389533 Mirador del Tala Caido ...

These are nowhere near Tulsa. I also tried the geo.Point() module, which had the same results, which are all over the place.

DarkOutcast6 commented 11 months ago

Please don’t include your credentials in your code. Also, (I’m not 100% sure) but I believe that geocoding takes in a address - there could be multiple places in the world with the name “Tulsa” in it.

SteveMan67 commented 11 months ago

I tried a coordinate point as well and got the same results.

BelKed commented 11 months ago

No idea what is happening, but with my account, on the latest version (0.4.4), I'm getting these results:

Coney v Hot Dog
36.106, -95.9178

#1 - Places we love to go!
PMO

We All Float Down Here #2
36.09898, -95.916256

An Extra Unextraordinary Corner
36.098216, -95.914181

We All Float Down Here
36.097555, -95.917133

Ramble and Read
36.0973, -95.9212

Disc-overy!
36.0993, -95.9266333333333

Lake view
36.115067, -95.928983

Quite a Darling Place
36.122667, -95.9177

Escape!!
36.119665, -95.904155
BelKed commented 11 months ago

Oh, now I know what's happening :D

So, the default sort parameter in the Geocaching.search() method is SortOrder.date_last_visited. And as I've mentioned in https://github.com/tomasbedrich/pycaching/issues/204, for basic members only SortOrder.distance works.

So your account probably isn't a basic member. And the caches you get from the code are sorted by SortOrder.date_last_visited.

For now, there's a working code that gives the expected results:

import pycaching
from pycaching.geocaching import SortOrder

geocaching = pycaching.login("login", "password")

point = geocaching.geocode("Tulsa")

for cache in geocaching.search(point, limit=10, sort_by=SortOrder.distance):
    print(cache.name)
    print(cache.location.format_decimal())
FriedrichFroebel commented 11 months ago

Given the comment by @BelKed, it seems like this is just some usage issue I am and going to close this as resolved.