[OSRS-PROJ] proj.4 in VB

Alexander Weidauer alex.weidauer at huckfinn.de
Wed Jun 25 13:36:43 PDT 2003


Hi Christopher,

The usage of the proj utility  under Microsoft einvirionment is a litte 
bit tricky because it is build for a unix environment and looks for
a standard directory called .....\nad\ in the distribution. But there is 
a routine tht tries to find that directory in 3 or 4 way

1. in /usr/locale/proj
2. in /usr/home/~/proj
3. in /bin/proj I' think not shure
4. via a environment vatriaable via proj_lib=....

I doi'nt know  what DLL do yo use. In my distribution I have the
same problems and add a new initalization routine in C.

//-------------------------------------------------------------------------
// proj_init_plus_path for the Win32 Borland Environment
// ..written by A. Weidauer alex.weidauer at huckfinn.de
//-------------------------------------------------------------------------
#include <string.h>.h"
#include "projects.h"

//---------------------------------------------------------------------------
static char *ProjDataPath = NULL;
//---------------------------------------------------------------------------
static const char *ProjFileFinder( const char *aFile )
{
      static char *aLastPath = NULL;

      if( ProjDataPath == NULL )
          return aFile;

      if( aLastPath != NULL )
         free( aLastPath );
      aLastPath = (char *) malloc(strlen(ProjDataPath)+strlen(aFile)+2);
      strcpy( aLastPath, ProjDataPath );
      strcat( aLastPath, "\\" );
      strcat( aLastPath, aFile );
      return aLastPath;
}
//---------------------------------------------------------------------------
PJ * pj_init_plus_path( const char *definition, const char *aDataPath )
{
    if( aDataPath != NULL )   {
       if( ProjDataPath != NULL )
           free( ProjDataPath );
       ProjDataPath = strdup(aDataPath);
    }
    pj_set_finder( ProjFileFinder );
    return pj_init_plus(definition);
}

If not you use my API (..see http://www.tripleware.huckfinn.de

So in the DLL version 4.4.7 it should work like this (Sorry vcode as 
pascal).

       // load transformation gk4-d from file ..\nad\world
       pj :=_pj_init_plus_path
       ('+proj=tmerc +ellps=bessel +lon_0=12 +x_0=500000'
                              ,'.\\nad');
       // if projection allocation fails
       If (pj=NIL) Then Begin
        // check error conditions
        cnt:=_pj_get_errno_ref;
        S:=String(_pj_strerrno(cnt));
        Writeln('error by init !',S);
        Readln;
        Exit;
       End;

I hope you will translate it in your language  and it will help you 
succesfull . If there more problems send me a mail.



//---------------------------------------------------------------------------
// EndOf
//---------------------------------------------------------------------------








Christopher Pouliot schrieb:
> Hello,
> 
> I have downloaded the proj.dll file (v4.4.6) and am trying
> unsuccessfully to use it in Visual Basic.  The simple initialization
> code below causes a fatal error in VB and crashes the program.  My
> experience working with external DLLs is limited so any assistance or
> sample VB code would be greatly appreciated.
> 
> Private Declare Function pj_init Lib "c:\software\proj\bin\proj.dll"
> (ByVal argc As Integer, ByRef argv() As String) As String
> 
> Private Sub Command1_Click()
>   Dim anArr(2) As String
>   Dim aResponse As String
>   
>   anArr(0) = "proj=utm"
>   anArr(1) = "zone=11"
>   anArr(2) = "ellps=GRS80"
>   
>   aResponse = pj_init(3, anArr)
> End Sub
> 
> 
> Thank you,
> 
> Chris
> ----------------------------------------
> PROJ.4 Discussion List
> See http://www.remotesensing.org/proj for subscription, unsubscription
> and other information.
> 


----------------------------------------
PROJ.4 Discussion List
See http://www.remotesensing.org/proj for subscription, unsubscription
and other information.



More information about the Proj mailing list