BEdita API doc | 4-cactus
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download

Namespaces

  • BEdita
    • API
      • Auth
      • Controller
        • Admin
        • Model
      • Exception
      • Middleware
      • Model
        • Action
      • Network
        • Exception
      • Utility
    • Core
      • Database
        • Type
      • Exception
      • Filesystem
        • Adapter
        • Exception
        • Thumbnail
      • Job
        • Service
      • Mailer
        • Preview
        • Transport
      • Model
        • Action
        • Behavior
        • Entity
        • Validation
      • ORM
        • Locator
      • Utility

Classes

  • GeometryBehavior
  • ObjectTypeBehavior

Class GeometryBehavior

Behavior for geographic searches.

Cake\ORM\Behavior
Extended by BEdita\Core\Model\Behavior\GeometryBehavior
Namespace: BEdita\Core\Model\Behavior
Since: 4.0.0
Located at Core/src/Model/Behavior/GeometryBehavior.php

Methods summary

protected Cake\Database\Expression\FunctionExpression
# getDistanceExpression( string|float[] $point1, string|float[] $point2 )

Get database expression to find distance between two points on a spheroid.

Get database expression to find distance between two points on a spheroid.

Points are expressed as pairs of floats, where the first number is the latitude, and the latter is the longitude.

Parameters

$point1
First point. Can be either a field name or a pair of floats.
$point2
Second point. Can be either a field name or a pair of floats.

Returns

Cake\Database\Expression\FunctionExpression
public static float[]
# parseCoordinates( mixed $point )

Parse coordinates.

Parse coordinates.

Value MUST be either: - a string containing two decimal numbers separated by a comma (,) or a space (), or - an array containing two decimal numbers

The two decimal numbers are interpreted as latitude and longitude, in this order. Latitude MUST be in the range [-90, 90], longitude in range [-180, 180]. Please note that, while many systems restrict longitude range to (-180, 180], here -180 is an accepted value.

Parameters

$point
Coordinates.

Returns

float[]
Latitude, longitude.

Throws

BEdita\Core\Exception\BadFilterException
Throws an exception if value could not be parsed into coords.
public boolean
# checkGeoSupport( )

Check if current DB supports geo operations.

Check if current DB supports geo operations.

Returns

boolean
public Cake\ORM\Query
# findGeo( Cake\ORM\Query $query, array $options )

Find objects by geo coordinates.

Find objects by geo coordinates.

Modify a query to filter objects using geo data: location objects are ordered by distance, from the nearest to the farthest from a center, optionally filtering those farther than a radius. Results will contain a distance computed field, expressing distance from that Location to the supplied center (or from, if present).

All distances are expressed in meters.

Accepted options are: - 'center' (required) with point coordinates, latitude and longitude - 'from' (optional, defaults to center) with point coordinates, latitude and longitude - 'radius' (optional, if omitted results are not filtered) with positive decimal number

The three options are to be interpreted as follows:

Find all bus stops close to the Coliseum (center) within a range of 2km (radius), refering how far these location are from Vatican City (from).

Examples

// Find location objects near a given center, either a string with comma separated values or an array.
$table->find('geo', ['center' => '44.4944183,11.3464055']);
$table->find('geo', ['center' => [44.4944183, 11.3464055]]);

// Find location objects within a radius of 10 kilometers from the given range.
$table->find('geo', ['center' => [44.4944183, 11.3464055], 'radius' => 10000]);

// Find location objects that are close to a center, but compute distances from another center.
$table->find('geo', ['center' => [44.4944183, 11.3464055], 'from' => [11.3464055, 44.4944183]]);

Parameters

$query
Query object instance.
$options
Array of acceptable geo localization conditions.

Returns

Cake\ORM\Query

Throws

BEdita\Core\Exception\BadFilterException

Throws an exception if value could not be parsed into valid coordinates, or if GIS SQL functions are not available.

Properties summary

protected array $_defaultConfig

Inheritdoc

# [ 'distanceFunction' => 'ST_Distance_Sphere', 'field' => 'coords', 'implementedFinders' => [ 'geo' => 'findGeo', ], ]
protected boolean $hasGeoSupport

Store geometry support for current connection.

Store geometry support for current connection.

#
BEdita API doc | 4-cactus API documentation generated by ApiGen