1+
2+ DROP FUNCTION ap .siteobject (_siteid integer );
13CREATE OR REPLACE FUNCTION ap .siteobject(_siteid integer )
2- RETURNS TABLE(siteid integer ,
3- sitename character varying,
4- sitedescription character varying,
5- geography text ,
6- area double precision ,
7- altitude double precision ,
8- notes text ,
9- geopolitical character varying[])
4+ RETURNS TABLE(siteid integer , site jsonb)
105 LANGUAGE sql
116AS $function$
127 SELECT sts .siteid ,
13- sts . sitename as sitename,
14- sts . sitedescription AS sitedescription,
15- ST_AsGeoJSON(sts .geog ,5 ,2 ) as geography ,
16- sts . area AS area,
17- sts . altitude AS altitude,
18- sts . notes AS notes,
19- gpn .names AS geopolitical
8+ jsonb_build_object( ' sitename' , sts . sitename ,
9+ ' sitedescription ' , sts . sitedescription ,
10+ ' geography ' , ST_AsGeoJSON(sts .geog ,5 ,2 ),
11+ ' area ' , sts . area ,
12+ ' altitude ' , sts . altitude ,
13+ ' notes ' , sts . notes ,
14+ ' geopolitical ' , gpn .names ) AS site
2015 FROM
2116 ndb .sites AS sts
2217 LEFT JOIN ap .geopolnames AS gpn ON gpn .siteid = sts .siteid
@@ -25,29 +20,26 @@ AS $function$
2520 sts .area , sts .altitude , sts .notes , gpn .names ;
2621$function$;
2722
23+ COMMENT ON FUNCTION ap.siteobject(_siteid integer) IS ' Create the JSON object used to return relevant site metadata from a single siteid.' ;
24+
25+ DROP FUNCTION ap .siteobject (_siteid integer []);
2826CREATE OR REPLACE FUNCTION ap .siteobject(_siteid integer [])
29- RETURNS TABLE(siteid integer ,
30- sitename character varying,
31- sitedescription character varying,
32- geography text ,
33- area double precision ,
34- altitude double precision ,
35- notes text ,
36- geopolitical character varying[])
27+ RETURNS TABLE(siteid integer , site jsonb)
3728 LANGUAGE sql
3829AS $function$
3930 SELECT sts .siteid ,
40- sts . sitename as sitename,
41- sts . sitedescription AS sitedescription,
42- ST_AsGeoJSON(sts .geog ,5 ,2 ) as geography ,
43- sts . area AS area,
44- sts . altitude AS altitude,
45- sts . notes AS notes,
46- gpn .names AS geopolitical
31+ jsonb_build_object( ' sitename' , sts . sitename ,
32+ ' sitedescription ' , sts . sitedescription ,
33+ ' geography ' , ST_AsGeoJSON(sts .geog ,5 ,2 ),
34+ ' area ' , sts . area ,
35+ ' altitude ' , sts . altitude ,
36+ ' notes ' , sts . notes ,
37+ ' geopolitical ' , gpn .names ) AS site
4738 FROM
4839 ndb .sites AS sts
4940 LEFT JOIN ap .geopolnames AS gpn ON gpn .siteid = sts .siteid
5041 WHERE sts .siteid = ANY(_siteid)
5142 GROUP BY sts .siteid , sts .sitename , sts .sitedescription , ST_AsGeoJSON(sts .geog ,5 ,2 ),
5243 sts .area , sts .altitude , sts .notes , gpn .names ;
53- $function$;
44+ $function$;
45+ COMMENT ON FUNCTION ap.siteobject(_siteid integer[]) IS ' Create the JSON object used to return relevant site metadata from an array of siteids.' ;
0 commit comments