NaviCodeGen
From Geohashing
Revision as of 14:26, 8 September 2008 by imported>M5rammy (→geohash.asp: forgot to change the "last updated" line)
ReadMe.txt
Geohash Wikimarkup Code Generator file: geohash.asp author: Rammy M (aka m5rammy) purpose: (assumes you know what geohashing is) generates wiki markup code for http://wiki.xkcd.com/geohashing meetup pages, so that you can easily get to meetup pages for neighboring graticules and to other days of the same graticule. parameters: none needed set-up: put on any server that can run asp pages optional set-up: 1) change the source-code, lines 8 and 9 to your own home lat & long 2) if you don't like the colors you can change them. usage: should all be self-explanatory. By default it picks the system date, but you can enter any date. By default uses the "HomeLat" and "HomeLong" from the code, but you can enter any numbers. known "issues": - Does not handle the equator, meridian or anti-meridian. That means no "-0" and no going over "180" or under "-180" - no error checking (it expects You to be smart enough) planned updates (perhaps): - fixing the known "issues" - adding the option of picking which weekdays to show (currently there is only None, All, or Today) Have fun, let me know if there are any problems ... on my user page, or find me ;-) Also, if you do put these links on your meetup pages, think about putting them on the linked pages as well (re-generated with the appropriate numbers). That is why I made it so that you can plug in other lat/longs and not only use the hard-coded ones.
geohash.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><head><title>Geohash Wikimarkup Code Generator</title><% ' by m5rammy http://wiki.xkcd.com/geohashing/User:M5rammy ' ' last update Sept 8th, 2008 ' ' this is the only part you should need to change (optional) ' ' store my home location ' Const HomeLat = "39" ' as a string, to handle -0 (not implemented yet) ' Const HomeLong = "-84" ' you can also change the default colors, if you want ' Dim bgc(4) bgc(1) = " bgcolor=""#FFFFCC""" ' lt yellow ' bgc(2) = " bgcolor=""#CCFFFF""" ' lt blue ' bgc(3) = " bgcolor=""#66FF99""" ' lt green ' bgc(4) = " bgcolor=""#FFCCFF""" ' lt pink ' ' That's it, no more changes needed ' ' get the date ' SystemDate = Date ' functions ' '------------------------------------' Function ChkIfSame(str1, str2) ret = "" If lcase(str1) = lcase(str2) Then ret = " checked=""checked""" ChkIfSame = ret End Function '------------------------------------' Function TwoDig(n) ' assumes input is up to 31 ' TwoDig = Mid(cStr(100 + n), 2) End Function '------------------------------------' Function WikiDate(OneDate) WikiDate = Year(OneDate) & "-" & TwoDig(Month(OneDate)) & "-" & TwoDig(Day(OneDate)) End Function '------------------------------------' ' get passed parameters ' myLat = Request.QueryString("lat") myLong = Request.QueryString("long") myDay = Request.QueryString("d") ' assumes 2 digits ' myMonth = Request.QueryString("m") ' assumes 2 digits ' myYear = Request.QueryString("y") myWeek = Request.QueryString("wkdys") ' may not match what we need ' If "" = myLat Then myLat = HomeLat If "" = myLong Then mylong = HomeLong If "" = myDay Then myDay = TwoDig(Day(SystemDate)) If "" = myMonth Then myMonth = TwoDig(Month(SystemDate)) If "" = myYear Then myYear = Year(SystemDate) myMonthName = MonthName(myMonth) myDate = myDay & "-" & myMonthName & "-" & Mid(myYear, 3) myWikiDate = WikiDate(myDate) myDayName = WeekdayName(Weekday(myDate), true, 0) IsSat = (7 = Weekday(myDate)) PrevWk = "" NextWk = "" Select Case IsSat Case true ' Inner 1 ' PrevSat = DateAdd("d", -7, myDate) NextSat = DateAdd("d", 7, myDate) Select case myWeek Case "prev" ' checking for valid input. Not the "best" way, but best for future enhancements ' ' do nothing ' Case "next" ' do nothing ' Case "both" ' do nothing ' Case Else myWeek = "none" End Select ' End Inner 1 ' Case false PrevSat = DateAdd("d", -(Weekday(myDate)), myDate) NextSat = DateAdd("d", +(7-Weekday(myDate)), myDate) ' Inner 2 ' Select case myWeek Case "all" ' do nothing ' Case Else myWeek = "today" End Select ' End Inner 2 ' End Select %></head><body> Geohash Wikimarkup Code Generator - for graticule and date-navigation links
<form method="get"> For Location:
Lat: <input type="text" name="lat" maxlength="4" size="5" value="<%=myLat %>"> Long: <input type="text" name="long" maxlength="4" size="5" value="<%=myLong %>">
For Date:
<td<%=bgc(1) %>><input type="radio" name="m" value="01"<%=ChkIfSame("01", TwoDig(myMonth)) %>>Jan <td<%=bgc(2) %>><input type="radio" name="m" value="02"<%=ChkIfSame("02", TwoDig(myMonth)) %>>Feb <td<%=bgc(1) %>><input type="radio" name="m" value="03"<%=ChkIfSame("03", TwoDig(myMonth)) %>>Mar <td<%=bgc(2) %>><input type="radio" name="m" value="04"<%=ChkIfSame("04", TwoDig(myMonth)) %>>Apr <td<%=bgc(1) %>><input type="radio" name="m" value="05"<%=ChkIfSame("05", TwoDig(myMonth)) %>>May <td<%=bgc(2) %>><input type="radio" name="m" value="06"<%=ChkIfSame("06", TwoDig(myMonth)) %>>Jun <td<%=bgc(1) %>><input type="radio" name="m" value="07"<%=ChkIfSame("07", TwoDig(myMonth)) %>>Jul <td<%=bgc(2) %>><input type="radio" name="m" value="08"<%=ChkIfSame("08", TwoDig(myMonth)) %>>Aug <td<%=bgc(1) %>><input type="radio" name="m" value="09"<%=ChkIfSame("09", TwoDig(myMonth)) %>>Sep <td<%=bgc(2) %>><input type="radio" name="m" value="10"<%=ChkIfSame("10", TwoDig(myMonth)) %>>Oct <td<%=bgc(1) %>><input type="radio" name="m" value="11"<%=ChkIfSame("11", TwoDig(myMonth)) %>>Nov <td<%=bgc(2) %>><input type="radio" name="m" value="12"<%=ChkIfSame("12", TwoDig(myMonth)) %>>Dec
<input type="text" name="y" value="<%=MyYear %>" maxlength="4" size="5"> |
If Saturday Include Links to Daily Meetup pages for ... <input type="radio" name="wkdys" value="prev"<%=ChkIfSame(myWeek, "prev") %>>Previous week (Su-Fr) <input type="radio" name="wkdys" value="next"<%=ChkIfSame(myWeek, "next") %>>Next week (Su-Fr) <input type="radio" name="wkdys" value="both"<%=ChkIfSame(myWeek, "both") %>>Both weeks <input type="radio" name="wkdys" value="none"<%=ChkIfSame(myWeek, "none") %>>Neither week (default) |
If Weekday Include Links to Daily Meetup pages for ... <input type="radio" name="wkdys" value="today"<%=ChkIfSame(myWeek, "today") %>>Today only (default) <input type="radio" name="wkdys" value="all"<%=ChkIfSame(myWeek, "all") %>>All of this week |
<% ' The Wiki Code ' %> <pre>
<map lat="<%=myLat %>" lon="<%=myLong %>" date="<strong class="error">Error: Invalid time.</strong>"></map> | ||
[[Error: Invalid time. | Error: Invalid time.]] in [[<%=myLat %>,<%=myLong %>|<%=myLat %>,<%=myLong %>]]: Expression error: Unexpected < operator.<%=myLat %>.0831481, Expression error: Unexpected < operator.<%=myLong %>.4403195 not yet announced |
[[<%=WikiDate(PrevSat) & "_" & myLat & "_" & myLong %>|Prev Sat]]<br> <% If ("prev" = MyWeek) or ("both" = myWeek) or ("all" = MyWeek) Then Response.Write("S") Response.Write("M") Response.Write("T") Response.Write("W") Response.Write("T") Response.Write("F<br> ") End If If IsSat Then Response.Write("Today<br> ") If ("today" = MyWeek) Then Response.Write("" & myDayName & "<br> ") If ("next" = MyWeek) or ("both" = myWeek) Then Response.Write("S") Response.Write("M") Response.Write("T") Response.Write("W") Response.Write("T") Response.Write("F<br> ") End If %>[[<%=WikiDate(NextSat) & "_" & myLat & "_" & myLong %>|Next Sat]] |
Neighboring<br> Meetups<br> today &rarr; |
[[<%=myWikiDate & "_" & (myLat + 1) & "_" & (myLong - 1) %>|NW]] | [[<%=myWikiDate & "_" & (myLat + 1) & "_" & myLong %>|N]] | [[<%=myWikiDate & "_" & (myLat + 1) & "_" & (myLong + 1) %>|NE]] |
[[<%=myWikiDate & "_" & myLat & "_" & (myLong - 1) %>|W]] | us | [[<%=myWikiDate & "_" & myLat & "_" & (myLong + 1) %>|E]] | ||
[[<%=myWikiDate & "_" & (myLat - 1) & "_" & (myLong - 1) %>|SW]] | [[<%=myWikiDate & "_" & (myLat - 1) & "_" & myLong %>|S]] | [[<%=myWikiDate & "_" & (myLat - 1) & "_" & (myLong + 1) %>|SE]] |