mapillary / mapillary/mapillary-python-sdk

Bug Report

Open
#150 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
66
Forks
23
Avg merge
1d 20h
Merged PRs (30d)
11

Description

Describe the bug
xtile = int(math.floor((x + EPSILON) * Z2))
ValueError: cannot convert float NaN to integer

To Reproduce
This is the code I am using to collect th close-to images to a specific coordinates:
for index, row in enumerate(df.iterrows()):
coordinates_to_image_id_dict: dict = {}
latitude, longitude = dict(row[1])['LATITUDE'], dict(row[1])['LONGITUDE']
coordinates_to_image_id_dict['lat'] = latitude
coordinates_to_image_id_dict['lng'] = longitude
try:
data= mly.get_image_close_to(
latitude=latitude,
longitude=longitude,
radius=35,
image_type="flat",
min_captured_at="2016-01-01"
).to_dict()

except AttributeError:
print('AttributeError occurred')
data = {}

print(data)
print('latitude and longitude:', latitude, longitude)

Expected behavior
if math.isnan(x):
# handle NaN case here
else:
xtile = int(math.floor((x + EPSILON) * Z2))

Screenshots
latitude and longitude: 51.9326934493218 -8.05201349824569
Requesting GET to https://tiles.mapillary.com/maps/vtp/mly1_public/2/14/7892/5318/?access_token=MLY%???
Response 200 OK received in 78ms
{'type': 'FeatureCollection', 'features': []}

latitude and longitude: 53.2429118794892 -6.58873419758931
Traceback (most recent call last):
File "Data_collection_json_metadata.py", line 39, in
min_captured_at="2016-01-01"
File "/home/peoplexxx/.local/lib/python3.7/site-packages/mapillary/utils/auth.py", line 59, in wrapper
return f(*args, **kwargs)
File "/home/people/xx/.local/lib/python3.7/site-packages/mapillary/interface.py", line 116, in get_image_close_to
kwargs=kwargs,
File "/home/people/xx/.local/lib/python3.7/site-packages/mapillary/controller/image.py", line 110, in get_image_close_to_controller
latitude=latitude,
File "/home/people/xxx/.local/lib/python3.7/site-packages/mapillary/models/api/vector_tiles.py", line 123, in fetch_layer
tile=mercantile.tile(lng=longitude, lat=latitude, zoom=zoom),
File "/home/people/xxxx/.local/lib/python3.7/site-packages/mercantile/init.py", line 426, in tile
xtile = int(math.floor((x + EPSILON) * Z2))
ValueError: cannot convert float NaN to integer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with mapillary/controller/image.py at get_image_close_to_controller and mapillary/models/api/vector_tiles.py at fetch_layer, then reproduce the reported coordinates through get_image_close_to. Inspect how the call reaches mercantile.tile and compare the result with the issue's expected NaN handling; done means the request no longer fails unexpectedly for this input and the behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.