Fixes plural forms
This commit is contained in:
parent
20cc610da5
commit
b71947bad0
@ -1,8 +1,8 @@
|
|||||||
-- Check that the public function is callable, even with no data
|
-- Check that the public function is callable, even with no data
|
||||||
-- It should return NULL
|
-- It should return NULL
|
||||||
SELECT cdb_geocoder_server.geocode_admin0_polygons(session_user, txid_current(), 'Spain');
|
SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, txid_current(), 'Spain');
|
||||||
geocode_admin0_polygons
|
geocode_admin0_polygon
|
||||||
-------------------------
|
------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
@ -16,8 +16,8 @@ INSERT INTO ne_admin0_v3 (adm0_a3, the_geom) VALUES('ESP', ST_GeomFromText(
|
|||||||
-71.1031880899493 42.3152774590236))',4326)
|
-71.1031880899493 42.3152774590236))',4326)
|
||||||
);
|
);
|
||||||
-- This should return the polygon inserted above
|
-- This should return the polygon inserted above
|
||||||
SELECT cdb_geocoder_server.geocode_admin0_polygons(session_user, txid_current(), 'Spain');
|
SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, txid_current(), 'Spain');
|
||||||
geocode_admin0_polygons
|
geocode_admin0_polygon
|
||||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540
|
0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540
|
||||||
(1 row)
|
(1 row)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
-- Check that the public function is callable, even with no data
|
-- Check that the public function is callable, even with no data
|
||||||
-- It should return NULL
|
-- It should return NULL
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California');
|
||||||
geocode_admin1_polygons
|
geocode_admin1_polygon
|
||||||
-------------------------
|
------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California', 'United States');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California', 'United States');
|
||||||
geocode_admin1_polygons
|
geocode_admin1_polygon
|
||||||
-------------------------
|
------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
@ -22,14 +22,14 @@ INSERT INTO global_province_polygons (synonyms, iso3, the_geom) VALUES (Array['c
|
|||||||
-71.1031880899493 42.3152774590236))',4326)
|
-71.1031880899493 42.3152774590236))',4326)
|
||||||
);
|
);
|
||||||
-- This should return the polygon inserted above
|
-- This should return the polygon inserted above
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California');
|
||||||
geocode_admin1_polygons
|
geocode_admin1_polygon
|
||||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540
|
0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California', 'United States');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California', 'United States');
|
||||||
geocode_admin1_polygons
|
geocode_admin1_polygon
|
||||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540
|
0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540
|
||||||
(1 row)
|
(1 row)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
-- Check that the public function is callable, even with no data
|
-- Check that the public function is callable, even with no data
|
||||||
-- It should return NULL
|
-- It should return NULL
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
--------------------
|
--------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
@ -19,38 +19,38 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain'], 'ES');
|
|||||||
-- Insert dummy data into admin1 decoder table
|
-- Insert dummy data into admin1 decoder table
|
||||||
INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES');
|
INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES');
|
||||||
-- This should return the point inserted above
|
-- This should return the point inserted above
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elche');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elche');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx', 'Spain');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elche', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elche', 'Spain');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx', 'Valencia', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx', 'Valencia', 'Spain');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elche', 'valencia', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elche', 'valencia', 'Spain');
|
||||||
geocode_namedplace
|
geocode_namedplace_point
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
0101000020E6100000637FD93D7958E63F2ECA6C9049A24340
|
||||||
(1 row)
|
(1 row)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- Geocodes a street address given a searchtext and a state and/or country
|
-- Geocodes a street address given a searchtext and a state and/or country
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_street(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL)
|
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)
|
||||||
RETURNS Geometry
|
RETURNS Geometry
|
||||||
AS $$
|
AS $$
|
||||||
import json
|
import json
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- Interface of the server extension
|
-- Interface of the server extension
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygons(user_id name, tx_id bigint, country_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, tx_id bigint, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
plpy.debug('Entering geocode_admin0_polygons')
|
plpy.debug('Entering geocode_admin0_polygons')
|
||||||
plpy.debug('user_id = %s' % user_id)
|
plpy.debug('user_id = %s' % user_id)
|
||||||
@ -14,7 +14,7 @@ RETURNS Geometry AS $$
|
|||||||
#--TODO: quota check
|
#--TODO: quota check
|
||||||
|
|
||||||
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
|
#-- 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_polygons($1) AS mypolygon", ["text"])
|
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin0_polygon($1) AS mypolygon", ["text"])
|
||||||
rv = plpy.execute(plan, [country_name], 1)
|
rv = plpy.execute(plan, [country_name], 1)
|
||||||
|
|
||||||
plpy.debug('Returning from Returning from geocode_admin0_polygons')
|
plpy.debug('Returning from Returning from geocode_admin0_polygons')
|
||||||
@ -26,7 +26,7 @@ $$ LANGUAGE plpythonu;
|
|||||||
|
|
||||||
-- Implementation of the server extension
|
-- Implementation of the server extension
|
||||||
-- Note: these functions depend on the cdb_geocoder extension
|
-- Note: these functions depend on the cdb_geocoder extension
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server._geocode_admin0_polygons(country_name text)
|
CREATE OR REPLACE FUNCTION cdb_geocoder_server._geocode_admin0_polygon(country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret Geometry;
|
ret Geometry;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
-- Interfacess of the server extension
|
-- Interfacess of the server extension
|
||||||
|
|
||||||
---- geocode_admin1_polygons(admin1_name text)
|
---- geocode_admin1_polygon(admin1_name text)
|
||||||
CREATE OR REPLACE FUNCTION geocode_admin1_polygons(user_id name, tx_id bigint, admin1_name text)
|
CREATE OR REPLACE FUNCTION geocode_admin1_polygon(user_id name, tx_id bigint, admin1_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
plpy.debug('Entering geocode_admin1_polygons(admin1_name text)')
|
plpy.debug('Entering geocode_admin1_polygon(admin1_name text)')
|
||||||
plpy.debug('user_id = %s' % user_id)
|
plpy.debug('user_id = %s' % user_id)
|
||||||
|
|
||||||
#-- Access control
|
#-- Access control
|
||||||
@ -15,17 +15,17 @@ RETURNS Geometry AS $$
|
|||||||
#--TODO: quota check
|
#--TODO: quota check
|
||||||
|
|
||||||
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
|
#-- 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_polygons($1) AS mypolygon", ["text"])
|
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin1_polygon($1) AS mypolygon", ["text"])
|
||||||
rv = plpy.execute(plan, [admin1_name], 1)
|
rv = plpy.execute(plan, [admin1_name], 1)
|
||||||
|
|
||||||
plpy.debug('Returning from Returning from geocode_admin1_polygons')
|
plpy.debug('Returning from Returning from geocode_admin1_polygons')
|
||||||
return rv[0]["mypolygon"]
|
return rv[0]["mypolygon"]
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
---- geocode_admin1_polygons(admin1_name text, country_name text)
|
---- geocode_admin1_polygon(admin1_name text, country_name text)
|
||||||
CREATE OR REPLACE FUNCTION geocode_admin1_polygons(user_id name, tx_id bigint, admin1_name text, country_name text)
|
CREATE OR REPLACE FUNCTION geocode_admin1_polygon(user_id name, tx_id bigint, admin1_name text, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
plpy.debug('Entering geocode_admin1_polygons(admin1_name text, country_name text)')
|
plpy.debug('Entering geocode_admin1_polygon(admin1_name text, country_name text)')
|
||||||
plpy.debug('user_id = %s' % user_id)
|
plpy.debug('user_id = %s' % user_id)
|
||||||
|
|
||||||
#-- Access control
|
#-- Access control
|
||||||
@ -37,10 +37,10 @@ RETURNS Geometry AS $$
|
|||||||
#--TODO: quota check
|
#--TODO: quota check
|
||||||
|
|
||||||
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
|
#-- 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_polygons($1, $2) AS mypolygon", ["text", "text"])
|
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin1_polygon($1, $2) AS mypolygon", ["text", "text"])
|
||||||
rv = plpy.execute(plan, [admin1_name, country_name], 1)
|
rv = plpy.execute(plan, [admin1_name, country_name], 1)
|
||||||
|
|
||||||
plpy.debug('Returning from Returning from geocode_admin1_polygons(admin1_name text, country_name text)')
|
plpy.debug('Returning from Returning from geocode_admin1_polygon(admin1_name text, country_name text)')
|
||||||
return rv[0]["mypolygon"]
|
return rv[0]["mypolygon"]
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ $$ LANGUAGE plpythonu;
|
|||||||
-- Implementation of the server extension
|
-- Implementation of the server extension
|
||||||
-- Note: these functions depend on the cdb_geocoder extension
|
-- Note: these functions depend on the cdb_geocoder extension
|
||||||
|
|
||||||
---- geocode_admin1_polygons(admin1_name text)
|
---- geocode_admin1_polygon(admin1_name text)
|
||||||
CREATE OR REPLACE FUNCTION _geocode_admin1_polygons(admin1_name text)
|
CREATE OR REPLACE FUNCTION _geocode_admin1_polygon(admin1_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret Geometry;
|
ret Geometry;
|
||||||
@ -73,8 +73,8 @@ RETURNS Geometry AS $$
|
|||||||
END
|
END
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
---- geocode_admin1_polygons(admin1_name text, country_name text)
|
---- geocode_admin1_polygon(admin1_name text, country_name text)
|
||||||
CREATE OR REPLACE FUNCTION _geocode_admin1_polygons(admin1_name text, country_name text)
|
CREATE OR REPLACE FUNCTION _geocode_admin1_polygon(admin1_name text, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret Geometry;
|
ret Geometry;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
-- Interfacess of the server extension
|
-- Interfacess of the server extension
|
||||||
|
|
||||||
---- geocode_namedplace(city_name text)
|
---- geocode_namedplace_point(city_name text)
|
||||||
CREATE OR REPLACE FUNCTION geocode_namedplace(user_id name, tx_id bigint, city_name text)
|
CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, tx_id bigint, city_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
plpy.debug('Entering geocode_namedplace(city_name text)')
|
plpy.debug('Entering geocode_namedplace_point(city_name text)')
|
||||||
plpy.debug('user_id = %s' % user_id)
|
plpy.debug('user_id = %s' % user_id)
|
||||||
|
|
||||||
#-- Access control
|
#-- Access control
|
||||||
@ -15,17 +15,17 @@ RETURNS Geometry AS $$
|
|||||||
#--TODO: quota check
|
#--TODO: quota check
|
||||||
|
|
||||||
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
|
#-- 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($1) AS mypoint", ["text"])
|
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1) AS mypoint", ["text"])
|
||||||
rv = plpy.execute(plan, [city_name], 1)
|
rv = plpy.execute(plan, [city_name], 1)
|
||||||
|
|
||||||
plpy.debug('Returning from Returning from geocode_namedplace')
|
plpy.debug('Returning from Returning from geocode_namedplace')
|
||||||
return rv[0]["mypoint"]
|
return rv[0]["mypoint"]
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
---- geocode_namedplace(city_name text, country_name text)
|
---- geocode_namedplace_point(city_name text, country_name text)
|
||||||
CREATE OR REPLACE FUNCTION geocode_namedplace(user_id name, tx_id bigint, city_name text, country_name text)
|
CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, tx_id bigint, city_name text, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
plpy.debug('Entering geocode_namedplace(city_name text, country_name text)')
|
plpy.debug('Entering geocode_namedplace_point(city_name text, country_name text)')
|
||||||
plpy.debug('user_id = %s' % user_id)
|
plpy.debug('user_id = %s' % user_id)
|
||||||
|
|
||||||
#-- Access control
|
#-- Access control
|
||||||
@ -37,17 +37,17 @@ RETURNS Geometry AS $$
|
|||||||
#--TODO: quota check
|
#--TODO: quota check
|
||||||
|
|
||||||
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
|
#-- 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($1, $2) AS mypoint", ["text", "text"])
|
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1, $2) AS mypoint", ["text", "text"])
|
||||||
rv = plpy.execute(plan, [city_name, country_name], 1)
|
rv = plpy.execute(plan, [city_name, country_name], 1)
|
||||||
|
|
||||||
plpy.debug('Returning from Returning from geocode_namedplace')
|
plpy.debug('Returning from Returning from geocode_namedplace')
|
||||||
return rv[0]["mypoint"]
|
return rv[0]["mypoint"]
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
---- geocode_namedplace(city_name text, admin1_name text, country_name text)
|
---- geocode_namedplace_point(city_name text, admin1_name text, country_name text)
|
||||||
CREATE OR REPLACE FUNCTION geocode_namedplace(user_id name, tx_id bigint, city_name text, admin1_name text, country_name text)
|
CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, tx_id bigint, city_name text, admin1_name text, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
plpy.debug('Entering geocode_namedplace(city_name text, admin1_name text, country_name text)')
|
plpy.debug('Entering geocode_namedplace_point(city_name text, admin1_name text, country_name text)')
|
||||||
plpy.debug('user_id = %s' % user_id)
|
plpy.debug('user_id = %s' % user_id)
|
||||||
|
|
||||||
#-- Access control
|
#-- Access control
|
||||||
@ -59,7 +59,7 @@ RETURNS Geometry AS $$
|
|||||||
#--TODO: quota check
|
#--TODO: quota check
|
||||||
|
|
||||||
#-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html
|
#-- 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($1, $2, $3) AS mypoint", ["text", "text", "text"])
|
plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1, $2, $3) AS mypoint", ["text", "text", "text"])
|
||||||
rv = plpy.execute(plan, [city_name, admin1_name, country_name], 1)
|
rv = plpy.execute(plan, [city_name, admin1_name, country_name], 1)
|
||||||
|
|
||||||
plpy.debug('Returning from Returning from geocode_namedplace')
|
plpy.debug('Returning from Returning from geocode_namedplace')
|
||||||
@ -71,8 +71,8 @@ $$ LANGUAGE plpythonu;
|
|||||||
-- Implementation of the server extension
|
-- Implementation of the server extension
|
||||||
-- Note: these functions depend on the cdb_geocoder extension
|
-- Note: these functions depend on the cdb_geocoder extension
|
||||||
|
|
||||||
---- geocode_namedplace(city_name text)
|
---- geocode_namedplace_point(city_name text)
|
||||||
CREATE OR REPLACE FUNCTION _geocode_namedplace(city_name text)
|
CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret Geometry;
|
ret Geometry;
|
||||||
@ -90,8 +90,8 @@ RETURNS Geometry AS $$
|
|||||||
END
|
END
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
---- geocode_namedplace(city_name text, country_name text)
|
---- geocode_namedplace_point(city_name text, country_name text)
|
||||||
CREATE OR REPLACE FUNCTION _geocode_namedplace(city_name text, country_name text)
|
CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text, country_name text)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret Geometry;
|
ret Geometry;
|
||||||
@ -110,8 +110,8 @@ RETURNS Geometry AS $$
|
|||||||
END
|
END
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
---- geocode_namedplace(city_name text, admin1_name text, country_name text)
|
---- geocode_namedplace_point(city_name text, admin1_name text, country_name text)
|
||||||
CREATE OR REPLACE FUNCTION _geocode_namedplace(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)
|
||||||
RETURNS Geometry AS $$
|
RETURNS Geometry AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret Geometry;
|
ret Geometry;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- Check that the public function is callable, even with no data
|
-- Check that the public function is callable, even with no data
|
||||||
-- It should return NULL
|
-- It should return NULL
|
||||||
SELECT cdb_geocoder_server.geocode_admin0_polygons(session_user, txid_current(), 'Spain');
|
SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, txid_current(), 'Spain');
|
||||||
|
|
||||||
-- Insert some dummy synonym
|
-- Insert some dummy synonym
|
||||||
INSERT INTO admin0_synonyms (name, adm0_a3) VALUES ('Spain', 'ESP');
|
INSERT INTO admin0_synonyms (name, adm0_a3) VALUES ('Spain', 'ESP');
|
||||||
@ -14,4 +14,4 @@ INSERT INTO ne_admin0_v3 (adm0_a3, the_geom) VALUES('ESP', ST_GeomFromText(
|
|||||||
);
|
);
|
||||||
|
|
||||||
-- This should return the polygon inserted above
|
-- This should return the polygon inserted above
|
||||||
SELECT cdb_geocoder_server.geocode_admin0_polygons(session_user, txid_current(), 'Spain');
|
SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, txid_current(), 'Spain');
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Check that the public function is callable, even with no data
|
-- Check that the public function is callable, even with no data
|
||||||
-- It should return NULL
|
-- It should return NULL
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California');
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California', 'United States');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California', 'United States');
|
||||||
|
|
||||||
-- Insert dummy data into country decoder table
|
-- Insert dummy data into country decoder table
|
||||||
INSERT INTO country_decoder (synonyms, iso3) VALUES (Array['united states'], 'USA');
|
INSERT INTO country_decoder (synonyms, iso3) VALUES (Array['united states'], 'USA');
|
||||||
@ -15,8 +15,8 @@ INSERT INTO global_province_polygons (synonyms, iso3, the_geom) VALUES (Array['c
|
|||||||
);
|
);
|
||||||
|
|
||||||
-- This should return the polygon inserted above
|
-- This should return the polygon inserted above
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California');
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygons(session_user, txid_current(), 'California', 'United States');
|
SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, txid_current(), 'California', 'United States');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- Check that the public function is callable, even with no data
|
-- Check that the public function is callable, even with no data
|
||||||
-- It should return NULL
|
-- It should return NULL
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx');
|
||||||
|
|
||||||
-- Insert dummy data into points table
|
-- Insert dummy data into points table
|
||||||
INSERT INTO global_cities_points_limited (geoname_id, name, iso2, admin1, admin2, population, lowername, the_geom) VALUES (3128760, 'Elche', 'ES', 'Valencia', 'AL', 34534, 'elche', ST_GeomFromText(
|
INSERT INTO global_cities_points_limited (geoname_id, name, iso2, admin1, admin2, population, lowername, the_geom) VALUES (3128760, 'Elche', 'ES', 'Valencia', 'AL', 34534, 'elche', ST_GeomFromText(
|
||||||
@ -19,9 +19,9 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain'], 'ES');
|
|||||||
INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES');
|
INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES');
|
||||||
|
|
||||||
-- This should return the point inserted above
|
-- This should return the point inserted above
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx');
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elche');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elche');
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx', 'Spain');
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elche', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elche', 'Spain');
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elx', 'Valencia', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elx', 'Valencia', 'Spain');
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace(session_user, txid_current(), 'Elche', 'valencia', 'Spain');
|
SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, txid_current(), 'Elche', 'valencia', 'Spain');
|
||||||
|
Loading…
Reference in New Issue
Block a user