'line'); $s['style'] = $track['style']; $s['points'] = _gmap_tracks_parse($track['filename']); $map['shapes'][] = $s; } unset ($map['tracks']); } break; } } /** * Parse a plt file into coordinates. */ function _gmap_tracks_parse($track) { $points = array(); $file = file_create_path($track); if ($file === FALSE) { drupal_set_message(t('Invalid path to track file!')); } else if (!file_exists($file)) { drupal_set_message(t('Track file not found!')); } else { // @@@ Oversimplified OziExplorer PLT parser. // @@@ This needs improvement for various file types. if ($handle = fopen($file, 'r')) { while (!feof($handle)) { $line = fgets($handle, 4096); $line = explode(',', $line); if (count($line) == 7) { $points[] = array( (float)trim($line[0]), // latitude (float)trim($line[1]), // longitude ); } } fclose($handle); } } return $points; }