Skip to content

Instantly share code, notes, and snippets.

@zimmicz
Created September 21, 2016 18:18
Show Gist options
  • Save zimmicz/828772137eff52835012a508c303a040 to your computer and use it in GitHub Desktop.
Save zimmicz/828772137eff52835012a508c303a040 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION ST_PolygonFromCentroid(centroid geometry, xsize numeric, ysize numeric)
RETURNS geometry
AS $ST_PolygonFromCentroid$
SELECT ST_MakeEnvelope(
ST_X(ST_Translate($1, -$2, -$3)),
ST_Y(ST_Translate($1, -$2, -$3)),
ST_X(ST_Translate($1, $2, $3)),
ST_Y(ST_Translate($1, $2, $3))
);
$ST_PolygonFromCentroid$
LANGUAGE SQL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment