You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
391 lines
14 KiB
391 lines
14 KiB
<?php
|
|
require_once('../ajax_asm.php');
|
|
|
|
$SAVE_AS_PICTURE = true;
|
|
|
|
if( $CUser->Data['id'] > 1 ){
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
|
header("Pragma: no-cache");
|
|
header("Content-Type: image/png");
|
|
if(isset( $_POST['NID'] )){
|
|
$NID = intval($_POST['NID']);
|
|
} else {
|
|
$NID = intval($_GET['NID']);
|
|
};
|
|
if(isset( $_POST['AUX'] )){
|
|
$AUX = intval($_POST['AUX']);
|
|
} elseif( isset($_GET['AUX']) ) {
|
|
$AUX = intval($_GET['AUX']);
|
|
} else $AUX = 0;
|
|
|
|
if( isset( $_POST['MAP'] ) ){
|
|
$TYPE = 2;
|
|
} elseif( isset($_GET['MAP']) ) {
|
|
$TYPE = 2;
|
|
} else $TYPE = 1;
|
|
|
|
$QS = "SELECT * FROM lrf_draw WHERE node_id={$NID} ORDER BY ts DESC LIMIT 1";
|
|
$Result = $DATABASE->Query( $QS, false );
|
|
if( count( $Result ) ){
|
|
if( $SAVE_AS_PICTURE ){
|
|
if( $Result[0]['rendered'] == 'Y' ){
|
|
if( $TYPE == 1 ){
|
|
if( $AUX ){
|
|
$FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
|
|
} else {
|
|
$FN = "data/device_draws/{$Result[0]['md5']}_100.png";
|
|
};
|
|
} else {
|
|
$FN = "data/device_draws/{$Result[0]['md5']}_map.png";
|
|
};
|
|
} else {
|
|
$FF = "data/device_draws/{$Result[0]['md5']}.raw";
|
|
$FN = "ddd";
|
|
if( file_exists( $FF ) ) {
|
|
$FD = fopen( $FF, "rb" );
|
|
if( $FD ){
|
|
if( $Result[0]['type'] == 1 ){
|
|
//$IM = imagecreatefrompng("../../style/assets/3d_draw_empty_100.png");
|
|
$IM = imagecreatefromjpeg("../../style/assets/3d_draw_empty_100.jpg");
|
|
imagesavealpha( $IM, true );
|
|
$bg = imagecolorallocate($IM, 0, 0, 0);
|
|
$black = imagecolorallocate($IM, 255, 255, 0);
|
|
//$green = imagecolorallocate($IM, 0, 255, 0);
|
|
$green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
|
|
imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
|
|
imagestring( $IM, 2, 6, 5, "LIBERMANDA", $black );
|
|
imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" );
|
|
imagedestroy( $IM );
|
|
$QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}";
|
|
$DATABASE->Query( $QS );
|
|
$FN = "data/device_draws/{$Result[0]['md5']}_100.png";
|
|
} else {
|
|
$CL = fread( $FD, 4 );
|
|
$size = unpack( "V", $CL );
|
|
$pts = array();
|
|
$as = $size[1];
|
|
for($i=0; $i< $as; $i++ ){
|
|
$CL = fread( $FD, 4 );
|
|
$T = unpack( "V", $CL );
|
|
//print_r( $T );
|
|
$pts[] = $T[1] >> 16;
|
|
};
|
|
fclose( $FD );
|
|
$QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}";
|
|
$PP = $DATABASE->Query( $QS );
|
|
$stp = 2.0 * ( M_PI / $as );
|
|
$MR = intval( $PP[0]['max_range'] );
|
|
$S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
|
|
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
|
|
imagesavealpha( $IM, true );
|
|
$bg = imagecolorallocate($IM, 0, 0, 0);
|
|
$black = imagecolorallocate($IM, 255, 255, 0);
|
|
$green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
|
|
$gray = imagecolorallocatealpha( $IM, 99, 111, 135, 0 );
|
|
imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
|
|
imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
|
|
$maxR = 98.0;
|
|
$rst = $maxR / 1025.0;
|
|
$x0 = 100;
|
|
$y0 = 100;
|
|
$ppA = array();
|
|
$ppB = array();
|
|
$nnA = array();
|
|
$nnB = array();
|
|
for( $i=0; $i< $as; $i++ ){
|
|
if( $pts[$i] > 0 ){
|
|
$cr = ($rst * $pts[$i]);
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $cr * cos( $ca );
|
|
$ppA[] = $y0 + $cr * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
} else {
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $maxR * cos( $ca );
|
|
$ppA[] = $y0 + $maxR * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
|
|
$nnA[] = $x0;
|
|
$nnA[] = $y0;
|
|
$nnB[] = $x0 + $maxR * cos( $ca );
|
|
$nnB[] = $y0 + $maxR * sin( $ca );
|
|
};
|
|
};
|
|
$ppB[] = $ppA[count($ppA)-2];
|
|
$ppB[] = $ppA[count($ppA)-1];
|
|
$popo = array_merge( $ppA, $ppB );
|
|
$nodra = array_merge( $nnA, $nnB );
|
|
imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
|
|
imagefilledpolygon( $IM, $nodra, count( $nodra ) / 2, $gray );
|
|
imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" );
|
|
imagedestroy( $IM );
|
|
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
|
|
imagesavealpha( $IM, true );
|
|
$bg = imagecolorallocate($IM, 0, 0, 0);
|
|
$black = imagecolorallocate($IM, 255, 255, 0);
|
|
$green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
|
|
$gray = imagecolorallocatealpha( $IM, 99, 111, 135, 0 );
|
|
imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
|
|
$NMR = sprintf( "%.2f", ( $MR / 2 ) );
|
|
imagestring( $IM, 2, 6, 5, $NMR . "m.", $black );
|
|
$rst = $maxR / 513.0;
|
|
$ppA = array();
|
|
$ppB = array();
|
|
$nnA = array();
|
|
$nnB = array();
|
|
for( $i=0; $i< $as; $i++ ){
|
|
if( $pts[$i] > 0 && $pts[$i] < 513 ){
|
|
$cr = ($rst * $pts[$i]);
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $cr * cos( $ca );
|
|
$ppA[] = $y0 + $cr * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
} else {
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $maxR * cos( $ca );
|
|
$ppA[] = $y0 + $maxR * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
$nnA[] = $x0;
|
|
$nnA[] = $y0;
|
|
$nnB[] = $x0 + $maxR * cos( $ca );
|
|
$nnB[] = $y0 + $maxR * sin( $ca );
|
|
};
|
|
};
|
|
$ppB[] = $ppA[count($ppA)-2];
|
|
$ppB[] = $ppA[count($ppA)-1];
|
|
$popo = array_merge( $ppA, $ppB );
|
|
$nodra = array_merge( $nnA, $nnB );
|
|
imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
|
|
imagefilledpolygon( $IM, $nodra, count( $nodra ) / 2, $gray );
|
|
imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_50.png" );
|
|
imagedestroy( $IM );
|
|
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
|
|
imagesavealpha( $IM, true );
|
|
$bg = imagecolorallocate($IM, 0, 0, 0);
|
|
$black = imagecolorallocate($IM, 255, 255, 0);
|
|
$green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
|
|
$gray = imagecolorallocatealpha( $IM, 99, 111, 135, 0 );
|
|
imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
|
|
$NMR = sprintf( "%.2f", ( $MR / 4 ) );
|
|
imagestring( $IM, 2, 6, 5, $NMR . "m.", $black );
|
|
$rst = $maxR / 257.0;
|
|
$ppA = array();
|
|
$ppB = array();
|
|
$nnA = array();
|
|
$nnB = array();
|
|
for( $i=0; $i< $as; $i++ ){
|
|
if( $pts[$i] > 0 && $pts[$i] < 256 ){
|
|
$cr = ($rst * $pts[$i]);
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $cr * cos( $ca );
|
|
$ppA[] = $y0 + $cr * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
} else {
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $maxR * cos( $ca );
|
|
$ppA[] = $y0 + $maxR * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
$nnA[] = $x0;
|
|
$nnA[] = $y0;
|
|
$nnB[] = $x0 + $maxR * cos( $ca );
|
|
$nnB[] = $y0 + $maxR * sin( $ca );
|
|
};
|
|
};
|
|
$ppB[] = $ppA[count($ppA)-2];
|
|
$ppB[] = $ppA[count($ppA)-1];
|
|
$popo = array_merge( $ppA, $ppB );
|
|
$nodra = array_merge( $nnA, $nnB );
|
|
imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
|
|
imagefilledpolygon( $IM, $nodra, count( $nodra ) / 2, $gray );
|
|
imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_25.png" );
|
|
imagedestroy( $IM );
|
|
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
|
|
imagesavealpha( $IM, true );
|
|
$bg = imagecolorallocate($IM, 0, 0, 0);
|
|
$black = imagecolorallocate($IM, 255, 255, 0);
|
|
$green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
|
|
$gray = imagecolorallocatealpha( $IM, 99, 111, 135, 0 );
|
|
imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
|
|
$NMR = sprintf( "%.2f", ( $MR / 8 ) );
|
|
imagestring( $IM, 2, 6, 5, $NMR . "m.", $black );
|
|
$rst = $maxR / 129.0;
|
|
$ppA = array();
|
|
$ppB = array();
|
|
$nnA = array();
|
|
$nnB = array();
|
|
for( $i=0; $i< $as; $i++ ){
|
|
if( $pts[$i] > 0 && $pts[$i] < 128 ){
|
|
$cr = ($rst * $pts[$i]);
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $cr * cos( $ca );
|
|
$ppA[] = $y0 + $cr * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
} else {
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $maxR * cos( $ca );
|
|
$ppA[] = $y0 + $maxR * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
$nnA[] = $x0;
|
|
$nnA[] = $y0;
|
|
$nnB[] = $x0 + $maxR * cos( $ca );
|
|
$nnB[] = $y0 + $maxR * sin( $ca );
|
|
};
|
|
};
|
|
$ppB[] = $ppA[count($ppA)-2];
|
|
$ppB[] = $ppA[count($ppA)-1];
|
|
$popo = array_merge( $ppA, $ppB );
|
|
$nodra = array_merge( $nnA, $nnB );
|
|
imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
|
|
imagefilledpolygon( $IM, $nodra, count( $nodra ) / 2, $gray );
|
|
imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_12.png" );
|
|
imagedestroy( $IM );
|
|
$QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}";
|
|
$DATABASE->Query( $QS );
|
|
if( $AUX ){
|
|
$FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
|
|
} else {
|
|
$FN = "data/device_draws/{$Result[0]['md5']}_100.png";
|
|
};
|
|
};
|
|
};
|
|
} else {
|
|
echo "No Res"; exit();
|
|
if( $AUX ){
|
|
$FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
|
|
} else {
|
|
$FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
};
|
|
};
|
|
};
|
|
if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
readfile( $FN );
|
|
} else {
|
|
//! $SAVE_AS_PICTURE
|
|
$FF = "data/device_draws/{$Result[0]['md5']}.raw";
|
|
if( file_exists( $FF ) ) {
|
|
$FD = fopen( $FF, "rb" );
|
|
if( $FD ){
|
|
$CL = fread( $FD, 4 );
|
|
$size = unpack( "V", $CL );
|
|
$pts = array();
|
|
$as = $size[1];
|
|
for($i=0; $i< $as; $i++ ){
|
|
$CL = fread( $FD, 4 );
|
|
$T = unpack( "V", $CL );
|
|
$pts[] = $T[1] >> 16;
|
|
};
|
|
fclose( $FD );
|
|
$QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}";
|
|
$PP = $DATABASE->Query( $QS );
|
|
$stp = 2.0 * ( M_PI / $as );
|
|
$MR = intval( $PP[0]['max_range'] );
|
|
$S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
|
|
switch( $AUX ){
|
|
case 12: {
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
|
|
$RR = 129.0;
|
|
$MR = $MR / 8;
|
|
$MD = 128;
|
|
break;
|
|
};
|
|
case 25: {
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
|
|
$RR = 257.0;
|
|
$MR = $MR / 4;
|
|
$MD = 256;
|
|
break;
|
|
};
|
|
case 50: {
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
|
|
$RR = 513.0;
|
|
$MR = $MR / 2;
|
|
$MD = 512;
|
|
break;
|
|
};
|
|
default:{
|
|
$IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
|
|
$RR = 1025.0;
|
|
$MD = 1025;
|
|
break;
|
|
};
|
|
};
|
|
imagesavealpha( $IM, true );
|
|
$bg = imagecolorallocate($IM, 0, 0, 0);
|
|
$black = imagecolorallocate($IM, 255, 255, 0);
|
|
//$green = imagecolorallocate($IM, 0, 255, 0);
|
|
$green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
|
|
imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
|
|
imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
|
|
$maxR = 98.0;
|
|
$x0 = 100;
|
|
$y0 = 100;
|
|
$rst = $maxR / $RR;
|
|
$ppA = array();
|
|
$ppB = array();
|
|
for( $i=0; $i< $as; $i++ ){
|
|
if( $pts[$i] > 0 && $pts[$i] < $MD ){
|
|
$cr = ($rst * $pts[$i]);
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $cr * cos( $ca );
|
|
$ppA[] = $y0 + $cr * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
} else {
|
|
$ca = 0.0 - ( $S + $i * $stp );
|
|
$ppA[] = $x0 + $maxR * cos( $ca );
|
|
$ppA[] = $y0 + $maxR * sin( $ca );
|
|
$ppB[] = $x0 + $maxR * cos( $ca );
|
|
$ppB[] = $y0 + $maxR * sin( $ca );
|
|
};
|
|
};
|
|
$ppB[] = $ppA[count($ppA)-2];
|
|
$ppB[] = $ppA[count($ppA)-1];
|
|
$popo = array_merge( $ppA, $ppB );
|
|
imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
|
|
imagepng( $IM );
|
|
imagedestroy( $IM );
|
|
} else {
|
|
if( $AUX ){
|
|
$FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
|
|
} else {
|
|
$FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
};
|
|
if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
readfile( $FN );
|
|
};
|
|
} else {
|
|
if( $AUX ){
|
|
$FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
|
|
} else {
|
|
$FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
};
|
|
if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
readfile( $FN );
|
|
};
|
|
};
|
|
} else {
|
|
if( $AUX ){
|
|
$FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
|
|
} else {
|
|
$FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
};
|
|
if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
|
|
readfile( $FN );
|
|
};
|
|
} else {
|
|
header('location: /');
|
|
};
|
|
?>
|