TPS1100 Convert Online
MultiBox
";
$uploadOk = 0;
} else {
echo "Procesiranje datoteke >>> " . basename($target_file) . "
";
$uploadOk = 1;
}
}
// // Check if file already exists
// if (file_exists($target_file)) {
// echo "Sorry, file already exists.";
// $uploadOk = 0;
// }
// // Check file size
// if ($_FILES["fileToUpload"]["size"] > 500000) {
// echo "Sorry, your file is too large.";
// $uploadOk = 0;
// }
// // Allow certain file formats
// if($datFileType != "gsi") {
// echo "Napaka! Nalozi datoteko GSI.";
// $uploadOk = 0;
// }
class ObdelavaGsi
{
// Properties
public $obdelavaTocke;
public $obdelavaZap;
// Funkcija za izvoz koordinat točk (GSI z kodami)
function izvoz_tocke($name)
{
$down_dir = "convert/";
$down_datime = $down_dir . basename($_FILES["fileToUpload"]["name"]);
$datnova_tip = $_POST['tipdat'];
if ($datnova_tip == "koo") {
$down_datnova = str_replace(".GSI", "_tocke.KOO", $down_datime);
} else {
$down_datnova = str_replace(".GSI", "_tocke.TXT", $down_datime);
}
$down_url = "https://gps.multibox.nohost.me/points/";
$down_daturl = $down_url . $down_datnova;
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
print "--------------------------------------------
";
// If the user file in existing directory already exist, delete it
if (file_exists($down_datnova)) {
unlink($down_datnova);
}
$this->obdelavaTocke = $name;
$file_handle = fopen($name, "rb");
$merjene = 0;
$stojisce = 0;
$kode_ok = 0;
while (!feof($file_handle)) {
$line_of_text = fgets($file_handle);
$parts = explode(' ', $line_of_text);
$word_index = substr($parts[0], 1, 2);
if ($word_index == 41) {
$kode_ok = 1;
$koda = ltrim(substr($parts[0], 8), "0");
if ($koda == 99) {
$merjene = 2;
$stojisce = 0;
} elseif ($koda >= 90) {
$merjene = 1;
$stojisce = 0;
} elseif ($koda >= 80) {
$merjene = 3;
$stojisce = 0;
} elseif ($koda < 80) {
$merjene = 0;
$stojisce = 1;
} else {
$merjene = 0;
$stojisce = 0;
}
}
if ($word_index == 11 && $merjene >= 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 81) {
$pointE = substr($datpart, 6) / 1000;
}
if ($data_index == 82) {
$pointN = substr($datpart, 6) / 1000;
}
if ($data_index == 83) {
$pointH = substr($datpart, 6) / 1000;
}
}
if ($merjene == 1) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\r\n";
print $lineout . "
";
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
if ($merjene == 2) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\r\n";
print $lineout . "
";
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
if ($merjene == 3) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\r\n";
print $lineout . "
";
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
}
if ($word_index == 11 && $stojisce == 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
$pointSta = 0;
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 25) {
$pointSta = 1;
}
if ($data_index == 84) {
$pointE = substr($datpart, 6) / 1000;
}
if ($data_index == 85) {
$pointN = substr($datpart, 6) / 1000;
}
if ($data_index == 86) {
$pointH = substr($datpart, 6) / 1000;
}
}
if ($pointSta == 1) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\r\n";
print $lineout . "
";
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
$pointSta = 0;
}
}
fclose($file_handle);
if ($kode_ok == 0) {
print "Ni podatkov... je datoteka kodirana?";
}
print "
";
if (!file_exists($down_datnova)) { // file does not exist
die('file not found');
} else {
print "--------------------------------------------
";
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
}
}
// Funkcija za izvoz koordinat točk z klasifikacijo (GSI z kodami)
function izvoz_tockeklas($name)
{
$down_dir = "convert/";
$down_datime = $down_dir . basename($_FILES["fileToUpload"]["name"]);
$datnova_tip = $_POST['tipdat'];
if ($datnova_tip == "koo") {
$down_datnova = str_replace(".GSI", "_tocke-klas.KOO", $down_datime);
} else {
$down_datnova = str_replace(".GSI", "_tocke-klas.TXT", $down_datime);
}
$down_url = "https://gps.multibox.nohost.me/points/";
$down_daturl = $down_url . $down_datnova;
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
print "--------------------------------------------
";
// If the user file in existing directory already exist, delete it
if (file_exists($down_datnova)) {
unlink($down_datnova);
}
$this->obdelavaTocke = $name;
$file_handle = fopen($name, "rb");
$merjene = 0;
$stojisce = 0;
$kode_ok = 0;
while (!feof($file_handle)) {
$line_of_text = fgets($file_handle);
$parts = explode(' ', $line_of_text);
$word_index = substr($parts[0], 1, 2);
if ($word_index == 41) {
$kode_ok = 1;
$koda = ltrim(substr($parts[0], 8), "0");
if ($koda == 99) {
$merjene = 2;
$stojisce = 0;
} elseif ($koda >= 90) {
$merjene = 1;
$stojisce = 0;
} elseif ($koda >= 80) {
$merjene = 3;
$stojisce = 0;
} elseif ($koda < 80) {
$merjene = 0;
$stojisce = 1;
} else {
$merjene = 0;
$stojisce = 0;
}
}
if ($word_index == 11 && $merjene >= 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 81) {
$pointE = substr($datpart, 6) / 1000;
}
if ($data_index == 82) {
$pointN = substr($datpart, 6) / 1000;
}
if ($data_index == 83) {
$pointH = substr($datpart, 6) / 1000;
}
}
if ($merjene == 1) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\tMEAS\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
if ($merjene == 2) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\tREF\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
if ($merjene == 3) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\tORI\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
}
if ($word_index == 11 && $stojisce == 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
$pointSta = 0;
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 25) {
$pointSta = 1;
}
if ($data_index == 84) {
$pointE = substr($datpart, 6) / 1000;
}
if ($data_index == 85) {
$pointN = substr($datpart, 6) / 1000;
}
if ($data_index == 86) {
$pointH = substr($datpart, 6) / 1000;
}
}
if ($pointSta == 1) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\tSTA\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
$pointSta = 0;
}
}
fclose($file_handle);
if ($kode_ok == 0) {
print "Ni podatkov... je datoteka kodirana?";
}
print "
";
if (!file_exists($down_datnova)) { // file does not exist
die('file not found');
} else {
print "--------------------------------------------
";
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
}
}
// Funkcija za izvoz koordinat točk z klasifikacijo (GSI z kodami)
function izvoz_geoskripta($name)
{
$down_dir = "convert/";
$down_datime = $down_dir . basename($_FILES["fileToUpload"]["name"]);
$down_datnova = str_replace(".GSI", ".GEO", $down_datime);
$down_url = "https://gps.multibox.nohost.me/points/";
$down_daturl = $down_url . $down_datnova;
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
print "--------------------------------------------
";
// If the user file in existing directory already exist, delete it
if (file_exists($down_datnova)) {
unlink($down_datnova);
}
$this->obdelavaTocke = $name;
$file_handle = fopen($name, "rb");
$merjene = 0;
$stojisce = 0;
$kode_ok = 0;
while (!feof($file_handle)) {
$line_of_text = fgets($file_handle);
$parts = explode(' ', $line_of_text);
$word_index = substr($parts[0], 1, 2);
$pointSta = 0;
if ($word_index == 41) {
$kode_ok = 1;
$koda = ltrim(substr($parts[0], 8), "0");
if ($koda == 99) {
$merjene = 2;
$stojisce = 0;
} elseif ($koda >= 90) {
$merjene = 1;
$stojisce = 0;
} elseif ($koda >= 80) {
$merjene = 3;
$stojisce = 0;
} elseif ($koda < 80) {
$merjene = 0;
$stojisce = 1;
} else {
$merjene = 0;
$stojisce = 0;
}
}
if ($word_index == 11 && $merjene >= 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 21) {
$pointHz = substr($datpart, 6) / 100000;
}
if ($data_index == 22) {
$pointV = substr($datpart, 6) / 100000;
}
if ($data_index == 31) {
$pointSd = substr($datpart, 6) / 1000;
}
if ($data_index == 87) {
$pointHr = substr($datpart, 6) / 1000;
}
}
if ($merjene == 1) {
$lineout = $pointid . "\t" . number_format($pointHz, 4, ".", "") . "\t" . number_format($pointV, 4, ".", "") . "\t" . number_format($pointSd, 3, ".", "") . "\t" . number_format($pointHr, 3, ".", "") . "\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
// if ($merjene == 2) {
// $lineout = $pointid . "\t" . number_format($pointHz, 4, ".", "") . "\t" . number_format($pointV, 4, ".", "") . "\t" . number_format($pointSd, 3, ".", "") . "\t" . number_format($pointHr, 3, ".", "") . "\r\n";
// print '' . $lineout . '
';
// file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
// }
if ($merjene == 3) {
$lineout = $pointid . "\t" . number_format($pointHz, 4, ".", "") . "\t" . number_format($pointV, 4, ".", "") . "\t" . number_format($pointSd, 3, ".", "") . "\t" . number_format($pointHr, 3, ".", "") . "\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
}
if ($word_index == 11 && $stojisce == 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 25) {
$pointSta = $pointSta + 1;
}
if ($data_index == 88) {
$pointHt = substr($datpart, 6) / 1000;
}
}
if ($pointSta == 1) {
$lineout = $pointid . " " . number_format($pointHt, 3, ".", "") . "\r\n21 759.81\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
} else {
$lineout = "-1 0 0 0 0\r\n" . $pointid . " " . number_format($pointHt, 3, ".", "") . "\r\n21 759.81\r\n";
print '' . $lineout . '
';
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
}
}
fclose($file_handle);
if ($kode_ok == 0) {
print "Ni podatkov... je datoteka kodirana?";
}
print "
";
if (!file_exists($down_datnova)) { // file does not exist
die('file not found');
} else {
print "--------------------------------------------
";
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
}
}
// Funkcija za izvoz koordinat točk (GSI brez kodiranja)
function izvoz_tockebrez($name)
{
$down_dir = "convert/";
$down_datime = $down_dir . basename($_FILES["fileToUpload"]["name"]);
$datnova_tip = $_POST['tipdat'];
if ($datnova_tip == "koo") {
$down_datnova = str_replace(".GSI", "_tocke-vse.KOO", $down_datime);
} else {
$down_datnova = str_replace(".GSI", "_tocke-vse.TXT", $down_datime);
}
$down_url = "https://gps.multibox.nohost.me/points/";
$down_daturl = $down_url . $down_datnova;
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
print "--------------------------------------------
";
// If the user file in existing directory already exist, delete it
if (file_exists($down_datnova)) {
unlink($down_datnova);
}
$this->obdelavaTocke = $name;
$file_handle = fopen($name, "rb");
$merjene = 1;
$stojisce = 0;
while (!feof($file_handle)) {
$line_of_text = fgets($file_handle);
$parts = explode(' ', $line_of_text);
$word_index = substr($parts[0], 1, 2);
$word_index2 = substr($parts[1], 1, 2);
if ($word_index2 == 25) {
$merjene = 0;
$stojisce = 1;
} else {
$merjene = 1;
$stojisce = 0;
}
if ($word_index == 11 && $merjene == 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 81) {
$pointE = substr($datpart, 6) / 1000;
}
if ($data_index == 82) {
$pointN = substr($datpart, 6) / 1000;
}
if ($data_index == 83) {
$pointH = substr($datpart, 6) / 1000;
}
}
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\r\n";
print $lineout . "
";
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
if ($word_index == 11 && $stojisce == 1) {
$pointid = ltrim(substr($parts[0], 8), "0");
$pointSta = 0;
foreach ($parts as $datpart) {
$data_index = substr($datpart, 0, 2);
if ($data_index == 25) {
$pointSta = 1;
}
if ($data_index == 84) {
$pointE = substr($datpart, 6) / 1000;
}
if ($data_index == 85) {
$pointN = substr($datpart, 6) / 1000;
}
if ($data_index == 86) {
$pointH = substr($datpart, 6) / 1000;
}
}
if ($pointSta == 1) {
$lineout = $pointid . "\t" . number_format($pointE, 3, ".", "") . "\t" . number_format($pointN, 3, ".", "") . "\t" . number_format($pointH, 3, ".", "") . "\r\n";
print $lineout . "
";
file_put_contents($down_datnova, $lineout, FILE_APPEND | LOCK_EX);
}
$pointSta = 0;
}
}
fclose($file_handle);
print "
";
if (!file_exists($down_datnova)) { // file does not exist
die('file not found');
} else {
print "--------------------------------------------
";
print "Nova datoteka: " . basename($down_datnova) . " (Prenos)
";
}
}
function get_name()
{
return $this->obdelavaTocke;
}
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Postopek je bil prekinjen.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
$datime = basename($_FILES["fileToUpload"]["name"]);
$datimenova = str_replace(".GSI", ".TXT", $datime);
//echo "Datoteka: " . htmlspecialchars($datime) . "
";
//echo "Nova Datoteka: " . htmlspecialchars($datimenova) . "
";
$datTocke = new ObdelavaGsi();
if ($_POST['obdelava'] == "tockeklas") {
$datTocke->izvoz_tockeklas($target_file);
} elseif ($_POST['obdelava'] == "tocke") {
$datTocke->izvoz_tocke($target_file);
} elseif ($_POST['obdelava'] == "tockebrez") {
$datTocke->izvoz_tockebrez($target_file);
} elseif ($_POST['obdelava'] == "geoskripta") {
$datTocke->izvoz_tockebrez($target_file);
} else {
echo "Izbrana opcija ni na voljo. Se opravičujemo.";
}
} else {
echo "Napaka!";
}
}
?>