[OSRS-PROJ] delphi API Conversion for proj.dll

=?gb2312?B?ydu98Q==?= bornkilled at 21cn.com
Sun Jul 21 23:21:18 EDT 2002


hi, I found the problem ,I should use "cdecl" but not "stdcall"
then everything is ok
thanks everybody

bornkilled at 21cn.com

-----------------------------------------------------------------
Re: [OSRS-PROJ] delphi API Conversion for proj.dll


To: osrs-proj at remotesensing.org, <osrs-proj at remotesensing.org>
Subject: Re: [OSRS-PROJ] delphi API Conversion for proj.dll
From: Mike Schmidt <mike at sepia.com>
Date: Thu, 11 Jul 2002 10:40:44 -0400
In-Reply-To: <000a01c228b4$3249b1f0$0400a8c0 at shaojin>
Reply-To: osrs-proj at remotesensing.org
Sender: owner-osrs-proj at remotesensing.org
I use proj from both VC++ and VB. I don't know Delphi very well, but I have a few suggestions:

1. pj_errno is a variable, not a function. Calling it as a function will cause you to crash with an access violation.

2. There is no need to know the contents of PJ*, you should use it simply as an opaque pointer. Then there is no problem calling PJ_free. 

3. I can't really comment on the stack overflow in the situation you show. All I can say is that I have not seen this problem myself.

BTW, You don't need definitions of UV and LP for anything.

At 04:23 PM 11/07/2002 +0800, bornkilled wrote:

hi, I want to make a delphi API Conversion for proj.dll( I have compile it by VC6)

 
I wrote pas in this way
unit proj_dll;
 
interface
uses
 windows;
const
 ProjDll='proj.dll';
type
 projPJ=Pointer;
 XY=record
   X:Double;
   Y:Double;
 end;
 UV=XY;
 LP=XY;
 function pj_init(argc:DWord;argv:PLPSTR):projPJ;stdcall;
 function pj_init_plus(definition:PChar):projPJ;stdcall;
 procedure pj_free(var P:projPJ);stdcall;
 procedure pj_deallocate_grids();stdcall;
 function pj_errno():DWORD;stdcall;
 function pj_fwd(aLP:LP;P:projPJ):XY;stdcall;
 function pj_inv(aXY:LP;P:projPJ):LP;stdcall;
 function pj_is_latlong(P:projPJ):DWORD;stdcall;
implementation
 function pj_init;external ProjDll Name 'pj_init';
 function pj_init_plus;external ProjDll Name 'pj_init_plus';
 procedure pj_free;external ProjDll Name 'pj_free';
 procedure pj_deallocate_grids();external ProjDll Name 'pj_deallocate_grids';
 function pj_errno;external ProjDll Name 'pj_errno';
 function pj_fwd;external ProjDll Name 'pj_fwd';
 function pj_inv;external ProjDll Name 'pj_inv';
 function pj_is_latlong ;external ProjDll Name 'pj_is_latlong';
 
But I meet some trouble :
 
1:pj_errno make an exception "Access Violation" in any case;
 
2:I can not find the excatly definition of PJ*,so i can not use pj_free(),that will cause a memory leak .
 
3:pj_fwd will raise stack overflow in the case of the code below:
procedure TForm2.Button1Click(Sender: TObject);
var
 P:projPJ;
 errorno:Integer;
 temp:XY;
 temp1:XY;
 nu:Cardinal;
 i:Integer;
begin
 P:=pj_init_plus(PChar(' +proj=utm +zone=11 +ellps=WGS84));
 i:=pj_errno;
 temp.X:=0;temp.Y:=0;
 nu:=GetTickCount;
 for i:=0 to 50000 do
   temp1:=pj_inv(temp,P);
 ShowMessage(IntToStr(GetTickCount-nu));
end;
 
 
if i<40000 there is no problem
 
 
Bornkilled at 21cn.com
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20020722/18e3d714/attachment.html


More information about the Proj mailing list