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

leaflet_polygon_parsing()

Description

Parses the resource polygon string to extract latitude and longitude bounds and formats the polygon string.

as well as the formatted polygon string for Leaflet display.

Parameters

ColumnTypeDefaultDescription
$fields array The resource fields array containing polygon data.
$minmax bool true Flag to determine if minimum and maximum latitude and longitude values should be calculated.

Return

array An associative array containing the minimum and maximum latitude and longitude values,

Location

include/map_functions.php lines 499 to 528

Definition

 
function leaflet_polygon_parsing($fields$minmax true)
    {
    global 
$map_polygon_field;

    
// Search resource $fields array for the $map_polygon_field.
    
$key1 array_search($map_polygon_fieldarray_column($fields'ref'));

    if (
$minmax)
        {
        
// Strip coordinate pair parathenses from polygon array.
        
$values str_replace(')'''str_replace('('''explode(','$fields[$key1]['value'])));

        
// Determine minimum and maximum latitude values.
        
$lat_values = array($values[0], $values[2], $values[4], $values[6]);
        
$polygon['lat_min'] = min($lat_values);
        
$polygon['lat_max'] = max($lat_values);

        
// Determine minimum and maximum longitude values.
        
$long_values = array($values[1], $values[3], $values[5], $values[7]);
        
$polygon['long_min'] = min($long_values);
        
$polygon['long_max'] = max($long_values);
        }

    
// Format polygon string for Leaflet footprint display below.
    
$polygon1 str_replace('(''['$fields[$key1]['value']);
    
$polygon1 str_replace(')'']'$polygon1);
    
$polygon['values'] = '[' $polygon1 ']';

    return 
$polygon;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 22nd November 2024 15:35 Europe/London time.