[
{
"name": "a field near Cambridge, about 100 m by 95 m, is just under a hectare",
"args": [
[
{
"lat": 52.2,
"lng": 0.12
},
{
"lat": 52.2,
"lng": 0.1214
},
{
"lat": 52.2009,
"lng": 0.1214
},
{
"lat": 52.2009,
"lng": 0.12
}
]
],
"expect": {
"squareMetres": 9548,
"hectares": 0.9548,
"acres": 2.3595
}
},
{
"name": "the same field walked clockwise has the same area",
"args": [
[
{
"lat": 52.2,
"lng": 0.12
},
{
"lat": 52.2009,
"lng": 0.12
},
{
"lat": 52.2009,
"lng": 0.1214
},
{
"lat": 52.2,
"lng": 0.1214
}
]
],
"expect": {
"squareMetres": 9548,
"hectares": 0.9548,
"acres": 2.3595
}
},
{
"name": "closing the ring with the first point again changes nothing",
"args": [
[
{
"lat": 52.2,
"lng": 0.12
},
{
"lat": 52.2,
"lng": 0.1214
},
{
"lat": 52.2009,
"lng": 0.1214
},
{
"lat": 52.2009,
"lng": 0.12
},
{
"lat": 52.2,
"lng": 0.12
}
]
],
"expect": {
"squareMetres": 9548,
"hectares": 0.9548,
"acres": 2.3595
}
},
{
"name": "a triangular field in Oxfordshire",
"args": [
[
{
"lat": 51.5,
"lng": -1.0
},
{
"lat": 51.505,
"lng": -1.0
},
{
"lat": 51.5,
"lng": -0.992
}
]
],
"expect": {
"squareMetres": 153931,
"hectares": 15.3931,
"acres": 38.0372
}
},
{
"name": "an L-shaped field with six corners",
"args": [
[
{
"lat": 53.0,
"lng": -2.0
},
{
"lat": 53.0,
"lng": -1.997
},
{
"lat": 53.001,
"lng": -1.997
},
{
"lat": 53.001,
"lng": -1.9985
},
{
"lat": 53.002,
"lng": -1.9985
},
{
"lat": 53.002,
"lng": -2.0
}
]
],
"expect": {
"squareMetres": 33484,
"hectares": 3.3484,
"acres": 8.2741
}
},
{
"name": "a field across the antimeridian (Chatham Islands side) is measured the short way round",
"args": [
[
{
"lat": -41.0,
"lng": 179.9995
},
{
"lat": -41.0,
"lng": -179.9995
},
{
"lat": -40.999,
"lng": -179.9995
},
{
"lat": -40.999,
"lng": 179.9995
}
]
],
"expect": {
"squareMetres": 9332,
"hectares": 0.9332,
"acres": 2.3059
}
},
{
"name": "the same shape at longitude 0 has the same area",
"args": [
[
{
"lat": -41.0,
"lng": -0.0005
},
{
"lat": -41.0,
"lng": 0.0005
},
{
"lat": -40.999,
"lng": 0.0005
},
{
"lat": -40.999,
"lng": -0.0005
}
]
],
"expect": {
"squareMetres": 9332,
"hectares": 0.9332,
"acres": 2.3059
}
},
{
"name": "a one-degree square on the equator is R² x (pi/180) x sin 1°",
"args": [
[
{
"lat": 0,
"lng": 0
},
{
"lat": 0,
"lng": 1
},
{
"lat": 1,
"lng": 1
},
{
"lat": 1,
"lng": 0
}
]
],
"expect": {
"squareMetres": 12363718145,
"hectares": 1236371.8145,
"acres": 3055141.2886
}
},
{
"name": "points in a straight line enclose nothing",
"args": [
[
{
"lat": 52.0,
"lng": 0.0
},
{
"lat": 52.0,
"lng": 0.001
},
{
"lat": 52.0,
"lng": 0.002
}
]
],
"expect": {
"squareMetres": 0,
"hectares": 0,
"acres": 0
}
},
{
"name": "two points are not a boundary",
"args": [
[
{
"lat": 52.0,
"lng": 0.0
},
{
"lat": 52.0,
"lng": 0.001
}
]
],
"expectError": "a boundary needs at least 3 distinct points"
},
{
"name": "three points with a repeat are not a boundary",
"args": [
[
{
"lat": 52.0,
"lng": 0.0
},
{
"lat": 52.0,
"lng": 0.001
},
{
"lat": 52.0,
"lng": 0.0
}
]
],
"expectError": "a boundary needs at least 3 distinct points"
},
{
"name": "an empty boundary is an error",
"args": [
[]
],
"expectError": "a boundary needs at least 3 distinct points"
},
{
"name": "a latitude over 90 is an error (latitude and longitude swapped?)",
"args": [
[
{
"lat": 52.0,
"lng": 0.0
},
{
"lat": 95.0,
"lng": 0.001
},
{
"lat": 52.001,
"lng": 0.0
}
]
],
"expectError": "point 2: latitude must be a finite number from -90 to 90 degrees"
},
{
"name": "a longitude over 180 is an error",
"args": [
[
{
"lat": 52.0,
"lng": 0.0
},
{
"lat": 52.0,
"lng": 181.0
},
{
"lat": 52.001,
"lng": 0.0
}
]
],
"expectError": "point 2: longitude must be a finite number from -180 to 180 degrees"
}
]