Пример #1
0
    $sth = $conn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $sth->execute(array(':id' => $_GET['id']));
    $rows = $sth->fetchAll();
    $numRow = count($rows);
    if ($numRow == 0) {
        error_log('skip user id not exist');
    } else {
        $gps = $_GET['gprmc'];
        $gprmc = explode(',', $gps);
        $data['timestamp'] = strtotime('now');
        $data['sat_status'] = $gprmc[2];
        $data['lattitude_dms'] = $gprmc[3];
        $data['lattitude_decimal'] = '-' . DMStoDEC($gprmc[3], 'lattitude');
        $data['lattitude_direction'] = $gprmc[4];
        $data['longitude_dms'] = $gprmc[5];
        $data['longitude_decimal'] = DMStoDEC($gprmc[5], 'longitude');
        $data['longitude_direction'] = $gprmc[6];
        $data['speed_knots'] = $gprmc[7];
        $data['bearing'] = $gprmc[8];
        $data['google_map'] = 'http://maps.google.com/maps?q=' . $data['lattitude_decimal'] . ',' . $data['longitude_decimal'] . '+(PHP Decoded)&iwloc=A';
        // query
        $sql = "INSERT INTO driver_location VALUES ('',:user_id,:time,:lat,:long)";
        $q = $conn->prepare($sql);
        $q->bindParam(':user_id', $_GET['id']);
        $q->bindParam(':time', $data['timestamp']);
        $q->bindParam(':lat', $data['lattitude_decimal']);
        $q->bindParam(':long', $data['longitude_decimal']);
        $q->execute();
        error_log('set new location user ' . $_GET['id']);
    }
}
Пример #2
0
$freqency_xml = curl_exec($ch);
curl_close($ch);
/* Parse the resulting XML file and pull out those transmitters where
   the "licensee" is "CBC/ RADIO-CANADA" */
$xml = simplexml_load_string($freqency_xml);
$list = array();
foreach ($xml->account as $key => $station) {
    if ((string) $station->licensee_name == "CBC/ RADIO-CANADA") {
        $s['type'] = 'Feature';
        $s['properties']['call_sign'] = (string) $station->licence->call_sign;
        $s['properties']['location'] = (string) $station->licence->location;
        $s['properties']['frequency'] = (string) $station->licence->frequency->tx_frequency;
        $s['properties']['longitude'] = (string) $station->licence->longitude;
        $s['properties']['latitude'] = (string) $station->licence->latitude;
        $s['geometry']['type'] = "Point";
        $s['geometry']['coordinates'] = array(0 - DMStoDEC((string) $station->licence->longitude), DMStoDEC((string) $station->licence->latitude));
        $list[] = $s;
    }
}
/* Convert the resulting array into JSON */
$json = json_encode(array("type" => "FeatureCollection", "features" => $list));
/* Dump the JSON file of the results. */
$fp = fopen("../www/data/stations.json", "w");
fwrite($fp, $json);
fclose($fp);
/* Convert latitude and longitude in format 
   DDMMSS or DDDMMSS to decimal degrees */
