diff --git a/api/get.php b/api/get.php index a2e39ec26328d3b69a502fb3267bbff79690bf30..3cfb2360b837f30edea8004c67bc4e6a62bd1600 100644 --- a/api/get.php +++ b/api/get.php @@ -58,7 +58,5 @@ if ( isset( $response['headers'] ) ){ foreach ( $response['headers'] as $header ) header( $header ); } else { - //TODO Maybe this will not be used due all queries use x-sendfile - error_log("Query not using X-SendFile!"); echo $response; } diff --git a/bin/smartdata/SmartAPI.php b/bin/smartdata/SmartAPI.php index 939fc0ddaa850e4973354a24cf67736335a95fbc..cf6c073cdb183216e9cb5dde8a5af882ce100be3 100644 --- a/bin/smartdata/SmartAPI.php +++ b/bin/smartdata/SmartAPI.php @@ -80,7 +80,12 @@ namespace SmartData\SmartAPI } if($return != NULL) { $pos = 0; + $isBigQuery = false; + $bigUnits = [0x02240003, 0x02230000, 0x03020000]; //Image, WAV, LIDAR 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'] ); $return['series'][$pos]['version'] = ( $ver >> 4 ) . "." . ( $ver & 0x0F ); if (array_key_exists("SmartData", $sd)) { @@ -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. // this saves a lot of memory. + if ( $isBigQuery ) { $file_path_for_digital_series = '/smartdata/tmp/' . microtime(true) . '.gets'; file_put_contents($file_path_for_digital_series, '{"series": [' , FILE_APPEND); foreach ( $return['series'] as $key => $sd ) { @@ -107,6 +113,9 @@ namespace SmartData\SmartAPI $return['headers'][] = 'X-Sendfile: ' . $file_path_for_digital_series ; $return['headers'][] = 'Content-type: application/json' ; $return['headers'][] = 'Content-Length: ' . (filesize( $file_path_for_digital_series ) + 1) ; + } else { + $return = json_encode( $return, JSON_NUMERIC_CHECK ); + } } else { throw new RequestFailedException("Error processing request: null return"); }