Coding standards
Security in ResourceSpace
Developer reference
Database
User api session functions
Geolocation functions

update_country_coords()

Description

Fill missing resource geolocation from a resolved country coordinate pair.

Parameters

ColumnTypeDefaultDescription
$refs array Resource IDs to update in bounded batches.
$latlong array Latitude and longitude, or an empty array for an unknown country.

Return

void

Location

include/geolocation_functions.php lines 57 to 69

Definition

 
function update_country_coords($refs, $latlong)
{
    if (
count($latlong) == 2) {
        
$chunks = array_chunk($refs, SYSTEM_DATABASE_IDS_CHUNK_SIZE);
        foreach (
$chunks as $chunk) {
            
ps_query(
                
"UPDATE resource SET geo_lat= ?, geo_long= ? WHERE ref IN (" . ps_param_insert(count($chunk)) . ")
                 AND (geo_lat IS NULL OR geo_long IS NULL)"
,
                
array_merge(['d', $latlong[0], 'd', $latlong[1]], ps_param_fill($chunk, 'i'))
            );
        }
    }
}

This article was last updated 11th November 2026 19:05 Europe/London time based on the source file dated 11th November 2026 14:55 Europe/London time.