simon04 / locator-tool

Tool to add {{Location}} or {{Object location}} to images on Wikimedia Commons
https://locator-tool.toolforge.org
GNU General Public License v3.0
26 stars 12 forks source link

Auto-calculate the Bearing (Compass) #73

Open valerio-bozzolan opened 1 month ago

valerio-bozzolan commented 1 month ago

This lovely tool has the potential ability to automagically calculate the bearing. That is, the direction between the location of the person, and the location of the object.

I'm talking about the heading: parameter here:

https://commons.wikimedia.org/wiki/Template:Location

Further details:

https://phabricator.wikimedia.org/T363052


This is an issue that may be interesting during hackatons, or this kind of things \o/

mkgrgis commented 1 month ago

Hello, @valerio-bozzolan ! Interface URL point like https://wikimap.toolforge.org/api.php?cat=Pavlovsk_park&subcats&subcatdepth=8&camera=true&locator=true&allco=true yet gives bearing. You also can find, observe and use code under the API.

valerio-bozzolan commented 1 month ago

Super interesting!

I do not understand if the above API "just" reads the bearing from the template, or, if it calculates it on-the-fly.

valerio-bozzolan commented 1 month ago

OK so you say that https://commons.wikimedia.org/wiki/File:009._Pavlovsk._Pavlovsky_Park.jpg returns {"pageid":58214112,"ns":6,"title":"File:009. Pavlovsk. Pavlovsky Park.jpg","coordinates":[{"lat":59.6843,"lon":30.44962,"primary":true,"bearing":218,"cam":""} and - since I cannot see the bearing nor in structured data, nor in the template - so it seems it's generating that 🤩

Now let's see that source code:

https://de.wikipedia.org/wiki/Benutzer_Diskussion:DB111/Tools#Issue_tracker_and_source_code_of_WikiMap

mkgrgis commented 1 month ago

@valerio-bozzolan I am sorry for closed source code of DB111's utility... Searching under https://commons.wikimedia.org/w/api.php?action=help doesn't seems me easy for our trivial example.