Difference between revisions of "Algorisme"

From Geohashing
imported>SastRe.O
(Created page with "thumb|301 px|L'Algorisme <small>This page in English / Aquesta pàgina en anglès The Algorithm</small> <!--'''This time, we ''did'' invent the a...")
 
m
 
Line 30: Line 30:
 
There are a number of results of the application of the algorithm that may not be immediately apparent, but which make for interesting thought experiments and even more interesting achievements under increasingly bizarre or adventurous scenarios.
 
There are a number of results of the application of the algorithm that may not be immediately apparent, but which make for interesting thought experiments and even more interesting achievements under increasingly bizarre or adventurous scenarios.
 
* The coordinates at the prime meridian are mirrored instead of following the grid pattern.  This means that a low longitude value (say, .001) could yield two hash points very close together on opposite sides of 0°.  At the prime meridian, once every 111 days or so there will be two hashes within 1km of each other due to this phenomenon.  The equator displays the same phenomenon, and the intersection of the two can put 4 hashes in close proximity to each other, unfortunately in the Atlantic Ocean.
 
* The coordinates at the prime meridian are mirrored instead of following the grid pattern.  This means that a low longitude value (say, .001) could yield two hash points very close together on opposite sides of 0°.  At the prime meridian, once every 111 days or so there will be two hashes within 1km of each other due to this phenomenon.  The equator displays the same phenomenon, and the intersection of the two can put 4 hashes in close proximity to each other, unfortunately in the Atlantic Ocean.
* The 30W and 180th meridians are not as special, simply having independently random hash points on either side of the line.  These may be arbitrarily close together or up to two graticule-diagonal-distances apart, depending on the two random coordinates involved.  These also interact with the equator as above.
+
* The 30W and [[Antimeridian|180th meridian]]s are not as special, simply having independently random hash points on either side of the line.  These may be arbitrarily close together or up to two graticule-diagonal-distances apart, depending on the two random coordinates involved.  These also interact with the equator as above.
 
* However, the interaction of the 180th meridian with the international date line leads back into interesting territory.  Where they diverge, up to three hash points can be found arbitrarily close together, even when not near the equator.  Standing just west of 180E, just east of the date line, you might be on the 179E hash for "today", with the 179E hash for "tomorrow" just west of you, and the 179W hash for "today" just east of you.  Getting three different random coordinates to come close to each other is an order of magnitude less likely than the previous case.
 
* However, the interaction of the 180th meridian with the international date line leads back into interesting territory.  Where they diverge, up to three hash points can be found arbitrarily close together, even when not near the equator.  Standing just west of 180E, just east of the date line, you might be on the 179E hash for "today", with the 179E hash for "tomorrow" just west of you, and the 179W hash for "today" just east of you.  Getting three different random coordinates to come close to each other is an order of magnitude less likely than the previous case.
 
* The date line can also produce a single graticule with two (or zero) hash points at the same time, depending on which side of the line the hash points for each of the two days fall on.  This can happen anywhere the line divides a graticule.
 
* The date line can also produce a single graticule with two (or zero) hash points at the same time, depending on which side of the line the hash points for each of the two days fall on.  This can happen anywhere the line divides a graticule.

Latest revision as of 12:57, 4 March 2020

L'Algorisme

This page in English / Aquesta pàgina en anglès The Algorithm

No és necessari entendre l'algorisme per a poder practicar el geohashing.

L'algorisme

  • Concatena en una cadena la data d'avui (naturalment en format yyyy-mm-dd, el qual hauria de ser l'únic format que fessis servir) amb el valor d'obertura del Dow Jones Industrial Average (tal com fiura a finance.google.com) separant els dos amb un guió simple.
    • Oest de la longitud -30º: Si encara no hi ha cap valor d'obertura del DJIA en el dia en qüestió, s'utilitza el valor d'obertura del dia anterior, o el valor més recent. Per tant, en Dissabte i Diumenge s'usa el valor d'obertura del Divendres (ja que la borsa no obre en dies festius).
    • Est de la longitud -30º: Igual que a l'oest, excepte que s'usa el valor d'obertura del DJIA del dia anterior, o el valor més recent, encara que durant el dia estigui disponible el valor d'aquell dia en la teva franja horària. És a dir, el Dijous s'usa el valor d'obertura del Dimecres, el Divendres el valor del Dijous, i pel Dissabte, Diumenge i Dilluns s'usa el valor d'obertura del Divendres. (vegeu 30W Time Zone Rule (en anglès))
    • Quan hi ha un dia festiu, s'utilitza el valor d'obertura més recent.
  • La cadena resultant es fa passar per un algorisme criptogràfic ben documentat, el MD5 que genera un "hash" pseudo-aleatori (fàcilment verificable) de 32 dígits hexadecimals.
  • Aleshores es parteix el "hash" en dues meitats de 16 dígits hexadecimals cada una.
  • Cada meitat del "hash" és precedida per un punt decimal (per tal de representar una fracció hexadecimal) i és convertit en una fracció decimal (base-10).
  • Les fraccions decimals resultants són sumades als valors integrals (lat,lon) de la gratícula en qüestió, per a produïr les coordenades del geohash de la gratícula d'aquell dia.

Eines d'ajuda


Implementacions

Si no vols fer els càlculs tu mateix, no cal que els facis. Hi ha una llista de referències d'implementacions que pots trobar en aquesta pàgina (en anglès).