[OSRS-PROJ] proj.4 in VB
Russell Jurgensen
russell at effectiveobjects.com
Wed Jun 25 18:30:16 EDT 2003
There probably will be several issues to solve to make Visual Basic work
with proj. I don't have example code, but here are a few ideas.
Part of the problem is that VB uses structures for arrays and strings. So a
way is needed to create an array of pointers to the string data that proj
will accept.
1. An array of Longs should work to hold the 4-byte pointers.
2. Getting a pointer to string data is tough in VB. You might use a Windows
kernel function like lstrcatA to get it roundabout.
Declare Function GetStringPointer Lib "kernel32" Alias "lstrcatA" (ByVal
lpString1 As String, ByVal lpString2 As String) As Long
3. Psuedocode
Dim Params(0 to 2) as Long
Str1 = "proj=utm"
Params(0) = GetStringPointer(Str1, "")
Str2 = "zone=11"
Params(0) = GetStringPointer(Str2, "")
... create more parameters here
Response = pj_init(3, Params(0))
4. I didn't check the parameters you gave, but I think it needs a "no_defs"
at the end.
I haven't tested these ideas with proj, but I hope they are helpful.
For a low cost DLL UTM converter that is directly compatible with VB, you
might look at the Effective Objects DLLs at
www.eobj.com/products-mapping-software.html. It could save a lot of time in
debugging.
Russell Jurgensen (rj at effectiveobjects.com)
-----Original Message-----
From: owner-osrs-proj at remotesensing.org
[mailto:owner-osrs-proj at remotesensing.org]On Behalf Of Christopher
Pouliot
Sent: Wednesday, June 25, 2003 11:04 AM
To: osrs-proj at remotesensing.org
Subject: [OSRS-PROJ] proj.4 in VB
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