<commit_before><?php
if(!empty($_POST)){
$angles = array();
$angles[0] = mt_rand(0, 89); // get first angle, within 1st quadrant
for($i = 1; $i < 4; $i++){
        $angles[$i] = $angles[$i-1]+90;
}

$directions = array('North', 'East', 'South', 'West');

$points = array();
$o = explode(',', $_POST['origin']);
$origin = array('lat' => trim($o[0]), 'lon' => trim($o[1]));

$distance = 10; //km
foreach($angles as $i => $bearing){

        //http://www.movable-type.co.uk/scripts/latlong.html

        $lat1 = deg2rad($origin['lat']);
        $lon1 = deg2rad($origin['lon']);
        $d = $distance/6371;  // convert dist to angular distance in radians
        $b = deg2rad($bearing);
        $lat2 = asin( sin($lat1)*cos($d) + cos($lat1)*sin($d)*cos($b) );
        $lon2 = $lon1 + atan2(sin($b)*sin($d)*cos($lat1), cos($d)-sin($lat1)*sin($lat2));
        //$lon2 = ($lon2+3*pi()) % (2*pi()) - pi();  // normalise to -180..+180º
        $points[$i] = array('lat' => rad2deg($lat2), 'lon' => rad2deg($lon2));

}
$file = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>4 random angles from '.implode(', ', $origin).'</name>
<open>1</open>
<Placemark>
<name>'.implode(', ', $origin).' [origin]</name>
<Point>
<coordinates>'.PHP_EOL;
$file .= implode(',', array_reverse($origin)).',0';
$file .= '
</coordinates>
</Point>
</Placemark>'.PHP_EOL;
foreach($points as $i => $point){
        $file .= '<Placemark>
        <name>Line '.$directions[$i].'</name>
        <LineString>
        <tessellate>1</tessellate>
        <altitudeMode>clampToGround</altitudeMode>
        <coordinates>'.PHP_EOL;
        $file .= implode(',', array_reverse($origin)).',0'.' '.implode(',', array_reverse($point)).',0'.' ';
        $file .= '
        </coordinates>
        </LineString>
        </Placemark>'.PHP_EOL;
}
$file .= '
</Document>
</kml>'.PHP_EOL;
}
ob_clean();
flush();
header("Content-Type: text/kml");
header("Content-Disposition: attachment; filename=Lines__".implode('_', $origin).".kml");
header("Expires: 0");
echo($file);
?>

<commit_msg>Applied fixes from StyleCI<commit_after><?php
if (!empty($_POST)) {
    $angles = [];
    $angles[0] = mt_rand(0, 89); // get first angle, within 1st quadrant
for ($i = 1; $i < 4; $i++) {
    $angles[$i] = $angles[$i - 1] + 90;
}

    $directions = ['North', 'East', 'South', 'West'];

    $points = [];
    $o = explode(',', $_POST['origin']);
    $origin = ['lat' => trim($o[0]), 'lon' => trim($o[1])];

    $distance = 10; //km
foreach ($angles as $i => $bearing) {

        //http://www.movable-type.co.uk/scripts/latlong.html

        $lat1 = deg2rad($origin['lat']);
    $lon1 = deg2rad($origin['lon']);
    $d = $distance / 6371;  // convert dist to angular distance in radians
        $b = deg2rad($bearing);
    $lat2 = asin(sin($lat1) * cos($d) + cos($lat1) * sin($d) * cos($b));
    $lon2 = $lon1 + atan2(sin($b) * sin($d) * cos($lat1), cos($d) - sin($lat1) * sin($lat2));
        //$lon2 = ($lon2+3*pi()) % (2*pi()) - pi();  // normalise to -180..+180º
        $points[$i] = ['lat' => rad2deg($lat2), 'lon' => rad2deg($lon2)];
}
    $file = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>4 random angles from '.implode(', ', $origin).'</name>
<open>1</open>
<Placemark>
<name>'.implode(', ', $origin).' [origin]</name>
<Point>
<coordinates>'.PHP_EOL;
    $file .= implode(',', array_reverse($origin)).',0';
    $file .= '
</coordinates>
</Point>
</Placemark>'.PHP_EOL;
    foreach ($points as $i => $point) {
        $file .= '<Placemark>
        <name>Line '.$directions[$i].'</name>
        <LineString>
        <tessellate>1</tessellate>
        <altitudeMode>clampToGround</altitudeMode>
        <coordinates>'.PHP_EOL;
        $file .= implode(',', array_reverse($origin)).',0'.' '.implode(',', array_reverse($point)).',0'.' ';
        $file .= '
        </coordinates>
        </LineString>
        </Placemark>'.PHP_EOL;
    }
    $file .= '
</Document>
</kml>'.PHP_EOL;
}
ob_clean();
flush();
header('Content-Type: text/kml');
header('Content-Disposition: attachment; filename=Lines__'.implode('_', $origin).'.kml');
header('Expires: 0');
echo($file);
?>


{'fraction_non_alphanumeric': 0.25800331989566044, 'fraction_numerical': 0.027507706900640267, 'mean_word_length': 3.4167539267015705, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 2, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, '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': '3443900', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1613, 'n_words': 294}