Hexgrids in Postgis
-- Function: makegrid_epsg3857(text, text, text, numeric)
-- DROP FUNCTION makegrid_epsg3857(text, text, text, numeric);
CREATE OR REPLACE FUNCTION makegrid_epsg3857(schemaname text, boundingbox text, gridtable text, halfwidth numeric)
RETURNS text AS
$BODY$
DECLARE
tbl_cnt int;
XMIN numeric;
XMAX numeric;
YMIN numeric;
YMAX numeric;
x_value numeric;
y_value numeric;
x_count integer;
y_count integer;
y_offset ...