Skip to content

A wrapper of the concept of Voronoi optimized for geolocations.

Notifications You must be signed in to change notification settings

achin42/Geo-voronoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NPM  

GeoVoronoi

Voronoi Diagram is partitioning of a plane with n points into convex polygons such that each polygon contains exactly one generating point and every point in a given polygon is closer to its generating point than to any other. A Voronoi diagram is sometimes also known as a Dirichlet tessellation. GeoVoronoi is an extension of Voronoi optimized for geo locations.

Example usage

var sites = [];
sites.push({x:32.123456, y:-175.654321});
sites.push({x:32.214365, y:162.123234});
sites.push({x:32.907856, y:-162.098765});
sites.push({x:32.019283, y:172.102938});
sites.push({x:32.444555, y:-176.555444});
sites.push({x:32.333222, y:-179.222333});

var geoVoronoi = require('geovoronoi');
var voronoiGraph = geoVoronoi.getGeoVoronoiGraph(sites);

Above code will generate generate this data

This Voronoi graph will contain following main components

  1. cells: This contains information for all the polygons(zone) along with their owner sites. A polygon is represented by halfedges (called so as most of them are shared among two adjacent polygons). Each half edge has start and end vertices called va and vb respectively. Set of start vertices of all half-edges will be all the vertices of the polygon. Information of cells is enough for basic calculations.
  2. edges: This contains information about start and end points of all the edges in the resulting Voronoi diagram.
  3. vertices: This contains information about all the vertices in the resulting Voronoi diagram.

See this blogpost for further explanation

Also check out Raycast as it goes very well with Voronoi.

About

A wrapper of the concept of Voronoi optimized for geolocations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages