Quantcast

Why are coordinates not listed for some pages in API query?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why are coordinates not listed for some pages in API query?

Bjoern Hassler-3
Hi all,

not sure whether this is an API issue, or something to do with the way coordinates are stored.

If you look at this query, you'll see that for some of the pages coordinates are listed, for others they are not:


However, quite a few pages do have coordinates on the corresponding wikipedia page, e.g.

Any ideas what that might be?

(As an aside, just in case it's related: How do coordinates end up in Wikidata? I assume it's a bot? Presumably the bot uses the API? Some of the above pages have got coordinates on the page, but not in Wikidata...)

Thanks!
Bjoern

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why are coordinates not listed for some pages in API query?

Brad Jorsch (Anomie)
On Mon, May 1, 2017 at 7:14 PM, Bjoern Hassler <[hidden email]> wrote:
not sure whether this is an API issue, or something to do with the way coordinates are stored.

Neither.
 
If you look at this query, you'll see that for some of the pages coordinates are listed, for others they are not:


That's because you're leaving colimit at its default of 10 and there are more than 10 pages with coordinates in the request, so you'll need to use query continuation to fetch the rest of the data and merge it in. See https://www.mediawiki.org/wiki/API:Query#Continuing_queries. You might also specify a larger limit, e.g. colimit=500 or colimit=max, to reduce the need for continuation.

Another thing to watch for is that there are two types of coordinates, "primary" and "secondary". By default, only primary coordinates are returned. If you need secondary coordinates as well, you'll need to specify coprimary=all in your request.


--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why are coordinates not listed for some pages in API query?

Bjoern Hassler-3
Hi Brad,

ahhh - that makes sense! Many thanks for the tips, that's great!

Bjoern

On 2 May 2017 at 15:19, Brad Jorsch (Anomie) <[hidden email]> wrote:
On Mon, May 1, 2017 at 7:14 PM, Bjoern Hassler <[hidden email]> wrote:
not sure whether this is an API issue, or something to do with the way coordinates are stored.

Neither.
 
If you look at this query, you'll see that for some of the pages coordinates are listed, for others they are not:


That's because you're leaving colimit at its default of 10 and there are more than 10 pages with coordinates in the request, so you'll need to use query continuation to fetch the rest of the data and merge it in. See https://www.mediawiki.org/wiki/API:Query#Continuing_queries. You might also specify a larger limit, e.g. colimit=500 or colimit=max, to reduce the need for continuation.

Another thing to watch for is that there are two types of coordinates, "primary" and "secondary". By default, only primary coordinates are returned. If you need secondary coordinates as well, you'll need to specify coprimary=all in your request.


--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api



_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Loading...