LanguageValues and typesStandard typesGeospatial
Circle
On this page
A centre and a distance around it.
Use it for "within 5 km of here", such as a delivery radius. For a drawn area, use Polygon.
Shape
Example
Circle { centre: Point { latitude: 51.5072 longitude: -0.1276 altitude: none } radius: 1km}
Good to know
- The radius can't be below zero, and it is measured on the ground.
==tells you whether two are the same.<andlist.sort_bydon't take it, so sort by one of its parts instead.
In JSON
An object of its parts, in a request, a response or json.write:
{"centre":{"type":"Point","coordinates":[-0.1276,51.5072]},"radius":{"value":"1000","unit":"metre"}}{"centre":{"type":"Point","coordinates":[0,0]},"radius":{"value":"0","unit":"metre"}}
Details
Text form, storage, how it is shown, and operations
Circle is in the group Geospatial, and has been in Jadpo since 0.1.0.
Text form
It has no single text form, so text.from and text.parse don't take it.
How it is stored
It is stored in 2 columns, each named for the field, _ and its suffix. This is {"centre":{"type":"Point","coordinates":[0,0]},"radius":{"value":"0","unit":"metre"}}:
| Column | Type | Holds |
|---|---|---|
<field>_centre |
geography |
'SRID=4326;POINT (0 0)'::geography |
<field>_radius |
numeric(38, 6) |
0 |
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
{"centre":{"type":"Point","coordinates":[-0.1276,51.5072]},"radius":{"value":"1000","unit":"metre"}} |
1,000 m around 51.5072° N, 0.1276° W |
{"centre":{"type":"Point","coordinates":[0,0]},"radius":{"value":"0","unit":"metre"}} |
0 m around 0°, 0° |
Operations
geo.contains(a: T, b: U) -> Bool: Whether no point ofblies outsidea, edges included.amay be aBoundingBox, whose sides are compared directly, or aCircle, holding the points within its radius of its centre.geo.within(a: T, b: U, distance: Length?) -> Bool:geo.contains(b, a); or, withdistance:, whether two points are at most that far apart, asgeo.distancemeasures them.
It also takes text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-circle.md.Built from Jadpo main at aee2e8f.