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

Mike Schmidt mike at sepia.com
Thu Jul 11 10:40:44 EDT 2002


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
>
>
><mailto:Bornkilled at 21cn.com>Bornkilled at 21cn.com
>

________________________________________________________
Mike Schmidt                        Systèmes Scientifiques SEPIA
President                              SEPIA Scientific Systems
Tel: 450-358-2266                  100 Richelieu, suite 2000
Fax: 450-358-2267                 Saint-Jean-sur-Richelieu
e-mail: mike at sepia.com        Québec, Canada J3B 6X3
http://www.sepia.com             http://www.intello.com

****************************************************************************
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
To reply to our email administrator directly, select the following
<mailto:postmaster at sepia.com>
**************************************************************************** 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20020711/02d27cfd/attachment.html


More information about the Proj mailing list