Yesterday I got a challenging assignment to generate a telco network coverage map. But the only data i got is BTS (Base Transceiver Station) location, which is only latitude, longitude and coverage radius given on excel file. I need to convert those excel sheet data into a google map page, and displayed it to subscribers accordingly.
The biggest problem that i had is the number of data is quite big, i need to map more than 20k BTS location and need displayed it fast and without lagging. So a simple google maps script wont work because google maps have a limitation for this.
So i need to create a workaround, and after researching for quite some times i pick KML and Google FusionTable. KML data format for creating radius, and Google FusionTable for displaying it.
This is my PHP code for converting latitude, longitude and radius into KML code.
<?
$lats = array('4.53191944444444','5.34593888888889');
$longs = array('97.93600000000001','95.99299999999999');
$meter = 2000;
$kml = '<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document>
<Style id="style0">
<LineStyle>
<color>ff000000</color>
<width>1</width>
</LineStyle>
<PolyStyle>
<color>7FAAAAAA</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>';
for($i = 0; $i < count($lats); $i++) {
$lat = $lats[$i];
$long = $longs[$i];
// Get circle coordinates
$coordinatesList = getCirclecoordinates($lat, $long, $meter);
// Output
$kml .= '<Placemark><name>Circle '.$i.'</name><styleUrl>#style0</styleUrl><Polygon><outerBoundaryIs><LinearRing><coordinates>'.$coordinatesList.'</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>';
}
$kml .= '</Document></kml>';
function getCirclecoordinates($lat, $long, $meter) {
// convert coordinates to radians
$lat1 = deg2rad($lat);
$long1 = deg2rad($long);
$d_rad = $meter/6378137;
$coordinatesList = "";
// loop through the array and write path linestrings
for($i=0; $i<=360; $i+=3) {
$radial = deg2rad($i);
$lat_rad = asin(sin($lat1)*cos($d_rad) + cos($lat1)*sin($d_rad)*cos($radial));
$dlon_rad = atan2(sin($radial)*sin($d_rad)*cos($lat1), cos($d_rad)-sin($lat1)*sin($lat_rad));
$lon_rad = fmod(($long1+$dlon_rad + M_PI), 2*M_PI) - M_PI;
$coordinatesList .= rad2deg($lon_rad).",".rad2deg($lat_rad).",0 ";
}
return $coordinatesList;
}
$fp = fopen('e:\lele.kml', 'w');
fwrite($fp, $kml);
fclose($fp);
?>
After KML is done, i just need to upload it to Google FusionTable and display it on my web page.

Google+