-0 Issue

From Geohashing
Revision as of 20:20, 24 May 2008 by imported>Gissehel (xkcd.js code change)

Granicule longitudes and lattitudes are indexes that look like relative integers. They are minimal value of all the points in the graticule if the values are positive, and they are the maximal value of all the points in the graticule if the values are negative.


So (-23.452365°,16.415222°) is located in the Ganicule -23,16.

And (23.452365°,-16.415222°) is located in the Ganicule 23,-16.


With this notation, 0 and -0 are different values (this rule will be called "-0 notation").

Issue with the official tool

The official tool doesn't accept -0 as an input, which make it difficult to make automatic templates for graticules x -0 or -0 x.

The official tool can use "abs" to work this around. If given abs=1 on the url, the official tool will consider the values as being south/west coordinate of the graticule (while this only true for positive lattitude and longitude). (This rule will be called "algebric notation")

But this workaround doesn't work for the <map.../> element, because the map element doesn't take the abs.

The xkcd.js of the official tool can be changed to take -0 as input.

Current code :

 if (qsParm['abs'] != 1) {
   if (qsParm['long'] < 0) qsParm['long']--;
   if (qsParm['lat'] < 0) qsParm['lat']--;
 }

New code :

 if (qsParm['abs'] != 1) {
   if (qsParm['long'] == "-0") { 
     qsParm['long']=-1; 
   } else if (qsParm['long'] < 0) { 
     qsParm['long']--; 
   }
   if (qsParm['lat'] == "-0") { 
     qsParm['lat']=-1; 
   } else if (qsParm['lat'] < 0) { 
     qsParm['lat']--; 
   }
 }

Another workaround, involving -360 instead of -0 is described in Template_talk:Graticule/-0_long_workaround_in_action

Issue with the Active Graticules's page

The "abs workaround" leeds the Active Graticules's page into chaos. While most of the graticules use the "-0 notation" (example Boston is refered as 42 -71), United kingdom mostly use the "algebric notation" (example Swindon is refered as 51 -2).

This inconsistency leeds to wrong labels in the official tool.