[Gdal-dev] GDAL with VB.net (VS 2005 Express)

Milo van der Linden milo at 3dsite.nl
Tue Mar 27 10:25:51 EDT 2007


Dear Tamas,

Thank you for the response! I did as you described. Downloaded FWtools 
and added a reference to ogr_csharp to my project.

I then copied a small piece of code from one of the csharp samples and 
translated it to VB.net

In the start of my module I added the line:
Imports OGR

And then in my test-routine, I created the following:

'/* -------------------------------------------------------------------- */
'/*      Initialize srs                                                  */
'/* -------------------------------------------------------------------- */
                        Dim src As SpatialReference
                        src = New SpatialReference("")
                        src.ImportFromProj4("+proj=latlong +datum=WGS84 
+no_defs")
                        Debug.Print("SOURCE IsGeographic:" + 
src.IsGeographic() + " IsProjected:" + src.IsProjected())
                        Dim dst As SpatialReference
                        dst = New SpatialReference("")
                        dst.ImportFromProj4("+proj=somerc 
+lat_0=47.14439372222222 +lon_0=19.04857177777778 +x_0=650000 
+y_0=200000 +ellps=GRS67 +units=m +no_defs")
                        Debug.Print("DEST IsGeographic:" + 
dst.IsGeographic() + " IsProjected:" + dst.IsProjected())
'/* -------------------------------------------------------------------- */
'/*      making the transform                                            */
'/* -------------------------------------------------------------------- */
                        Dim ct As CoordinateTransformation = New 
CoordinateTransformation(src, dst)
                        Dim p(3) As Double
                        p(0) = 19
                        p(1) = 47
                        p(2) = 0
                        ct.TransformPoint(p)
                        Debug.Print("x:" + p(0) + " y:" + p(1) + " z:" + 
p(2))
                        ct.TransformPoint(p, 19.2, 47.5, 0)
                        Console.WriteLine("x:" + p(0) + " y:" + p(1) + " 
z:" + p(2))

At design time, VB.net has no errors or warnings, but when I run the 
application in Debug mode it halts on the line stating:

                        src = New SpatialReference("")

The message I get is:
                        The type initializer for 'OGR.osrPINVOKE' threw 
an exception.


Anyone had this before? Can It be that the OGR_csharp cannot find my 
proj files or something?

Kind regards,

Milo van der Linden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070327/af9c596f/attachment.html


More information about the Gdal-dev mailing list