Rebuilding FourSquare for ActivityPub using OpenStreetMap
https://shkspr.mobi/blog/2024/01/rebuilding-foursquare-for-activitypub-using-openstreetmap/
I used to like the original FourSquare. The "mayor" stuff was a bit silly, and my friends never left that many reviews, but I loved being able to signal to my friends "I am at this cool museum" or "We're at this pub if you want to meet" or "Spending the day at the park".
So, is there a way to recreate that early Web 2.0 experience with open data and ActivityPub? Let's find out!
This quest is divided into two parts.
OpenStreetMap is the Wikipedia of maps. It is a freely available resource which anyone can edit (if they're skilled enough).
It also comes with a pretty decent API for querying things. For example,
As you can see, it has highlighted some useful areas - a pharmacy and a pub. But it has ignored other useful locations - the train station and the park. It has also included some things that we may not want - bike parking and a taxi rank.
What API call is needed to get useful locations of of OverPass?
It's possible to specify the type of thing to find using
It is also possible to exclude specific types of places. This retrieves all amenities except for fast food joints:
Again, that would be complex.
Perhaps one solution is just to return everything and let the user decide if they want to check in to a telephone kiosk or a fire hydrant? That's a bit user-hostile.
Instead, this query returns everything which has a name
That cuts out any unnamed things - like park benches and car-sharing spots. But it does add named roads and train lines.
It is possible to use filters to exclude results from OverPass. The best that I can come up with is:
That gets everything which has a name, but isn't a highway or railway or waterway or powerline. It isn't perfect - but it will do!
This is the query which will retrieve the 25 nearest things within 100 metres of a specific latitude and longitude. It includes the name and any other tags, the location, and the OSM ID.
There's good news and bad news here. Firstly, ActivityStreams (which are subscribed to in ActivityPub) supports the concept of "Place" and "Location".
Once the user has a latitude and longitude, the can share it - along with a message, photo, or anything else.
Something like:
For example, here's a PixelFed post with an attached location - and this is the JSON representation. That status can be reposted into other social networks.
It is worth noting that Mastodon doesn't (natively) support location - if you view my repost of that PixelFed post you'll see there's no location metadata attached. That's OK! It just means that the status needs to include human-readable data.
Similarly, Mastodon doesn't support the
Other ActivityPub services do support location.
Well… that's a job for next week. Probably!
https://shkspr.mobi/blog/2024/01/rebuilding-foursquare-for-activitypub-using-openstreetmap/
#ActivityPub #fediverse #FOURSQUARE #geolocation #OpenStreetMap
https://shkspr.mobi/blog/2024/01/rebuilding-foursquare-for-activitypub-using-openstreetmap/
I used to like the original FourSquare. The "mayor" stuff was a bit silly, and my friends never left that many reviews, but I loved being able to signal to my friends "I am at this cool museum" or "We're at this pub if you want to meet" or "Spending the day at the park".
So, is there a way to recreate that early Web 2.0 experience with open data and ActivityPub? Let's find out!
This quest is divided into two parts.
- Get nearby "Points of Interest" (POI) from OpenStreetMap.
- Share a location on the Fediverse.
OpenStreetMap API
OpenStreetMap is the Wikipedia of maps. It is a freely available resource which anyone can edit (if they're skilled enough).
It also comes with a pretty decent API for querying things. For example,
nw["amenity"]({{bbox}});
finds all "amenities" near a specific location.As you can see, it has highlighted some useful areas - a pharmacy and a pub. But it has ignored other useful locations - the train station and the park. It has also included some things that we may not want - bike parking and a taxi rank.
What API call is needed to get useful locations of of OverPass?
It's possible to specify the type of thing to find using
nw["amenity"="restaurant"];
- but adding every single type of thing would quickly end up with a very large query containing hundreds of types.It is also possible to exclude specific types of places. This retrieves all amenities except for fast food joints:
nw["amenity"]({{bbox}});-nw["amenity"="fast_food"]({{bbox}});
Again, that would be complex.
Perhaps one solution is just to return everything and let the user decide if they want to check in to a telephone kiosk or a fire hydrant? That's a bit user-hostile.
Instead, this query returns everything which has a name
nw["name"]({{bbox}});
That cuts out any unnamed things - like park benches and car-sharing spots. But it does add named roads and train lines.
It is possible to use filters to exclude results from OverPass. The best that I can come up with is:
nw["name"][!"highway"][!"railway"][!"waterway"][!"power"]({{bbox}});
That gets everything which has a name, but isn't a highway or railway or waterway or powerline. It isn't perfect - but it will do!
This is the query which will retrieve the 25 nearest things within 100 metres of a specific latitude and longitude. It includes the name and any other tags, the location, and the OSM ID.
overpass-api.de/api/interpreter?data=[out:json];nw["name"][!"highway"][!"railway"][!"waterway"][!"power"](around:100,51.5202,-0.1040);out center qt 25;
ActivityPub
There's good news and bad news here. Firstly, ActivityStreams (which are subscribed to in ActivityPub) supports the concept of "Place" and "Location".
Once the user has a latitude and longitude, the can share it - along with a message, photo, or anything else.
Something like:
{ "@context": "https://www.w3.org/ns/activitystreams", "type": "Note", "content": "Here in NYC! <a href=\"https://www.openstreetmap.org/way/958999496\">John Lennon's Imagine Mosaic</a>.", "attachment": [ { "type": "Image", "mediaType": "image\/jpeg", "url": "https:\/\/fastly.4sqi.net\/img\/general\/590x786\/56367_9pxuZJD7d1hgPdaMFcFq1pipvTTMynBJsYcpHH-b8mU.jpg", "name": "A photo of a mosaic which says 'Imagine'." } ], "location": { "name": "John Lennon's Imagine", "type": "Place", "longitude": 40.77563, "latitude": -73.97474 }}
For example, here's a PixelFed post with an attached location - and this is the JSON representation. That status can be reposted into other social networks.
It is worth noting that Mastodon doesn't (natively) support location - if you view my repost of that PixelFed post you'll see there's no location metadata attached. That's OK! It just means that the status needs to include human-readable data.
Similarly, Mastodon doesn't support the
arrive
vocabulary. So this will be limited to a message with a location attached.Other ActivityPub services do support location.
Putting it all together
Well… that's a job for next week. Probably!
- Building a web site which gets the user's location is easy.
- Getting the data from OverPass should be straightforward.
- Creating an ActivityPub server which can post geotagged notes into the Fediverse might be a little beyond my skillset! Some testing with Darius Kazemi's AP Glitch suggests this should work.
https://shkspr.mobi/blog/2024/01/rebuilding-foursquare-for-activitypub-using-openstreetmap/
#ActivityPub #fediverse #FOURSQUARE #geolocation #OpenStreetMap
Rebuilding FourSquare for ActivityPub using OpenStreetMap
I used to like the original FourSquare. The "mayor" stuff was a bit silly, and my friends never left that many reviews, but I loved being able to signal to my friends "I am at this cool museum" or "We're at this pub if you want to meet" or "Spending …Terence Eden’s Blog
MiKlo:~/citizen4.eu$💙💛 lubi to.
💙💛:~/eu/pl/priv$:idle:udostępnił to.
MiKlo:~/citizen4.eu$💙💛
#Friendica also allows you to add a #geolocation to a post (but not to a comment).
Terence Eden’s Blog
•For me, it is important to have a human-readable location. So that might be a statue in a park, but it is unlikely to be a specific tree.
Suggestions welcome for how to structure that query!
Terence Eden’s Blog
•So that's why I'm just going for things which have names, but aren't streets.