Closed RaoOfPhysics closed 7 years ago
Converting lat/lng to address is done here: https://github.com/wildtreetech/sentinel2-bot/blob/master/sentinel2.py#L122-L143 so we have everything OSM knows about the place.
It uses the centre of the image as the point it reverse geocodes via nominatim. You can have a fiddle with the API to see if you can get the info you need from it.
The tweets already are geotagged, via the lat/lng so in principle searching for the tweets via "location" info should find them. Click the little pin in the top right of a tweet:
Adding more text to the tweet is tricky, because already they use a lot of the 140 characters so some text would have to go/be swapped.
Note: sometimes (twice or three times?) a bot seems to spot that a tweet is about their country and retweets a tweet. I've seen it happen for Mozambique (I think)
@betatim: Your link to “reverse geocodes” is broken.
So, I think what we need to do is change this line:
return _cut(info['display_name'])
needs to be (?):
return (_cut(info['state_district']), ', ', _cut(info['state']), ', ', _cut(info['postcode']), ', #', _cut(info['country']))
Is this correct syntax?
I should've clarified that when I said "tag" I meant "hashtag". :) It's just one additional character.
Adding more text to the tweet is tricky, because already they use a lot of the 140 characters so some text would have to go/be swapped.
How about changing the date displayed to, say, "5 Mar ’16" instead of "5 March 2016"?
EDIT: Just realised that the hashtagging would become a problem for countries like "New Zealand" or "South Africa" with spaces. :(
(Fixed the reverse geo link)
Syntax is basically right, you'd probably run the _cut()
on the whole string. The idea is to shrink the overall string to the right length.
return _cut(', '.join(info['state_district'], info['state'], info['postcode'], '#' + info['country'])
is the pythonic way of saying "join these strings together using ', '
.
Id' remove the postcode I think, not that exciting a piece of information. The other thing to add would be a check that the info
actually contains something for each of the fields you want.
fields = []
for field in ('state_district', 'state', 'country'):
if field in info:
if field == 'country':
# add hashsymbol and do something smart about spaces
fields.append(processed_country_name)
else:
fields.append(info[field])
return _cut(", ".join(fields))
OK, closing this issue after private chat with Tim. There are issues with the API spitting out the full name of USA (making #UnitedStatesofAmerica
a clunky hashtag) and marking South Africa as RSA. Not priority to figure out how to properly hashtag places.
Hey @betatim. Nice work!
It would be nice if you were able to tag the countries (and maybe cities?) shown in the tweets. Would mean that your bot's tweets show up in tag-search results.
EDIT: I will try poking in the code to see where this needs to be added, but pointers are appreciated! :)