Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

extractFitsMetadata()

Description

Extract FITS metadata from a file for a specific resource.

Parameters

ColumnTypeDefaultDescription
$file_path string Path to the file from which you will extract FITS metadata
$resource integer|array Resource ID or resource array (as returned by get_resource_data())

Return

boolean

Location

include/metadata_functions.php lines 112 to 178

Definition

 
function extractFitsMetadata($file_path$resource)
    {
    if(
get_utility_path('fits') === false)
        {
        return 
false;
        }

    if(!
file_exists($file_path))
        {
        return 
false;
        }

    if(!
is_array($resource) && !is_numeric($resource))
        {
        return 
false;
        }

    if(!
is_array($resource) && is_numeric($resource) && $resource)
        {
        
$resource get_resource_data($resource);
        }

    
$resource_type $resource['resource_type'];

    
// Get a list of all the fields that have a FITS field set
    
$allfields get_resource_type_fields($resource_type);
    
$rs_fields_to_read_for array_filter($allfields,function($field){return trim((string)$field["fits_field"]) != "";});

    if(
=== count($rs_fields_to_read_for))
        {
        return 
false;
        }

    
// Run FITS and extract metadata
    
$fits_xml            runFitsForFile($file_path);
    if(!
$fits_xml)
        {
        return 
false;
        }
    
$fits_updated_fields = array();

    foreach(
$rs_fields_to_read_for as $rs_field)
        {
        
$fits_fields explode(',', (string)$rs_field['fits_field']);

        foreach(
$fits_fields as $fits_field)
            {
            
$fits_field_value getFitsMetadataFieldValue($fits_xml$fits_field);

            if(
'' == $fits_field_value)
                {
                continue;
                }

            
update_field($resource['ref'], $rs_field['ref'], $fits_field_value);

            
$fits_updated_fields[] = $rs_field['ref'];
            }
        }

    if(
count($fits_updated_fields))
        {
        return 
true;
        }

    return 
false;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.