2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, country_name text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_admin0_polygon(trim($1)) AS mypolygon", ["text"])
|
|
|
|
rv = plpy.execute(plan, [country_name], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypolygon"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_admin1_polygon(trim($1)) AS mypolygon", ["text"])
|
|
|
|
rv = plpy.execute(plan, [admin1_name], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypolygon"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text, country_name text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_admin1_polygon(trim($1), trim($2)) AS mypolygon", ["text", "text"])
|
|
|
|
rv = plpy.execute(plan, [admin1_name, country_name], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypolygon"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_namedplace_point(trim($1)) AS mypoint", ["text"])
|
|
|
|
rv = plpy.execute(plan, [city_name], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypoint"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, country_name text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_namedplace_point(trim($1), trim($2)) AS mypoint", ["text", "text"])
|
|
|
|
rv = plpy.execute(plan, [city_name, country_name], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypoint"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, admin1_name text, country_name text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_namedplace_point(trim($1), trim($2), trim($3)) AS mypoint", ["text", "text", "text"])
|
|
|
|
rv = plpy.execute(plan, [city_name, admin1_name, country_name], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypoint"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, code text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_postalcode_point(trim($1)) AS mypoint", ["text"])
|
|
|
|
rv = plpy.execute(plan, [code], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypoint"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, code text, country text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_postalcode_point(trim($1), trim($2)) AS mypoint", ["TEXT", "TEXT"])
|
|
|
|
rv = plpy.execute(plan, [code, country], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypoint"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, code text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_postalcode_polygon(trim($1)) AS mypolygon", ["text"])
|
|
|
|
rv = plpy.execute(plan, [code], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypolygon"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, code text, country text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_postalcode_polygon(trim($1), trim($2)) AS mypolygon", ["TEXT", "TEXT"])
|
|
|
|
rv = plpy.execute(plan, [code, country], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypolygon"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|
2016-02-05 23:00:46 +08:00
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, ip text)
|
2016-02-05 23:00:46 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
from cartodb_services.metrics import QuotaService
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
|
2016-02-06 00:57:22 +08:00
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
2016-02-05 23:00:46 +08:00
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection']
|
|
|
|
user_geocoder_config = InternalGeocoderConfig(redis_conn, username, orgname)
|
|
|
|
|
|
|
|
quota_service = QuotaService(user_geocoder_config, redis_conn)
|
|
|
|
try:
|
2016-02-06 00:57:22 +08:00
|
|
|
plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_geocode_ipaddress_point(trim($1)) AS mypoint", ["TEXT"])
|
|
|
|
rv = plpy.execute(plan, [ip], 1)
|
2016-02-05 23:00:46 +08:00
|
|
|
result = rv[0]["mypoint"]
|
|
|
|
if result:
|
|
|
|
quota_service.increment_success_geocoder_use()
|
|
|
|
return result
|
|
|
|
else:
|
|
|
|
quota_service.increment_empty_geocoder_use()
|
|
|
|
return None
|
|
|
|
except BaseException as e:
|
|
|
|
import sys, traceback
|
|
|
|
type_, value_, traceback_ = sys.exc_info()
|
|
|
|
quota_service.increment_failed_geocoder_use()
|
|
|
|
error_msg = 'There was an error trying to geocode using admin0 geocoder: {0}'.format(e)
|
|
|
|
plpy.notice(traceback.format_tb(traceback_))
|
|
|
|
plpy.error(error_msg)
|
|
|
|
finally:
|
|
|
|
quota_service.increment_total_geocoder_use()
|
2020-03-17 16:49:54 +08:00
|
|
|
$$ LANGUAGE plpythonu;
|