Add properties for user and geocoder config keys instead of hardcode it in the template
This commit is contained in:
parent
e09af1463d
commit
963da6c5c7
@ -8,11 +8,11 @@ CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>.<%= name %> (<%= params
|
|||||||
RETURNS <%= return_type %> AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
ret <%= return_type %>;
|
ret <%= return_type %>;
|
||||||
user_config JSON;
|
user_config json;
|
||||||
geocoder_config JSON;
|
geocoder_config json;
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT cartodb.CDB_Conf_GetConf('user_config') INTO user_config;
|
SELECT cartodb.CDB_Conf_GetConf('<%= user_config_key %>') INTO user_config;
|
||||||
SELECT cartodb.CDB_Conf_GetConf('geocoder_config') INTO geocoder_config;
|
SELECT cartodb.CDB_Conf_GetConf('<%= geocoder_config_key %>') INTO geocoder_config;
|
||||||
SELECT <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %>(session_user, user_config, geocoder_config, <%= params %>) INTO ret;
|
SELECT <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %>(session_user, user_config, geocoder_config, <%= params %>) INTO ret;
|
||||||
RETURN ret;
|
RETURN ret;
|
||||||
END;
|
END;
|
||||||
|
@ -1,33 +1,45 @@
|
|||||||
---
|
---
|
||||||
- name: geocode_admin0_polygon
|
- name: geocode_admin0_polygon
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: country_name, type: text }
|
- { name: country_name, type: text }
|
||||||
|
|
||||||
- name: geocode_admin1_polygon
|
- name: geocode_admin1_polygon
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: admin1_name, type: text }
|
- { name: admin1_name, type: text }
|
||||||
|
|
||||||
- name: geocode_admin1_polygon
|
- name: geocode_admin1_polygon
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: admin1_name, type: text }
|
- { name: admin1_name, type: text }
|
||||||
- { name: country_name, type: text }
|
- { name: country_name, type: text }
|
||||||
|
|
||||||
- name: geocode_namedplace_point
|
- name: geocode_namedplace_point
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: city_name, type: text}
|
- { name: city_name, type: text}
|
||||||
|
|
||||||
- name: geocode_namedplace_point
|
- name: geocode_namedplace_point
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: city_name, type: text}
|
- { name: city_name, type: text}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: geocode_namedplace_point
|
- name: geocode_namedplace_point
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: city_name, type: text}
|
- { name: city_name, type: text}
|
||||||
- { name: admin1_name, type: text}
|
- { name: admin1_name, type: text}
|
||||||
@ -36,18 +48,24 @@
|
|||||||
|
|
||||||
- name: geocode_postalcode_polygon
|
- name: geocode_postalcode_polygon
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: postal_code, type: text}
|
- { name: postal_code, type: text}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: geocode_postalcode_point
|
- name: geocode_postalcode_point
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: postal_code, type: text}
|
- { name: postal_code, type: text}
|
||||||
- { name: country_name, type: text}
|
- { name: country_name, type: text}
|
||||||
|
|
||||||
- name: geocode_ipaddress_point
|
- name: geocode_ipaddress_point
|
||||||
return_type: Geometry
|
return_type: Geometry
|
||||||
|
user_config_key: user_config
|
||||||
|
geocoder_config_key: geocoder_config
|
||||||
params:
|
params:
|
||||||
- { name: ip_address, type: text}
|
- { name: ip_address, type: text}
|
||||||
|
|
||||||
|
@ -27,6 +27,14 @@ class SqlTemplateRenderer
|
|||||||
@function_signature['return_type']
|
@function_signature['return_type']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_config_key
|
||||||
|
@function_signature['user_config_key']
|
||||||
|
end
|
||||||
|
|
||||||
|
def geocoder_config_key
|
||||||
|
@function_signature['geocoder_config_key']
|
||||||
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
@function_signature['params'].map { |p| p['name'] }.join(', ')
|
@function_signature['params'].map { |p| p['name'] }.join(', ')
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user