Added cdb_* prefix to all the functions

This commit is contained in:
Mario de Frutos
2015-11-24 13:30:18 +01:00
parent 9880965d07
commit 97cab091b6
31 changed files with 428 additions and 398 deletions

View File

@@ -1,5 +1,5 @@
-- Geocodes a street address given a searchtext and a state and/or country
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_street_point(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_street_point(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL)
RETURNS Geometry
AS $$
import json

View File

@@ -1,18 +1,18 @@
-- Interface of the server extension
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, user_config_data JSON, geocoder_config_data JSON, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config_data JSON, geocoder_config_data JSON, country_name text)
RETURNS Geometry AS $$
plpy.debug('Entering geocode_admin0_polygons')
plpy.debug('Entering cdb_geocode_admin0_polygons')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin0_polygon($1) AS mypolygon", ["text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_admin0_polygon($1) AS mypolygon", ["text"])
rv = plpy.execute(plan, [country_name], 1)
plpy.debug('Returning from Returning from geocode_admin0_polygons')
plpy.debug('Returning from Returning from cdb_geocode_admin0_polygons')
return rv[0]["mypolygon"]
$$ LANGUAGE plpythonu;
@@ -21,7 +21,7 @@ $$ LANGUAGE plpythonu;
-- Implementation of the server extension
-- Note: these functions depend on the cdb_geocoder extension
CREATE OR REPLACE FUNCTION cdb_geocoder_server._geocode_admin0_polygon(country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_admin0_polygon(country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;

View File

@@ -1,36 +1,36 @@
-- Interfacess of the server extension
---- geocode_admin1_polygon(admin1_name text)
CREATE OR REPLACE FUNCTION geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text)
---- cdb_geocode_admin1_polygon(admin1_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text)
RETURNS Geometry AS $$
plpy.debug('Entering geocode_admin1_polygon(admin1_name text)')
plpy.debug('Entering cdb_geocode_admin1_polygon(admin1_name text)')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin1_polygon($1) AS mypolygon", ["text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_admin1_polygon($1) AS mypolygon", ["text"])
rv = plpy.execute(plan, [admin1_name], 1)
plpy.debug('Returning from Returning from geocode_admin1_polygons')
plpy.debug('Returning from Returning from cdb_geocode_admin1_polygons')
return rv[0]["mypolygon"]
$$ LANGUAGE plpythonu;
---- geocode_admin1_polygon(admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text, country_name text)
---- cdb_geocode_admin1_polygon(admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text, country_name text)
RETURNS Geometry AS $$
plpy.debug('Entering geocode_admin1_polygon(admin1_name text, country_name text)')
plpy.debug('Entering cdb_geocode_admin1_polygon(admin1_name text, country_name text)')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin1_polygon($1, $2) AS mypolygon", ["text", "text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_admin1_polygon($1, $2) AS mypolygon", ["text", "text"])
rv = plpy.execute(plan, [admin1_name, country_name], 1)
plpy.debug('Returning from Returning from geocode_admin1_polygon(admin1_name text, country_name text)')
plpy.debug('Returning from Returning from cdb_geocode_admin1_polygon(admin1_name text, country_name text)')
return rv[0]["mypolygon"]
$$ LANGUAGE plpythonu;
@@ -39,8 +39,8 @@ $$ LANGUAGE plpythonu;
-- Implementation of the server extension
-- Note: these functions depend on the cdb_geocoder extension
---- geocode_admin1_polygon(admin1_name text)
CREATE OR REPLACE FUNCTION _geocode_admin1_polygon(admin1_name text)
---- cdb_geocode_admin1_polygon(admin1_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_admin1_polygon(admin1_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
@@ -63,8 +63,8 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;
---- geocode_admin1_polygon(admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION _geocode_admin1_polygon(admin1_name text, country_name text)
---- cdb_geocode_admin1_polygon(admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_admin1_polygon(admin1_name text, country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;

View File

@@ -1,50 +1,50 @@
-- Interfacess of the server extension
---- geocode_namedplace_point(city_name text)
CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text)
---- cdb_geocode_namedplace_point(city_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text)
RETURNS Geometry AS $$
plpy.debug('Entering geocode_namedplace_point(city_name text)')
plpy.debug('Entering cdb_geocode_namedplace_point(city_name text)')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1) AS mypoint", ["text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_namedplace_point($1) AS mypoint", ["text"])
rv = plpy.execute(plan, [city_name], 1)
plpy.debug('Returning from Returning from geocode_namedplace')
return rv[0]["mypoint"]
$$ LANGUAGE plpythonu;
---- geocode_namedplace_point(city_name text, country_name text)
CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, country_name text)
---- cdb_geocode_namedplace_point(city_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, country_name text)
RETURNS Geometry AS $$
plpy.debug('Entering geocode_namedplace_point(city_name text, country_name text)')
plpy.debug('Entering cdb_geocode_namedplace_point(city_name text, country_name text)')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1, $2) AS mypoint", ["text", "text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_namedplace_point($1, $2) AS mypoint", ["text", "text"])
rv = plpy.execute(plan, [city_name, country_name], 1)
plpy.debug('Returning from Returning from geocode_namedplace')
return rv[0]["mypoint"]
$$ LANGUAGE plpythonu;
---- geocode_namedplace_point(city_name text, admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, admin1_name text, country_name text)
---- cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, admin1_name text, country_name text)
RETURNS Geometry AS $$
plpy.debug('Entering geocode_namedplace_point(city_name text, admin1_name text, country_name text)')
plpy.debug('Entering cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1, $2, $3) AS mypoint", ["text", "text", "text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_namedplace_point($1, $2, $3) AS mypoint", ["text", "text", "text"])
rv = plpy.execute(plan, [city_name, admin1_name, country_name], 1)
plpy.debug('Returning from Returning from geocode_namedplace')
@@ -56,8 +56,8 @@ $$ LANGUAGE plpythonu;
-- Implementation of the server extension
-- Note: these functions depend on the cdb_geocoder extension
---- geocode_namedplace_point(city_name text)
CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text)
---- cdb_geocode_namedplace_point(city_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_namedplace_point(city_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
@@ -75,8 +75,8 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;
---- geocode_namedplace_point(city_name text, country_name text)
CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text, country_name text)
---- cdb_geocode_namedplace_point(city_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_namedplace_point(city_name text, country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
@@ -95,8 +95,8 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;
---- geocode_namedplace_point(city_name text, admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text, admin1_name text, country_name text)
---- cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;

View File

@@ -1,68 +1,66 @@
-- TODO geocode_postalcode_polygon(code text, country text)
-- Interface of the server extension
CREATE OR REPLACE FUNCTION geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text)
RETURNS Geometry AS $$
plpy.debug('Entering _geocode_postalcode_point')
plpy.debug('Entering _cdb_geocode_postalcode_point')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_point($1) AS point", ["text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_point($1) AS point", ["text"])
rv = plpy.execute(plan, [code], 1)
plpy.debug('Returning from _geocode_postalcode_point')
plpy.debug('Returning from _cdb_geocode_postalcode_point')
return rv[0]["point"]
$$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text, country text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text, country text)
RETURNS Geometry AS $$
plpy.debug('Entering _geocode_postalcode_point')
plpy.debug('Entering _cdb_geocode_postalcode_point')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_point($1, $2) AS point", ["TEXT", "TEXT"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_point($1, $2) AS point", ["TEXT", "TEXT"])
rv = plpy.execute(plan, [code, country], 1)
plpy.debug('Returning from _geocode_postalcode_point')
plpy.debug('Returning from _cdb_geocode_postalcode_point')
return rv[0]["point"]
$$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text)
RETURNS Geometry AS $$
plpy.debug('Entering _geocode_postalcode_polygon')
plpy.debug('Entering _cdb_geocode_postalcode_polygon')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_polygon($1) AS polygon", ["text"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_polygon($1) AS polygon", ["text"])
rv = plpy.execute(plan, [code], 1)
plpy.debug('Returning from _geocode_postalcode_polygon')
plpy.debug('Returning from _cdb_geocode_postalcode_polygon')
return rv[0]["polygon"]
$$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text, country text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text, country text)
RETURNS Geometry AS $$
plpy.debug('Entering _geocode_postalcode_point')
plpy.debug('Entering _cdb_geocode_postalcode_point')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_polygon($1, $2) AS polygon", ["TEXT", "TEXT"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_polygon($1, $2) AS polygon", ["TEXT", "TEXT"])
rv = plpy.execute(plan, [code, country], 1)
plpy.debug('Returning from _geocode_postalcode_point')
plpy.debug('Returning from _cdb_geocode_postalcode_point')
return rv[0]["polygon"]
$$ LANGUAGE plpythonu;
@@ -71,7 +69,7 @@ $$ LANGUAGE plpythonu;
-- Implementation of the server extension
-- Note: these functions depend on the cdb_geocoder extension
CREATE OR REPLACE FUNCTION _geocode_postalcode_point(code text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_point(code text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
@@ -92,7 +90,7 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION _geocode_postalcode_point(code text, country text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_point(code text, country text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
@@ -117,7 +115,7 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION _geocode_postalcode_polygon(code text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_polygon(code text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
@@ -138,7 +136,7 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION _geocode_postalcode_polygon(code text, country text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_polygon(code text, country text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;

View File

@@ -1,18 +1,18 @@
-- Interface of the server extension
CREATE OR REPLACE FUNCTION geocode_ipaddress_point(user_id name, user_config json, geocoder_config json, ip text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config json, geocoder_config json, ip text)
RETURNS Geometry AS $$
plpy.debug('Entering _geocode_ipaddress_point')
plpy.debug('Entering _cdb_geocode_ipaddress_point')
plpy.debug('user_id = %s' % user_id)
#--TODO: rate limiting check
#--TODO: quota check
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_ipaddress_point($1) AS point", ["TEXT"])
plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_ipaddress_point($1) AS point", ["TEXT"])
rv = plpy.execute(plan, [ip], 1)
plpy.debug('Returning from _geocode_ipaddress_point')
plpy.debug('Returning from _cdb_geocode_ipaddress_point')
return rv[0]["point"]
$$ LANGUAGE plpythonu;
@@ -21,7 +21,7 @@ $$ LANGUAGE plpythonu;
-- Implementation of the server extension
-- Note: these functions depend on the cdb_geocoder extension
CREATE OR REPLACE FUNCTION _geocode_ipaddress_point(ip text)
CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_ipaddress_point(ip text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;