Background
The wish to display coordinates produced by a SPARQL query on a map came up in our initial interviews and has been a longstanding ticket T188291: Display point features (coordinates) from the results of a SPARQL query on a map in Wikipedia. We see adding this functionality as being a potential key improvement for Kartographer and its usefulness for Wikipedia users.
Questions to answer:
- Is it possible to implement this?
- How much effort is it?
- Why hasn't it been done already?
Answers
It should be possible to implement this. Kartotherian already handles SPARQL queries for geoshapes. So we can re-use that mechanism and ask in a query for a list of datapoints as well as their coordinates. The implementation to display them should be easier than the geoshapes who have an extra database for caching OSM data. A simple implementation that displays datapoints (without further features like images and colors) should be managable.
Related:
- T188291: Display point features (coordinates) from the results of a SPARQL query on a map in Wikipedia
- T157752 is similar, but asks for something like "service": "geopoint", "ids": "Q797" to draw a single point from a Wikidata Q-ID, without SPARQL.
Proof of Concept
- setup kartodock locally: pull request
- setup up geoshape example locally: used Q1218 to display geoshape that is part of the example map set
- create sparql example for geopoints: multiple ids with their geo coordinates see also T188291#4266453
- add query to code and display geopoints
<mapframe text="Churches in Jerusalem" width=300 height=300 zoom=5 longitude=31.77917 latitude=35.22361>
{
"type": "ExternalData",
"service": "geopoint",
"query": "SELECT distinct ?id ?geo WHERE {?id wdt:P31/wdt:P279* wd:Q16970; wdt:P625 ?geo. ?id p:P131 ?statement1. ?statement1 (ps:P131/(wdt:P131*)) wd:Q1218.} LIMIT 2"
}
</mapframe>Open questions / Follow up tasks
IDs
- Do we want to support a single (or a list of) Wikidata ID input by the user (to display the location of one wikidata entry)? This is also implemented for GeoShapes (example).
- Could we also use a single ID input to display a set of geopoints? Where would we find an ID that can be used to define a set of geopoints?
Properties ➔ T302290
Possible properties are: icon types, colors, labels, etc. This could be implemented in steps:
- Set a default styling of markers when the user doesn't add any themselves.
- Allow users to set a styling of the markers outside of the sparql query.
- Allow users to to define properties for geopoints the same way as for geoshapes (as part of the sparql query)?
Caching (devs) ➔ T302291
- We should cache the datapoints. How can we do that (e.g. Geoshapes seems to use OSM)?
