function _gmap_gpx_stop_element in GMap Addons 5
Same name and namespace in other branches
- 6 gmap_gpx.inc \_gmap_gpx_stop_element()
- 7 gmap_gpx.inc \_gmap_gpx_stop_element()
1 string reference to '_gmap_gpx_stop_element'
File
- ./
gmap_gpx.inc, line 129
Code
function _gmap_gpx_stop_element(&$parser, $name) {
global $gmap_gpx;
static $info_tags = array(
'NAME' => 1,
'DESC' => 1,
'CMT' => 1,
'URL' => 1,
'URLNAME' => 1,
'TIME' => 1,
);
static $wpa = array(
'GPX WPT' => 1,
'GPX RTE RTEPT' => 1,
'GPX TRK TRKSEG TRKPT' => 1,
);
$path = join(' ', $gmap_gpx['stack']);
array_pop($gmap_gpx['stack']);
// remove $name from stack
$point_type = $gmap_gpx['point_type'];
if (isset($wpa[$path])) {
// closing tag of one point
$gmap_gpx[$point_type]['points'][] = $gmap_gpx['waypoint'];
unset($gmap_gpx['waypoint']);
unset($gmap_gpx['point_type']);
}
elseif (isset($gmap_gpx['waypoint'])) {
// more info for a point
if ($gmap_gpx['in_extension']) {
if ($name == 'EXTENSIONS') {
unset($gmap_gpx['in_extension']);
}
return;
}
if ($name == 'TIME') {
$gmap_gpx['waypoint']['time'] = strtotime($gmap_gpx['char_data']);
}
else {
$gmap_gpx['waypoint'][strtolower($name)] = $gmap_gpx['char_data'];
}
}
elseif ($path == 'GPX RTE') {
// end of a route
$gmap_gpx['rte'][] = $gmap_gpx['rtept'];
unset($gmap_gpx['rtept']);
}
elseif ($path == 'GPX TRK TRKSEG') {
// end of a track segment
$gmap_gpx['cur_trk']['segs'][] = $gmap_gpx['trkpt'];
unset($gmap_gpx['trkpt']);
}
elseif ($path == 'GPX TRK') {
// end of a track
$gmap_gpx['trk'][] = $gmap_gpx['cur_trk'];
unset($gmap_gpx['cur_trk']);
}
elseif (isset($info_tags[$name])) {
// more info for track, route or whole file
$nl = strtolower($name);
$v = $name == 'time' ? strtotime($gmap_gpx['char_data']) : $gmap_gpx['char_data'];
switch ($gmap_gpx['stack'][1]) {
case 'RTE':
$gmap_gpx['rtept']['info'][$nl] = $v;
break;
case 'TRK':
$gmap_gpx['cur_trk']['info'][$nl] = $v;
break;
default:
$gmap_gpx['info'][$nl] = $v;
}
}
unset($gmap_gpx['char_data']);
}