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

bornkilled bornkilled at 21cn.com
Thu Jul 11 01:23:09 PDT 2002


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.osgeo.org/pipermail/proj/attachments/20020711/73542942/attachment.html>


More information about the Proj mailing list