Python bindings for the mapbox earcut C++ polygon triangulation library.
Project description
mapbox_earcut
Python bindings for the C++ implementation of the Mapbox Earcut library, which provides very fast and quite robust triangulation of 2D polygons.
Original code: earcut.hpp
Original description:
The library implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn't guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data like geographical shapes.
Provided functions (depending on dtype of vertex data):
triangulate_float32
triangulate_float64
triangulate_int32
triangulate_int64
Example:
import mapbox_earcut as earcut
import numpy as np
# A Nx2 array of vertices. Must be 2D.
verts = np.array([[0, 0], [1, 0], [1, 1]]).reshape(-1, 2)
# An array of end-indices for each ring.
# The first ring is the outer contour of the polygon.
# Subsequent ones are holes.
# This implies that the last index must always be equal to the size of verts!
rings = np.array([3])
result = earcut.triangulate_float32(verts, rings)
# Result is an np.ndarray with dtype np.uint32 and shape (3,)
# containing indices into the verts array.
print(verts[result])
# [[1 0]
# [1 1]
# [0 0]]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for mapbox_earcut-0.12.7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 662207e5627deb10fb464ef6b73fdd3621d6bf65cbe6cdf0af734fbf8cca3b9c |
|
MD5 | cf86c4b2263af1033306aa880db8256f |
|
BLAKE2b-256 | 180f80b59829702b10897809565ab0403577deceed64e882cc7e1b563c482f39 |
Hashes for mapbox_earcut-0.12.7-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 159f607c330b58c0d80bda2fe3b904a30d3f6cb360598b196f4090968231c491 |
|
MD5 | 93fe1d24b29a0e4ced72406144dd20cc |
|
BLAKE2b-256 | 491bc58062ab81e689ffa02670b8f7cf4a79cbdfb3ce7ec4522dec07d5e8178e |
Hashes for mapbox_earcut-0.12.7-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f63f9d88c9a35f8ecf18d698ab73af154e900b71eacec9ef716a71fa69da5012 |
|
MD5 | b3711f6b8fe1cae24d31e583e08f1507 |
|
BLAKE2b-256 | cbea4fbad2aaca0d8359da18946aaf57cfb0d63ba654cd4f573d66b8d6e5b539 |
Hashes for mapbox_earcut-0.12.7-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7efdc4a4f2ac96bf26087043ba14cb80df0ec6829539afa725e6f633a373995f |
|
MD5 | 2636331d23d702106fd086f351bcf530 |
|
BLAKE2b-256 | 061e1eaaf1ad91b8aea22d052238c9cc72bc752ccce57f9b5f3e88a847fb1769 |
Hashes for mapbox_earcut-0.12.7-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f310863fedadc6ce9f258a87fe4938c51e596857905970d6c71b2f154f0a3ad3 |
|
MD5 | 2182db8ede6328e843c353ea7522c73f |
|
BLAKE2b-256 | 22effd4990c027875800c09c8828545d14e611c415c8aebf8bf392b997d7c447 |
Hashes for mapbox_earcut-0.12.7-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5620717ae260d88ea4847a11147a1d31f7e4d0149d972eee7b6d8478062cb552 |
|
MD5 | fbba8e8629bf2b3bdcf93cbbff2383f6 |
|
BLAKE2b-256 | 8d3468a4917027a7db57b942319fdb6a3221fd61aad3a22e1e431ee0b3ef5867 |
Hashes for mapbox_earcut-0.12.7-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fab22738446d5b9be77536937aa3a2654f75c3558e224e68f8b188e12aa57d3f |
|
MD5 | 5d13bce6b3fac7df5b5b3be1b3c732d5 |
|
BLAKE2b-256 | 2331addd643afa977a79f9871e0dee5ed937917466578d8d24654aad4a3bb381 |
Hashes for mapbox_earcut-0.12.7-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c72dbde597b4fd8b0512bb3e5354dbc341e5082342709ad7244cc02a54242160 |
|
MD5 | f80388783710756ae91d18f982d089d9 |
|
BLAKE2b-256 | 23fc8cec94ae2a38dab64ac5e5856a870517f7724cecd70491d7134914b014ef |
Hashes for mapbox_earcut-0.12.7-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4cbfbc1181d5bb0f37eb0f359531b70bd94d64090b45bfa3c2b03ecaa29ceff |
|
MD5 | 84a1d99e6067a116814b2c2a574614ea |
|
BLAKE2b-256 | 00478e0a5ac2e48bf810d4df094633c7ce78bb8581c31e245d02ad6d9e77e635 |