January 3, 2008
filed in the early afternoon by DrScofield in: from the grid,hacking
technorati tags:
QR code for this entry · average time to read 0:49 minutes

yesterday i updated the wordpress plugins on our d2h.net and xyzzyxyzzy.net blogs. once done, both blogs would not work anymore…duh! the updated geopress plugin was borked :-( — or so it seemed…

…it turned out that i had added code to the earlier version of geopress to do pretty printing of coordinates, and, of course, the update flushed that code down the drain. thanks to a regular backup running on our web server, however, that code was not gone forever. here are the functions that i added:

function the_geo_coord() { $coord = the_coord(); $coord = str_replace(‘ ‘, ‘,’, $c); return $coord; }

the_geo_coord() gets the coordinates via geopress’s the_coord() function and simply substitutes commas for spaces.

likewise,

function the_geo_pretty_print() {

$coord = the_coord(); $coord = split(” “, $coord);

$coord_lat = intval($coord[0]); $coord_lon = intval($coord[1]); $coord_lat_min = intval(($coord[0] – $coord_lat) * 60); $coord_lon_min = intval(($coord[1] – $coord_lon) * 60); $coord_lat_sec = intval(((($coord[0] – $coord_lat) * 60) – $coord_lat_min) * 60); $coord_lon_sec = intval(((($coord[1] – $coord_lon) * 60) – $coord_lon_min) * 60);

if (0 <= $coord_lat) { $coord_lat = ‘N ‘ . $coord_lat; } else { $coord_lat = ‘S ‘ . abs($coord_lat); }

if (0 <= $coord_lon) { $coord_lon = ‘E ‘ . $coord_lon; } else { $coord_lon = ‘W ‘ . abs($coord_lon); }

$coord_tag = “$coord_lat° $coord_lat_min’ $coord_lat_sec\”, $coord_lon° $coord_lon_min’ $coord_lon_sec\”";

return $coord_tag;

}

takes geopress’s the_coord() and pretty-prints it as human readable “old-style” latitute–longitude coordinates. the_geo_coord_esc() finally, produces a URL escaped longitude–latitude coordinate for use inside a, well, URL:

function the_geo_coord_esc() { $q = the_geo_pretty_print(); $q = str_replace(‘”‘, ‘%22′, $q); $q = str_replace(‘\”, ‘%27′, $q); $q = str_replace(‘ ‘, ‘+’, $q);

    return $q;

}

just add those PHP functions to geopress/geopress.php, shake, stir, and save.

all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.

no Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment