This project has moved. For the latest updates, please go here.

Possible to display a map and label from FeatureDataSet?

Topics: SharpMap v0.9 / v1.x
Aug 31, 2013 at 6:31 PM
Edited Aug 31, 2013 at 6:33 PM

I am trying to draw the geometry and then label it's attribute and having some difficulty. I am thinking if I can draw and label the data from FeatureDataSet then it will work as I can load the FeatureDataSet separately.
| X      | Y      | LabelA  
|10.0   | 10.0  | 1
|20.0   | 20.0  | 2
Let's say, if I have a DataTable or DataFeatureTable like above, will I be able to display the point feature using X and Y and then label that feature using the LabelA.

Searching the source code and discussion it feels like, it's doable but I just could connect all the dots together so looking for some guidance.

I don't need a full blown working code if I get some guidance, I probably be OK.

Thanks for your help.
Aug 31, 2013 at 7:19 PM
You can use a DataTablePointProvider as datasource. IIRC you need an (u)int identifier column. For labeling you must use a LabelLayer, but you can reuse the DataTablePointProvider

There are a lot of examples in the WinFormSamples project that should get you started.

Hth FObermaier
Aug 31, 2013 at 9:30 PM
Thanks FObermaier,

I couldn't find "DataTablePointProvider" class for some reason. Now, can we apply similar method for drawing lines as well? Reason I am asking is because of the vertices coordinates... as I have all three types of geometry to draw.

I downloaded the repository and been able to compile the Projects under Examples folder. Any reference to this cs files will be great too.

Thanks much for helping me out.
Sep 1, 2013 at 5:29 AM
I figured it out.
FeatureDataTable fdt = new FeatureDataTable();
fdt.Columns.Add("LabelX", typeof(string));

FeatureDataRow fdr = fdt.NewRow();
Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(10, 0) };
fdr.Geometry = GeometryFactory.CreateLineString(coordinates);
fdr["LabelX"] = "10f, 10f";
vl3.DataSource = new GeometryFeatureProvider(fdt);
and for labeling
LabelLayer label = new LabelLayer("label");
label.DataSource = vl3.DataSource;
label.LabelColumn = "LabelX";
label.Enabled = true;
Sep 1, 2013 at 1:27 PM
DataTablePoint Provider is in SharpMap.Extensions.
The one in SharpMap is called OleDbPoint. Sorry.