<?php

require 'lib.php';

// What kind of request?

if($_GET === array()) // do usage
{
    
readfile('map-wizard.html');
    die();
}
else 
// prepare a feed
{
    if(
$debug)
        
header('Content-Type: text/plain; charset=UTF-8');
    else
        
header('Content-Type: text/html; charset=UTF-8');
}

// gather parameters

$dow getDowParam('dow''Dow Jones opening value');
$date getDateParam('date''local date');
$lat getCoord('lat'$LATITUDE);
$lon getCoord('lon'$LONGITUDE);

//compute meetup

$meetup theAlgorithm($date$dow$lat$lon);

// map it

$staticMapSource createMeetupStaticMap($lat$lon$meetup);

//display

$safeMapSource htmlentities($staticMapSource);

echo <<<EOHTML
    <p>Meetup: {$meetup['lat']['full']}{$meetup['lon']['full']}</p>
    
    <a href="http://carabiner.peeron.com/xkcd/map/map.html?lat=
{$lat['ID']}&amp;long={$lon['ID']}&amp;date={$date}&amp;zoom=8"><img src="{$safeMapSource}" alt="Static map" /></a>
EOHTML;

?>