JPEG Layer + SharpMAP v0.9

Topics: Algorithms, Data Access, General Topics, SharpMap v0.9 / v1.x, WinForms Controls
Jul 2, 2009 at 4:19 PM

I am creating a WinForms app.  I can create vector layers (using ESRI Shape files) no problems.  Point and label layers from Access.MDB files.  I now have a JPG file fully georeff'd with a jpw file.  But No joy!  How do I implement a GDALRaterLayer?  I am using VB.NET in VS2008 Express.  The code is this...

'================

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myMAP As New SharpMap.Map(New Size(MapImage1.Width, MapImage1.Height))
        Dim OSJPGLayer As SharpMap.Layers.GdalRasterLayer = New SharpMap.Layers.GdalRasterLayer("OS", "OS10K.jpg")
        myMAP.Layers.Add(OSJPGLayer)
        myMAP.BackColor = Color.White
        myMAP.ZoomToExtents()
        MapImage1.Image = myMAP.GetMap()
    End Sub
End Class

'================

it is the OSJPGLayer that screw things up.  I have sharpMap.dll and sharpMap.UI.dll referenced... again I am using v0.9.

 

Any tips or help gratefully received.

 

Cheers

James

Coordinator
Jul 2, 2009 at 4:24 PM

Hi JDNelson, usually when people have issues with the GDALRasterLayer it is due to not copying _all_ the unmanaged FWTools dlls to the bin folder hth jd

Jul 2, 2009 at 4:27 PM

Hi John

 

THanks for the very quick reply.  Where do I get the FWTools DLLs from?  Will I need to reference them from my VB.NET project?

 

Cheers

 

James

 

Coordinator
Jul 2, 2009 at 4:36 PM
Edited Jul 2, 2009 at 4:38 PM

Hi James, they should be in the ExternalReferences/References4SharpMap.Extensions dir - anything that starts gdal|ogr|osr

alternatively you may get them from http://fwtools.maptools.org/ but you may have issues with versioning

http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=46843 may be useful

hth jd

Jul 2, 2009 at 4:46 PM

I did that and got this error

Error    1    Type 'SharpMap.Layers.GdalRasterLayer' is not defined.    C:\LCC\RankMAP\RankMAP\TAXI\TAXI\Form1.vb   

 

Where would I find "ExternalReferences/References4SharpMap.Extensions "?

 

Cheers

 

James

 

Coordinator
Jul 2, 2009 at 5:08 PM

ExternalReferences/References4SharpMap.Extensions  is in  the trunk of the SharpMap source (http://sharpmap.codeplex.com/SourceControl/ListDownloadableCommits.aspx)- download with tortoise and build and use that instead of the dlls from the releases tab..

Jul 2, 2009 at 5:12 PM

OK I think I get where you are coming from.  Will this be buildable in VS2008 C# express?

 

Cheers

 

James

Coordinator
Jul 2, 2009 at 5:21 PM

To be honest I dont know... as there are multiple projects in the solution - not sure if that is a limitation of the express versions currently..

Jul 6, 2009 at 6:04 PM

Hi John

 

I have installed full version of VS2008 and SP1.  I have downloaded, installed Tortoise and used it to download latest version of SharpMap v0.9 source.   Now how do i create all the required DLLs from VS2008.  I have tried and weird stuff happens like missing dependencies and it tries to "convert" projects!... I might need some hand holding as I come from a Pascal/Delphi background.

 

Best regards

 

James

 

 

Coordinator
Jul 6, 2009 at 6:22 PM

Hi James, make sure you open the SharpMap.VS2008.sln  from the trunk directory.. everything _should_ build out of the box.. hth jd

Jul 6, 2009 at 6:37 PM

Sorry John i cannot find the "SharpMap.VS2008.sln" in the v0.9 version?!

 

Cheers

James

 

Coordinator
Jul 6, 2009 at 7:35 PM
Edited Jul 6, 2009 at 7:35 PM

Hi James, assuming you used tortoise to checkout the codeplex source to a directory at c:\sharpmap the path would be c:\sharpmap\trunk\SharpMap.VS2008.sln

Just to make sure you have successfully checked out the code (the following instructions are from memory and may be slightly incorrect)

you would have created the folder e.g c:\sharpmap

right clicked on the folder and hit checkout

entered https://sharpmap.svn.codeplex.com/svn as the repository directory

leave the radio option set to 'head' and click ok

then to keep it up to date you would just right click on the root directory and hit update

hth jd

 

Jul 6, 2009 at 7:46 PM

Hi John

 

So close now!!!!!!  Managed to build everything... thanks for the tip... like a burk I had been using "branches" of code rather than the trunk..  Now the code I have put in (see original post) builds.  When I run/debug the app i get            " Gdal.AllRegister();" highlighted in the GdalRasterLayer.cs file... what does this mean?  Am I any closer?

 

Cheers

 

James

Coordinator
Jul 7, 2009 at 10:16 AM

Hi James, I think you are getting closer.. that message is usually due to the unmanaged (e.g native, non -.net) dlls not being present in the bin folder hth jd

Jul 7, 2009 at 10:24 AM

Are these the FWTools DLLs from the FWTools bin folder?  I have tried copying those into the folder but still get the error.  Do I need to add them to the project through the VS IDE?

 

Cheers

 

James

 

Coordinator
Jul 7, 2009 at 10:44 AM

Hi James, You cannot add them through the IDE as they are not .net assemblies they just need to 'be there'. I dont really use the GDAL Layer so I am no expert but I know that people do use it successfully and that it is a PITA to actually get it running ;).  Did you copy the gdal|ogr|osr dlls from the ExternalReferences/References4SharpMap.Extensions dir to your bin folder? If so you may be hitting a versioning issue with FWTools.. You could try using the dlls extracted from Dan3258's patch (#607) from http://sharpmap.codeplex.com/SourceControl/PatchList.aspx hth jd

Jul 9, 2009 at 2:18 PM

Still no joy!  I think I will have to give up on Raster images and insist on vector/shapefiles only.

 

Thanks for all you help... very much appreciated.

 

Best regards

James