I am trying to write a plv8 function that returns an integer representing a UTM zone value. The function utilizes PostGIS functions. Here is the (not-functioning) idea:
CREATE OR REPLACE FUNCTION utm_z(geometry)
RETURNS integer AS
$$
var geom_geog = st_transform($1, 4326);
var utm_zone = Math.floor((st_x(geom_geog)+180)/6)+1;
return utm_zone;
$$ LANGUAGE plv8;
When invoking that function I get
ERROR: ReferenceError: st_transform is not defined
How am I able to access those PostGIS functions from inside plv8?