Client with isodistance and isochrone feature working

This commit is contained in:
Mario de Frutos
2016-02-11 11:10:12 +01:00
parent f36a345db2
commit 0ca20196c0
15 changed files with 159 additions and 81 deletions
@@ -1,7 +1,12 @@
CREATE TYPE cdb_dataservices_client.isoline AS (
center geometry(Geometry,4326),
data_range integer,
the_geom geometry(Multipolygon,4326)
);
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT NULL)
RETURNS SETOF isoline AS $$
RETURNS SETOF cdb_dataservices_client.isoline AS $$
DECLARE
ret SETOF isoline;
username text;
orgname text;
BEGIN
@@ -13,23 +18,22 @@ BEGIN
IF username IS NULL OR username = '' OR username = '""' THEN
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
END IF;
SELECT cdb_dataservices_client._cdb_isodistance(username, orgname, source, mode, range, options) INTO ret;
RETURN ret;
RETURN QUERY
SELECT * FROM cdb_dataservices_client._cdb_isodistance(username, orgname, source, mode, range, options);
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isodistance (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT NULL)
RETURNS SETOF isoline AS $$
RETURNS SETOF cdb_dataservices_client.isoline AS $$
CONNECT cdb_dataservices_client._server_conn_str();
SELECT cdb_dataservices_server.cdb_isodistance (username, organization_name, source, mode, range, options);
SELECT * FROM cdb_dataservices_server.cdb_isodistance (username, organization_name, source, mode, range, options);
$$ LANGUAGE plproxy;
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT NULL)
RETURNS SETOF isoline AS $$
RETURNS SETOF cdb_dataservices_client.isoline AS $$
DECLARE
ret SETOF isoline;
username text;
orgname text;
BEGIN
@@ -41,14 +45,14 @@ BEGIN
IF username IS NULL OR username = '' OR username = '""' THEN
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
END IF;
SELECT cdb_dataservices_client._cdb_isochrone(username, orgname, source, mode, range, options) INTO ret;
RETURN ret;
RETURN QUERY
SELECT * FROM cdb_dataservices_client._cdb_isochrone(username, orgname, source, mode, range, options);
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isochrone (username text, organization_name text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT NULL)
RETURNS SETOF isoline AS $$
RETURNS SETOF cdb_dataservices_client.isoline AS $$
CONNECT cdb_dataservices_client._server_conn_str();
SELECT cdb_dataservices_server.cdb_isochrone (username, organization_name, source, mode, range, options);
$$ LANGUAGE plproxy;