-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
49 lines (38 loc) · 1.06 KB
/
process.php
File metadata and controls
49 lines (38 loc) · 1.06 KB
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
<?php
// This script converts a CSV of cell tower data to a KML file for use in Google Earth.
ini_set('memory_limit', '64M');
$d = Array();
$csv = file($_FILES['that_file']['tmp_name']);
$fn = explode(',',array_shift($csv));
foreach($csv as $rn => $row){
str_replace(Array("\r","\n"),'',rtrim($row,','));
$row = explode(',',trim($row));
foreach($row as $n => $v){
if(isset($fn[$n])){
$d[$rn][trim($fn[$n])] = str_replace(',','',trim($v));
}
}
}
// print_r($d);
$o = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
';
foreach($d as $r){
$o .= '<Placemark>'."\n";
$o .= '<name>'.$r['owner_entity_name'].'</name>'."\n";
$o .= '<description>';
foreach($r as $n => $v){
$o .= $n.': '.$v."\n";
}
$o .= '</description>';
$o .= '<Point>'."\n";
$o .= '<coordinates>'.$r['longitude'].','.$r['latitude'].',0</coordinates>'."\n";
$o .= '</Point>'."\n";
$o .= '</Placemark>'."\n";
}
$o .= '</Document>
</kml>';
header('Content-Disposition: attachment; filename="towers.kml"');
echo $o;
?>