ढाँचा:Location map/modulo math details
For a map using an equirectangular projection which does not cross +/-180 longitude, or +/-90 latitude, the following expressions can be used:
x = 100*(long - left)/(right - left)
y = 100*(lat - top)/(bottom - top)
where lat and long are the degrees latitude and longitude respectively. Here, top and bottom are the degrees latitude of the top and bottom edges of the map, left and right are the degrees latitude of the left and right edges of the map.
Things are a bit more complicated when the map crosses +/-180 longitude, and some sort of "modulo arithmetic" is required. Here, we add 360 if the longitude is less than 0, then use a mapping based on positive coordinates. The following table can be used to check if the expressions are working as desired:
location | lat | long | (x,y) test | (x,y) exact |
---|---|---|---|---|
top/left | 0 | 0 | (0,0) | |
top/right | 0 | 100 | (100,0) | |
bottom/left | 100 | 0 | (0,100) | |
bottom/right | 100 | 100 | (100,100) | |
center | 50 | 50 | (50,50) |
This subtemplate of {{Location map}} is used to explain and check the arithmetical logic used by Location map's which cross the 180 degree meridian. It is intended to be used on the documentation page as
{{Location map/modulo math details|top = |bottom = |left = |right = }}
, where left/right are the longitude coordinates of the left/right map border, and top/bottom are the latitude coordinates of the top/bottom map border.