Home > Blockchain >  postgis function correctly returns table with geom but not picked up by pg_featureserv
postgis function correctly returns table with geom but not picked up by pg_featureserv

Time:10-02

Using pg_featureserv

wrote a function that returns a table geometry

CREATE OR REPLACE FUNCTION public.nearest_retail(lon float, lat float)
RETURNS table(id int,
              dba_name varchar,
              entity_name varchar,
              category varchar,
              address varchar,
              notes varchar,
              distance float,
              geom geometry
              ) 
AS $$
    select t.uid,dba_name,entity_name,md2.category,address,notes,distance,st_union(shape,geom) geom
        from
            (   select distinct on(category) category,uid,
                st_distance(st_transform(geom,2263),st_transform(st_setsrid(st_makepoint(lon, lat),4326),2263)) distance,
                st_shortestline(geom,st_setsrid(st_makepoint(lon, lat),4326)) shape
                from merged_datasets md 
                where st_dwithin(st_transform(st_setsrid(st_makepoint(lon, lat),4326),2263),st_transform(geom,2263),5280) 
                and category is not null 
            )t join merged_datasets md2 using(uid);
$$  LANGUAGE sql;

calling the function in the DB itself it works as its supposed to, however I cannot get it to show up in the pg_featureserv

enter image description here

CodePudding user response:

The doc says

Because there are usually many functions in a Postgres database, the service only publishes functions defined in the postgisftw schema.

  • Related