-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetTracking.php
72 lines (63 loc) · 2.16 KB
/
GetTracking.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
# Connect to PostgreSQL database
$conn = pg_connect("dbname='ITAU_BR' user='osmuser' password='osmuser' host='192.168.1.21'");
if (!$conn) {
echo "Not connected : " . pg_error();
exit;
}
//print("Conectado");
# Build SQL SELECT statement and return the geometry as a GeoJSON element in EPSG: 4326
$sql = "SELECT DWTPPOI,
trunc(DWCDCOGX,8) as DWCDCOGX,
trunc(DWCDCOGY,8) as DWCDCOGY,
DWDSUSR3,
DWDSUSR4,
DWDSINFO
FROM DWITAUMON
";
//WHERE DWTPPOI = '3599340' AND (DWFLUSR1 = '0' OR DWFLUSR1 = ' ' OR DWFLUSR1 IS NULL) AND (DWDSUSR3 > '2014-05-27' AND DWDSUSR3 < '2014-05-28')
//echo $sql;
# Try query or error
$rs = pg_query($conn, $sql);
if (!$rs) {
//echo "An SQL error occured.\n";
//exit;
}
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
while ($row = pg_fetch_array($rs, null, PGSQL_ASSOC+PGSQL_RETURN_NULLS)) {
$marker = array(
'type' => 'Feature',
'features' => array(
'type' => 'Feature',
'properties' => array(
'id' => "".$row['dwtppoi']."",
'UserName' => "".$row['dwdsinfo']."",
'time' => "".$row['dwdsusr4']."",
'long' => "".$row['dwcdcogy']."",
'lat' => "".$row['dwcdcogx']."",
'color' => 'blue',
'icon' => 'images/itau3_small'
//'marker-color' => '#f00',
//'marker-size' => 'small'
//'url' =>
),
"geometry" => array(
'type' => 'Point',
'coordinates' => array(
$row['dwcdcogx'],
$row['dwcdcogy']
)
)
)
);
array_push($geojson['features'], $marker['features']);
}
//Liberamos la memoria (no creo que sea necesario con consultas tan simples)
pg_free_result($res);
//Cerramos la conexión
pg_close($conn);
print (json_encode($geojson, JSON_NUMERIC_CHECK));
?>