imported>Nzsteak (test graticule ordering) |
imported>Nzsteak |
||
Line 1: | Line 1: | ||
+ | <pre> | ||
+ | <nowiki> | ||
+ | #!/usr/bin/python | ||
+ | |||
+ | import urllib2 | ||
+ | import re | ||
+ | from xml.dom import minidom | ||
+ | |||
+ | # set up some different sort routines | ||
+ | def sort_ns_we((name1,lat1,long1,city1),(name2,lat2,long2,city2)): | ||
+ | if ((lat2 - lat1) == 0): | ||
+ | return (long1 - long2) | ||
+ | else: | ||
+ | return (lat2 - lat1) | ||
+ | |||
+ | # puts a category and all its graticules in sorted order into the output buffer | ||
+ | def output_category(name, graticules): | ||
+ | output.append("\n" + name + "\n") | ||
+ | graticules.sort(sort_ns_we) | ||
+ | for (graticuleName, lat, long, cityName) in graticules: | ||
+ | output.append("[[" + | ||
+ | graticuleName + "|" + | ||
+ | str(lat) + ", " + str(long) + " (" + | ||
+ | cityName + | ||
+ | ")]]\n") | ||
+ | |||
+ | # MAINLINE | ||
+ | |||
+ | curCategory = "" | ||
+ | curGraticules = [] | ||
+ | output = [] | ||
+ | |||
+ | # category regex matches the === [[:Category:name|name]] === lines | ||
+ | category = re.compile("===.*\[\[:Category:(.*)\|(.*)\]\].*===") | ||
+ | # graticule regex maches the [[graticuleName|lat, long (cityName)]] lines | ||
+ | graticule = re.compile("\[\[(.*)\|([- 0-9]*),([- 0-9]*)\((.*)\)\]\]") | ||
+ | |||
+ | # get the current data from the Active Graticules page | ||
+ | text = urllib2.urlopen("http://wiki.xkcd.com/wgh/api.php?action=query&titles=Active_Graticules&prop=revisions&rvprop=content&format=xml") | ||
+ | xml = minidom.parse(text) | ||
+ | # hack, hack, hack, nasty hack | ||
+ | text = unicode(xml.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.firstChild.data).split("\n") | ||
+ | |||
+ | # go through all the current text | ||
+ | for line in text: | ||
+ | if curCategory == "": | ||
+ | # we haven't seen a category yet | ||
+ | match = category.match(line) | ||
+ | if match: | ||
+ | # this is a category line so set the current category | ||
+ | curCategory = line | ||
+ | else: | ||
+ | # this is text before any categories that we want to keep | ||
+ | output.append(line) | ||
+ | else: | ||
+ | # we are in the middle of a category | ||
+ | match = category.match(line) | ||
+ | if match and (line != curCategory): | ||
+ | # we're at the next category, so we output the last one and reset | ||
+ | output_category(curCategory, curGraticules) | ||
+ | curCategory = line | ||
+ | curGraticules = [] | ||
+ | |||
+ | match = graticule.match(line) | ||
+ | if match: | ||
+ | # we've got a graticule line so record the data | ||
+ | curGraticules.append( | ||
+ | (match.group(1), | ||
+ | int(match.group(2)), | ||
+ | int(match.group(3)), | ||
+ | match.group(4)) | ||
+ | ) | ||
+ | |||
+ | # we're at the end of the data, we may need to output the last one | ||
+ | if curCategory != "": | ||
+ | output_category(curCategory, curGraticules) | ||
+ | |||
+ | # print out all the output buffer | ||
+ | for line in output: | ||
+ | print line.encode('utf-8') | ||
+ | </nowiki> | ||
+ | </pre> | ||
This page contains a link to every [[Graticule]], contained within geographical categories. | This page contains a link to every [[Graticule]], contained within geographical categories. | ||
Perhaps you would like to look at the [[:Category:Active_Graticules|Active]] or [[:Category:Inactive_Graticules|Inactive]] Graticules instead? | Perhaps you would like to look at the [[:Category:Active_Graticules|Active]] or [[:Category:Inactive_Graticules|Inactive]] Graticules instead? |
Revision as of 13:31, 12 June 2008
#!/usr/bin/python import urllib2 import re from xml.dom import minidom # set up some different sort routines def sort_ns_we((name1,lat1,long1,city1),(name2,lat2,long2,city2)): if ((lat2 - lat1) == 0): return (long1 - long2) else: return (lat2 - lat1) # puts a category and all its graticules in sorted order into the output buffer def output_category(name, graticules): output.append("\n" + name + "\n") graticules.sort(sort_ns_we) for (graticuleName, lat, long, cityName) in graticules: output.append("[[" + graticuleName + "|" + str(lat) + ", " + str(long) + " (" + cityName + ")]]\n") # MAINLINE curCategory = "" curGraticules = [] output = [] # category regex matches the === [[:Category:name|name]] === lines category = re.compile("===.*\[\[:Category:(.*)\|(.*)\]\].*===") # graticule regex maches the [[graticuleName|lat, long (cityName)]] lines graticule = re.compile("\[\[(.*)\|([- 0-9]*),([- 0-9]*)\((.*)\)\]\]") # get the current data from the Active Graticules page text = urllib2.urlopen("http://wiki.xkcd.com/wgh/api.php?action=query&titles=Active_Graticules&prop=revisions&rvprop=content&format=xml") xml = minidom.parse(text) # hack, hack, hack, nasty hack text = unicode(xml.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.firstChild.data).split("\n") # go through all the current text for line in text: if curCategory == "": # we haven't seen a category yet match = category.match(line) if match: # this is a category line so set the current category curCategory = line else: # this is text before any categories that we want to keep output.append(line) else: # we are in the middle of a category match = category.match(line) if match and (line != curCategory): # we're at the next category, so we output the last one and reset output_category(curCategory, curGraticules) curCategory = line curGraticules = [] match = graticule.match(line) if match: # we've got a graticule line so record the data curGraticules.append( (match.group(1), int(match.group(2)), int(match.group(3)), match.group(4)) ) # we're at the end of the data, we may need to output the last one if curCategory != "": output_category(curCategory, curGraticules) # print out all the output buffer for line in output: print line.encode('utf-8')
This page contains a link to every Graticule, contained within geographical categories. Perhaps you would like to look at the Active or Inactive Graticules instead?
Contents
Guidelines
NOTE: These guidelines MUST be followed; this page is read by automated scripts.
- Region/Graticule pages named "City Name, Country" where "City Name" is the most major (by population) urban center contained within it.
- Use the code
[[page name|lat, lon (city name)]]
to accomplish this.
- Use the code
- Interactive map is available for Google Earth or on Google Maps. This map also tried to judge how many users are active in each graticule.
- Note that for graticules to be listed in on http://xkcd.com/geohashing and in the interactive map, they must be listed here, in the proper format above.
Graticules
Africa
-26, 27 (Johannesburg, South Africa)
-33, 18 (Cape Town, South Africa)
-34, 18 (Cape Town, South Africa)
Middle East
32, 34 (Tel-Aviv (Goosh Dan), Israel)
Asia
Australia
-19, 146 (Townsville, Australia)
-27, 153 (Brisbane, Australia)
-34, 138 (Adelaide, Australia)
-34, 150 (Wollongong, Australia)
-35, 138 (Adelaide, Australia)
-35, 149 (Canberra, Australia)
-37, 145 (Melbourne, Australia)
New Zealand
-36, 174 (Auckland, New Zealand)
-37, 175 (Hamilton, New Zealand)
-41, 174 (Wellington, New Zealand)
-41, 175 (Upper Hutt, New Zealand)
-43, 172 (Christchurch, New Zealand)
-45, 170 (Dunedin, New Zealand)
Europe
71, 24 (Havøysund North, Norway)
71, 25 (Honningsvåg North, Norway)
69, 28 (Sevettijärvi, Finland)
66, 23 (Pello - Ylitornio, Finland/Sweden)
60, 12 (Kongsvinger East, Norway)
59, 30 (St.Petersburg, Russia)
58, 7 (Kristiansand West, Norway)
58, 8 (Kristiansand East, Norway)
57, -2 (Aberdeen, United Kingdom)
55, -4 (Glasgow, United Kingdom)
55, -3 (Edinburgh, United Kingdom)
54, -2 (Carlisle, United Kingdom)
54, -1 (Middlesbrough, United Kingdom)
54, 0 (Scarborough, United Kingdom)
53, -2 (Manchester, United Kingdom)
53, -1 (Sheffield / Leeds / Bradford, United Kingdom)
53, 0 (Hull / Lincoln, United Kingdom)
53, 6 (Groningen, the Netherlands)
52, -2 (Shrewsbury, United Kingdom)
52, -1 (Birmingham East / Leicester / Coventry, United Kingdom)
52, 0 (Northampton, United Kingdom)
52, 0 (Cambridge, United Kingdom)
52, 1 (Norwich, United Kingdom)
51, -3 (Cardiff, United Kingdom)
51, -2 (Bristol, United Kingdom)
51, -1 (Swindon, United Kingdom)
51, 0 (London West, United Kingdom)
51, 0 (London East, United Kingdom)
51, 1 (Canterbury, United Kingdom)
51, 4 (Rotterdam / Antwerpen, Nederland / Belgium)
51, 5 (Eindhoven, Nederland - plus wat België)
50, -5 (West Cornwall, United Kingdom)
50, -4 (Plymouth / East Cornwall, United Kingdom)
50, -3 (Exeter, United Kingdom)
50, -2 (Yeovil / Weymouth / Dorchester / Ilminster / Crewkerne)
50, -1 (Southampton, United Kingdom)
49, 2 (Amiens/Paris North, France)
49, 6 (Luxembourg, Luxembourg / Metz, France / Trier and West of Saarbrücken, Germany)
49, 7 (East of Saarbrücken and Kaiserslautern, Germany)
46, 5 (Bourg-en-Bresse, France)
46, 8 (St. Gotthard Pass, Switzerland)
46, 16 (Zalaegerszeg, Hungary)
43, 18 (Sarajevo, Bosna i Hercegovina)
43, 25 (Veliko Tarnovo and most of Rousse, Bulgaria)
42, 25 (Stara Zagora, Bulgaria)
41, 21 (Skopje South and Bitola, Macedonia)
41, 24 (Western Rhodope mountains)
41, 28 (Istanbul North-West, Turkey)
40, 23 (Chalcidicean peninsula, Greece)
North America
56, -111 (Fort McMurray, Alberta)
55, -118 (Grande Prairie, Alberta)
54, -128 (Terrace and District, British Columbia)
53, -122 (Prince George, British Columbia)
53, -105 (Prince Albert, Saskatchewan)
52, -126 (Bella Coola, British Columbia)
52, -106 (Saskatoon, Saskatchewan)
51, -121 (100 Mile House, British Columbia)
51, -120 (Barrière, British Columbia)
50, -125 (Campbell River North, British Columbia)
50, -122 (Whistler, British Columbia)
50, -121 (Cache Creek, British Columbia)
50, -120 (Kamloops, British Columbia)
50, -119 (Vernon, British Columbia)
50, -105 (Moose Jaw, Saskatchewan)
50, -104 (Regina, Saskatchewan)
49, -125 (Courtenay West, British Columbia)
49, -124 (Port Alberni, British Columbia)
49, -123 (Vancouver, British Columbia)
49, -122 (Surrey, British Columbia)
49, -121 (Chilliwack, British Columbia)
49, -120 (Princeton, British Columbia)
49, -119 (Kelowna, British Columbia)
49, -112 (Lethbridge, Alberta)
49, -110 (Medicine Hat, Alberta)
48, -124 (Port Renfrew, British Columbia)
48, -123 (Victoria, British Columbia)
48, -122 (Bellingham, Washington)
48, -121 (North Cascades National Park, Washington)
48, -120 (Lake Chelan, Washington)
48, -118 (Kettle Falls, Washington)
48, -117 (Colville, Washington)
48, -96 (Thief River Falls, Minnesota)
48, -93 (International Falls, Minnesota)
48, -92 (Voyageurs National Park (east), Minnesota)
48, -91 (BWCA, Minnesota / Quetico PP, Ontario)
48, -89 (Thunder Bay, Ontario)
47, -123 (Olympic National Park, Washington)
47, -122 (Seattle, Washington)
47, -121 (Snoqualmie, Washington)
47, -120 (Wenatchee, Washington)
47, -119 (Moses Lake, Washington)
47, -118 (Davenport, Washington)
47, -117 (Spokane, Washington)
47, -53 (Bay Roberts, Newfoundland & Labrador)
47, -52 (St. John's, Newfoundland)
46, -124 (Ocean Shores, Washington)
46, -122 (Mt. St. Helens, Washington)
46, -121 (Mt. Rainier, Washington)
46, -119 (Tri Cities, Washington)
46, -118 (Walla Walla, Washington)
46, -117 (Pullman, Washington)
46, -116 (Coeur d'Alene, Idaho)
46, -110 (White Sulfur Springs, Montana)
46, -84 (Sault Ste. Marie, Ontario)
46, -72 (Trois-Rivières, Québec)
46, -64 (Moncton, New Brunswick)
46, -63 (Charlottetown, Prince Edward Island)
45, -123 (McMinnville, Oregon)
45, -110 (Livingston, Montana)
45, -94 (St. Cloud, Minnesota)
45, -93 (Minneapolis NW, Minnesota)
45, -92 (St. Paul NE, Minnesota)
45, -74 (Saint-Jérôme West, Québec)
45, -72 (Drummondville, Québec)
45, -66 (Saint John, New Brunswick)
45, -65 (Sussex, New Brunswick)
44, -111 (West Yellowstone, Montana)
44, -110 (Yellowstone, Montana)
44, -93 (Minneapolis SW, Minnesota)
44, -92 (St. Paul SE, Minnesota)
44, -78 (Peterborough, Ontario)
44, -71 (Gorham, New Hampshire)
44, -63 (Halifax, Nova Scotia)
43, -96 (Sioux Falls, South Dakota)
43, -88 (Fond du Lac, Wisconsin)
43, -87 (Milwaukee, Wisconsin)
43, -82 (Sarnia North, Ontario)
43, -81 (London North, Ontario)
43, -73 (Glens Falls, New York)
43, -72 (Claremont, New Hampshire)
43, -71 (Concord, New Hampshire)
42, -88 (Schaumburg, Illinois)
42, -85 (Grand Rapids, Michigan)
42, -83 (Detroit/Ann Arbor, Michigan)
42, -82 (Detroit Northeast, Michigan)
42, -81 (London South, Ontario)
42, -75 (Binghamton, New York)
42, -74 (Cooperstown, New York)
42, -72 (Springfield, Massachusetts)
42, -71 (Boston, Massachusetts)
41, -109 (Rock Springs, Wyoming)
41, -100 (North Platte, Nebraska)
41, -77 (Williamsport, Pennsylvania)
41, -76 (Berwick, Pennsylvania)
41, -75 (Scranton, Pennsylvania)
41, -73 (Danbury, Connecticut)
41, -72 (Hartford, Connecticut)
41, -71 (Providence, Rhode Island)
41, -70 (Cape Cod, Massachusetts)
41, -69 (Chatham, Massachusetts)
40, -111 (Salt Lake City, Utah)
40, -105 (Denver/Boulder, Colorado)
40, -92 (Kirksville, Missouri)
40, -88 (Champaign/Urbana, Illinois)
40, -80 (Pittsburgh, Pennsylvania)
40, -79 (Pittsburgh, Pennsylvania)
40, -77 (State College, Pennsylvania)
40, -76 (Harrisburg, Pennsylvania)
40, -75 (Allentown, Pennsylvania)
40, -73 (New York City, New York)
39, -123 (Bodega Bay, California)
39, -95 (Lawrence/Topeka, Kansas)
39, -94 (Kansas City, Missouri)
39, -86 (Indianapolis, Indiana)
39, -78 (Cumberland, Maryland)
39, -75 (Philadelphia, Pennsylvania)
39, -74 (Atlantic City, New Jersey)
38, -122 (Santa Rosa, California)
38, -121 (Sacramento, California)
38, -119 (South Lake Tahoe, California)
38, -104 (Colorado Springs/Pueblo, Colorado)
38, -95 (Lawrence/Topeka, Kansas)
38, -85 (Louisville, Kentucky)
38, -78 (Shenandoah Valley, Virginia)
38, -77 (Washington, District of Columbia)
38, -76 (Washington, District of Columbia)
38, -74 (Cape May, New Jersey)
37, -122 (San Francisco, California)
37, -121 (San Jose, California)
37, -89 (Carbondale, Illinois)
37, -80 (Blacksburg, Virginia)
37, -79 (Blue Ridge, Virginia)
37, -76 (Newport News, Virginina)
36, -122 (Santa Cruz, California)
36, -121 (Salinas, California)
36, -94 (Fayetteville, Arkansas)
36, -86 (Nashville, Tennessee)
36, -82 (Tri-Cities, Tennessee)
36, -75 (Virginia Beach, Virginia)
35, -120 (San Luis Obispo, California)
35, -106 (Albuquerque/Santa Fe, New Mexico)
35, -105 (Santa Fe, New Mexico)
35, -97 (Oklahoma City, Oklahoma)
35, -86 (Murfreesboro, Tennessee)
35, -85 (Chattanooga, Tennessee)
35, -83 (Knoxville, Tennessee)
35, -81 (Gastonia, North Carolina)
35, -80 (Charlotte, North Carolina)
35, -78 (Raleigh, North Carolina)
34, -120 (Santa Maria, California)
34, -119 (Santa Barbara, California)
34, -118 (Los Angeles, California)
34, -117 (San Bernardino, California)
34, -84 (Talking Rock, Georgia)
34, -82 (Greenville, South Carolina)
34, -81 (Rock Hill, South Carolina)
33, -118 (Long Beach, California)
33, -117 (Santa Ana, California)
33, -116 (Borrego_Springs, California)
33, -112 (Phoenix West Valley, Arizona)
33, -111 (Phoenix East Valley, Arizona)
33, -98 (Wichita Falls, Texas)
32, -117 (San Diego, California)
32, -87 (Talladega National Forest)
32, -83 (Warner Robins, Georgia)
32, -79 (Charleston, South Carolina)
31, -93 (Natchitoches, Louisiana)
30, -98 (Fredericksburg, Texas)
30, -96 (College Station, Texas)
30, -92 (Lafayette, Louisiana)
30, -91 (Baton Rouge, Louisiana)
30, -90 (New Orleans, Louisiana)
30, -89 (New Orleans, Louisiana)
30, -84 (Tallahassee, Florida)
29, -90 (New Orleans, Louisiana)
29, -89 (New Orleans, Louisiana)
29, -82 (Gainesville, Florida)
27, -97 (Corpus Christi, Texas)
27, -80 (Port St Lucie, Florida)
21, -102 (Aguascalientes, México)
Central America
13, -89 (San Salvador, El Salvador)
South America
-33, -71 (Viña del Mar, Chile)
-34, -58 (Buenos Aires, Argentina)