This project has moved and is read-only. For the latest updates, please go here.

Implementing NtsProvider with VB

May 2, 2008 at 1:10 AM
Edited May 12, 2008 at 1:06 AM
I am trying to implement ntsprovider in VB to solve the problem of getting back mulitiple poygons when I click on a map. The lines that seem to do the trick in the the NTS_DemoApp, InitializeMap are:

1) SharpMap.Map map = new SharpMap.Map(size);

2) SharpMap.Layers.VectorLayer layGeoms = new SharpMap.Layers.VectorLayer("Geometries");

3) layGeoms.DataSource = new ShapeFile(Server.MapPath(@"~/App_Data/E2LoganSubcatchments.shp"));

4) NtsProvider nts = new NtsProvider(layGeoms.DataSource, delegate List<GisSharpBlog.NetTopologySuite.Features.Feature> features)

5) SharpMap.Layers.VectorLayer layNts = new SharpMap.Layers.VectorLayer("Buffers");

6) layNts.DataSource = nts;

7) map.Layers.Add(layNts)

I would appreciate it if someone could translate line 4 into VB. The translators on the web are not able to do this properly. Also, I have put GeometryConverter.cs and NtsProvider.cs into a new C# project in my VB solution. How do I reference these classes from my code? because "Imports SharpMap.Geometries" and "Imports SharpMap.Data.Providers" does not do the trick.

May 12, 2008 at 1:02 AM
I would appreciate it if someone could reply to this post. It is an important part of getting my website to work properly and I have no other solutions.

May 12, 2008 at 12:42 PM
Edited May 12, 2008 at 12:47 PM
Hi mc_oz - I dont think there is a direct translation to VB (at least prior to .net 3.5) - it is a language feature of c# - similar results can be attained though.

delegate (List<GisSharpBlog.NetTopologySuite.Features.Feature> features)

in this context is referred to as an anonymous method - i.e one that is declared inline within another method.

In the example above it is to satisfy the NTS constructor with the signature:

public NtsProvider(SharpMap.Data.Providers.IProvider provider, GeometryOperationDelegate operation)

There are other NTS constructors that do not require the GeometryOperationDelegate param and since the supplied delegate in the example above does nothing you should be ok to leave it out. HTH jd