Closed synrg closed 5 years ago
As we started to discuss on #makers on iNat Discord server, in addition to the taxon_id values for both taxa, the URL contains the Google maps zoom factor (7) and lat,lon (43.469, -82.442) of the center point of the map.
This call could provide just the bounds needed for both taxa:
That would give us the center point. Then we need to compute a zoom level. The result would then be trivial to put into an embed as a link to the map.
As for the command itself, here are suggested inputs:
[p]inat map <taxon1>,<taxon2>,...,<taxonN>
Each taxon is identified by terms that uniquely identify that taxon as per: [p]inat taxon <terms>
.
e.g. since the taxon
subcommand accepts taxon_id, this would work:
[p]inat map 24255,24267
Or alternatively:
[p]inat map boreal chorus frog,western chorus frog
Although it is not yet supported in the syntax, with some more work on taxon
support for advanced syntaxes, this might be possible in future:
[p]inat map (boreal,western) in genus chorus frogs
See https://gis.stackexchange.com/questions/7430/what-ratio-scales-do-google-maps-zoom-levels-correspond-to in order to choose a zoom factor that encompasses the rectangle represented by the coordinate pairs returned by return_bounds.
Roughly speaking, we want to:
Zoom levels on which range maps still show seem to max out at 10 (i.e. theoretically you could go up to 21, but then iNat no longer shows the polygons for the ranges at that level of zoom; plus there's not enough context to really see where the range is anyway). So we should only use zoom levels between 2 (about 20,000 km to a side) and 10 (about 78 km to a side).
>>> math.radians(180)*6.3781*10**6
20037392.10386106
Example showing 180 degrees is about 20,000 km (the calculation above is in metres).
If you take zoom level 2 to show about 20,000 km, then this gives you the size in km for other zoom levels by cutting that in half every zoom level up:
>>> z = 2
>>> 20000/2**(z-2)
20000.0
>>> z = 10
>>> 20000/2**(z-2)
78.125
Thanks to michaelpirrello from iNat Discord for suffering through the math with me. :)
From mws on iNat discord: