Geo

Geo
in package

Please report bugs on https://github.com/matthiasmullie/geo/issues.

Tags
author

Matthias Mullie geo@mullie.eu

copyright

Copyright (c) 2013, Matthias Mullie. All rights reserved.

license

MIT License

Table of Contents

Methods

__construct()  : mixed
bounds()  : Bounds
This calculates the boundary at $distance north, east, south & west from $coord.
distance()  : float
setRadius()  : mixed
Allows to override radius.

Methods

__construct()

public __construct([mixed $unit = 'km' ]) : mixed
Parameters
$unit : mixed = 'km'

e.g. km (kilometers) or mi (miles)

Tags
throws
Exception

bounds()

This calculates the boundary at $distance north, east, south & west from $coord.

public bounds(Coordinate $coord, float $distance) : Bounds

This can be used to easily query a database for coordinate within certain boundaries, like this: SELECT * FROM coordinates WHERE lat BETWEEN :swlat AND :nelat lng BETWEEN :swlng AND :nelng

:swlat being $bounds->sw->latitude :swlng being $bounds->sw->longitude :nelat being $bounds->ne->latitude :nelng being $bounds->ne->longitude

We only need 2 opposite corners in a rectangle to know all 4 boundaries, in this case the northeast & southwest coordinate. The northwest coordinate, for example, will have the same latitude as the southwest coordinate, and the same latitude as the northeast coordinate.

Parameters
$coord : Coordinate

Coordinate to generate bounds for

$distance : float

Distance in human readable format (e.g. km or mi)

Return values
Bounds

setRadius()

Allows to override radius.

public setRadius([mixed $radius = null ]) : mixed

If null, radius will be reset to the default for the given unit.

Parameters
$radius : mixed = null

        
On this page

Search results