Difference between revisions of "User:Hessophanes/Regiohashing"

From Geohashing
imported>Hessophanes
(+Netherlands... this project is really getting popular...)
imported>Hessophanes
Line 26: Line 26:
 
** Automatic
 
** Automatic
 
*** ''wikiuser=User'': This makes the CGI script attempt to automagically parse your wiki userpage for your home graticule (by looking for an <nowiki>{{ASG}}</nowiki> tag) and your visited geohashes (by including all links that match <nowiki>[[\d{4}-\d\d-\d\d[_ ]-?\d{1,3}[_ ]-?\d{1,3}|</nowiki>). This has some intrinsic weaknesses, though - see below.
 
*** ''wikiuser=User'': This makes the CGI script attempt to automagically parse your wiki userpage for your home graticule (by looking for an <nowiki>{{ASG}}</nowiki> tag) and your visited geohashes (by including all links that match <nowiki>[[\d{4}-\d\d-\d\d[_ ]-?\d{1,3}[_ ]-?\d{1,3}|</nowiki>). This has some intrinsic weaknesses, though - see below.
 +
 +
NEW: You may also use ISO-3166-1 and -2 codes for the ''region='' and ''subregion='' parameters.
  
 
E.g.:
 
E.g.:
Line 121: Line 123:
 
</pre>
 
</pre>
  
* The tags should consist of one to three characters and should ideally match ISO 3166-1 and -2. They are currently not exposed, but I want to keep the option open to add small pictograms/flags/labels in the top bar.
+
* The tags should consist of one to three characters and should ideally match ISO 3166-1 and -2. Maybe I'll add small pictograms/flags/labels in the top bar someday.
 
* The second tag of the subregion should match the tag of the corresponding region.
 
* The second tag of the subregion should match the tag of the corresponding region.
 
* No array declarations, just define the elements. I'm employing some crazy preprocessor constructs to include everything at the right place and still allow for regions and their corresponding subregions to be stored close to each other in the same header file.
 
* No array declarations, just define the elements. I'm employing some crazy preprocessor constructs to include everything at the right place and still allow for regions and their corresponding subregions to be stored close to each other in the same header file.
 
* I'm zealously sanitizing CGI input: the only accepted characters are [A-Za-z0-9 =.-] - if your region name contains non-ascii chars, please replace those. (%xx constructs are decoded before matching against that char list, of course.)
 
* I'm zealously sanitizing CGI input: the only accepted characters are [A-Za-z0-9 =.-] - if your region name contains non-ascii chars, please replace those. (%xx constructs are decoded before matching against that char list, of course.)
  
[http://130.149.11.99/hesso/Region_Europe.h Example: current contents of Europe header file]
+
[http://130.149.11.99/hesso/Region_Europe.h Example: somewhat outdated contents of Europe header file]
  
 
== Feedback ==
 
== Feedback ==
Line 134: Line 136:
 
== My agenda ==
 
== My agenda ==
  
* Add 4th digit for the grat counter.
 
 
* Support arbitrary nesting of regions. Slightly redesign region storage format.
 
* Support arbitrary nesting of regions. Slightly redesign region storage format.
 
* Stop compiling the maps into the binary. It was easy to code and comfortable while there were only few maps, but now the binary is growing at an insane pace.
 
* Stop compiling the maps into the binary. It was easy to code and comfortable while there were only few maps, but now the binary is growing at an insane pace.
 
* Release the code!
 
* Release the code!
* Optimize, Europe is taking way too long to generate. What if I wanted a world map?
+
* Encode the image on my own instead of creating an XPM and relying on ImageMagick to do the final conversion. (This is the cause of the main delay now.) libpng's API is horrible, so when I do this, I'll probably switch to GIF.
  
 
[[Category:Regional Geohash map]]
 
[[Category:Regional Geohash map]]

Revision as of 10:05, 24 October 2008

How to fancifully display your regiohash progress

How it began...

While moving from one flat to another, I had to live without ISP for a few weeks... and as I sat there, determined to waste my time by dedicating it to some totally insane task even without internet access, I came up with this: several active regiohashers have started to create loose tables with minesweeper images showing their progress - why not take this minesweeper thing to the next level and create true regiohash minesweeper boards?

After doing a first proof-of-concept using only a shell script and the wonderful ImageMagick toolset (which took almost 8 seconds to render a full Australia board) I did it once again with a speedy language (read: C).

As it is prohibited to directly reference foreign images from wiki sites, interested users have to query the CGI themselves, copy the image into the wiki and include that in their page.

How to use it...

The request URL looks like one of these:

http://130.149.11.99/hesso/xkcdregio.cgi?region=YOURREGION&subregion=YOURSUBREGION&visited=GRATICULELIST&home=HOMEGRAT&started=FIRSTHASH
http://130.149.11.99/hesso/xkcdregio.cgi?region=YOURREGION&subregion=YOURSUBREGION&wikiuser=WIKIUSER&started=FIRSTHASH
  • Common parameters
    • region=Regionname: This is the only mandatory parameter. It determines the size and shape of the board. See below for a list of currently supported regions.
    • subregion=Subregionname: If you don't want to aim for the full region, you may specify a subregion which will be drawn onto the map as a yellow borderline.
    • start=yyyymmdd: If you enter your first visited geohash for this regiohash attempt, a day counter will be added in the top right corner.
  • Progress parameters
    • Manual
      • home=lat.lng: This should be your home graticule. If you have visited a geohash there, it will be marked with a green flag instead of a red one.
      • visited=lat.lng.lat.lng....: This is your list of visited graticules (which might become very long as time flies by).
    • Automatic
      • wikiuser=User: This makes the CGI script attempt to automagically parse your wiki userpage for your home graticule (by looking for an {{ASG}} tag) and your visited geohashes (by including all links that match [[\d{4}-\d\d-\d\d[_ ]-?\d{1,3}[_ ]-?\d{1,3}|). This has some intrinsic weaknesses, though - see below.

NEW: You may also use ISO-3166-1 and -2 codes for the region= and subregion= parameters.

E.g.:

http://130.149.11.99/hesso/xkcdregio.cgi?region=Germany&subregion=Brandenburg&visited=52.13.52.12&home=52.13
http://130.149.11.99/hesso/xkcdregio.cgi?region=Germany&subregion=Brandenburg&wikiuser=Hessophanes

Go ahead and play with it, but please keep in mind that I'm hosting this on a university server. Play nicely.

What it looks like...

Again with myself as example:

example regiohash

  • The counter in the top left corner shows the remaining graticules of the smallest (sub)region that hasn't been completed yet. When we add North America and Asia I guess I'll have to enlarge it to four digits, though.

What it still lacks...

  1. The tool does not (and will never be able to) know which (sub)region a certain geohash visit pertains to. It would need full Google and DJIA data to accomplish that. Still wikiuser= is not completely useless - I'll add a parameter notvisited= so you can still benefit from the comfort of the parser and correct its mistakes.

List of available regions

Now that the code is working, data is starting to trickle in. I've converted Australia myself using the wonderful map that UnwiseOwl is compiling. Thanks to all submitters!

Region Subregion submitted by
Germany Schleswig-Holstein, Niedersachsen, Mecklenburg-Vorpommern, Sachsen-Anhalt,

Nordrhein-Westfalen, Brandenburg, Thueringen, Sachsen, Hessen, Rheinland-Pfalz, Saarland, Baden-Wuerttemberg, Bayern, Berlin, Bremen, Hamburg

Hessophanes
Netherlands Friesland, Groningen, Noord-Holland, Drenthe, Overijssel,

Flevoland, Utrecht, Gelderland, Zuid-Holland, Zeeland

Arvid
Australia Western Australia, Northern Territory, South Australia, Queensland,

New South Wales, Victoria, Tasmania, Australian Capital Territory

UnwiseOwl
Europe Iceland, Portugal, Ireland, France, Netherlands, Denmark,

United Kingdom, Spain, Italy, Sweden, Belgium, Norway, Germany, Finland, Poland, Switzerland, Austria, Czech Republic, Russia

Danatar
South America Brazil, Chile, Ecuador, Galapagos, Peru, Venezuela,

Suriname, Paraguay, Uruguay, Argentina, Colombia, Guyana, French Guiana, Bolivia

Joannac

How to add regions

If someone wants to lend a hand, great! I'd prefer email submissions to <jckn@gmx.net> (that address is already heavily spam-infested, obfuscation would be futile)... the format is (just making up an example here):

 {"RegionName", "TAG", (lat-top), (lat-bot), (lng-left), (lng-right),
  "oooooo00oooo" \
  "oooo0000000o" \
  "ooo00000o000" \
  "ooo000000000" \
  "oooooooo000o"},

/* ... */

 {"SubRegion1", "ST1", "TAG",
  "oooooo00oooo" \
  "oooo###0000o" \
  "ooo####0o000" \
  "ooo###000000" \
  "oooooooo000o"},
 {"SubRegion2", "ST2", "TAG",
  "oooooo##oooo" \
  "oooo00#####o" \
  "ooo000##o000" \
  "ooo00###0000" \
  "oooooooo000o"},
 {"SubRegion3", "ST3", "TAG",
  "oooooo00oooo" \
  "oooo000000#o" \
  "ooo00000o###" \
  "ooo0000#####" \
  "oooooooo###o"},
  • The tags should consist of one to three characters and should ideally match ISO 3166-1 and -2. Maybe I'll add small pictograms/flags/labels in the top bar someday.
  • The second tag of the subregion should match the tag of the corresponding region.
  • No array declarations, just define the elements. I'm employing some crazy preprocessor constructs to include everything at the right place and still allow for regions and their corresponding subregions to be stored close to each other in the same header file.
  • I'm zealously sanitizing CGI input: the only accepted characters are [A-Za-z0-9 =.-] - if your region name contains non-ascii chars, please replace those. (%xx constructs are decoded before matching against that char list, of course.)

Example: somewhat outdated contents of Europe header file

Feedback

... per IRC or talk page, as usual.

My agenda

  • Support arbitrary nesting of regions. Slightly redesign region storage format.
  • Stop compiling the maps into the binary. It was easy to code and comfortable while there were only few maps, but now the binary is growing at an insane pace.
  • Release the code!
  • Encode the image on my own instead of creating an XPM and relying on ImageMagick to do the final conversion. (This is the cause of the main delay now.) libpng's API is horrible, so when I do this, I'll probably switch to GIF.