You are here

public function GeofieldRectBoundaryArgument::getParsedBoundary in Geofield 8

Processes the passed argument into an array of relevant geolocation data.

Return value

array|bool The calculated values.

1 call to GeofieldRectBoundaryArgument::getParsedBoundary()
GeofieldRectBoundaryArgument::query in src/Plugin/views/argument/GeofieldRectBoundaryArgument.php
Set up the query for this argument.

File

src/Plugin/views/argument/GeofieldRectBoundaryArgument.php, line 72

Class

GeofieldRectBoundaryArgument
Argument handler for geofield rectangular boundary.

Namespace

Drupal\geofield\Plugin\views\argument

Code

public function getParsedBoundary() {

  // Cache the vales so this only gets processed once.
  static $values;
  if (!isset($values)) {

    // Process argument values into an array.
    preg_match('/^([0-9\\-.]+),+([0-9\\-.]+),+([0-9\\-.]+),+([0-9\\-.]+)(.*$)/', $this
      ->getValue(), $values);

    // Validate and return the passed argument.
    $values = is_array($values) ? [
      'lat_north_east' => isset($values[1]) && is_numeric($values[1]) && $values[1] >= -90 && $values[1] <= 90 ? floatval($values[1]) : FALSE,
      'lng_north_east' => isset($values[2]) && is_numeric($values[2]) && $values[2] >= -180 && $values[2] <= 180 ? floatval($values[2]) : FALSE,
      'lat_south_west' => isset($values[2]) && is_numeric($values[3]) && $values[3] >= -90 && $values[3] <= 90 ? floatval($values[3]) : FALSE,
      'lng_south_west' => isset($values[2]) && is_numeric($values[4]) && $values[4] >= -180 && $values[4] <= 180 ? floatval($values[4]) : FALSE,
    ] : FALSE;
  }
  return $values;
}