$starttm = microtime(true); //删除10天前的每个台站最后状态数据包 $q = "delete from lastpacket where tm<=date_sub(now(),INTERVAL 10 day)"; $mysqli->query($q); $endtm = microtime(true); $spantm = $endtm - $starttm; $startm = $endtm; echo "//" . $spantm . "\n"; $q = "select lat,lon,`call`,unix_timestamp(tm),tm,concat(`table`,symbol),msg,datatype from aprspacket where tm>=FROM_UNIXTIME(?) and tm>=? and lat<>'' and not lat like '0000.00%'"; $stmt = $mysqli->prepare($q); $stmt->bind_param("is", $tm, $startdatestr); $stmt->execute(); $stmt->bind_result($glat, $glon, $dcall, $dtm, $dtmstr, $dts, $dmsg, $ddt); while ($stmt->fetch()) { $lat = strtolat($glat); $lon = strtolon($glon); if ($jiupian == 1) { $p = $mp->WGStoBaiDuPoint($lon, $lat); $lon = $p->getX(); $lat = $p->getY(); } else { if ($jiupian == 2) { $p = $mp->ChinatoBaiDuPoint($lon, $lat); $lon = $p->getX(); $lat = $p->getY(); } } $icon = "/img/" . bin2hex($dts) . ".png"; $dmsg = urlmessage($dcall, $icon, $dtmstr, $dmsg, $ddt, $glon, $glat); echo "setstation(" . $lon . "," . $lat . ",\"" . $dcall . "\"," . $dtm . ",\"" . $icon . "\",\n\"" . $dmsg . "\");\n"; }
function download_kml($call, $startdatestr, $enddatestr) { global $mysqli; date_default_timezone_set("Asia/Shanghai"); header("Content-Type:application/gpx+xml"); header("Content-Disposition:attachment; filename=\"" . $call . "-" . $startdatestr . "Track.kml\""); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; echo "<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">\n"; echo "<Document>\n"; echo "<name>" . $call . " Track</name>\n"; ?> <Style id="ylw"> <LabelStyle> <color>ff1307ff</color> </LabelStyle> <LineStyle> <color>ff00ffff</color> <width>4</width> </LineStyle> </Style> <?php echo "<Folder><name>" . $call . "-" . $startdatestr . "</name>\n"; echo "<Placemark>\n"; echo "<styleUrl>#ylw</styleUrl>\n"; echo "<gx:Track id=\"1\">\n"; echo "<altitudeMode>absolute</altitudeMode>\n"; $q = "select date_format(CONVERT_TZ(tm,@@session.time_zone, '+00:00'),\"%Y-%m-%dT%H:%i:%sZ\"),lat,lon,msg,datatype from aprspacket where tm>=? and tm<=? and `call`=? and lat<>'' and not lat like '0000.00%' order by tm"; $stmt = $mysqli->prepare($q); $stmt->bind_param("sss", $startdatestr, $enddatestr, $call); $stmt->execute(); $stmt->bind_result($dtm, $glat, $glon, $msg, $ddt); $stmt->store_result(); while ($stmt->fetch()) { echo "<when>" . $dtm . "</when>\n"; } $stmt->data_seek(0); while ($stmt->fetch()) { $lat = strtolat($glat); $lon = strtolon($glon); // $wpt = gpx_wpt($dtm, $msg,$ddt); echo "<gx:coord>" . $lon . " " . $lat . " "; echo kml_alt($msg); echo "</gx:coord>\n"; } echo "</gx:Track>\n"; echo "</Placemark>\n"; echo "</Folder>\n"; echo "</Document>\n"; echo "</kml>\n"; exit(0); }