   geom geometry(Geometry, 4326), -- point
   radius numeric, -- radius in meters
   boundary_id text,
-  time_span text DEFAULT NULL)
+  time_span text DEFAULT NULL,
+  overlap_type text DEFAULT 'contains')
 RETURNS TABLE(boundary geometry, geom_refs text)
 AS $$
 DECLARE

  EXECUTE format(
    'SELECT ST_PointOnSurface(t.%s) As %s, t.%s
     FROM observatory.%s As t
     WHERE ST_Contains($1, t.the_geom)
     ', geom_colname, geom_colname, geoid_colname, target_table)
  USING geom;

END;

  EXECUTE format(
    'SELECT t.%s, t.%s
     FROM observatory.%s As t
     WHERE ST_%s($1, t.the_geom)
     ', geom_colname, geoid_colname, target_table, overlap_type)
  USING geom;

END;
