The Delaunay API provides robust and efficient constrained Delaunay triangulation of multipolygons.
The format of the input data is an array of one or more multipolygons. A multipolygon is an array of one or more simple polygons, the first having positive orientation and any remaining having negative orientation. A simple polygon is an array of at least three points in order around its boundary. A point is an array of two Cartesian coordinates.
Each interior edge of the output polygon triangulation is Delaunay: that is, there is a circle passing through the two vertices whose interior does not contain any vertices. Over all triangulations of the multipolygons, the result maximises the minimum internal angle and minimises the maximum radius of the circumcircle of a triangle.
The implementation of the triangulation algorithm is robust and uses exact predicates with symbolic perturbation to construct the result. The speed of execution is competitive with polygon meshing via constrained Delaunay triangulation with CGAL. For example, for the Vice-Counties MLWM dataset from the Biological Records Centre, the throughput is 1.02 million polygon triangles per second versus 725 thousand for CGAL version 5.5.1. The code was built with the -O3 and -DNDEBUG compiler settings using clang version 14.0.3 and executed on an Apple M1 Max chip.
The API supports POST requests which can have JSON or URL-encoded bodies and the format should be specified via the Content-Type header. CORS is supported, allowing JavaScript requests across domains.
The API does not require registration, authentication or impose limits on usage. This is subject to fair-use and, for example, many requests closely-spaced in time should be avoided.
The API is free to use and this site does not display adverts. If you find the API useful and would like to contribute to server costs or just buy the developer a coffee then you can visit buymeacoffee.com/geodojo.
Please contact hello@geodojo.net with any problems or feedback.
This endpoint will convert multipolygons into a constrained Delaunay triangulation.
curl --request POST --url 'https://api.geodojo.net/delaunay/polygon' --header 'Content-Type: application/json' --data '{"points":[[[[0,0],[1,0],[1,1],[0,1]],[[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]]]]}'
https://api.geodojo.net/delaunay/polygon
Parameter | Required/Optional | Description | Example |
---|---|---|---|
points |
required | An array of multipolygons | points: [[[[0,0],[1,0],[1,1],[0,1]],[[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]]]] |
POST /delaunay/polygon HTTP/1.1
Host: api.geodojo.net
Content-Type: application/json
Content-Length: 90
{"points":[[[[0,0],[1,0],[1,1],[0,1]],[[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]]]]}
{
"points": [
[0, 0],
[1, 0],
[1, 1],
[0, 1],
[0.25, 0.25],
[0.25, 0.75],
[0.75, 0.75],
[0.75, 0.25]
],
"triangles": [
[0, 1, 7],
[0, 4, 3],
[0, 7, 4],
[1, 2, 6],
[1, 6, 7],
[2, 3, 6],
[3, 4, 5],
[3, 5, 6]
]
}
A POST request for meshing a multipolygon:
const params = {
points: [[[[0,0],[1,0],[1,1],[0,1]],[[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]]]]
};
fetch('https://api.geodojo.net/delaunay/polygon', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(response => response.json())
.then(data => console.log(data));
A POST request for meshing a multipolygon:
$params = array(
'points' => [[[[0,0],[1,0],[1,1],[0,1]],[[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]]]]
);
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/json\r\n',
'content' => json_encode($params)
)
));
$data = json_decode(file_get_contents('https://api.geodojo.net/delaunay/polygon', false, $context), true);
var_dump($data);
A POST request for meshing a multipolygon:
import requests
params = {
'points': [[[[0,0],[1,0],[1,1],[0,1]],[[0.25,0.25],[0.25,0.75],[0.75,0.75],[0.75,0.25]]]]
}
data = requests.post('https://api.geodojo.net/delaunay/polygon', json=params).json()
print(data)