function DMStoDEC($ddmmss)
{
    if (strlen($ddmmss) == 7) {
        $deg = substr($ddmmss, 0, 3);
Пример #3
0
require_once '../includes/database.php';
require_once '../includes/pagination.php';
// load database-related classes
require_once '../includes/propiedades.php';
require_once '../includes/regiones.php';
// Tamaño máximo de la foto
$max_file_size = 2097152;
// expressed in bytes
//     10240 =  10 KB
//    102400 = 100 KB
//   1048576 =   1 MB
//  10485760 =  10 MB
// Si envío el formulario, guardamos
if (isset($_POST['enviar_nuevo'])) {
    $latitud = DMStoDEC(intval($_POST['la_grados']), intval($_POST['la_minutos']), intval($_POST['la_segundos']));
    $longitud = DMStoDEC(intval($_POST['lo_grados']), intval($_POST['lo_minutos']), intval($_POST['lo_segundos']));
    $propiedades = new Propiedades();
    $propiedades->ref_alf = $_POST['ref_alf'];
    $propiedades->ref_num = $_POST['ref_num'];
    $propiedades->region = $_POST['region'];
    $propiedades->departamento = $_POST['departamento'];
    $propiedades->distrito = $_POST['distrito'];
    $propiedades->lugar = $_POST['lugar'];
    $propiedades->campo_urbano = $_POST['campo_urbano'];
    $propiedades->propietario = $_POST['propietario'];
    $propiedades->sin_uso = $_POST['sin_uso'];
    $propiedades->descripcion = $_POST['descripcion'];
    $propiedades->breve = $_POST['breve'];
    $propiedades->sin_uso2 = $_POST['sin_uso2'];
    $propiedades->superficie = $_POST['superficie'];
    $propiedades->unidad_medida = $_POST['unidad_medida'];
$datamarker = "";
if ($row) {
    foreach ($row as $keys => $full_data) {
        $nama_aset = $full_data->NamAset;
        $nomorreg = $full_data->NomorReg;
        $nomorkontrak = $full_data->NomorKontrak;
        $koordinat = $full_data->koordinat;
        $tmp = explode(".", $koordinat);
        $deg_long = $tmp[0];
        $min_long = $tmp[1];
        $sec_long = $tmp[2] . "." . $tmp[3];
        $latitude = DMStoDEC($deg_long, $min_long, $sec_long);
        $deg_lat = $tmp[4];
        $min_lat = $tmp[5];
        $sec_lat = $tmp[6] . "." . $tmp[7];
        $longitude = DMStoDEC($deg_lat, $min_lat, $sec_lat);
        $lokasi = $full_data->Lokasi;
        if ($i == 0) {
            $datamarker .= " {lat:{$latitude}, lng:{$longitude}, title: '{$nama_aset}', infoWindow: {\n                                                                                                                        content: '<p>Nama Aset: {$nama_aset} <br/> Nomor Reg: {$nomorreg} <br/>Nomor Kontrak:{$nomorkontrak} <br/>Lokasi:{$lokas}</p>'\n                                                                                                                   }}";
        } else {
            $datamarker .= ",{lat:{$latitude}, lng:{$longitude}, title: '{$nama_aset}', infoWindow: {\n                                                                                                                        content: '<p>Nama Aset: {$nama_aset} <br/> Nomor Reg: {$nomorreg} <br/>Nomor Kontrak:{$nomorkontrak} <br/>Lokasi:{$lokasi}</p>'\n                                                                                                                   }}";
        }
        $i++;
    }
}
// echo $datamarker
?>
                             
                                <script type="text/javascript">
                                                       var map;
                                                       $(document).ready(function(){
function buildFeature($account, $company, $colour)
{
    $list = array();
    foreach ($account->licence as $key1 => $license) {
        $s['type'] = 'Feature';
        $s['properties']['shortcompany'] = $company;
        $s['properties']['company'] = (string) $account->licensee_name;
        $s['properties']['call_sign'] = (string) $license->call_sign;
        $s['properties']['location'] = (string) $license->location;
        $s['properties']['longitude'] = (string) $license->longitude;
        $s['properties']['latitude'] = (string) $license->latitude;
        $s['properties']['site_elevation'] = (string) $license->site_elevation;
        $s['properties']['structure_height'] = (string) $license->structure_height;
        $s['properties']['colour'] = $colour;
        $s['geometry']['type'] = "Point";
        $s['geometry']['coordinates'] = array(0 - DMStoDEC((string) $license->longitude), DMStoDEC((string) $license->latitude));
        $list[] = $s;
    }
    return $list;
}
Пример #6
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include "convert_latitude_longitude.php";
$longitude = DMStoDEC(5, 31, 0);
$latitude = DMStoDEC(95, 32, 0);
echo "Longitude: {$longitude} <br/>Latitude: {$latitude}";