<commit_before><?php
// Set the name of the json file here
$source = "datasource/setthishere.json";

// here we go

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if($source == "datasource/setthishere.json"){
	die("You need to change the name of the source file.");
}


require_once("lib/point.php");
require_once("lib/line.php");
require_once("lib/map.php");

$storyline = json_decode(file_get_contents($source));

$lines = array();

$center = false;

foreach($storyline as $d){
	if(isset($d->segments) && is_array($d->segments)) {
		foreach ( $d->segments as $segment ) {
			if ( $segment->type == "move" ) {
				$line = new \mapdraw\line();
				foreach ($segment->activities as $activity) {
					// Moves is a bit wonky for flights.
					if($activity->activity != "airplane"){
						foreach ($activity->trackPoints as $trackPoint) {
							$point = new \mapdraw\point();
							$point->setLatitude($trackPoint->lat);
							$point->setLongitude($trackPoint->lon);
							$line->addPoint($point);
							// If in doubt, center on the last point. This gets overwritten by the bounds thing anyway.
							$center = $point;
						}
					}
				}
				$lines[] = $line;
			}
		}
	}
}

$map = new \mapdraw\map();

foreach($lines as $line){

	$map->addLine($line,166,10,46);
}

// $map->setCenter($center);
$map->getZoomFromBounds();

$map->draw();<commit_msg>map.php can now upload json-files<commit_after><?php
// here we go
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// show upload-form if no file is present
if (empty($_FILES)) : ?>

	<form action="map.php" method="POST" enctype="multipart/form-data">
		<input type="file" name="sourcefile" />
		<input type="submit" />
	</form>

<?php
// and die, die, die my darling
die();

// get content of uploaded file
else :
	$source = file_get_contents($_FILES["sourcefile"]["tmp_name"]);
endif;

// draw map
require_once("lib/point.php");
require_once("lib/line.php");
require_once("lib/map.php");

$storyline = json_decode($source);

$lines = array();

$center = false;

foreach($storyline as $d){
	if(isset($d->segments) && is_array($d->segments)) {
		foreach ( $d->segments as $segment ) {
			if ( $segment->type == "move" ) {
				$line = new \mapdraw\line();
				foreach ($segment->activities as $activity) {
					// Moves is a bit wonky for flights.
					if($activity->activity != "airplane"){
						foreach ($activity->trackPoints as $trackPoint) {
							$point = new \mapdraw\point();
							$point->setLatitude($trackPoint->lat);
							$point->setLongitude($trackPoint->lon);
							$line->addPoint($point);
							// If in doubt, center on the last point. This gets overwritten by the bounds thing anyway.
							$center = $point;
						}
					}
				}
				$lines[] = $line;
			}
		}
	}
}

$map = new \mapdraw\map();

foreach($lines as $line){

	$map->addLine($line,166,10,46);
}

// $map->setCenter($center);
$map->getZoomFromBounds();

$map->draw();

{'fraction_non_alphanumeric': 0.18472824274758254, 'fraction_numerical': 0.006002000666888963, 'mean_word_length': 3.6296296296296298, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2412466', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1023, 'n_words': 235}