Created
February 5, 2019 19:20
-
-
Save ka7eh/1852894c5532bff2d5b4e7ee0488f378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION ST_GridFromBbox( | |
IN x0 double precision, | |
IN y0 double precision, | |
IN x1 double precision, | |
IN y1 double precision, | |
IN xsize double precision, | |
IN ysize double precision, | |
OUT "row" integer, | |
OUT col integer, | |
OUT geom geometry) | |
RETURNS SETOF record AS | |
$BODY$ | |
SELECT i + 1 AS row, j + 1 AS col, ST_Translate(cell, j * $5 + $1, i * $6 + $2) AS geom | |
FROM generate_series(0, abs(ceil(($3 - $1)) / $5)::integer - 1) AS i, | |
generate_series(0, abs(ceil(($4 - $2)) / $6)::integer - 1) AS j, | |
( | |
SELECT ('POLYGON((0 0, 0 '||$6||', '||$5||' '||$6||', '||$5||' 0,0 0))')::geometry AS cell | |
) AS foo; | |
$BODY$ | |
LANGUAGE sql IMMUTABLE STRICT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment