94 lines
4.2 KiB
PHP
94 lines
4.2 KiB
PHP
<?php
|
|
/*
|
|
* Definitions
|
|
*/
|
|
define("REL_PATH", "../");
|
|
define("ABS_PATH", "support/");
|
|
|
|
|
|
/*
|
|
* Required pages
|
|
*/
|
|
require_once(REL_PATH . "include/utilities.php");
|
|
require_once(REL_PATH . "include/db.php");
|
|
require_once(REL_PATH . "include/document.php");
|
|
|
|
// Send document header
|
|
download_document_header("application/vnd.google-earth.kml+xml", "Mtinfo_Devices_Position.kml", "download", "kml");
|
|
|
|
// Send KML header
|
|
download_document_data("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "download", "kml");
|
|
download_document_data("<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n", "download", "kml");
|
|
download_document_data("<Folder>\n", "download", "kml");
|
|
|
|
// Initial values
|
|
$valid_device = array();
|
|
$invalid_device = array();
|
|
$valid_equip = array();
|
|
|
|
// Get all devices
|
|
$equipment = db_fetch_all_lances();
|
|
|
|
if (is_array($equipment)) {
|
|
foreach($equipment as $item) {
|
|
// Valid device
|
|
if ((!in_array($item['device'], $valid_device)) && (!in_array($item['device'], $invalid_device))) {
|
|
// valid capability
|
|
if (db_check_system_device_capabilities($item['device'], array("kortsluiting schakelen"))) {
|
|
array_push($valid_device, $item['device']);
|
|
}
|
|
else {
|
|
array_push($invalid_device, $item['device']);
|
|
}
|
|
}
|
|
|
|
// Handle device?
|
|
if (in_array($item['device'], $valid_device)) {
|
|
array_push($valid_equip, $item);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Define style
|
|
download_document_data("\t<Style id=\"default\">\n", "download", "kml");
|
|
download_document_data("\t\t<IconStyle>\n", "download", "kml");
|
|
download_document_data("\t\t\t<scale>0.5</scale>\n", "download", "kml");
|
|
download_document_data("\t\t\t<Icon>\n", "download", "kml");
|
|
download_document_data("\t\t\t\t<href>" . $_DEFAULT['base'] . "skin/dualinventive/image/di_kml.png</href>\n", "download", "kml");
|
|
download_document_data("\t\t\t</Icon>\n", "download", "kml");
|
|
download_document_data("\t\t</IconStyle>\n", "download", "kml");
|
|
download_document_data("\t\t<LabelStyle>\n", "download", "kml");
|
|
download_document_data("\t\t\t<scale>0.5</scale>\n", "download", "kml");
|
|
download_document_data("\t\t</LabelStyle>\n", "download", "kml");
|
|
download_document_data("\t</Style>\n", "download", "kml");
|
|
|
|
// Valid equipment?
|
|
if (is_array($valid_equip)) {
|
|
foreach($valid_equip as $equip) {
|
|
// Get last position
|
|
$last_position = db_fetch_lance_log_gps_info($equip['id']);
|
|
|
|
if (is_array($last_position)) {
|
|
download_document_data("\t<Placemark>\n", "download", "kml");
|
|
$device = db_fetch_system_device_name("nl", $equip['device'], "download");
|
|
$idcode = ($equip['idcode'] == $equip['serienr']) ? $equip['idcode'] : $equip['idcode'] . " - " . $equip['serienr'];
|
|
download_document_data("\t<name>" . $idcode . " (" . $device . ")" . "</name>\n", "download", "kml");
|
|
download_document_data("\t<Point>\n", "download", "kml");
|
|
download_document_data("\t\t<coordinates>" . $last_position[0]['longitude'] . "," . $last_position[0]['latitude'] . ",0</coordinates>\n", "download", "kml");
|
|
download_document_data("\t</Point>\n", "download", "kml");
|
|
download_document_data("\t<LookAt>\n", "download", "kml");
|
|
download_document_data("\t\t<longitude>" . $last_position[0]['longitude'] . "</longitude>\n", "download", "kml");
|
|
download_document_data("\t\t<latitude>" . $last_position[0]['latitude'] . "</latitude>\n", "download", "kml");
|
|
download_document_data("\t\t<gx:TimeStamp><when>" . date("Y-m-d", $last_position[0]['t']) . "T" . date("H:i:s", $last_position[0]['t']) . "</when></gx:TimeStamp>\n", "download", "kml");
|
|
download_document_data("\t\t<range>200</range>\n", "download", "kml");
|
|
download_document_data("\t</LookAt>\n", "download", "kml");
|
|
download_document_data("\t<styleUrl>#default</styleUrl>\n", "download", "kml");
|
|
download_document_data("\t</Placemark>\n", "download", "kml");
|
|
}
|
|
}
|
|
}
|
|
|
|
// KML footer
|
|
download_document_data("</Folder>\n", "download", "kml");
|
|
download_document_data("</kml>", "download", "kml");
|
|
?>
|