<commit_before><?php
$file = 'test/data/ride-one.kmz';

$zip = new ZipArchive;

if ($zip->open($file) === TRUE) {
  $contents = $zip->getFromIndex(0);
  if ($contents) {
    $xml = simplexml_load_string($contents);
    echo $xml->Document->name . PHP_EOL;

    foreach ($xml->Document->Placemark as $placemark) {
      if ($placemark->styleUrl == '#fpTrackStyle') {
        foreach ($placemark->description->div->div->table->tr as $row) {
          var_dump($row);
        }
      }
      echo $placemark->styleUrl . PHP_EOL;
    }

    $xml->registerXPathNamespace('kml', 'http://earth.google.com/kml/2.2');
    var_dump($xml->xpath('//kml:description'));
  }

  $zip->close();
} else {
  echo "Failed to open {$file}";
}<commit_msg>Start pulling out stats from MotionX description<commit_after><?php
$file = 'test/data/ride-one.kmz';

$xml = getXml($file);

echo getTrackName($xml) . PHP_EOL;
echo getTrackDate($xml) . PHP_EOL;
echo getDistance($xml) . PHP_EOL;
echo getElapsedTime($xml) . PHP_EOL;

function getXml($file) {
    $zip = new ZipArchive;

    if ($zip->open($file) === TRUE) {
        $contents = $zip->getFromIndex(0);
        $zip->close();
        if ($contents) {
            return simplexml_load_string($contents);
        }
    } else {
        echo "Failed to open {$file}";
    }
}

function getTrackName($xml) {
    return $xml->Document->name;
}

function getTrackDescription($xml) {
    $xml->registerXPathNamespace('kml', 'http://earth.google.com/kml/2.2');
    return $xml->xpath('//kml:description')[0];
}

function getTrackDate($xml) {
    return strip_tags(getTrackDescription($xml)->div->div->table->tr->td[1]->asXML());
}

function getDistance($xml) {
    return strip_tags(getTrackDescription($xml)->div->div->table->tr[1]->td[1]->asXML());
}

function getElapsedTime($xml) {
    return strip_tags(getTrackDescription($xml)->div->div->table->tr[2]->td[1]->asXML());
}

function getMaxSpeed($xml) {
    return $xml->Document->name;
}

function getAverageSpeed($xml) {
    return $xml->Document->name;
}

function getAveragePace($xml) {
    return $xml->Document->name;
}

function getMinAltitude($xml) {
    return $xml->Document->name;
}

function getMaxAltitude($xml) {
    return $xml->Document->name;
}

function getStartLocation($xml) {
    return $xml->Document->name;
}

function getFinishLocation($xml) {
    return $xml->Document->name;
}

function getStartTime($xml) {
    return $xml->Document->name;
}

function getFinishTime($xml) {
    return $xml->Document->name;
}
{'fraction_non_alphanumeric': 0.18807157057654075, 'fraction_numerical': 0.004771371769383698, 'mean_word_length': 3.7561436672967865, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 41}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2579359', 'n_tokens_mistral': 874, 'n_tokens_neox': 864, 'n_words': 145}