Skip to content
Snippets Groups Projects
Commit 794296ae authored by root's avatar root Committed by Guilherme Arthur Gerônimo
Browse files

Fix #14

parent 56a4a1f8
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,5 @@ if ( isset( $response['headers'] ) ){ ...@@ -58,7 +58,5 @@ if ( isset( $response['headers'] ) ){
foreach ( $response['headers'] as $header ) foreach ( $response['headers'] as $header )
header( $header ); header( $header );
} else { } else {
//TODO Maybe this will not be used due all queries use x-sendfile
error_log("Query not using X-SendFile!");
echo $response; echo $response;
} }
...@@ -80,7 +80,12 @@ namespace SmartData\SmartAPI ...@@ -80,7 +80,12 @@ namespace SmartData\SmartAPI
} }
if($return != NULL) { if($return != NULL) {
$pos = 0; $pos = 0;
$isBigQuery = false;
$bigUnits = [0x02240003, 0x02230000, 0x03020000]; //Image, WAV, LIDAR
foreach ( $return['series'] as $key => $sd ) { foreach ( $return['series'] as $key => $sd ) {
//Check if the series are a "big unit"
$isBigQuery = in_array( $sd['unit'] & 0x0FFF0000 , $bigUnits );
$ver = intval( $sd['version'] ); $ver = intval( $sd['version'] );
$return['series'][$pos]['version'] = ( $ver >> 4 ) . "." . ( $ver & 0x0F ); $return['series'][$pos]['version'] = ( $ver >> 4 ) . "." . ( $ver & 0x0F );
if (array_key_exists("SmartData", $sd)) { if (array_key_exists("SmartData", $sd)) {
...@@ -95,6 +100,7 @@ namespace SmartData\SmartAPI ...@@ -95,6 +100,7 @@ namespace SmartData\SmartAPI
} }
// The following lines dumps the response to a file and uses X-SendFile to notify Apache to send the response. // The following lines dumps the response to a file and uses X-SendFile to notify Apache to send the response.
// this saves a lot of memory. // this saves a lot of memory.
if ( $isBigQuery ) {
$file_path_for_digital_series = '/smartdata/tmp/' . microtime(true) . '.gets'; $file_path_for_digital_series = '/smartdata/tmp/' . microtime(true) . '.gets';
file_put_contents($file_path_for_digital_series, '{"series": [' , FILE_APPEND); file_put_contents($file_path_for_digital_series, '{"series": [' , FILE_APPEND);
foreach ( $return['series'] as $key => $sd ) { foreach ( $return['series'] as $key => $sd ) {
...@@ -107,6 +113,9 @@ namespace SmartData\SmartAPI ...@@ -107,6 +113,9 @@ namespace SmartData\SmartAPI
$return['headers'][] = 'X-Sendfile: ' . $file_path_for_digital_series ; $return['headers'][] = 'X-Sendfile: ' . $file_path_for_digital_series ;
$return['headers'][] = 'Content-type: application/json' ; $return['headers'][] = 'Content-type: application/json' ;
$return['headers'][] = 'Content-Length: ' . (filesize( $file_path_for_digital_series ) + 1) ; $return['headers'][] = 'Content-Length: ' . (filesize( $file_path_for_digital_series ) + 1) ;
} else {
$return = json_encode( $return, JSON_NUMERIC_CHECK );
}
} else { } else {
throw new RequestFailedException("Error processing request: null return"); throw new RequestFailedException("Error processing request: null return");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment