Skip to content

Geo

mash.geo · Utilities

geo.byDistance(from: mixed, sites: mixed, unit?: string = "km") → array

Every site that can be found, closest first, each with distance and unit added. Sites that cannot be found are left out.

geo.distance(from: mixed, to: mixed, unit?: string = "km") → float

Straight-line distance between two places, each a postcode, an address, “lat,lon”, or a map from locate(). Null when either cannot be found.

geo.locate(text: mixed, country?: string) → array

Where a postcode or address is. Returns a map with lat, lon, point (“lat,lon”, the form a location field stores), precision (address, postcode, sector, district or place), source, country, postcode and place, or null when it cannot be found.

geo.nearest(from: mixed, sites: mixed, unit?: string = "km") → array

The closest of a list of sites. Each site is a map with a name and one of postcode, address, point (“lat,lon”), or lat and lon; or just a postcode string. Returns the site’s map with distance and unit added, or null when the starting place or every site cannot be found.

geo.postcode(text: mixed) → string

The UK postcode in a piece of text (the last one, as an address ends with it), formatted “BS8 4JZ”; null when there is none.