View on GitHub

leaflet-city-mapper

A small 3D rendering engine for leaflet

Triangulation

Source guide Project README

Triangulates polygon contours and holes, cleaning rings and normalizing their winding while retaining indices into the original input vertices.

Polygon to triangles

flowchart LR
  Rings["Outer contour + holes"] --> Clean["Clean + normalize winding"]
  Clean --> Bridge["Connect holes"]
  Bridge --> Clip["Clip ears"]
  Clip --> Triangles["Triangles indexed into original inputs"]

Input rings omit the repeated closing vertex. Indices still refer to the original contour followed by holes after cleanup; preserve that contract. MVT has a separate fallback for quantized rings.

Related: geometry, mvt.