2015-11-12 18:06:50 +08:00
|
|
|
-- Make sure dbs are clean
|
|
|
|
DELETE FROM global_postal_code_points;
|
2015-11-12 18:20:12 +08:00
|
|
|
DELETE FROM global_postal_code_polygons;
|
2015-11-12 18:06:50 +08:00
|
|
|
DELETE FROM country_decoder;
|
|
|
|
DELETE FROM available_services;
|
|
|
|
DELETE FROM admin0_synonyms;
|
|
|
|
|
2015-11-12 02:25:48 +08:00
|
|
|
-- Check that the public function is callable, even with no data
|
|
|
|
-- It should return NULL
|
2018-09-10 20:26:53 +08:00
|
|
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point('test_user', 'test_org', '03204');
|
2015-11-12 02:25:48 +08:00
|
|
|
|
|
|
|
-- Insert dummy data into ip_address_locations
|
|
|
|
INSERT INTO global_postal_code_points (the_geom, iso3, postal_code, postal_code_num) VALUES (
|
|
|
|
'0101000020E61000000000000000E040408036B47414764840',
|
|
|
|
'ESP',
|
|
|
|
'03204',
|
|
|
|
3204
|
|
|
|
);
|
|
|
|
|
2015-11-12 18:20:12 +08:00
|
|
|
INSERT INTO global_postal_code_polygons (the_geom, iso3, postal_code, postal_code_num) VALUES (
|
|
|
|
'0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040',
|
|
|
|
'ESP',
|
|
|
|
'03204',
|
|
|
|
3204
|
|
|
|
);
|
|
|
|
|
2015-11-12 18:06:50 +08:00
|
|
|
INSERT INTO country_decoder (iso3, synonyms) VALUES (
|
|
|
|
'ESP',
|
|
|
|
Array['spain', 'Spain', 'ESP']
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO available_services (adm0_a3, admin0, postal_code_points, postal_code_polygons) VALUES (
|
|
|
|
'ESP',
|
|
|
|
't',
|
|
|
|
't',
|
|
|
|
't'
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO admin0_synonyms (adm0_a3, name, name_, rank) VALUES (
|
|
|
|
'ESP',
|
|
|
|
'Spain',
|
|
|
|
'spain',
|
|
|
|
3
|
|
|
|
);
|
|
|
|
|
2015-11-12 02:25:48 +08:00
|
|
|
-- This should return the polygon inserted above
|
2018-09-10 19:15:19 +08:00
|
|
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point('test_user', 'test_org', '03204');
|
2015-11-12 18:06:50 +08:00
|
|
|
|
2018-09-10 19:15:19 +08:00
|
|
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_point('test_user', 'test_org', '03204', 'spain');
|
2015-11-12 18:06:50 +08:00
|
|
|
|
2018-09-10 19:15:19 +08:00
|
|
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon('test_user', 'test_org', '03204');
|
2015-11-12 18:20:12 +08:00
|
|
|
|
2018-09-10 19:15:19 +08:00
|
|
|
SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon('test_user', 'test_org', '03204', 'spain');
|
2015-11-12 18:20:12 +08:00
|
|
|
|
2015-11-12 18:06:50 +08:00
|
|
|
-- Clean dbs
|
|
|
|
DELETE FROM global_postal_code_points;
|
2015-11-12 18:20:12 +08:00
|
|
|
DELETE FROM global_postal_code_polygons;
|
2015-11-12 18:06:50 +08:00
|
|
|
DELETE FROM country_decoder;
|
|
|
|
DELETE FROM available_services;
|
|
|
|
DELETE FROM admin0_synonyms;
|
2015-11-23 18:48:24 +08:00
|
|
|
|
|
|
|
-- Check for namedplaces signatures (point and polygon)
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = 'cdb_geocode_postalcode_point'
|
2018-09-10 19:15:19 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text, text, text');
|
2015-11-23 18:48:24 +08:00
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = 'cdb_geocode_postalcode_point'
|
2018-09-10 19:15:19 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text, text, text, text');
|
2015-11-23 18:48:24 +08:00
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = 'cdb_geocode_postalcode_polygon'
|
2018-09-10 19:15:19 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text, text, text');
|
2015-11-23 18:48:24 +08:00
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = 'cdb_geocode_postalcode_polygon'
|
2018-09-10 19:15:19 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text, text, text, text');
|
2015-11-23 18:48:24 +08:00
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = '_cdb_geocode_postalcode_point'
|
2015-11-23 18:48:24 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text');
|
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = '_cdb_geocode_postalcode_point'
|
2015-11-23 18:48:24 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text, text');
|
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = '_cdb_geocode_postalcode_polygon'
|
2015-11-23 18:48:24 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text');
|
|
|
|
|
|
|
|
SELECT exists(SELECT *
|
|
|
|
FROM pg_proc p
|
|
|
|
INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid)
|
2016-02-06 00:57:22 +08:00
|
|
|
WHERE ns.nspname = 'cdb_dataservices_server'
|
2015-11-24 20:30:18 +08:00
|
|
|
AND proname = '_cdb_geocode_postalcode_polygon'
|
2016-02-06 00:57:22 +08:00
|
|
|
AND oidvectortypes(p.proargtypes) = 'text, text');
|