This will be a quick post. I just looked at how ST_Buffer is written in the PostGIS codebase, and I thought this was interesting. When you use ST_Buffer and specify geometry, buffer distance, and an integer value, this gets converted in the overloaded function into a quad_segs version.
CREATE OR REPLACE FUNCTION ST_Buffer(geometry,float8,integer) RETURNS geometry AS $$ SELECT _ST_Buffer($1, $2, CAST('quad_segs='||CAST($3 AS text) as cstring)) $$ LANGUAGE 'sql' IMMUTABLE STRICT;
P.S. I would have written more, but Sherlock just started.
2 thoughts on “ST_Buffer diving under the covers part 1”
Do you know a good resource to learn how to write SQL functions?
Offhand, no. But maybe a reader does… else I can write a quick primer.