Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

ST_Buffer diving under the covers part 1

Posted by smathermather on January 10, 2016

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 Responses to “ST_Buffer diving under the covers part 1”

  1. Do you know a good resource to learn how to write SQL functions?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: