# # APRSWorld Mapper Using Google Maps # Copyright (C) 2008 Erik G. Burrows # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # require "db.conf"; $track_colors = array( "#ff0000", "#00ff00", "#0000ff", "#f0f000", "#f00f00", "#f000f0", "#f0000f", "#0ff000", "#0f0f00", "#0f00f0", "#0f000f", "#00f0f0", "#00f00f", "#000f0f" ); $icon_index = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); # Break patterns text field into array of words, defaulting to $DEFAULT_CALLSIGN from db.conf if ($_REQUEST['patterns']) { $input_patterns = preg_split("/[\s,]+/", $_REQUEST['patterns']); } else { $input_patterns = array($DEFAULT_CALLSIGN); } # Input tracklog hours value, defaulting to $DEFAULT_TRACKLOG_HOURS from db.conf if ($_REQUEST['tracklog_hrs'] && is_numeric($_REQUEST['tracklog_hrs'])) { $tracklog_hrs = $_REQUEST['tracklog_hrs']; } else { $tracklog_hrs = $DEFAULT_TRACKLOG_HOURS; } # Validate, and quote patterns for safe DB use. $patterns = array(); for ($i = 0; $i < sizeof($input_patterns); ++$i) { if ($input_patterns[$i]) array_push($patterns, pg_escape_string($input_patterns[$i])); } ($aprs_dbh = pg_connect($DB_CONNECTION_STRING)) || die ("Could not connect to APRS database."); # For each pattern specified, search for callsigns $sql = "select source from aprs_lastposition where source like '" . join("%' or source like '", $patterns) . "%' and packet_date > now() - '$tracklog_hrs hours'::interval"; $sth = pg_query($aprs_dbh, $sql); $callsigns = array(); while(list($source) = pg_fetch_array($sth)) { array_push($callsigns, $source); } # Find center of all callsigns returned from pattern matching query, for map center. $sql = "select avg(ST_Y(position)) as latitude, avg(ST_X(position)) as longitude from aprs_lastposition where source in ('" . join("', '", $callsigns) . "')"; $sth = pg_query($aprs_dbh, $sql); $row = pg_fetch_array($sth); $middle_lat = $row[0]; $middle_long = $row[1]; # # HTML Start # ?>