如何从这个Delphi函数编写等效的PL / SQL函数:
Function TConvert.MGRS(lat : Double; Lon : Double; a : Double;
InverseFlattening : Double; Coding:Integer; Digits : Integer) : String ;
var
UTMs1 : String;
E1 : Double;
N1 : Double;
Zn : Integer;
Lzn : String;
Sq : String;
begin
UTMs1 := UTM(lat, Lon, a, InverseFlattening) ;
E1 := UTMX(UTMs1);
N1 := UTMY(UTMs1);
Zn := UTMZone(lat, Lon);
Lzn := MGRSLatZone(lat);
Sq := SquareID(Zn, N1, E1, Coding);
Result := Format('%.2d', [Zn] ) + Lzn + Sq +
Copy(Format('%.5d',[Round(E1 - 100000 * Trunc(E1 / 100000))]), 1, Digits) +
Copy(Format('%.5d',[Round(N1 - 100000 * Trunc(N1 / 100000))]), 1, Digits);
end;
MGRS(0,0,6378.137,298.2572236,1,5)= 31NAA6602100000
答案 0 :(得分:4)
不确定整个代码是否可以转换为本机Oracle调用,但是关于字符串格式化的初始问题,结果代码可能如下所示:
create or replace function MyFunction(
Zn in number,
Lzn in varchar2,
Sq in varchar2,
E1 in number,
N1 in number,
Digits in number
)
return varchar2
as
vRes varchar2(4000);
begin
vRes := trim(to_char(Zn,'999999999999999999.00')) || LZn || Sq ||
substr(trim(to_char(round(E1 - 100000 * trunc(E1/100000)),'999999999999999999.00000')), 1, Digits) ||
substr(trim(to_char(round(N1 - 100000 * trunc(N1/100000)),'999999999999999999.00000')), 1, Digits)
;
return vRes;
end;
Google;)