-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGETGEOJSON.sql
More file actions
35 lines (25 loc) · 838 Bytes
/
GETGEOJSON.sql
File metadata and controls
35 lines (25 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
create or replace FUNCTION getGeoJSON(inlayer in varchar2, infield in varchar2, inid in varchar2, return_properties in number) return CLOB AS
v_clob CLOB;
v_geom CLOB;
v_props CLOB;
BEGIN
v_clob :='{ "type": "FeatureCollection", "features": [ { "type": "Feature",';
if return_properties =1 THEN
select getJSONProperties(inlayer, infield, inid) into v_props from dual;
if v_props is null THEN
raise NO_DATA_FOUND;
end if;
v_clob := v_clob || v_props || ', ';
else
v_clob := v_clob || '"properties" : {"' || infield || '" : "' || inid || '"}, ';
end if;
select getJSONGeometry(inlayer, infield, inid) into v_geom from dual;
if v_geom is null THEN
raise NO_DATA_FOUND;
end if;
v_clob := v_clob || v_geom || '}]}';
return v_clob;
EXCEPTION
WHEN NO_DATA_FOUND THEN
return '{ "type": "FeatureCollection", "features": []}';
END;