mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
feat: get_ip_addr
This commit is contained in:
parent
572fd894c9
commit
cdbe33b15f
@ -54,7 +54,8 @@
|
||||
generate_random_gps/3,
|
||||
nmea0183_frame/1,
|
||||
towgs84/2,
|
||||
fromwgs84/2
|
||||
fromwgs84/2,
|
||||
get_ip_addr/1
|
||||
]).
|
||||
|
||||
%%// 定义一些常量
|
||||
@ -367,6 +368,22 @@ get_baidu_addr(AK, Coordtype, Lng, Lat) ->
|
||||
#{}
|
||||
end.
|
||||
|
||||
get_ip_addr(Ip) ->
|
||||
AppKey =
|
||||
case dgiot_data:get(dgiot_configuration, baidu_sak) of
|
||||
not_find ->
|
||||
dgiot_utils:to_binary(application:get_env(dgiot_http, baidumap_appkey, <<"">>));
|
||||
Ak ->
|
||||
Ak
|
||||
end,
|
||||
Url = "https://api.map.baidu.com/location/ip?ip=" ++ dgiot_utils:to_list(Ip) ++ "&coor=bd09ll&ak=" ++ dgiot_utils:to_list(AppKey),
|
||||
case dgiot_http_client:request(get, {Url, []}) of
|
||||
{ok, #{<<"status">> := 0, <<"content">> := #{<<"address">> := Address}}} ->
|
||||
Address;
|
||||
_Error ->
|
||||
Ip
|
||||
end.
|
||||
|
||||
%%# 参数含义
|
||||
%%# base_log:经度基准点,
|
||||
%%# base_lat:维度基准点,
|
||||
|
@ -137,6 +137,7 @@ alter_table(#{<<"tableName">> := TableName}, #{<<"channel">> := Channel} = Conte
|
||||
pass
|
||||
end.
|
||||
|
||||
%% ALTER TABLE _24b9b4bc50._5392ccb3d7 drop COLUMN status;
|
||||
get_addSql(ProductId, TdColumn, Database, TableName) ->
|
||||
case dgiot_product:lookup_prod(ProductId) of
|
||||
{ok, #{<<"thing">> := #{<<"properties">> := Props} = Thing}} ->
|
||||
|
Loading…
Reference in New Issue
Block a user