Database Reference
In-Depth Information
The approach we will use for the construction of the subplots is to construct the
grid with a series of ST_MakeLine and use ST_Union to flatten or node the
results. This ensures that we have all of our lines properly intersecting each other.
ST_Polygonize willthenconstructourmultipolygongeometryforus.Wewilllever-
age this function through our wrapper from the Improving ST_Polygonize recipe.
Ourplotsare10unitsonaside,ina5x2array.Assuch,wecanimagineafunction
to which we pass our plot origin, and the function returns a multipolygon of all the
subplotgeometries.Oneadditionalelementtoconsideristhattheorientationofthe
layoutofourplotsisrotatedtoabearing.Weexpectthefunctiontoactuallyusetwo
inputs, so origin and rotation will be the variables that we will pass to our function.
How to do it...
Wecanconsidergeometryandafloatvalueastheinputs,andwewantthefunction
to return geometry:
CREATE OR REPLACE FUNCTION chp04.create_grid
(geometry, float) RETURNS geometry AS $$
Inordertoconstructthesubplots,wewillrequirethreelinesrunningparalleltothex
axis:
WITH middleline AS (
SELECT ST_MakeLine(ST_Translate($1,
-10, 0), ST_Translate($1, 40.0, 0)) AS the_geom
),
topline AS (
SELECT ST_MakeLine(ST_Translate($1,
-10, 10.0), ST_Translate($1, 40.0, 10)) AS
the_geom
),
bottomline AS (
SELECT ST_MakeLine(ST_Translate($1,
-10, -10.0), ST_Translate($1, 40.0, -10)) AS
the_geom
),
Search WWH ::




Custom Search