diff --git a/navigator-parser.php b/navigator-parser.php
new file mode 100755
index 0000000..6dbb44a
--- /dev/null
+++ b/navigator-parser.php
@@ -0,0 +1,88 @@
+ $row) {
+ handleTower($row);
+}
+
+writeFile();
+
+
+function handleTower($row)
+{
+ $cells = explode(",", $row);
+
+ $lon = trim($cells[0]);
+ $lat = trim($cells[1]);
+
+ $muni = trim($cells[2]);
+ $tower = trim($cells[3]); // suppressed errors from missing comma between muni and tower
+
+ $tempMuni = trim($muni, "\"");
+ $tempTower = trim($tower, "\"");
+ $tempLocation = $tempMuni . " " . $tempTower;
+ $firstWhitespace = strpos($tempLocation, " ");
+ $muni = substr($tempLocation, 0, $firstWhitespace);
+ $tower = substr($tempLocation, $firstWhitespace);
+
+ // create an id based on name
+ $id = sha1(($muni . $tower));
+
+ // Save to master array
+ global $allData;
+ $allData[$id]['lat'] = $lat;
+ $allData[$id]['lon'] = $lon;
+ $allData[$id]['muni'] = $muni;
+ $allData[$id]['tower'] = $tower;
+
+ // Save to database (test)
+ saveTower($id, $lat, $lon, $muni, $tower);
+}
+
+function saveTower($id, $lat, $lon, $muni, $tower)
+{
+// echo "$id / $lat / $lon / $muni / $tower
\n";
+// echo "\t$lat\t$lon\twgs84\t$tower
\n";
+
+
+}
+
+function writeFile()
+{
+ global $allData;
+// print_r ($allData); // debug
+
+ $json = json_encode($allData);
+
+ if ($json === FALSE)
+ {
+ echo "JSON encoding failed!";
+ }
+
+// echo "JSON follows: " . $json; // debug
+
+ file_put_contents("towers-autogenerated.json", $json);
+
+ echo "writeFile END";
+}
+
+
+
diff --git a/tiira-soap.php b/tiira-soap.php
new file mode 100755
index 0000000..faec590
--- /dev/null
+++ b/tiira-soap.php
@@ -0,0 +1,123 @@
+haeTornit($params); // array('iTopN'=>5)
+}
+catch (Exception $e)
+{
+ echo 'Caught exception: ', $e->getMessage(), "\n";
+ echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
+ echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "\n";
+ echo "RESPONSE:\n" . $client->__getLastRequest() . "\n";
+ echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "\n";
+
+}
+
+//print_r ($result); // debug
+
+saveTowersAsJSON($result);
+
+
+echo "\n
END";
+
+
+function saveTowersAsJSON($data)
+{
+ global $masterTowers; // data goes here
+
+ // Numeric id's could cause unintended sorting
+ $towersArr = $data->tornit->torni;
+
+ foreach ($towersArr as $key => $tower)
+ {
+ $id = sha1($tower->paikka_id);
+
+ if (strpos($tower->nimi, "lintutorni"))
+ {
+ $type = "lintutorni";
+ }
+ elseif (strpos($tower->nimi, "näkötorni") || strpos($tower->nimi, "näköalatorni"))
+ {
+ $type = "näkötorni";
+ }
+ elseif (strpos($tower->nimi, "vesitorni"))
+ {
+ $type = "vesitorni";
+ }
+ elseif (strpos($tower->nimi, "lava"))
+ {
+ $type = "lava";
+ }
+ else
+ {
+ $type = "tuntematon";
+ }
+
+ $masterTowers[$id]['muni'] = $tower->kunta;
+ $masterTowers[$id]['name'] = $tower->nimi;
+ $masterTowers[$id]['society'] = $tower->yhdistys;
+ $masterTowers[$id]['lat'] = substr($tower->n_wgs84, 0, 8);
+ $masterTowers[$id]['lon'] = substr($tower->e_wgs84, 0, 8);
+ $masterTowers[$id]['type'] = $type;
+ }
+
+ writeFile(); // debug
+}
+
+function writeFile()
+{
+ global $masterTowers; // data to be written
+ global $localSecret; // to hide the full json file
+
+ $json = json_encode($masterTowers);
+
+ if ($json === FALSE)
+ {
+ echo "JSON encoding failed!";
+ }
+
+ $filename = ("data-" . $localSecret . "/towers-autogenerated.json");
+ file_put_contents($filename, $json);
+
+ header('Content-Type: text/html; charset=utf-8');
+// print_r (masterTowers); // debug
+ echo "Data written to $filename";
+}
+
+
+
+