 
 -- Creates a table of demographic snapshot
 
-CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry, time_span text default '2009 - 2013', geometry_level text default 'us.census.tiger.block_group')
+CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry,
+  time_span text DEFAULT NULL,
+  boundary_id text DEFAULT NULL)
 RETURNS SETOF JSON
 AS $$
-  DECLARE 
+  DECLARE
   target_cols text[];
   BEGIN
+
+  IF time_span IS NULL THEN
+    time_span = '2010 - 2014';
+  END IF;
+
+  IF boundary_id IS NULL THEN
+    boundary_id = 'us.census.tiger.block_group';
+  END IF;
+
   target_cols := Array['us.census.acs.B01001001',
                   'us.census.acs.B01001002',
                   'us.census.acs.B01001026',

    EXECUTE
      q
    into result 
    USING geom, target_cols, geometry_level, segment_name;
    
    return result;


                  'us.census.acs.B19001014',
                  'us.census.acs.B19001015',
                  'us.census.acs.B19001016',
                  'us.census.acs.B19001017'];
    RETURN QUERY
    EXECUTE
    'select * from cdb_observatory._OBS_Get($1, $2, $3, $4 )'
    USING geom, target_cols, time_span, boundary_id
    RETURN;
END;
$$ LANGUAGE plpgsql;
